generate-changeset-created-values
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 diff-changelog command and generate-changelog command. By default, it is set to false
.
Uses
If you use the diff-changelog
or generate-changelog
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:
- In the Liquibase properties file
- As a global parameter in the CLI
- As a JVM system property
- As an environment variable (Liquibase Pro)
Liquibase properties file parameter
In Liquibase 4.1+, add the following to Liquibase properties file:
liquibase.generateChangesetCreatedValues
: <true|false>
CLI global parameter
In your command line, use a global parameter with a single Liquibase command:
liquibase --generate-changeset-created-values
=<true|false>
generate-changelog
--changelog-file=dbchangelog.xml
Java system property
In your command line, use the JAVA_OPTS Environment Variable to set a JVM system property:
Mac/Linux syntax:
JAVA_OPTS=-Dliquibase.generateChangesetCreatedValues
=<true|false>
Windows syntax:
set JAVA_OPTS=-Dliquibase.generateChangesetCreatedValues
=<true|false>
Note: To use a Liquibase command alongside JAVA_OPTS
, add && liquibase <command>
to the end of your input.
Environment variable (Liquibase Pro)
In Liquibase Pro, set an environment variable:
Mac/Linux syntax:
LIQUIBASE_GENERATE_CHANGESET_CREATED_VALUES
=<true|false>
Windows syntax:
set LIQUIBASE_GENERATE_CHANGESET_CREATED_VALUES
=<true|false>
Note: These environment variable commands 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 diff-changelog/generate-changelog 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: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-4.9.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-4.9.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>