Imagine you have four MySQL database schemas across two environments:
foo
(the prod db),bar
(the in-progress restructuring of thefoo
db),foo_beta
(the test db),- and
bar_beta
(the test db for new structures).
Further, imagine you have a Spring Boot app with Hibernate annotations on the entities, like so:
@Table(name="customer", schema="bar")
public class Customer { ... }
@Table(name="customer", schema="foo")
public class LegacyCustomer { ... }
When developing locally it's no problem. You mimic the production database table names in your local environment. But then you try to demo functionality before it goes live and want to upload it to the server. You start another instance of the app on another port and realize this copy needs to point to "foo_beta" and "bar_beta", not "foo" and "bar"! What to do!
Were you using only one schema in your app, you could've left off the schema all-together and specified hibernate.default_schema
, but... you're using two. So that's out.
Spring EL--e.g. @Table(name="customer", schema="${myApp.schemaName}")
isn't an option--(with even some snooty "no-one needs this" comments), so if dynamically defining schemas is absurd, what does one do? Other than, you know, not getting into this ridiculous scenario in the first place.