generate-changeset-created-values parameter

The generate-changeset-created-values global parameter is a Boolean that determines whether Liquibase adds timestamps to changesets in the changelog it generates when you run the diffChangeLog command and generateChangeLog command. By default, it is set to false.

Uses

If you use the diffChangeLog or generateChangeLog commands to create a changelog with the contents of your database, you can set generate-changeset-created-values to true to include a timestamp in the header of each changeset in your changelog. The timestamp is stored as the value of the created parameter and uses the format YYYY-MM-DD hh:mm-ssss.

Setting the generate-changeset-created-values parameter

You can set generate-changeset-created-values in four ways:

  • As a JVM system property
  • In your liquibase.properties file
  • As a global parameter in the CLI
  • As an environment variable (Liquibase Pro)

Java system property

You can set generate-changeset-created-values as a Java system property by using the JAVA_OPTS Environment Variable in your command line. The syntax on Mac/Linux is as follows:

JAVA_OPTS=-Dliquibase.generateChangesetCreatedValues=<true|false> && liquibase generate-changelog --changelog-file=dbchangelog.xml

The syntax on Windows requires the set command:

set JAVA_OPTS=-Dliquibase.generateChangesetCreatedValues=<true|false> && liquibase generate-changelog --changelog-file=dbchangelog.xml

liquibase.properties parameter

In Liquibase 4.1+, you can set generate-changeset-created-values by adding the following to your liquibase.properties file:

liquibase.generateChangesetCreatedValues: <true|false>

CLI global parameter

You can use generate-changeset-created-values as a global parameter in your command line with a single Liquibase command, such as generateChangeLog:

liquibase --generate-changeset-created-values=<true|false> generate-changelog --changelog-file=dbchangelog.xml

Environment variable (Liquibase Pro)

If you use Liquibase Pro, you can set generate-changeset-created-values as an environment variable. The syntax on Mac/Linux is as follows:

LIQUIBASE_GENERATE_CHANGESET_CREATED_VALUES=<true|false>

The syntax on Windows requires the set command:

set LIQUIBASE_GENERATE_CHANGESET_CREATED_VALUES=<true|false>

Note: The commands shown above only apply to the current shell. If you need to pass an environment variable to a child process without affecting the parent process, you can use the export command on Mac/Linux or the setx command on Windows.

Output

If you run a command like generate-changelog with generate-changeset-created-values set to true, the output is:

BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed.
Generated changelog written to C:\<filepath>\dbchangelog.xml
Liquibase command 'generate-changelog' was executed successfully.

The generated changelog includes a created parameter that has a timestamp:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xmlns:pro="http://www.liquibase.org/xml/ns/pro"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="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-4.1.xsd
	http://www.liquibase.org/xml/ns/dbchangelog
	http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
	<changeSet author="adrian (generated)" created="2021-08-02 16:26-0400" id="1627936002055-1">
		<createTable tableName="TEST_TABLE">
			<column name="TEST_ID" type="INT">
				<constraints nullable="false" primaryKey="true" primaryKeyName="PK_TEST_TABLE"/>
			</column>
			<column name="TEST_COLUMN" type="VARCHAR(2147483647)"/>
		</createTable>
	</changeSet>
</databaseChangeLog>

Related links