Browse Source

always disable migration when creating database for the first time

tags/2.0.1
Jonathan Cobb 4 years ago
parent
commit
443e62eee7
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/SystemInitializerListener.java

+ 4
- 3
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/SystemInitializerListener.java View File

@@ -66,8 +66,9 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {
if (checkTable) { if (checkTable) {
ok = checkTable(config); ok = checkTable(config);
if (!ok) { if (!ok) {
// create the schema when the test table does not exist
// create the schema when the test table does not exist. Disable migration
config.getDatabase().getHibernate().setHbm2ddlAuto("create"); config.getDatabase().getHibernate().setHbm2ddlAuto("create");
config.getDatabase().setMigrationEnabled(false);
} }
} else { } else {
config.execSql("select 1"); config.execSql("select 1");
@@ -124,7 +125,7 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {
try { try {
return runTableCheck(config, tableName); return runTableCheck(config, tableName);
} catch (Exception e) { } catch (Exception e) {
log.warn("table '"+tableName+"' not found, will create schema: " + shortError(e));
log.warn("table '"+tableName+"' not found, will create schema (disabling migration): " + shortError(e));
config.getDatabase().getHibernate().setHbm2ddlAuto("create"); config.getDatabase().getHibernate().setHbm2ddlAuto("create");
config.getDatabase().setMigrationEnabled(false); config.getDatabase().setMigrationEnabled(false);
} }
@@ -145,7 +146,7 @@ public class SystemInitializerListener extends RestServerLifecycleListenerBase {
try { try {
runTableCheck(config, tableName); runTableCheck(config, tableName);
} catch (Exception e) { } catch (Exception e) {
die(PREFIX + "table '"+tableName+"' not found: " + shortError(e));
die(PREFIX + "runTableCheck failed for table '"+tableName+"': " + shortError(e));
} }
} }
if (isCheckRedis()) { if (isCheckRedis()) {


Loading…
Cancel
Save