Skip to content

Commit

Permalink
Merge pull request #2335 from liquibase/fix-changeloglock-duplication…
Browse files Browse the repository at this point in the history
…-on-updatesql

Remove duplicate databasechangeloglock SQL when running update-sql against a new database
  • Loading branch information
nvoxland committed Jan 24, 2022
2 parents bcfec04 + 16756ab commit 462d721
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.executor.Executor;
import liquibase.executor.ExecutorService;
import liquibase.executor.LoggingExecutor;
import liquibase.snapshot.InvalidExampleException;
import liquibase.snapshot.SnapshotGeneratorFactory;
import liquibase.sql.Sql;
Expand Down Expand Up @@ -99,6 +100,14 @@ public void init() throws DatabaseException {
Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database);

int maxIterations = 10;
if (executor instanceof LoggingExecutor) {
//can't / don't have to re-check
if (hasDatabaseChangeLogLockTable()) {
maxIterations = 0;
} else {
maxIterations = 1;
}
}
for (int i = 0; i < maxIterations; i++) {
try {
if (!hasDatabaseChangeLogLockTable(true)) {
Expand Down
Expand Up @@ -64,7 +64,7 @@ public void setAllowPrompt(boolean allowPrompt) throws IllegalArgumentException

@Override
public boolean getAllowPrompt() {
return allowPrompt;
return getConsole().supportsInput() && allowPrompt;
}

@Override
Expand Down

0 comments on commit 462d721

Please sign in to comment.