set-labels
Note: This is a Liquibase Pro feature, so you need a Liquibase Pro License Key to use it.
The set-labels
command sets or replaces
You can choose which changesets to target by specifying a changeset author, ID, path, or an existing context or label filter.
The command works with any SQL, XML, YAML, or JSON changelog. It also works with multiple changelogs specified with the include
or includeAll
tags. set-labels
is available in Liquibase 4.23.1+.
Uses
If you need to apply set-labels
to quickly add or replace
By default, Liquibase appends any set-labels
to the list of --force-replace
to true
, Liquibase drops existing
The command is also useful if you want to standardize multiple similar
After setting your set-labels
, you can deploy your changes with the update
command. While deploying, specify the --labels
command argument to control which changesets are run.
Syntax
To run the set-labels
command, specify the driver, classpath, and URL in Liquibase properties file. For more information, see Create and Configure a liquibase.properties File. You can also specify these properties in your command line.
Then run the set-labels
command:
liquibase set-labels --changelog-file=example-changelog.xml --set-as=dev,test
For example, targeting changesets by author and existing label filter:
liquibase set-labels
--set-as=rel-02-final
--changelog-file=release-02.sql
--changeset-author="bob"
--label-filter="rel-02"
Replacing existing --force-replace
instead of appending them:
liquibase set-labels
--set-as=rel-02-final
--changelog-file=release-02.sql
--changeset-author="bob"
--context-filter="dev,uat,stage"
--label-filter="rel-02"
--force-replace=true
Note: Even though you're setting context-filter
and label-filter
.
Parameters
Global parameters
Attribute | Definition | Requirements |
---|---|---|
|
Your Liquibase Pro license key |
Required |
Command parameters
Attribute | Definition | Requirements |
---|---|---|
|
The root changelog |
Required |
|
Specifies the context(s)/label(s) to apply to the changesets you select. Case-insensitive. Separate multiple values with commas (equivalent to |
Required |
|
The name of the author for the changeset. Supports |
Optional |
|
The changeset ID from the changelog. |
Optional |
|
The path to the changelog containing the changeset you want to roll back. |
Optional |
|
Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run. Note: If you use Liquibase 4.23.0 or earlier, use the syntax |
Optional |
|
Specifies which database type a changeset is to be used for. See valid database type names on Liquibase Database Tutorials. The keywords |
Optional |
|
Name of the default catalog to use for the database connection |
Optional |
|
Name of the default schema to use for the database connection. If Tip: In Liquibase v4.23.0+, camelCase for Note: The syntax |
Optional |
|
The JDBC driver class |
Optional |
|
The JDBC driver properties file |
Optional |
|
If |
Optional |
|
Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run. |
Optional |
|
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 |
|
The JDBC database connection URL. See Using JDBC URL in Liquibase. |
Optional |
|
Username 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 |
Global parameters
Attribute | Definition | Requirements |
---|---|---|
|
Your Liquibase Pro license key |
Required |
Command parameters
Attribute | Definition | Requirements |
---|---|---|
|
The root changelog |
Required |
|
Specifies the context(s)/label(s) to apply to the changesets you select. Case-insensitive. Separate multiple values with commas (equivalent to |
Required |
|
The name of the author for the changeset. Supports |
Optional |
|
The changeset ID from the changelog. |
Optional |
|
The path to the changelog containing the changeset you want to roll back. |
Optional |
|
Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run. Note: If you use Liquibase 4.23.0 or earlier, use the syntax |
Optional |
|
Specifies which database type a changeset is to be used for. See valid database type names on Liquibase Database Tutorials. The keywords |
Optional |
|
Name of the default catalog to use for the database connection |
Optional |
|
Name of the default schema to use for the database connection. If Tip: In Liquibase v4.23.0+, camelCase for Note: The syntax |
Optional |
|
The JDBC driver class |
Optional |
|
The JDBC driver properties file |
Optional |
|
If |
Optional |
|
Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run. |
Optional |
|
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 |
|
The JDBC database connection URL. See Using JDBC URL in Liquibase. |
Optional |
|
Username 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 |
Global parameters
Attribute | Definition | Requirements |
---|---|---|
|
Your Liquibase Pro license key |
Required |
Command parameters
Attribute | Definition | Requirements |
---|---|---|
|
The root changelog |
Required |
|
Specifies the context(s)/label(s) to apply to the changesets you select. Case-insensitive. Separate multiple values with commas (equivalent to |
Required |
|
The name of the author for the changeset. Supports |
Optional |
|
The changeset ID from the changelog. |
Optional |
|
The path to the changelog containing the changeset you want to roll back. |
Optional |
|
Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run. Note: If you use Liquibase 4.23.0 or earlier, use the syntax |
Optional |
|
Specifies which database type a changeset is to be used for. See valid database type names on Liquibase Database Tutorials. The keywords |
Optional |
|
Name of the default catalog to use for the database connection |
Optional |
|
Name of the default schema to use for the database connection. If Tip: In Liquibase v4.23.0+, camelCase for Note: The syntax |
Optional |
|
The JDBC driver class |
Optional |
|
The JDBC driver properties file |
Optional |
|
If |
Optional |
|
Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run. |
Optional |
|
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 |
|
The JDBC database connection URL. See Using JDBC URL in Liquibase. |
Optional |
|
Username 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 |
Global parameters
Attribute | Definition | Requirements |
---|---|---|
|
Your Liquibase Pro license key |
Required |
Command parameters
Attribute | Definition | Requirements |
---|---|---|
|
The root changelog |
Required |
|
Specifies the context(s)/label(s) to apply to the changesets you select. Case-insensitive. Separate multiple values with commas (equivalent to |
Required |
|
The name of the author for the changeset. Supports |
Optional |
|
The changeset ID from the changelog. |
Optional |
|
The path to the changelog containing the changeset you want to roll back. |
Optional |
|
Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run. Note: If you use Liquibase 4.23.0 or earlier, use the syntax |
Optional |
|
Specifies which database type a changeset is to be used for. See valid database type names on Liquibase Database Tutorials. The keywords |
Optional |
|
Name of the default catalog to use for the database connection |
Optional |
|
Name of the default schema to use for the database connection. If Tip: In Liquibase v4.23.0+, camelCase for Note: The syntax |
Optional |
|
The JDBC driver class |
Optional |
|
The JDBC driver properties file |
Optional |
|
If |
Optional |
|
Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run. |
Optional |
|
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 |
|
The JDBC database connection URL. See Using JDBC URL in Liquibase. |
Optional |
|
Username 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 |
Global parameters
Attribute | Definition | Requirements |
---|---|---|
|
Your Liquibase Pro license key |
Required |
Command parameters
Attribute | Definition | Requirements |
---|---|---|
|
The root changelog |
Required |
|
Specifies the context(s)/label(s) to apply to the changesets you select. Case-insensitive. Separate multiple values with commas (equivalent to |
Required |
|
The name of the author for the changeset. Supports |
Optional |
|
The changeset ID from the changelog. |
Optional |
|
The path to the changelog containing the changeset you want to roll back. |
Optional |
|
Specifies the changeset contexts to match. Contexts are tags you can add to changesets to control which changesets are executed in any particular migration run. Note: If you use Liquibase 4.23.0 or earlier, use the syntax |
Optional |
|
Specifies which database type a changeset is to be used for. See valid database type names on Liquibase Database Tutorials. The keywords |
Optional |
|
Name of the default catalog to use for the database connection |
Optional |
|
Name of the default schema to use for the database connection. If Tip: In Liquibase v4.23.0+, camelCase for Note: The syntax |
Optional |
|
The JDBC driver class |
Optional |
|
The JDBC driver properties file |
Optional |
|
If |
Optional |
|
Specifies the changeset labels to match. Labels are tags you can add to changesets to control which changesets will be executed in any migration run. |
Optional |
|
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 |
|
The JDBC database connection URL. See Using JDBC URL in Liquibase. |
Optional |
|
Username 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 |
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.
Output
When successful, the set-labels
command produces the following output:
* Changelog file 'changelog.xml' modified successfully.
Liquibase command 'set-labels' was executed successfully.
If you specify an invalid value for the dbms
argument:
Mismatched dbms for changeset 'createPrimaryTable::Liquibase Pro User::changelog.xml'
When there is an ignored changeset:
Ignoring changeset 'createSecondaryTable::Liquibase Pro User::changelog.xml'
When there is nothing to modify:
* Changelog file 'changelog.xml' was not modified.