@@ -352,6 +358,47 @@ public class DbMigrationConfig { this.dbPassword = dbPassword; } + /** + * Return migration versions that should be added to history without running. + */ + public String getPatchInsertOn() { + return patchInsertOn; + } + + /** + * Set migration versions that should be added to history without running. + *
+ * Value can be a string containing comma delimited list of version numbers. + *
+ */ + public void setPatchInsertOn(String patchInsertOn) { + this.patchInsertOn = patchInsertOn; + } + + /** + * Return migration versions that should have their checksum reset and not run. + */ + public String getPatchResetChecksumOn() { + return patchResetChecksumOn; + } + + /** + * Set migration versions that should have their checksum reset and not run. + *+ * Value can be a string containing comma delimited list of version numbers. + *
+ */ + public void setPatchResetChecksumOn(String patchResetChecksumOn) { + this.patchResetChecksumOn = patchResetChecksumOn; + } + + /** + * Return the underlying migration runner configuration allowing for more advanced settings. + */ + public MigrationConfig getRunnerConfig() { + return runnerConfig; + } + /** * Load the settings from the PropertiesWrapper. */ @@ -370,6 +417,8 @@ public class DbMigrationConfig { generate = properties.getBoolean("migration.generate", generate); version = properties.get("migration.version", version); name = properties.get("migration.name", name); + patchInsertOn = properties.get("migration.patchInsertOn", patchInsertOn); + patchResetChecksumOn = properties.get("migration.patchResetChecksumOn", patchResetChecksumOn); runMigration = properties.getBoolean("migration.run", runMigration); metaTable = properties.get("migration.metaTable", metaTable); @@ -446,7 +495,6 @@ public class DbMigrationConfig { */ public MigrationRunner createRunner(ClassLoader classLoader, Properties properties) { - MigrationConfig runnerConfig = new MigrationConfig(); runnerConfig.setMetaTable(metaTable); runnerConfig.setApplySuffix(applySuffix); runnerConfig.setMigrationPath(migrationPath); @@ -455,6 +503,12 @@ public class DbMigrationConfig { runnerConfig.setDbUsername(getDbUsername()); runnerConfig.setDbPassword(getDbPassword()); runnerConfig.setClassLoader(classLoader); + if (patchInsertOn != null) { + runnerConfig.setPatchInsertOn(patchInsertOn); + } + if (patchResetChecksumOn != null) { + runnerConfig.setPatchResetChecksumOn(patchResetChecksumOn); + } if (properties != null) { runnerConfig.load(properties); } diff --git a/src/test/java/io/ebean/config/DbMigrationConfigTest.java b/src/test/java/io/ebean/config/DbMigrationConfigTest.java index 10cd3721a..8e5480cde 100644 --- a/src/test/java/io/ebean/config/DbMigrationConfigTest.java +++ b/src/test/java/io/ebean/config/DbMigrationConfigTest.java @@ -29,6 +29,8 @@ public class DbMigrationConfigTest { Properties properties = new Properties(); properties.setProperty("ebean.migration.dbusername", "banana"); properties.setProperty("ebean.migration.dbpassword", "apple"); + properties.setProperty("ebean.migration.patchInsertOn", "1.3,my_views"); + properties.setProperty("ebean.migration.patchResetChecksumOn", "foo"); PropertiesWrapper wrapper = new PropertiesWrapper("ebean", "db", properties); @@ -37,6 +39,8 @@ public class DbMigrationConfigTest { assertEquals(migrationConfig.getDbUsername(),"banana"); assertEquals(migrationConfig.getDbPassword(),"apple"); + assertEquals(migrationConfig.getPatchInsertOn(),"1.3,my_views"); + assertEquals(migrationConfig.getPatchResetChecksumOn(),"foo"); } @Test