ソースを参照

add tableExists method, use it

tags/2.0.1
Jonathan Cobb 4年前
コミット
9c6caddb0e
2個のファイルの変更11行の追加3行の削除
  1. +9
    -0
      wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java
  2. +2
    -3
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java

+ 9
- 0
wizard-server/src/main/java/org/cobbzilla/wizard/server/config/PgRestServerConfiguration.java ファイルの表示

@@ -417,4 +417,13 @@ public class PgRestServerConfiguration extends RestServerConfiguration implement
.generateConstraintSql(includeIndexes).toArray(new String[0]);
}

public boolean tableExists(String tableName) {
try {
execSql("select count(*) from "+tableName);
return true;
} catch (Exception e) {
return false;
}
}

}

+ 2
- 3
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java ファイルの表示

@@ -33,10 +33,9 @@ public class FlywayMigrationListener<C extends RestServerConfiguration> extends
final PgRestServerConfiguration configuration = (PgRestServerConfiguration) server.getConfiguration();
if (configuration.getDatabase().isMigrationEnabled()) {
// does the flyway table exist? If not, this is a first-time setup
try {
configuration.execSql("select count(*) from "+getFlywayTableName());
if (configuration.tableExists(getFlywayTableName())) {
migrate(configuration);
} catch (Exception e) {
} else {
log.warn("beforeStart: database schema does not seem to exist, will create it");
configuration.getDatabase().getHibernate().setHbm2ddlAuto("create");
}


読み込み中…
キャンセル
保存