Ant changeLogSyncToTagSql
changeLogSyncToTagSql
is a helper task that produces the raw SQL that Liquibase would run when using the changeLogSyncToTag
task to mark all undeployed changesets associated with the specified tag as executed in your database.
Uses
The changeLogSyncToTagSql
task is typically used when you want to inspect the SQL Liquibase will use to baseline a new database environment.
It is best practice to inspect any SQL that Liquibase would run when using the cchangeLogSyncToTag
task so you can review any changes the task would make to your database before running it. The changeLogSyncToTag
task marks all changesets starting with the first changeset at the top of the changelog file and moving down to the changeset up to and including the tag.
Note: If you don't have any tag specified in your changelog file, add it by using the tagDatabase Change Types as follows:
<changeSet id="13.1" author="liquibase">
<tagDatabase tag="version_2.0"/>
</changeSet>
Syntax
To execute the changeLogSyncToTagSql
task, include the following values in your Ant default file, which can be build.xml
:
<project name="Example" xmlns:liquibase="antlib:liquibase.integration.ant">
<taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant">
<classpath path="path/to/liquibase/libs"/>
</taskdef>
<property name="db.changelog.file" value="changelog.xml" />
<target name="changeLogSyncToTagSql" depends="prepare">
<liquibase:database
id="my-database"
driver="${driver.classname}"
url="${jdbc.url}"
user="${username}"
password="${password}"/>
<liquibase:changeLogSyncToTagSql
databaseref="my-database"
changeLogFile="com/example/changelog.xml"
labelFilter="mylabels"
toTag="version_1.1"
classpathref="classpath"/>
</target>
</project>
This example will sync the referenced database with the changesets found in the changelog file up to and including the tag changeset.
Next, run the following in the CLI to implement the task and update your database:
ant -f build.xml changeLogSyncToTagSql
Note: It is important to type the task name in the command prompt exactly like you specify it in the target name of your build.xml
file. Ant uses the task name to determine which Liquibase command it will run.
Attributes
Attribute | Description | Required |
---|---|---|
changelogFile
|
The changelog file for Liquibase to use. | Yes |
toTag
|
Syncs the changesets up to and including the tag. | Yes |
contexts
|
A comma-separated list of Contexts to execute. If not specified, all contexts are run. | No |
outputFile
|
If specified, Liquibase will save the update SQL statements to the specified file rather than executing them in the database. | No |
outputEncoding
|
The character encoding to use when writing to output file. | No. Defaults to system encoding. |
promptOnNonLocalDatabase
|
If set to true, a dialog box with warn you if you attempt to run the Liquibase against a database that is not on localhost. | No. The default value is set to false. |
classpathref
|
A reference to the classpath used to run the task with. | No |
databaseref
|
A reference to the database that Liquibase will connect to. | Yes, unless a nested <database> element is present. |
driver
|
Deprecated: Name of the database driver to connect with. | No |
url
|
Deprecated: Use <database> 's url attribute instead. The database URL.
|
No |
username
|
Deprecated: The database username to connect with. | No |
password
|
Deprecated: The password to use when connecting to the database. | No |
defaultSchemaName
|
Deprecated: Schema to use by default for managed database objects and Liquibase control tables. | No |
currentDateTimeFunction
|
Deprecated: Overrides current date time function used in SQL. Useful for unsupported databases. | No |
databaseChangeLogTableName
|
Deprecated: Overrides the name of the DATABASECHANGELOG table to use. | No |
databaseChangeLogLockTableName
|
Deprecated: Overrides the name of the DATABASECHANGELOGLOCK table to use. | No |
logLevel
|
Deprecated: Specifies one of the following logging levels: debug, info, warning, severe, off. The default level is info. | No |
Nested attributes
Attribute | Description | Required |
---|---|---|
classpath
|
The classpath used to run the task. | Optional |
database
|
See database data type for more information. | Required unless a databaseref attribute is given. |
changelogparameters
|
See Substituting Properties in Changelogs for more information. | Optional |