The generateChangeLog command creates a changelog file that has a sequence of changeSets which describes how to re-create the current state of the database.
The generateChangeLog command is typically used when you want to capture the current state of a database, then apply those changes to any number of databases. This is typically only done when a project has an existing database, but hasn’t used Liquibase before. See Adding Liquibase to an Existing project for more details.
Note: When using the update command to apply the changes in the changelog, Liquibase will not create a new database or schema. You must create them before applying the changelog to it.
Running the generateChangeLog command
To generate a changelog:
Configure the liquibase.properties file to include your driver class path, URL, and user authentication information for the database you want to capture.
Note: For information on how to configure your liquibase.properties file, view the Creating & Configuring your liquibase.properties File topic in the knowledge base. Instead of using a liquibase.properties file, you can also pass the necessary information on the command line.
Open your command prompt or Linux terminal and run the following command:
generateChangeLog Global Parameters
Specifies the root changelog.
Specifies the JDBC database connection URL.
Specifies the database username.
Specifies the database password.
Your Liquibase Pro license key.
generateChangeLog Command Parameters
Default database catalog to use.
Default database schema to use.
Database schemas you want to include.
Can be used to
If true, the catalog will be included in generated changeSets. Defaults to false.
If true, the schema will beincluded in generated changeSets. Defaults to false.
If true, the tablespace of tables and indexes will be included. Defaults to false.
Output data as CSV in the given directory
List of diff types to include in changelog expressed as a comma separated list from: tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data.
* The default value of --includeTablespace is False. --includeTablespace only captures the tablespace if it was specified in the create table statement.
** If this is null then the default types will be: tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints.
The generateChangeLog command generates a changelog that contains all of your Objects (represented as changeSets) and places the file in the same directory where the command was ran.
The extension provided determines the format of the changelog, so if you specify the filename as changelog.xml you will get an XML formatted changelog. However, if you specify the filename as changelog.yaml or changelog.json or changelog.postgresql.sql you will get changelogs formatted in YAML or JSON or SQL, respectively.
Note: When generating an SQL formatted changelog, you must specify the short name of the targeted database type as part of the filename (as shown above).
Liquibase Community changelog
Additional Functionality with Liquibase Pro
While Liquibase Community stores all changeSets in a changelog, Liquibase Pro creates a directory called Objects and places the directory at the same level as your changelog. The Objects directory contains a subdirectory for each of the following stored logic types.
Note: Not all database platforms support all of these types.