Skip to content

Commit

Permalink
liquibase upgrade (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
Athou committed Mar 22, 2022
1 parent 13a0516 commit 4b346dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
9 changes: 2 additions & 7 deletions pom.xml
Expand Up @@ -309,15 +309,10 @@
<artifactId>dropwizard-hibernate</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-migrations</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.6.3</version>
<version>4.9.0</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
Expand Down Expand Up @@ -509,7 +504,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/commafeed/CommaFeedApplication.java
Expand Up @@ -57,7 +57,6 @@
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;
Expand Down Expand Up @@ -97,13 +96,6 @@ public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configurati
}
});

bootstrap.addBundle(new MigrationsBundle<CommaFeedConfiguration>() {
@Override
public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configuration) {
return configuration.getDataSourceFactory();
}
});

bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
bootstrap.addBundle(new MultiPartBundle());
}
Expand Down
Expand Up @@ -41,7 +41,7 @@ public void start() throws Exception {
updateSchema();
long count = UnitOfWork.call(sessionFactory, () -> userDAO.count());
if (count == 0) {
UnitOfWork.run(sessionFactory, () -> initialData());
UnitOfWork.run(sessionFactory, this::initialData);
}
}

Expand All @@ -63,8 +63,9 @@ public String escapeObjectName(String objectName, Class<? extends DatabaseObject
}

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);
Expand Down

0 comments on commit 4b346dd

Please sign in to comment.