Maven syncHub

syncHub synchronizes the local DATABASECHANGELOG table with Liquibase Hub.


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, or dropAll 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. 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>
<hubConnectionId>TARGET 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
  • There are three ways to specify your API Key:

    • Including liquibase.hub.ApiKey value in the Liquibase properties file, as follows:
    • 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 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>"
    • 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 the changelog file to pom.xml or the Liquibase properties file, or specify it as the -Dliquibase.changeLogFile attribute while running the goal.

  • The hubConnectionId attribute:
    • If you enter the -Dliquibase.changeLogFile attribute, do not specify hubConnectionId with the goal.

    • If you use hubConnectionId, add it to pom.xml, the Liquibase properties file, or the syncHub goal on the command line. You can find the hubConnectionId 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 the hubConnectionId is used instead.

<!--liquibase.hubConnectionId>TARGET ID</liquibase.hubConnectionId>
<hubConnectionId: <addYourHubTargetId>
liquibase syncHub --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:

  • 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.

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


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] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[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 target (also called connection) needed for the syncHub goal to synchronize the local DATABASECHANGELOG table with Liquibase Hub.