1 | |
package liquibase.sqlgenerator.core; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
import liquibase.exception.ValidationErrors; |
5 | |
import liquibase.sql.Sql; |
6 | |
import liquibase.sqlgenerator.SqlGenerator; |
7 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
8 | |
import liquibase.sqlgenerator.SqlGeneratorFactory; |
9 | |
import liquibase.statement.core.UnlockDatabaseChangeLogStatement; |
10 | |
import liquibase.statement.core.UpdateStatement; |
11 | |
|
12 | 28 | public class UnlockDatabaseChangeLogGenerator extends AbstractSqlGenerator<UnlockDatabaseChangeLogStatement> { |
13 | |
|
14 | |
public ValidationErrors validate(UnlockDatabaseChangeLogStatement statement, Database database, |
15 | |
SqlGeneratorChain sqlGeneratorChain) { |
16 | 15 | return new ValidationErrors(); |
17 | |
} |
18 | |
|
19 | |
public Sql[] generateSql(UnlockDatabaseChangeLogStatement statement, Database database, |
20 | |
SqlGeneratorChain sqlGeneratorChain) { |
21 | 0 | String liquibaseSchema = database.getLiquibaseSchemaName(); |
22 | |
|
23 | 0 | UpdateStatement releaseStatement = new UpdateStatement(liquibaseSchema, |
24 | |
database.getDatabaseChangeLogLockTableName()); |
25 | 0 | releaseStatement.addNewColumnValue("LOCKED", false); |
26 | 0 | releaseStatement.addNewColumnValue("LOCKGRANTED", null); |
27 | 0 | releaseStatement.addNewColumnValue("LOCKEDBY", null); |
28 | 0 | releaseStatement.setWhereClause(database.escapeColumnName(liquibaseSchema, |
29 | |
database.getDatabaseChangeLogTableName(), "ID") |
30 | |
+ " = 1"); |
31 | |
|
32 | 0 | return SqlGeneratorFactory.getInstance().generateSql(releaseStatement, database); |
33 | |
} |
34 | |
} |