0

We have two different envirionments

  • Dev (develop git branch)
  • Production (release/1.0 git branch)

release/1.0 release was the first release and a developer has changed the old Flyway files in the release/1.0. So, following are the changes in databases.

$ git diff develop..origin/release/1.0 src/main/resources/db/migration/

diff --git a/src/main/resources/db/migration/V1.7__add_table_css_setting.sql b/src/main/resources/db/migration/V1.7__add_table_css_setting.sql
index 1aff026..b9d916b 100644
--- a/src/main/resources/db/migration/V1.7__add_table_css_setting.sql
+++ b/src/main/resources/db/migration/V1.7__add_table_css_setting.sql
@@ -1,4 +1,5 @@
 CREATE TABLE css_setting(
+  `id` integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `value` TEXT DEFAULT NULL,
   `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

diff --git a/src/main/resources/db/migration/V1.12__insert_table_css_setting.sql b/src/main/resources/db/migration/V1.12__insert_table_css_setting.sql
index f54c737..e640ab1 100644
--- a/src/main/resources/db/migration/V1.12__insert_table_css_setting.sql
+++ b/src/main/resources/db/migration/V1.12__insert_table_css_setting.sql
@@ -1 +1 @@
-ALTER TABLE css_setting ADD `id` integer NOT NULL AUTO_INCREMENT PRIMARY KEY;
\ No newline at end of file
+INSERT INTO css_setting(`id`,`value`) VALUES(1,'');

Versions in respective branches have been migrated in respective environments. So,

  • We cannot merge back the hotfixes in release/1.0 back to develop
  • In the next production release, we cannot create the release/2.0 from develop

Since this is such small change, I guess one option is to replace develop Flyway files with release/1.0, Flaway clean & migrate the database in the Dev environment so both of them are in the same state.

I'm wondering if Flyway "undo migrations" any help here or if there are any other solutions, just in case this happens in the future.

s1n7ax
  • 2,750
  • 6
  • 24
  • 53

0 Answers0