Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

previewing the SQL Statements before migration using Flyway

Tags:

flyway

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

like image 817
user2176326 Avatar asked Mar 16 '13 08:03

user2176326


People also ask

How do I test Flyway migration?

Run Flyway migration tests Once you've pushed all your scripts to GitHub, you can now manually run the migration test workflow by navigating to the Actions tab in GitHub and clicking on 'Database migration test', then 'Run workflow'.


1 Answers

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.

like image 93
Axel Fontaine Avatar answered Oct 23 '22 22:10

Axel Fontaine