juplo / hibernate4-maven-plugin

http://juplo.de/hibernate4-maven-plugin/
12 stars 13 forks source link

Incremental names for the Juplo-generated SQL schemas files to be consumed by Flyway #2

Open balteo opened 10 years ago

balteo commented 10 years ago

I think Juplo hibernate4-maven-plugin could be used a part of a continuous delivery toolchain together with DB migration tools such as Flyway.

Instead of relying on Hibernate's out-of-the-box hbm2ddl feature, one could use Juplo plugin in order to generate the SQL migration scripts that would later be applied by Flyway.

However, as of now and for the above to work, it seems one has to rename the Juplo-generated scripts manually so that they follow Flyway's migration naming requirements i.e.

A version must have the following structure:

  • One or more numeric parts
  • Separated by a dot (.) or an underscore (_)
  • Underscores are replaced by dots at runtime
  • Leading zeroes are ignored in each part

Examples of valid versions:

  • 1
  • 001
  • 5.2
  • 5_2 (5.2 at runtime)
  • 1.2.3.4.5.6.7.8.9
  • 205.68
  • 20130115113556
  • 2013.1.15.11.35.56
  • 2013.01.15.11.35.56

See here for documentation.

Therefore, it would be great if the Juplo plugin could somehow - and upon activation/configuration - manage different versions/names of its outputFile parameter that would follow the above specification/requirements (or a subset thereof).

One would eventually end up with N generated files that would could easily be consumed by Flyway for its DB migrations.

kai-moritz commented 10 years ago

I am not sure, if I understood right, what you would like to do. Would it be sufficient, if hibernate4-maven-plugin would automatically add the version-string of the project to the configured name of the outputFile?

balteo commented 10 years ago

@juplo This would be great yes as long as they meet the above version requirements (see quote above). And also one should be able to have several files with incremental version numbers. These files could later be fed to Flyway for a DB migration. Do you see what I mean?

kai-moritz commented 10 years ago

Whether the version string meets the flyway-requirements, or not, would depend on you: you define the version of your project in the pom.xml of your project. The same would go for several versions of that file: if you would increase the version of your project in your pom.xml and do not delete the old files (with a "mvn clean"), you would end up with what your are looking for...