Skip to content

Commit a41b719

Browse files
committed
Upgrade to Liquibase 4.20.0
Migrate to new API and Args Closes gh-2
1 parent 1a890ca commit a41b719

File tree

4 files changed

+48
-41
lines changed

4 files changed

+48
-41
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ graceVersion=2023.0.2
33
graceHibernatePluginVersion=2023.1.0-M1
44
groovyVersion=4.0.23
55
HibernateCoreVersion=5.6.15.Final
6-
liquibaseVersion=4.19.0
7-
liquibaseHibernateVersion=4.19.0
6+
liquibaseVersion=4.20.0
7+
liquibaseHibernateVersion=4.20.0
88
websiteUrl=https://github.com/graceframework/grace-database-migration
99
issueTrackerUrl=https://github.com/graceframework/grace-database-migration/issues
1010
vcsUrl=https://github.com/graceframework/grace-database-migration

src/main/groovy/org/grails/plugins/databasemigration/command/DatabaseMigrationCommand.groovy

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 original authors
2+
* Copyright 2015-2024 original authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,12 @@ import liquibase.changelog.filter.ContextChangeSetFilter
3131
import liquibase.changelog.filter.CountChangeSetFilter
3232
import liquibase.changelog.filter.DbmsChangeSetFilter
3333
import liquibase.command.CommandScope
34-
import liquibase.command.core.InternalDiffChangelogCommandStep
35-
import liquibase.command.core.InternalGenerateChangelogCommandStep
34+
import liquibase.command.core.DiffChangelogCommandStep
35+
import liquibase.command.core.GenerateChangelogCommandStep
36+
import liquibase.command.core.helpers.DbUrlConnectionCommandStep
37+
import liquibase.command.core.helpers.DiffOutputControlCommandStep
38+
import liquibase.command.core.helpers.PreCompareCommandStep
39+
import liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep
3640
import liquibase.database.Database
3741
import liquibase.database.DatabaseConnection
3842
import liquibase.database.DatabaseFactory
@@ -240,10 +244,14 @@ trait DatabaseMigrationCommand {
240244
def changeLogFilePath = changeLogFile?.path
241245
def compareControl = new CompareControl([] as CompareControl.SchemaComparison[], null as String)
242246
final CommandScope commandScope = new CommandScope("groovyGenerateChangeLog")
243-
commandScope.addArgumentValue(InternalGenerateChangelogCommandStep.REFERENCE_DATABASE_ARG, originalDatabase)
244-
commandScope.addArgumentValue(InternalGenerateChangelogCommandStep.CHANGELOG_FILE_ARG, changeLogFilePath)
245-
commandScope.addArgumentValue(InternalGenerateChangelogCommandStep.COMPARE_CONTROL_ARG, compareControl)
246-
commandScope.addArgumentValue(InternalGenerateChangelogCommandStep.DIFF_OUTPUT_CONTROL_ARG, createDiffOutputControl())
247+
commandScope.addArgumentValue(ReferenceDbUrlConnectionCommandStep.REFERENCE_DATABASE_ARG, originalDatabase)
248+
commandScope.addArgumentValue(DiffChangelogCommandStep.CHANGELOG_FILE_ARG, changeLogFilePath)
249+
commandScope.addArgumentValue(DbUrlConnectionCommandStep.DATABASE_ARG, originalDatabase)
250+
commandScope.addArgumentValue(PreCompareCommandStep.COMPARE_CONTROL_ARG, compareControl)
251+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_CATALOG_ARG, true)
252+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_SCHEMA_ARG, true)
253+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_TABLESPACE_ARG, true)
254+
commandScope.addArgumentValue(GenerateChangelogCommandStep.OVERWRITE_OUTPUT_FILE_ARG, true)
247255
commandScope.setOutput(System.out)
248256
commandScope.execute()
249257
}
@@ -252,11 +260,13 @@ trait DatabaseMigrationCommand {
252260
def changeLogFilePath = changeLogFile?.path
253261
def compareControl = new CompareControl([] as CompareControl.SchemaComparison[], null as String)
254262
final CommandScope commandScope = new CommandScope("groovyDiffChangelog")
255-
commandScope.addArgumentValue(InternalDiffChangelogCommandStep.REFERENCE_DATABASE_ARG, referenceDatabase)
256-
commandScope.addArgumentValue(InternalDiffChangelogCommandStep.TARGET_DATABASE_ARG, targetDatabase)
257-
commandScope.addArgumentValue(InternalDiffChangelogCommandStep.CHANGELOG_FILE_ARG, changeLogFilePath)
258-
commandScope.addArgumentValue(InternalDiffChangelogCommandStep.COMPARE_CONTROL_ARG, compareControl)
259-
commandScope.addArgumentValue(InternalDiffChangelogCommandStep.DIFF_OUTPUT_CONTROL_ARG, createDiffOutputControl())
263+
commandScope.addArgumentValue(ReferenceDbUrlConnectionCommandStep.REFERENCE_DATABASE_ARG, referenceDatabase)
264+
commandScope.addArgumentValue(DbUrlConnectionCommandStep.DATABASE_ARG, targetDatabase)
265+
commandScope.addArgumentValue(DiffChangelogCommandStep.CHANGELOG_FILE_ARG, changeLogFilePath)
266+
commandScope.addArgumentValue(PreCompareCommandStep.COMPARE_CONTROL_ARG, compareControl)
267+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_CATALOG_ARG, true)
268+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_SCHEMA_ARG, true)
269+
commandScope.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_TABLESPACE_ARG, true)
260270
commandScope.setOutput(System.out)
261271
commandScope.execute()
262272
}

src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyDiffToChangeLogCommandStep.groovy

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 original authors
2+
* Copyright 2015-2024 original authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License")
55
* you may not use this file except in compliance with the License.
@@ -16,53 +16,46 @@
1616
package org.grails.plugins.databasemigration.liquibase
1717

1818
import groovy.transform.CompileStatic
19-
import liquibase.command.CommandBuilder
20-
import liquibase.command.CommandDefinition
21-
import liquibase.command.CommandResult
2219
import liquibase.command.CommandResultsBuilder
2320
import liquibase.command.CommandScope
24-
import liquibase.command.core.DiffToChangeLogCommand
25-
import liquibase.command.core.InternalDiffChangelogCommandStep
21+
import liquibase.command.core.DiffChangelogCommandStep
22+
import liquibase.command.core.DiffCommandStep
2623
import liquibase.command.core.InternalSnapshotCommandStep
24+
import liquibase.command.core.helpers.DiffOutputControlCommandStep
25+
import liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep
2726
import liquibase.database.Database
2827
import liquibase.database.ObjectQuotingStrategy
29-
import liquibase.diff.DiffGeneratorFactory
3028
import liquibase.diff.DiffResult
31-
import liquibase.diff.compare.CompareControl
3229
import liquibase.diff.output.DiffOutputControl
33-
import liquibase.diff.output.changelog.DiffToChangeLog
34-
import liquibase.exception.DatabaseException
3530
import liquibase.serializer.ChangeLogSerializerFactory
36-
import liquibase.snapshot.DatabaseSnapshot
37-
import liquibase.snapshot.InvalidExampleException
3831
import liquibase.util.StringUtil
3932

4033
@CompileStatic
41-
class GroovyDiffToChangeLogCommandStep extends InternalDiffChangelogCommandStep {
34+
class GroovyDiffToChangeLogCommandStep extends DiffChangelogCommandStep {
4235

4336
public static final String[] COMMAND_NAME = new String[] {"groovyDiffChangelog"}
4437

4538
@Override
4639
void run(CommandResultsBuilder resultsBuilder) {
4740
CommandScope commandScope = resultsBuilder.getCommandScope()
48-
Database referenceDatabase = commandScope.getArgumentValue(REFERENCE_DATABASE_ARG);
41+
Database referenceDatabase = commandScope.getArgumentValue(ReferenceDbUrlConnectionCommandStep.REFERENCE_DATABASE_ARG)
4942
String changeLogFile = commandScope.getArgumentValue(CHANGELOG_FILE_ARG);
5043

5144
InternalSnapshotCommandStep.logUnsupportedDatabase(referenceDatabase, this.getClass());
5245

53-
DiffResult diffResult = createDiffResult(commandScope);
46+
DiffOutputControl diffOutputControl = (DiffOutputControl) resultsBuilder.getResult(DiffOutputControlCommandStep.DIFF_OUTPUT_CONTROL.getName())
5447

55-
PrintStream outputStream = new PrintStream(resultsBuilder.getOutputStream());
48+
DiffResult diffResult = (DiffResult) resultsBuilder.getResult(DiffCommandStep.DIFF_RESULT.getName())
5649

57-
outputBestPracticeMessage();
50+
PrintStream outputStream = new PrintStream(resultsBuilder.getOutputStream());
5851

5952
ObjectQuotingStrategy originalStrategy = referenceDatabase.getObjectQuotingStrategy();
6053
try {
6154
referenceDatabase.setObjectQuotingStrategy(ObjectQuotingStrategy.QUOTE_ALL_OBJECTS);
6255
if (StringUtil.trimToNull(changeLogFile) == null) {
63-
createDiffToChangeLogObject(diffResult, commandScope).print(outputStream, ChangeLogSerializerFactory.instance.getSerializer('groovy'))
56+
createDiffToChangeLogObject(diffResult, diffOutputControl).print(outputStream, ChangeLogSerializerFactory.instance.getSerializer('groovy'))
6457
} else {
65-
createDiffToChangeLogObject(diffResult, commandScope).print(changeLogFile, ChangeLogSerializerFactory.instance.getSerializer(changeLogFile))
58+
createDiffToChangeLogObject(diffResult, diffOutputControl).print(changeLogFile, ChangeLogSerializerFactory.instance.getSerializer(changeLogFile))
6659
}
6760
}
6861
finally {

src/main/groovy/org/grails/plugins/databasemigration/liquibase/GroovyGenerateChangeLogCommandStep.groovy

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 original authors
2+
* Copyright 2015-2024 original authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,17 +19,21 @@ import groovy.transform.CompileStatic
1919
import liquibase.Scope
2020
import liquibase.command.CommandResultsBuilder
2121
import liquibase.command.CommandScope
22-
import liquibase.command.core.InternalGenerateChangelogCommandStep
22+
import liquibase.command.core.DiffCommandStep
23+
import liquibase.command.core.GenerateChangelogCommandStep
2324
import liquibase.command.core.InternalSnapshotCommandStep
25+
import liquibase.command.core.helpers.DiffOutputControlCommandStep
2426
import liquibase.database.Database
2527
import liquibase.database.ObjectQuotingStrategy
2628
import liquibase.diff.DiffResult
29+
import liquibase.diff.output.DiffOutputControl
2730
import liquibase.diff.output.changelog.DiffToChangeLog
2831
import liquibase.serializer.ChangeLogSerializerFactory
2932
import liquibase.util.StringUtil
33+
import liquibase.command.core.helpers.ReferenceDbUrlConnectionCommandStep
3034

3135
@CompileStatic
32-
class GroovyGenerateChangeLogCommandStep extends InternalGenerateChangelogCommandStep {
36+
class GroovyGenerateChangeLogCommandStep extends GenerateChangelogCommandStep {
3337

3438
public static final String[] COMMAND_NAME = new String[] {"groovyGenerateChangeLog"};
3539

@@ -42,21 +46,21 @@ class GroovyGenerateChangeLogCommandStep extends InternalGenerateChangelogComman
4246
void run(CommandResultsBuilder resultsBuilder) throws Exception {
4347
CommandScope commandScope = resultsBuilder.getCommandScope();
4448

45-
outputBestPracticeMessage();
46-
4749
String changeLogFile = StringUtil.trimToNull(commandScope.getArgumentValue(CHANGELOG_FILE_ARG));
4850
if (changeLogFile != null && changeLogFile.toLowerCase().endsWith(".sql")) {
4951
Scope.getCurrentScope().getUI().sendMessage("\n" + INFO_MESSAGE + "\n");
5052
Scope.getCurrentScope().getLog(getClass()).info("\n" + INFO_MESSAGE + "\n");
5153
}
5254

53-
final Database referenceDatabase = commandScope.getArgumentValue(REFERENCE_DATABASE_ARG);
55+
final Database referenceDatabase = commandScope.getArgumentValue(ReferenceDbUrlConnectionCommandStep.REFERENCE_DATABASE_ARG);
5456

5557
InternalSnapshotCommandStep.logUnsupportedDatabase(referenceDatabase, this.getClass());
5658

57-
DiffResult diffResult = createDiffResult(commandScope);
59+
DiffOutputControl diffOutputControl = (DiffOutputControl) resultsBuilder.getResult(DiffOutputControlCommandStep.DIFF_OUTPUT_CONTROL.getName())
60+
61+
DiffResult diffResult = (DiffResult) resultsBuilder.getResult(DiffCommandStep.DIFF_RESULT.getName())
5862

59-
DiffToChangeLog changeLogWriter = new DiffToChangeLog(diffResult, commandScope.getArgumentValue(DIFF_OUTPUT_CONTROL_ARG));
63+
DiffToChangeLog changeLogWriter = new DiffToChangeLog(diffResult, diffOutputControl)
6064

6165
changeLogWriter.setChangeSetAuthor(commandScope.getArgumentValue(AUTHOR_ARG));
6266
changeLogWriter.setChangeSetContext(commandScope.getArgumentValue(CONTEXT_ARG));

0 commit comments

Comments
 (0)