#918 - Remove DbMigrationConfig.generateOnStart() ... migrate to offline generation

This commit is contained in:
Rob Bygrave
2016-12-10 00:04:41 +13:00
parent a727a98a21
commit 514047e680
2 changed files with 0 additions and 43 deletions
@@ -384,47 +384,6 @@ public class DbMigrationConfig {
dbPassword = properties.get("migration.dbpassword", adminPwd);
}
/**
* Return true if the migration should be generated.
* <p>
* It is expected that when an environment variable <code>ddl.migration.enabled</code>
* is set to <code>true</code> then the DB migration will generate the migration DDL.
* </p>
*/
public boolean isGenerateOnStart() {
// environment properties take precedence
String envGenerate = readEnvironment("ddl.migration.generate");
if (envGenerate != null) {
return "true".equalsIgnoreCase(envGenerate.trim());
}
return generate;
}
/**
* Called by EbeanServer on start.
* <p>
* If enabled this generates the migration xml and DDL scripts.
* </p>
*/
public void generateOnStart(EbeanServer server) {
if (isGenerateOnStart()) {
if (platform == null) {
logger.warn("No platform set for migration DDL generation");
} else {
// generate the migration xml and platform specific DDL
DbMigration migration = new DbMigration(server);
migration.setPlatform(platform);
try {
migration.generateMigration();
} catch (Exception e) {
throw new RuntimeException("Error generating DB migration", e);
}
}
}
}
/**
* Return the migration version (typically FlywayDb compatible).
* <p>
@@ -356,8 +356,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
*/
public void start() {
if (!TenantMode.DB.equals(serverConfig.getTenantMode())) {
DbMigrationConfig migrationConfig = serverConfig.getMigrationConfig();
migrationConfig.generateOnStart(this);
serverConfig.runDbMigration(serverConfig.getDataSource());
}
}