generate-changelog Task

Generates a changelog to re-create an existing database.

generate-changelog task examples

<liquibase:generate-changelog  classpathref="classpath">  
    <liquibase:database  driver="${driver.class}"  url="${jdbc.url}"  user="${jdbc.user}"  password="${jdbc.user}"/>  
    <liquibase:xml  output-file="/path/to/output/changelog.xml"  encoding="UTF-8"/>  
</liquibase:generate-changelog>

Generates a changelog file for the database in XML format.

<liquibase:generate-changelog  classpathref="classpath">  
    <liquibase:database  driver="${driver.class}"  url="${jdbc.url}"  user="${jdbc.user}"  password="${jdbc.user}"/>  
    <liquibase:xml  output-file="/path/to/output/changelog.xml"  encoding="UTF-8"/>  
    <liquibase:yaml  output-file="/path/to/output/changelog.yaml"  encoding="UTF-8"/>  
</liquibase:generate-changelog>

Generates the changelog in both XML and YAML format.

Parameters

Attribute Description Required
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.
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; default is false.
outputFile

Deprecated: Where to save the generated changelog file.

No
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

Parameters Specified as Nested Elements

xml, yaml, json, or txt

This task is capable of generating changelog files in multiple formats. At least one of these elements is required.

Attribute Description Required
outputFile

The location to write the changelog file to.

Yes
encoding

The character encoding to use when writing to output file.

No. Defaults to system encoding

For example:

<liquibase:xml  output-file="/path/to/output/changelog.xml"  encoding="UTF-8"/>

Other attributes

Attribute Description Required
classpath

The classpath used to run the task.

Optional
database

See database data type for more information.

Required unless a databaserefattribute is given.
changelogparameters

See Substituting Properties in Changelogs for more information.

Optional