소스 검색

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");
}


불러오는 중...
취소
저장