diff --git a/pom.xml b/pom.xml index f9d779db..2b3d293f 100644 --- a/pom.xml +++ b/pom.xml @@ -309,15 +309,10 @@ dropwizard-hibernate ${dropwizard.version} - - io.dropwizard - dropwizard-migrations - ${dropwizard.version} - org.liquibase liquibase-core - 3.6.3 + 4.9.0 io.dropwizard @@ -509,7 +504,7 @@ mysql mysql-connector-java - 8.0.22 + 8.0.28 org.postgresql diff --git a/src/main/java/com/commafeed/CommaFeedApplication.java b/src/main/java/com/commafeed/CommaFeedApplication.java index 5a21486c..1a90f0a8 100644 --- a/src/main/java/com/commafeed/CommaFeedApplication.java +++ b/src/main/java/com/commafeed/CommaFeedApplication.java @@ -57,7 +57,6 @@ import io.dropwizard.assets.AssetsBundle; import io.dropwizard.db.DataSourceFactory; import io.dropwizard.forms.MultiPartBundle; import io.dropwizard.hibernate.HibernateBundle; -import io.dropwizard.migrations.MigrationsBundle; import io.dropwizard.server.DefaultServerFactory; import io.dropwizard.servlets.CacheBustingFilter; import io.dropwizard.setup.Bootstrap; @@ -97,13 +96,6 @@ public class CommaFeedApplication extends Application { } }); - bootstrap.addBundle(new MigrationsBundle() { - @Override - public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configuration) { - return configuration.getDataSourceFactory(); - } - }); - bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html")); bootstrap.addBundle(new MultiPartBundle()); } diff --git a/src/main/java/com/commafeed/backend/service/StartupService.java b/src/main/java/com/commafeed/backend/service/StartupService.java index 6c5e36b1..c22978f4 100644 --- a/src/main/java/com/commafeed/backend/service/StartupService.java +++ b/src/main/java/com/commafeed/backend/service/StartupService.java @@ -41,7 +41,7 @@ public class StartupService implements Managed { updateSchema(); long count = UnitOfWork.call(sessionFactory, () -> userDAO.count()); if (count == 0) { - UnitOfWork.run(sessionFactory, () -> initialData()); + UnitOfWork.run(sessionFactory, this::initialData); } } @@ -63,8 +63,9 @@ public class StartupService implements Managed { } ResourceAccessor accessor = new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader()); - Liquibase liq = new Liquibase("migrations.xml", accessor, database); - liq.update("prod"); + try (Liquibase liq = new Liquibase("migrations.xml", accessor, database)) { + liq.update("prod"); + } } catch (Exception e) { throw new RuntimeException(e);