#1218 - ENH: Bump to migration 11.2.1 with support for options patchInsertOn and patchResetChecksumOn

This commit is contained in:
Rob Bygrave
2017-11-23 19:05:35 +13:00
parent fd2d083971
commit 69c045443c
3 changed files with 60 additions and 2 deletions
+1 -1
View File
@@ -122,7 +122,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>11.1.1</version>
<version>11.2.1</version>
</dependency>
<dependency>
@@ -16,6 +16,8 @@ public class DbMigrationConfig {
protected static final Logger logger = LoggerFactory.getLogger(DbMigrationConfig.class);
protected MigrationConfig runnerConfig = new MigrationConfig();
/**
* The database platform to generate migration DDL for.
*/
@@ -105,6 +107,10 @@ public class DbMigrationConfig {
*/
protected String dbPassword;
protected String patchInsertOn;
protected String patchResetChecksumOn;
/**
* Return the DB platform to generate migration DDL for.
* <p>
@@ -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.
* <p>
* Value can be a string containing comma delimited list of version numbers.
* </p>
*/
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.
* <p>
* Value can be a string containing comma delimited list of version numbers.
* </p>
*/
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);
}
@@ -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