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. Also, you can use JSON and YAML changelog formats (since 4.2.1).
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 in multiple ways. One way is to define your Liquibase configuration properties in your pom.xml
file. To configure your pom.xml
file, refer to Configuring Liquibase Attributes in your Maven POM File.
There is also a list of the Liquibase Hub properties you can specify in your pom.xml
file under <configuration>
in the <project></project>
level:
<!-- Hub Mode -->
<!--hub.apiKey>HUB API KEY</hub.apiKey>
<hubMode>all|meta|off</hubMode>
<hubConnectionId>CONNECTION ID</hubConnectionId>
<hubProjectId>PROJECT ID</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
- Including
liquibase.hub.ApiKey
value in theliquibase.properties
file:
There are three ways to specify your API Key:
liquibase.hub.ApiKey: <addYourHubApiKeyHere>
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, runSET 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.
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 isall
).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. |