Skip to content

Extended CLI wrapper for Liquibase functions that are not easily available from the normal CLI

Notifications You must be signed in to change notification settings

aditosoftware/liquibase-extended-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liquibase-extended-cli

Quality Gate Status Maintainability Rating Coverage Lines of Code

Extended CLI functionality for liquibase.

Build

You can build via mvn clean install.

Alternatively, you can build via the installScript.sh. This will also copy the jar to the desired directory of the extension.

Updating dependencies

Whenever you are updating dependencies, you need also check the vscode-liquibase extension if it still works. If it no longer works, then you might want to update the dependencies there as well.

Usage

Basic usage

The built jar does not include any dependency. Instead, you need to give the required jars in the classpath argument, separated by the specific separator of your OS (; (semicolon) for windows, : (colon) for macOS and Linux).

You need the following JARs in your classpath

  • liquibase-core: Executing liquibase
  • picocli: Using CLI features
  • snakeyaml: Working with JSON/YAML changelogs
  • gson: Parsing the output to a valid JSON
  • commons-lang3: Utility dependency needed by liquibase
  • commons-io: Utility dependency needed by liquibase
  • opencsv: Utility dependency needed by liquibase

The following is an example for Windows:

java -cp "liquibase-extended-cli.jar;picocli-4.7.5.jar;liquibase-core-4.28.0.jar;commons-io-2.16.1.jar;commons-lang3-3.14.0.jar;gson-2.10.1.jar;opencsv-5.9.jar;snakeyaml-2.2.jar" de.adito.LiquibaseExtendedCli <command and arguments that should be called>

Please note that you will need to give correct paths for all the jars.

Commands

Every command can be executed via the following:

java -cp "[...]" de.adito.LiquibaseExtendedCli <command-name> <parameters>

You can always call --help for a detailed command help.

context

Takes an absolute file path and gets all contexts from the given changelog and their linked changelogs.

Example call: de.adito.LiquibaseExtendedCli context "C:\dev\project\.liquibase\Data\changelog.xml"

Example output: ["example", "workspace"]. Every successful output is written to stdout. This will be always a valid JSON array. This array is already sorted.

convert

Converts a file or a directory to another liquibase format.

Example call: de.adito.LiquibaseExtendedCli convert --format YAML "C:\dev\project\.liquibase\Data\changelog.xml" "C:\dev\project\.liquibase\yaml"

This will write directly to the given path.

NOTE: You should always check the created files for any errors.

Known issues
  • Files with include / includeAll will not be transformed to the new format. This is due to the limitations of Liquibase. But all path given in the file attribute will be transformed to a new path, if the old path was transformed as well.

  • YAML and JSON files with preConditions will produce invalid results (Liquibase Issue #4379)

About

Extended CLI wrapper for Liquibase functions that are not easily available from the normal CLI

Resources

Stars

Watchers

Forks

Releases

No releases published