Maven registerChangeLog

registerChangeLog connects your local Liquibase activity to a specific Liquibase Hub Project. By registering your changelog, this activity will be visible only to one Project within one Organization in Liquibase Hub.

Uses

registerChangeLog is used to connect an XML or formatted SQL changelog to your Liquibase Hub Project. (Additional changelog formats coming soon!)

The goal also assigns the changeLogId to the changelog file that you register. The changeLogId is a unique identifier in your changelog, which is automatically added by the registerChangeLog goal to provide real-time monitoring and reports.

You can connect the needed changelog file with your existing project or create a new project from the CLI.

Note: If you follow a master changelog structure, register only the master changelog without registering the nested changelogs.

Maven configuration

Liquibase Maven can be configured multiple ways. One way is to define your Liquibase configuration properties in your pom.xml file. You can also indicate the location of your liquibase.properties file using the following syntax:

<liquibase.propertyFile>path/to/properties_file</liquibase.propertyFile>

Note: Replace path/to/properties_file with the location of your default properties file. See the example below.

Example: <liquibase.propertyFile>${project.basedir}/local.liquibase.properties</liquibase.propertyFile>

Note: Multiple profiles can be created in the pom.xml which contain different Liquibase properties. See the example below.

There is also a list of the Liquibase Hub properties you can specify in the pom.xml file:

<!-- Hub Mode -->
<liquibase.hub.apiKey>HUB API KEY</liquibase.hub.apiKey>
<!--liquibase.hubMode>all|meta|off</liquibase.hubMode-->
<!--liquibase.hubConnectionId>CONNECTION ID</liquibase.hubConnectionId>
<!--liquibase.hubProjectId>PROJECT ID</liquibase.hubProjectId->

Running the registerChangeLog Maven goal

Running the registerChangeLog goal requires a Maven project to be implemented.

Also, the following items are required:

  • The Liquibase Hub API Key
  • There are three ways to specify your API Key:

    • Including liquibase.hub.ApiKey value in the liquibase.properties file:
    • liquibase.hub.ApiKey: <addYourHubApiKeyHere>
    • Including liquibase.hub.apiKey value in the pom.xml file:
    • <liquibase.hub.apiKey>HUB API KEY</liquibase.hub.apiKey>
    • Passing liquibaseHubApiKey on the command line:
    • -- liquibaseHubApiKey=addYourHubApiKeyHere
    • Specifying API key in your JAVA_OPTS as -Dliquibase.hub.apiKey. To specify JAVA_OPTS on Windows, Linux, or MacOS, run SET JAVA_OPTS=”-Dliquibase.hub.apikey=<myapikey>”
    • Note: To retrieve or manage your API keys, go to Settings > API Keys by selecting the settings icon on the left side of the page.

  • The changelog file
  • Note: Add your changelog file to the pom.xml or liquibase.properties file or specify it as the -Dliquibase.changeLogFile attribute while running the goal.

  • The hubProjectId of the Project you want to associate your changelog with

  • Note: As registerChangeLog is non-interactive, you cannot select the project from the command line for Maven. For this reason, you need to provide the hubProjectId to run the goal. You can find the hubProjectId in Project > Operations. Specify the hubProjectId in the Maven pom.xml file or the liquibase.properties file.

<!--liquibase.hubProjectId>PROJECT ID</liquibase.hubProjectId->
hubProjectId: <addYourHubProjectId>

Additionally, you can set the level of data, which you want to send to Liquibase Hub, in your JAVA_OPTS as -Dliquibase.hub.apiKey or in the liquibase.properties file:

liquibase.hub.mode:[all|meta|off]
  • all sends all data, including the changeset body, generated SQL, and logs (the default value is all).
  • meta does not send the changeset body, generated SQL, or operation-event and change-event logs. This mode sends the changeset name, author, id, timestamps, Liquibase version, and others.
  • off sends no data to Liquibase Hub.

To run the goal, type the following in your command line:

mvn liquibase:registerChangeLog

Output

When successful, the registerChangeLog Maven goal produces the following output:

Starting Liquibase at 11:35:54 (version 4.0.1-DAT-5252-SNAPSHOT #7 built at 2020-09-08 17:40+0000)
[INFO] Executing on Database: jdbc:oracle:thin:@//localhost:1522/BUCKET_01
Sep 11, 2020 11:35:55 AM liquibase.hub
INFO: Connected to Liquibase Hub with an API Key 'cTMOXZ************'
Changelog file 'src/main/resources/com/example/changelog001.h2.sql' has been registered with changelog ID 'da8567ba-f89c-4e13-a046-c06fcec2a333' and connected to project 'erz's Project' with project ID '752a7a64-c337-4438-a4cd-edc30c2c5ff7'
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.445 s
[INFO] Finished at: 2020-09-11T11:35:56-05:00
[INFO] ------------------------------------------------------------------------

registerChangeLog required Maven configuration properties

Property Definition
hubProjectId

Specifies the project you want to associate your changelog with.