forked from Archives/Athou_commafeed
liquibase upgrade (#993)
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -309,15 +309,10 @@
|
|||||||
<artifactId>dropwizard-hibernate</artifactId>
|
<artifactId>dropwizard-hibernate</artifactId>
|
||||||
<version>${dropwizard.version}</version>
|
<version>${dropwizard.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.dropwizard</groupId>
|
|
||||||
<artifactId>dropwizard-migrations</artifactId>
|
|
||||||
<version>${dropwizard.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.liquibase</groupId>
|
<groupId>org.liquibase</groupId>
|
||||||
<artifactId>liquibase-core</artifactId>
|
<artifactId>liquibase-core</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>4.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.dropwizard</groupId>
|
<groupId>io.dropwizard</groupId>
|
||||||
@@ -509,7 +504,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>8.0.22</version>
|
<version>8.0.28</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ import io.dropwizard.assets.AssetsBundle;
|
|||||||
import io.dropwizard.db.DataSourceFactory;
|
import io.dropwizard.db.DataSourceFactory;
|
||||||
import io.dropwizard.forms.MultiPartBundle;
|
import io.dropwizard.forms.MultiPartBundle;
|
||||||
import io.dropwizard.hibernate.HibernateBundle;
|
import io.dropwizard.hibernate.HibernateBundle;
|
||||||
import io.dropwizard.migrations.MigrationsBundle;
|
|
||||||
import io.dropwizard.server.DefaultServerFactory;
|
import io.dropwizard.server.DefaultServerFactory;
|
||||||
import io.dropwizard.servlets.CacheBustingFilter;
|
import io.dropwizard.servlets.CacheBustingFilter;
|
||||||
import io.dropwizard.setup.Bootstrap;
|
import io.dropwizard.setup.Bootstrap;
|
||||||
@@ -97,13 +96,6 @@ public class CommaFeedApplication extends Application<CommaFeedConfiguration> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bootstrap.addBundle(new MigrationsBundle<CommaFeedConfiguration>() {
|
|
||||||
@Override
|
|
||||||
public DataSourceFactory getDataSourceFactory(CommaFeedConfiguration configuration) {
|
|
||||||
return configuration.getDataSourceFactory();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
|
bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
|
||||||
bootstrap.addBundle(new MultiPartBundle());
|
bootstrap.addBundle(new MultiPartBundle());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class StartupService implements Managed {
|
|||||||
updateSchema();
|
updateSchema();
|
||||||
long count = UnitOfWork.call(sessionFactory, () -> userDAO.count());
|
long count = UnitOfWork.call(sessionFactory, () -> userDAO.count());
|
||||||
if (count == 0) {
|
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());
|
ResourceAccessor accessor = new ClassLoaderResourceAccessor(Thread.currentThread().getContextClassLoader());
|
||||||
Liquibase liq = new Liquibase("migrations.xml", accessor, database);
|
try (Liquibase liq = new Liquibase("migrations.xml", accessor, database)) {
|
||||||
liq.update("prod");
|
liq.update("prod");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user