Maven sync-hub
sync-hub
synchronizes the local DATABASECHANGELOG table with Liquibase Hub.
Uses
sync-hub
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
,changelog-sync
, ordrop-all
were run while Liquibase Hub was offline.
When you run the sync-hub
goal, you will not see any operations added to the Project associated with your changelog. sync-hub
cannot associate previous Liquibase
operations. 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>TARGET ID</hubConnectionId>
<hubProjectId>PROJECT ID</hubProjectId-->
Running the sync-hub
Maven goal
Running the sync-hub
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 the Liquibase properties file, as follows:
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 Environment Variable as
-Dliquibase.hub.apiKey
.- On Linux or MacOS:
JAVA_OPTS="-Dliquibase.hub.apiKey=<myapikey>"
- On Windows:
set JAVA_OPTS="-Dliquibase.hub.apiKey=<myapikey>"
- On Linux or MacOS:
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 the changelog file to pom.xml
or the Liquibase properties file, or specify it as the -Dliquibase.changelog-file
attribute while running the goal.
hubConnectionId
attribute:If you enter the
-Dliquibase.changelog-file
attribute, do not specifyhubConnectionId
with the goal.If you use
hubConnectionId
, add it topom.xml
, the Liquibase properties file, or thesync-hub
goal on the command line. You can find thehubConnectionId
in Project > View Details for the required project > Targets > View Status > Target ID.If you specify both the
hubConnectionId
and the changelog file, the changelog file is ignored and thehubConnectionId
is used instead.
<!--liquibase.hubConnectionId>TARGET ID</liquibase.hubConnectionId>
<hubConnectionId: <addYourHubTargetId>
liquibase sync-hub --hubConnectionId=myTargetID
Set the level of data to send to Liquibase Hub in JAVA_OPTS as -Dliquibase.hub.apiKey
or in the Liquibase properties file, as follows:
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 sync-hub
goal, register your changelog file by using the register-changelog
goal:
mvn liquibase:register-changelog
Note: The register-changelog
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:sync-hub
Output
When successful, the sync-hub
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] ------------------------------------------------------------------------
sync-hub
optional Maven configuration properties
Property | Definition |
---|---|
hubConnectionId |
Specifies the target (also called connection) needed for the |