Explorar el Código

check for schema before migrating

tags/2.0.1
Jonathan Cobb hace 4 años
padre
commit
7716949a32
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. +8
    -1
      wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java

+ 8
- 1
wizard-server/src/main/java/org/cobbzilla/wizard/server/listener/FlywayMigrationListener.java Ver fichero

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


Cargando…
Cancelar
Guardar