diff-changelog

Last published July 28, 2025

The diff-changelog command displays the differences between two databases you are comparing. It also generates a changelog file containing deployable changesets to resolve most of these differences.

Uses

The diff-changelog command is typically used when you want to create a deployable changelog to synchronize multiple databases. The diff-changelog command also provides more information about database drift:

  • Missing objects in your database

  • Changes made to your database

  • Unexpected items in your database

In Liquibase Pro 4.25.1 and later, you can use diff-changelog to seamlessly generate a Drift Report for your databases.

In order to track changes to a database, you can generate a snapshot of the database, make the changes, and create a changelog, which you can use to compare the snapshot with your database.

Running the diff-changelog command

Running the diff-changelog command requires two URLs:

  • reference-url– the source for the comparison. The --reference-url attribute represents your source (reference) database, which is the basis for the database you want to compare.

  • url– the target of the comparison. The --url attribute represents your target database, which you want to compare to the source (reference) database. You typically perform actions and run commands on this database.

To create a diff changelog:

Option 1

Run the diff-changelog command with all necessary attributes in the CLI:

liquibase diff-changelog --changelog-file=example-changelog.xml --url="jdbc:oracle:thin:@<IP OR HOSTNAME>:<PORT>:<SERVICE NAME OR SID>" --username=<USERNAME> --password=<PASSWORD> --reference-url="jdbc:oracle:thin:@<IP OR HOSTNAME>:<PORT>:<SERVICE NAME OR SID>" --reference-username=<USERNAME> --reference-password=<PASSWORD>

Note: To run this command with an offline database snapshot, use the following pattern for the reference URL: --reference-url="offline:mysql?snapshot=SNAPSHOT_DEV.json".

Tip: For best results, specify all commands and parameters in the --kebab-case format in the CLI. If your preference is camelCase, it also works in the CLI.

Tip: Liquibase recommends that you place your database's JDBC driver JAR file in the $LIQUIBASE_HOME/lib directory. If you place the driver file in a different directory, specify the path in the properties file: classpath:../<path-to-drivers>/ojdbc<version>.jar. When you run the diff command against two databases, either the drivers for both must be in the $LIQUIBASE_HOME/lib directory or the classpath property must reference both JAR files. Use the appropriate path separator for your operating system: for Windows, use a semicolon; for Mac or Linux, use a colon.

Tip: $LIQUIBASE_HOME is an environment variable that points to the location of the directory where Liquibase is installed on your machine. You can set environment variables using your operating system's shell. The location of $LIQUIBASE_HOME will depend on where Liquibase was installed on your machine.

Example: classpath: ojdbc7.jar:postgresql-42.2.8.jar

Option 2:

Configure the Liquibase properties file to include the connection information for both databases. Then, run the following command in the CLI:

liquibase diff-changelog --changelog-file=example-changelog.xml

Note: If you specify a changelog file name that already exists, Liquibase will append your changes to the existing file.

Output

The diff-changelog command produces a list of all objects and creates a changelog with a list of changesets.

Liquibase Open Source diff-changelog categories:

  • Catalog

  • Column

  • Foreign Key

  • Index

  • Primary Key

  • Schema

  • Sequence

  • Unique Constraints

  • View

Console output example

Liquibase Version: 4.9.1 BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed. Some database objects and their dependencies cannot be represented automatically, and they may need to be manually updated before being deployed. Liquibase command 'diff-changelog' was executed successfully.

Filtering diff-changelog types

You can filter what objects diff-changelog generates with the --diff-types attribute:

--diff-types=<catalogs,tables,functions,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,storedprocedures,triggers,sequences,databasepackage,databasepackagebody>

You can also filter specific objects by name with the --include-objects and --exclude-objects attributes. For example:

--include-objects=table:tableName,column:columnName,view:viewName,index:indexName --exclude-objects=table:tableName,column:columnName,view:viewName,index:indexName

This way, you can prevent undesired objects from ending in the resulting changelog.

Additional Functionality with Liquibase Pro

While Liquibase Open Source stores all changesets in a changelog, Liquibase Pro creates a directory called Objects and places the directory at the same level as your changelog. The Objects directory contains a subdirectory for each of the following Stored Logic types:

  • checkconstraint

  • package

  • packagebody

  • procedure

  • function

  • trigger

  • synonyms

Note: Not all database platforms support all stored logic types that are listed.

The diff-changelog command structures stored logic files into timestamped directories every time you run the command.

Note: Liquibase does not currently check data type length.

Note: The username and password attributes are not required for connections and systems which use alternate means of authentication. Also, you can specify database credentials as part of the url attribute.

Liquibase Pro diff-changelog example file

<?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd"> <changeSet author="Administrator (generated)" id="1571345362466-8"> <pro:createTrigger disabled="false" path="objects/trigger/TS_T_EXEMPLAR_SEQEXEMPLAR.sql" relativeToChangelogFile="true" tableName="T_EXEMPLAR" triggerName="TS_T_EXEMPLAR_SEQEXEMPLAR"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-9"> <pro:createTrigger disabled="false" path="objects/trigger/ORDERS_BEFORE_INSERT4.sql" relativeToChangelogFile="true" tableName="orders" triggerName="ORDERS_BEFORE_INSERT4"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-10"> <pro:createTrigger disabled="false" path="objects/trigger/ORDERS_BEFORE_INSERT2.sql" relativeToChangelogFile="true" tableName="orders" triggerName="ORDERS_BEFORE_INSERT2"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-11"> <pro:createTrigger disabled="false" path="objects/trigger/ORDERS_BEFORE_INSERT.sql" relativeToChangelogFile="true" tableName="orders" triggerName="ORDERS_BEFORE_INSERT"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-12"> <createView fullDefinition="true" path="objects/view/OREDERS_VIEW.sql" relativeToChangelogFile="true" viewName="OREDERS_VIEW"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-13"> <pro:createTrigger disabled="false" path="objects/trigger/ORDERS_BEFORE_INSERT3.sql" relativeToChangelogFile="true" tableName="orders" triggerName="ORDERS_BEFORE_INSERT3"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-14"> <createProcedure path="objects/storedprocedure/P_CUSTOMER_HAS_NUM_FILM.sql" procedureName="P_CUSTOMER_HAS_NUM_FILM" relativeToChangelogFile="true"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-15"> <createView fullDefinition="true" path="objects/view/V_CUSTOMER_HAS_FILM.sql" relativeToChangelogFile="true" viewName="V_CUSTOMER_HAS_FILM"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-16"> <createProcedure path="objects/storedprocedure/SP_CUSTOMER_SOCIAL_ACCTS.sql" procedureName="SP_CUSTOMER_SOCIAL_ACCTS" relativeToChangelogFile="true"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-17"> <pro:createTrigger disabled="false" path="objects/trigger/TRI_BORROWING.sql" relativeToChangelogFile="true" tableName="T_BORROWING" triggerName="TRI_BORROWING"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-18"> <pro:createTrigger disabled="false" path="objects/trigger/TRU_BORROWING.sql" relativeToChangelogFile="true" tableName="T_BORROWING" triggerName="TRU_BORROWING"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-19"> <pro:createTrigger disabled="false" path="objects/trigger/TSU_T_EXEMPLAR_SEQEXEMPLAR.sql" relativeToChangelogFile="true" tableName="T_EXEMPLAR" triggerName="TSU_T_EXEMPLAR_SEQEXEMPLAR"/> </changeSet> <changeSet author="Administrator (generated)" id="1571345362466-20"> <pro:createFunction functionName="F_CUSTOMER_HAS_NUM_FILM" path="objects/function/F_CUSTOMER_HAS_NUM_FILM.sql" relativeToChangelogFile="true"/> </changeSet> </databaseChangeLog>

Command parameters

Attribute

Definition

Requirement

--changelog-file=<string>

The root changelog

Required

--reference-url=<string>

The JDBC reference database connection URL

Required

--data-output-directory=<string>

Specifies a directory to send the loadData output to a CSV file which is generated by running the diff-changelog or generate-changelog command.

Optional

--url=<string>

The JDBC database connection URL.

Required

--author=<string>

Specifies the author for changesets in the generated changelog.

Optional

--context-filter=<string>

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

--default-catalog-name=<string>

Name of the default catalog to use for the database connection

Optional

--default-schema-name=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Note: In the properties file and JAVA_OPTS only: in 4.18.0 and earlier, specify this parameter using the syntax defaultSchemaName. In 4.19.0 and later, use the syntax liquibase.command.defaultSchemaName.

Note: In Liquibase 4.12.0 and later, you can use mixed-case schema names if you set --preserve-schema-case to true. However, in Liquibase 4.12.0–4.22.0, the Liquibase validator still throws a DatabaseException error if you specify a mixed-case value of defaultSchemaName. In 4.23.0 and later, the Liquibase validator accepts any casing.

Optional

--diff-types=<string>

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

--drift-severity=<string>

Specifies the severity level of all error types in the drift report (changed, missing, or unexpected content). Valid values are INFO (0), MINOR (1), MAJOR (2), CRITICAL (3), and BLOCKER (4), from least severe to most severe. If both --drift-severity and one of the individual error type arguments are set, the individual error type arguments take priority. Default: INFO.

Optional

--drift-severity-changed=<string>

Specifies the severity level of changed content in the drift report. Valid values are INFO (0), MINOR (1), MAJOR (2), CRITICAL (3), and BLOCKER (4), from least severe to most severe. Overrides the value of --drift-severity for changed content only. Default: INFO.

Optional

--drift-severity-missing=<string>

Specifies the severity level of missing content in the drift report. Valid values are INFO (0), MINOR (1), MAJOR (2), CRITICAL (3), and BLOCKER (4), from least severe to most severe. Overrides the value of --drift-severity for missing content only. Default: INFO.

Optional

--drift-severity-unexpected=<string>

Specifies the severity level of unexpected content in the drift report. Valid values are INFO (0), MINOR (1), MAJOR (2), CRITICAL (3), and BLOCKER (4), from least severe to most severe. Overrides the value of --drift-severity for unexpected content only. Default: INFO.

Optional

--driver=<string>

The JDBC driver class

Optional

--driver-properties-file=<string>

The JDBC driver properties file

Optional

--exclude-objects=<string>

Objects to exclude from diff

Optional

--include-catalog=<true|false>

If true, the catalog will be included in generated changesets. Default: false

Optional

--include-objects=<string>

Objects to include in diff

Optional

--include-schema=<true|false>

If true, the schema will be included in generated changesets. Default: false

Optional

--include-tablespace=<true|false>

Include the tablespace attribute in the changelog. Default: false

Optional

--label-filter=<string>

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

--report-open=<true|false>

If true, automatically opens the report in your default browser. Default: false.

Note: Prior to Liquibase 4.29.0, this parameter was called --open-report instead of --report-open.

Optional

--output-schemas=<string>

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

--password=<string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--preserve-null-values=<string>

If true, column nodes will be created with null values. For example:

<insert schemaName="public" tableName="liquibase_rules">

<column name="a" value="AA" />

<column name="b" value="null" />

<column name="c" value="null" />

</insert>

If false, null values will be ignored. For example:

<insert schemaName="public" tableName="liquibase_rules">

<column name="a" value="AA" />

</insert>

Optional

--reference-default-catalog-name=<string>

The reference default catalog name to use for the database connection

Optional

--reference-default-schema-name=<string>

The reference default schema name to use for the database connection

Optional

--reference-driver=<string>

The JDBC driver class for the reference database

Optional

--reference-driver-properties-file=<string>

The JDBC driver properties file for the reference database

Optional

--reference-liquibase-catalog-name=<string>

Reference database catalog to use for Liquibase objects. Liquibase 4.24.0+.

Optional

--reference-liquibase-schema-name=<string>

Reference database schema to use for Liquibase objects. Liquibase 4.24.0+.

Optional

--reference-password=<string>

The reference database password.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--reference-schemas=<string>

Schemas names on reference database to use in diff. This is a CSV list.

Optional

--reference-username=<string>

The reference database username.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--replace-if-exists-types=<string>

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

--report-enabled=<true|false>

Enables a report at the command level. Overrides the global parameter --reports-enabled. Default: true.

Optional

--report-name=<string>

Specifies the name of the report file at the command level. Overrides the global parameter --reports-name. By default, Liquibase generates a new report file labeled with a timestamp (user's local time). If you set a custom name, Liquibase overwrites the existing file every time you generate a new report. Default: report-<DD-Mon-YYYY-HHmmss>.html.

Optional

--report-path=<string>

Specifies the file path to the report file at the command level. Overrides the global parameter --reports-path. Default: ./.

Optional

--report-suppress-exception=<true|false>

Liquibase 4.31.0+. Specifies whether to hide exceptions (which may contain SQL) from the operation report at the command level. Overrides the global parameter --reports-suppress-exception. Default: false. However:

If --report-suppress-exception is not set and --report-suppress-sql=true, Liquibase suppresses all SQL, including exception SQL.

If --report-suppress-exception=false and --report-suppress-sql=true, Liquibase suppresses most SQL but shows exception SQL.

Optional

--report-suppress-sql=<true|false>

Liquibase 4.31.0+. Specifies whether to hide changeset SQL in operation reports at the command level. Overridden by the global parameter --reports-suppress-sql. Default: false.

Optional

--run-on-change-types=<string>

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

--schemas=<string>

Schemas to include in diff

Optional

--skip-object-sorting=<true|false>

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

--username=<string>

Username to connect to the target database.

Tip: It is best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Drift report

In Liquibase 4.25.1 and later, you can automatically generate a Drift Report using the diff-changelog command. The drift report requires a Liquibase Pro license key.