浏览代码

Read flyway history table name dynamically

pull/5/head
父节点
当前提交
14d542a4c5
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. +3
    -3
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java

+ 3
- 3
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java 查看文件

@@ -21,7 +21,6 @@ import static org.cobbzilla.util.time.TimeUtil.DATE_FORMAT_YYYYMMDD;
@Slf4j
public class FlywayMigrationListener<C extends RestServerConfiguration> extends RestServerLifecycleListenerBase<C> {

public static final String FLYWAY_TABLE_NAME = "flyway_schema_history";
protected RestServer server;

@Override public void beforeStart(RestServer server) {
@@ -39,12 +38,13 @@ public class FlywayMigrationListener<C extends RestServerConfiguration> extends
public void migrate(PgRestServerConfiguration configuration) {

// check to see if flyway tables exist
final var flywayTableName = Flyway.configure().getTable();
boolean baseline = false;
try {
configuration.execSql("SELECT * from " + FLYWAY_TABLE_NAME);
configuration.execSql("SELECT * from " + flywayTableName);
} catch (UncheckedSqlException e) {
if (e.getSqlException() != null && e.getSqlException() instanceof PSQLException && e.getMessage().contains(" does not exist")) {
log.warn(FLYWAY_TABLE_NAME + " table does not exist, will baseline DB");
log.warn(flywayTableName + " table does not exist, will baseline DB");
baseline = true;
} else {
throw e;


正在加载...
取消
保存