using flyway to patch multiple identical schemas

2019-07-20 06:57发布

问题:

i have thoroughly read the flyway documentation but i am unclear if the scenario i want is possible or not. i need to patch many identical schemas within the same database but i do not know all the schema names at the time when i am writing the sql scripts.

i know about the schemas parameter, but the 2 possible strategies mentioned in the FAQ do not apply to my scenario.

the scenario is similar to a university providing schemas for their students:

  • i would like to provide sql scripts with no schema prefixes for objects
  • every schema should have its own schema_version table
  • upon flyway:migrate every schema defined in the schemas parameter should be patched separately, i.e. the sql scripts should be run in each schema.

i know that a potential problem is, that 'schema' means something different in f.ex. oracle than in postgres, so i wonder if there is any other recommended way to achieve this.

otherwise i am thinking of implementing this functionality myself...is there a chance to get this feature upstream if we do it on our own?

thanks :)

回答1:

Your best chance is to wrap Flyway with a method that will list the applicable schemas, and then make one Flyway run per schema with the schemas property set to the correct one.

This really is a nice feature, so at this time I would say the chances are pretty slim to see it included in the main distro.



标签: flyway