9
votes

I am new to Flyway and I am using Flyway 2.1 code base for migration and execution of SQL statements on a previous schema version using Flyway. Once i execute my newer SQL statements the version entry in the metadata table is incremented.

But before I migrate my new version of the schema (i.e before I migrate/ execute the newer SQL statements on the database schema), I would like to capture all the new SQLs in another preview.sql file, so that the DBAs can see the SQLs before they proceed with the migrate.

I plan to do this by adding a flyway.preview() method to the Flyway.java file. Could you please let me know what other files would need to be changed to accomplish this?

Also, I only want to do this if the new version is > current schema version currently in the database. I checked the 2.1 code but the SchemaVersion class has been deprecated in 2.1 and I am not sure how to obtain the current version from the database.

I would appreciate your help or any suggestions that would correct my approach.

Thank you

1
There's possible overlap between what you're doing and this: github.com/flyway/flyway/issues/87 - Maybe once you've built your solution you can submit it via a pull request?Adam Luchjenbroers

1 Answers

2
votes

The necessary abstractions are not in place yet to support this, but I plan on adding them over the next few weeks to support batch updates in 2.2. Once that is done, it should be much easier to implement this.

As for querying the state of the DB, you have the Flyway.info() to assist you.