Maven syncHub
syncHub
synchronizes the local DATABASECHANGELOG table with Liquibase Hub.
Uses
syncHub
is typically used when you want to:
- Ensure that Liquibase Hub shows the latest results from your DATABASECHANGELOG table.
- Synchronize the DATABASECHANGELOG table of a new project that has pre-existing data in the DATABASECHANGELOG table.
- Synchronize your local data if
update
,rollback
,changelogSync
, ordropAll
were run while Liquibase Hub was offline.
When you run the syncHub
goal, you will not see any operations added to the Project associated with your changelog. syncHub
cannot associate previous Liquibase
operations, so you will not see any operations in Liquibase Hub. You will only see changesets added to the changesets tab in your Liquibase Hub project.
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 syncHub
Maven goal
Running the syncHub
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.
hubConnectionId
attribute:If you enter the
-Dliquibase.changeLogFile
attribute, there is no need to specifyhubConnectionId
with the goal.If you use
hubConnectionId
, add it to thepom.xml
file, theliquibase.properties
file, or to thesyncHub
goal on the command line. You can find thehubConnectionId
in Project > Connections > Connection in the lower-left corner.If you specify both the
hubConnectionId
and the changelog file, the changelog file will be ignored and the connection Id will be used.
<!--liquibase.hubConnectionId>CONNECTION ID</liquibase.hubConnectionId>
<hubConnectionId: <addYourHubConnectionId>
liquibase syncHub --hubConnectionId=myConnectionID
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.
Before running the syncHub
goal, register your changelog file by using the registerChangeLog
goal:
mvn liquibase:registerChangeLog
Note: The registerChangeLog
goal connects your local Liquibase activity to a specific Liquibase Hub Project.
To run the goal, type the following in your command line:
mvn liquibase:syncHub
Output
When successful, the syncHub
Maven goal produces the following output:
Starting Liquibase at 12:18:41 (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 12:18:42 PM liquibase.hub
INFO: Connected to Liquibase Hub with an API Key 'cTMOXZ************'
Sep 11, 2020 12:18:42 PM liquibase.changelog
INFO: Reading from DATABASECHANGELOG
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.028 s
[INFO] Finished at: 2020-09-11T12:18:43-05:00
[INFO] ------------------------------------------------------------------------
syncHub
optional Maven configuration properties
Property | Definition |
---|---|
hubConnectionId |
Specifies the connection needed for the |