소스 검색

use lazy static for flyway table name

tags/2.0.1
Jonathan Cobb 4 년 전
부모
커밋
5e9baa01f6
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. +6
    -4
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java

+ 6
- 4
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java 파일 보기

@@ -1,5 +1,6 @@
package org.cobbzilla.wizard.server.listener;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.util.jdbc.UncheckedSqlException;
import org.cobbzilla.wizard.server.RestServer;
@@ -21,7 +22,8 @@ import static org.cobbzilla.util.time.TimeUtil.DATE_FORMAT_YYYYMMDD;
@Slf4j
public class FlywayMigrationListener<C extends RestServerConfiguration> extends RestServerLifecycleListenerBase<C> {

public static final MigrationResolver[] EMPTY_MIGRATION_RESOLVERS = new MigrationResolver[0];
@Getter(lazy=true) private static final String flywayTableName = Flyway.configure().getTable();

protected RestServer server;

@Override public void beforeStart(RestServer server) {
@@ -41,13 +43,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;
final String flywayTable = getFlywayTableName();
try {
configuration.execSql("SELECT * from " + flywayTableName);
configuration.execSql("SELECT * from " + flywayTable);
} catch (UncheckedSqlException e) {
if (e.getSqlException() != null && e.getSqlException() instanceof PSQLException && e.getMessage().contains(" does not exist")) {
log.warn(flywayTableName + " table does not exist, will baseline DB");
log.warn(flywayTable + " table does not exist, will baseline DB");
baseline = true;
} else {
throw e;


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