From 865565c82564655a0fb6502913e4202724bb6ff9 Mon Sep 17 00:00:00 2001 From: Vitalii Makarchenkov Date: Wed, 5 Jul 2023 14:59:17 +0300 Subject: [PATCH] Temporary fix dropAll command after command refactoring Fix will be reverted in the scope of DAT-15327 --- .../mongodb/database/MongoLiquibaseDatabase.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/liquibase/ext/mongodb/database/MongoLiquibaseDatabase.java b/src/main/java/liquibase/ext/mongodb/database/MongoLiquibaseDatabase.java index cf1e85fd..5b45e980 100644 --- a/src/main/java/liquibase/ext/mongodb/database/MongoLiquibaseDatabase.java +++ b/src/main/java/liquibase/ext/mongodb/database/MongoLiquibaseDatabase.java @@ -23,12 +23,15 @@ import com.mongodb.client.MongoDatabase; import liquibase.CatalogAndSchema; import liquibase.Scope; +import liquibase.changelog.ChangeLogHistoryService; import liquibase.changelog.ChangeLogHistoryServiceFactory; import liquibase.exception.LiquibaseException; import liquibase.executor.Executor; import liquibase.executor.ExecutorService; import liquibase.ext.mongodb.configuration.MongoConfiguration; import liquibase.ext.mongodb.statement.DropAllCollectionsStatement; +import liquibase.lockservice.LockService; +import liquibase.lockservice.LockServiceFactory; import liquibase.nosql.database.AbstractNoSqlDatabase; import lombok.NoArgsConstructor; import lombok.Setter; @@ -53,6 +56,16 @@ public void dropDatabaseObjects(final CatalogAndSchema schemaToDrop) throws Liqu final Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor(EXECUTOR_NAME, this); DropAllCollectionsStatement dropAllCollectionsStatement = new DropAllCollectionsStatement(); executor.execute(dropAllCollectionsStatement); + + // TODO Revert this changes in the scope of DAT-15327 + LockService lockService = LockServiceFactory.getInstance().getLockService(this); + lockService.releaseLock(); + lockService.destroy(); + LockServiceFactory.getInstance().resetAll(); + ChangeLogHistoryService changeLogService = Scope.getCurrentScope().getSingleton(ChangeLogHistoryServiceFactory.class).getChangeLogService(this); + Scope.getCurrentScope().getSingleton(ChangeLogHistoryServiceFactory.class).unregister(changeLogService); + Scope.getCurrentScope().getSingleton(ChangeLogHistoryServiceFactory.class).resetAll(); + Scope.getCurrentScope().getSingleton(ExecutorService.class).reset(); Scope.getCurrentScope().getSingleton(ChangeLogHistoryServiceFactory.class).getChangeLogService(this).destroy(); }