Skip to content

Commit

Permalink
Merge pull request #30778 from gsmet/liquibase-mongodb-optimizations
Browse files Browse the repository at this point in the history
Avoid creating 3 Liquibase MongoDB instances for startup operations
  • Loading branch information
gsmet authored Feb 1, 2023
2 parents 5d7c271 + d4eebd0 commit a5e78b7
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@ public void doStartActions() {
for (InstanceHandle<LiquibaseMongodbFactory> liquibaseFactoryHandle : liquibaseFactoryInstance.handles()) {
try {
LiquibaseMongodbFactory liquibaseFactory = liquibaseFactoryHandle.get();
if (liquibaseFactory.getConfiguration().cleanAtStart) {
try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {

if (!liquibaseFactory.getConfiguration().cleanAtStart
&& !liquibaseFactory.getConfiguration().migrateAtStart) {
// Don't initialize if no clean or migration required at start
return;
}

try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {
if (liquibaseFactory.getConfiguration().cleanAtStart) {
liquibase.dropAll();
}
}
if (liquibaseFactory.getConfiguration().migrateAtStart) {
if (liquibaseFactory.getConfiguration().validateOnMigrate) {
try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {
if (liquibaseFactory.getConfiguration().migrateAtStart) {
if (liquibaseFactory.getConfiguration().validateOnMigrate) {
liquibase.validate();
}
}
try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {
liquibase.update(liquibaseFactory.createContexts(), liquibaseFactory.createLabels());
}
}
Expand Down

0 comments on commit a5e78b7

Please sign in to comment.