generate-changelog

The generate-changelog command creates a changelog file that has a sequence of changesets which describe how to re-create the current state of the database.


Uses

The generate-changelog 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 How to set up Liquibase with an Existing Project and Multiple Environments 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.

Run the generate-changelog command

In this example, our sample database has the following content:

To generate a changelog from our sample database:

  1. Configure the Liquibase properties file to include your driver, classpath, and URL for the database you want to capture. Alternatively, you can pass the necessary information as environment variables or from the command line.
  2. Decide which data types you want to include. You can specify these with the --diff-types parameter.
  3. Open your CLI and run one of the following commands:
    • Generate a changelog without specifying diff types (Liquibase uses the default diff types: columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, and views):
    • liquibase generate-changelog --changelog-file=example-changelog.xml
    • Generate a changelog with specific diff types:
    • liquibase generate-changelog --changelog-file=example-changelog.xml --diff-types=catalogs,checkconstraints,columns,databasepackage,databasepackagebody,foreignkeys,functions,indexes,primarykeys,sequences,storedprocedures,tables,triggers,uniqueconstraints,views

Liquibase then generates your changelog and displays the following message:

BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed. Some database objects and their dependencies cannot be represented automatically, and they may need to be manually updated before being deployed.
Generated changelog written to example-changelog.xml
Liquibase command 'generate-changelog' was executed successfully.

Output changelogs

The generate-changelog command generates a changelog that contains all your objects (represented as changesets) and places the file in the same directory where the command was ran.

The extension you provide 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, changelog.json, or changelog.sql, you will get changelogs formatted in YAML, JSON, or SQL, respectively.

Default diff types

<?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-latest.xsd
    http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
    <changeSet author="tfernandez (generated)" id="1704821089427-1">
        <createTable tableName="testtable">
            <column defaultValue="My text value" name="text" type="VARCHAR" />
            <column autoIncrement="true" name="number" type="INTEGER">
                <constraints nullable="false" />
            </column>
            <column name="date" type="date">
                <constraints nullable="false" />
            </column>
        </createTable>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-2">
        <pro:createFunction functionName="customfunction"
            path="objects/function/customfunction-bcd8b0c2.sql" relativeToChangelogFile="true" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-3">
        <createTable tableName="foreigntable">
            <column autoIncrement="true" name="id" type="INTEGER">
                <constraints nullable="false" />
            </column>
            <column name="foreignid" type="INTEGER">
                <constraints nullable="false" />
            </column>
        </createTable>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-4">
        <pro:createTrigger disabled="false"
            path="objects/trigger/testtable_customtrigger-41365cf7.sql"
            relativeToChangelogFile="true" tableName="testtable" triggerName="customtrigger" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-5">
        <addUniqueConstraint columnNames="number" constraintName="testtable_un"
            tableName="testtable" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-6">
        <createView fullDefinition="false" viewName="customview">SELECT id,
            foreignid
            FROM foreigntable;
        </createView>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-7">
        <createProcedure path="objects/storedprocedure/customProcedure.sql"
            procedureName="customProcedure" relativeToChangelogFile="true" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821089427-8">
        <addForeignKeyConstraint baseColumnNames="foreignid" baseTableName="foreigntable"
            constraintName="fk_foreigntable" deferrable="false" initiallyDeferred="false"
            onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="number"
            referencedTableName="testtable" validate="true" />
    </changeSet>
</databaseChangeLog>
databaseChangeLog:
- changeSet:
    id: 1704821121380-1
    author: tfernandez (generated)
    changes:
    - createTable:
        columns:
        - column:
            defaultValue: My text value
            name: text
            type: VARCHAR
        - column:
            autoIncrement: true
            constraints:
              nullable: false
            name: number
            type: INTEGER
        - column:
            constraints:
              nullable: false
            name: date
            type: date
        tableName: testtable
- changeSet:
    id: 1704821121380-2
    author: tfernandez (generated)
    changes:
    - createFunction:
        functionName: customfunction
        path: objects/function/customfunction-bcd8b0c2.sql
        relativeToChangelogFile: true
- changeSet:
    id: 1704821121380-3
    author: tfernandez (generated)
    changes:
    - createTable:
        columns:
        - column:
            autoIncrement: true
            constraints:
              nullable: false
            name: id
            type: INTEGER
        - column:
            constraints:
              nullable: false
            name: foreignid
            type: INTEGER
        tableName: foreigntable
- changeSet:
    id: 1704821121380-4
    author: tfernandez (generated)
    changes:
    - createTrigger:
        disabled: false
        path: objects/trigger/testtable_customtrigger-41365cf7.sql
        relativeToChangelogFile: true
        tableName: testtable
        triggerName: customtrigger
- changeSet:
    id: 1704821121380-5
    author: tfernandez (generated)
    changes:
    - addUniqueConstraint:
        columnNames: number
        constraintName: testtable_un
        tableName: testtable
- changeSet:
    id: 1704821121380-6
    author: tfernandez (generated)
    changes:
    - createView:
        fullDefinition: false
        selectQuery: |-
          SELECT id,
              foreignid
             FROM foreigntable;
        viewName: customview
- changeSet:
    id: 1704821121380-7
    author: tfernandez (generated)
    changes:
    - createProcedure:
        path: objects/storedprocedure/customProcedure.sql
        procedureName: customProcedure
        relativeToChangelogFile: true
- changeSet:
    id: 1704821121380-8
    author: tfernandez (generated)
    changes:
    - addForeignKeyConstraint:
        baseColumnNames: foreignid
        baseTableName: foreigntable
        constraintName: fk_foreigntable
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: number
        referencedTableName: testtable
        validate: true
{ "databaseChangeLog": [
  {
    "changeSet": {
      "id": "1704821132889-1",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTable": {
            "columns": [
              {
                "column": {
                  "defaultValue": "My text value",
                  "name": "text",
                  "type": "VARCHAR"
                }
              },
              {
                "column": {
                  "autoIncrement": true,
                  "constraints": {
                    "nullable": false
                  },
                  "name": "number",
                  "type": "INTEGER"
                }
              },
              {
                "column": {
                  "constraints": {
                    "nullable": false
                  },
                  "name": "date",
                  "type": "date"
                }
              }
            ]
            ,
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-2",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createFunction": {
            "functionName": "customfunction",
            "path": "objects/function/customfunction-bcd8b0c2.sql",
            "relativeToChangelogFile": true
          }
        }
      ]
      
    }
  },
  {
    "changeSet": {
      "id": "1704821132889-3",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTable": {
            "columns": [
              {
                "column": {
                  "autoIncrement": true,
                  "constraints": {
                    "nullable": false
                  },
                  "name": "id",
                  "type": "INTEGER"
                }
              },
              {
                "column": {
                  "constraints": {
                    "nullable": false
                  },
                  "name": "foreignid",
                  "type": "INTEGER"
                }
              }
            ]
            ,
            "tableName": "foreigntable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-4",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTrigger": {
            "disabled": false,
            "path": "objects/trigger/testtable_customtrigger-41365cf7.sql",
            "relativeToChangelogFile": true,
            "tableName": "testtable",
            "triggerName": "customtrigger"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-5",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "addUniqueConstraint": {
            "columnNames": "number",
            "constraintName": "testtable_un",
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-6",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createView": {
            "fullDefinition": false,
            "selectQuery": "SELECT id,\n    foreignid\n   FROM foreigntable;",
            "viewName": "customview"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-7",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createProcedure": {
            "path": "objects/storedprocedure/customProcedure.sql",
            "procedureName": "customProcedure",
            "relativeToChangelogFile": true
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821132889-8",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "addForeignKeyConstraint": {
            "baseColumnNames": "foreignid",
            "baseTableName": "foreigntable",
            "constraintName": "fk_foreigntable",
            "deferrable": false,
            "initiallyDeferred": false,
            "onDelete": "NO ACTION",
            "onUpdate": "NO ACTION",
            "referencedColumnNames": "number",
            "referencedTableName": "testtable",
            "validate": true
          }
        }
      ]
      
    }
  }
  
]}
--liquibase formatted sql

--changeset tfernandez:1704821094961-1
CREATE TABLE "testtable" ("text" VARCHAR DEFAULT 'My text value', "number" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, "date" date NOT NULL);

--changeset tfernandez:1704821094961-2 splitStatements:false
CREATE OR REPLACE FUNCTION "public".customfunction()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
BEGIN
	IF NEW.text <> OLD.text THEN
		 INSERT INTO testtable (text,number,date)
		 VALUES(new.text,new.number,new.date);
	END IF;

	RETURN NEW;
END;
$function$;

--changeset tfernandez:1704821094961-3
CREATE TABLE "foreigntable" ("id" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, "foreignid" INTEGER NOT NULL);

--changeset tfernandez:1704821094961-4 splitStatements:false
CREATE TRIGGER customtrigger BEFORE UPDATE ON "public".testtable FOR EACH ROW EXECUTE FUNCTION customfunction();

--changeset tfernandez:1704821094961-5
ALTER TABLE "testtable" ADD CONSTRAINT "testtable_un" UNIQUE ("number");

--changeset tfernandez:1704821094961-6
CREATE VIEW "customview" AS SELECT id,
    foreignid
   FROM foreigntable;

--changeset tfernandez:1704821094961-7 splitStatements:false
CREATE OR REPLACE PROCEDURE public."customProcedure"()
 LANGUAGE plpgsql
AS $procedure$
	BEGIN
		insert into public.testtable (text,date) values ('first',CURRENT_DATE);
	END;
$procedure$;

--changeset tfernandez:1704821094961-8
ALTER TABLE "foreigntable" ADD CONSTRAINT "fk_foreigntable" FOREIGN KEY ("foreignid") REFERENCES "testtable" ("number") ON UPDATE NO ACTION ON DELETE NO ACTION;

Specific diff types

<?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-latest.xsd
    http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
    <changeSet author="tfernandez (generated)" id="1704821340603-1">
        <createTable tableName="testtable">
            <column defaultValue="My text value" name="text" type="VARCHAR" />
            <column autoIncrement="true" name="number" type="INTEGER">
                <constraints nullable="false" />
            </column>
            <column name="date" type="date">
                <constraints nullable="false" />
            </column>
        </createTable>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-2">
        <insert tableName="testtable">
            <column name="text" value="one" />
            <column name="number" valueNumeric="1" />
            <column name="date" valueDate="2024-01-09" />
        </insert>
        <insert tableName="testtable">
            <column name="text" value="three" />
            <column name="number" valueNumeric="2" />
            <column name="date" valueDate="2024-01-09" />
        </insert>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-3">
        <pro:createFunction functionName="customfunction"
            path="objects/function/customfunction-bcd8b0c2.sql" relativeToChangelogFile="true" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-4">
        <createTable tableName="foreigntable">
            <column autoIncrement="true" name="id" type="INTEGER">
                <constraints nullable="false" />
            </column>
            <column name="foreignid" type="INTEGER">
                <constraints nullable="false" />
            </column>
        </createTable>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704822563807-1">
        <pro:addCheckConstraint constraintName="testtable_check" disabled="false" tableName="testtable">
            ((number > 0))
        </pro:addCheckConstraint>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-5">
        <pro:createTrigger disabled="false"
            path="objects/trigger/testtable_customtrigger-41365cf7.sql"
            relativeToChangelogFile="true" tableName="testtable" triggerName="customtrigger" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-6">
        <addUniqueConstraint columnNames="number" constraintName="testtable_un"
            tableName="testtable" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-7">
        <createView fullDefinition="false" viewName="customview">SELECT id,
            foreignid
            FROM foreigntable;
        </createView>
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-8">
        <addForeignKeyConstraint baseColumnNames="foreignid" baseTableName="foreigntable"
            constraintName="fk_foreigntable" deferrable="false" initiallyDeferred="false"
            onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="number"
            referencedTableName="testtable" validate="true" />
    </changeSet>
    <changeSet author="tfernandez (generated)" id="1704821340603-9">
        <createProcedure path="objects/storedprocedure/customProcedure.sql"
            procedureName="customProcedure" relativeToChangelogFile="true" />
    </changeSet>
</databaseChangeLog>
databaseChangeLog:
- changeSet:
    id: 1704821709768-1
    author: tfernandez (generated)
    changes:
    - createTable:
        columns:
        - column:
            defaultValue: My text value
            name: text
            type: VARCHAR
        - column:
            autoIncrement: true
            constraints:
              nullable: false
            name: number
            type: INTEGER
        - column:
            constraints:
              nullable: false
            name: date
            type: date
        tableName: testtable
- changeSet:
    id: 1704821709768-2
    author: tfernandez (generated)
    changes:
    - insert:
        columns:
        - column:
            name: text
            value: one
        - column:
            name: number
            valueNumeric: 1
        - column:
            name: date
            valueDate: 2024-01-09
        tableName: testtable
    - insert:
        columns:
        - column:
            name: text
            value: three
        - column:
            name: number
            valueNumeric: 2
        - column:
            name: date
            valueDate: 2024-01-09
        tableName: testtable
- changeSet:
    id: 1704821709768-3
    author: tfernandez (generated)
    changes:
    - createFunction:
        functionName: customfunction
        path: objects/function/customfunction-bcd8b0c2.sql
        relativeToChangelogFile: true
- changeSet:
    id: 1704821709768-4
    author: tfernandez (generated)
    changes:
    - createTable:
        columns:
        - column:
            autoIncrement: true
            constraints:
              nullable: false
            name: id
            type: INTEGER
        - column:
            constraints:
              nullable: false
            name: foreignid
            type: INTEGER
        tableName: foreigntable
- changeSet:
    id: 1704822601396-1
    author: tfernandez (generated)
    changes:
    - addCheckConstraint:
        constraintBody: ((number > 0))
        constraintName: testtable_check
        disabled: false
        tableName: testtable
- changeSet:
    id: 1704821709768-5
    author: tfernandez (generated)
    changes:
    - createTrigger:
        disabled: false
        path: objects/trigger/testtable_customtrigger-41365cf7.sql
        relativeToChangelogFile: true
        tableName: testtable
        triggerName: customtrigger
- changeSet:
    id: 1704821709768-6
    author: tfernandez (generated)
    changes:
    - addUniqueConstraint:
        columnNames: number
        constraintName: testtable_un
        tableName: testtable
- changeSet:
    id: 1704821709768-7
    author: tfernandez (generated)
    changes:
    - createView:
        fullDefinition: false
        selectQuery: |-
          SELECT id,
              foreignid
             FROM foreigntable;
        viewName: customview
- changeSet:
    id: 1704821709768-8
    author: tfernandez (generated)
    changes:
    - addForeignKeyConstraint:
        baseColumnNames: foreignid
        baseTableName: foreigntable
        constraintName: fk_foreigntable
        deferrable: false
        initiallyDeferred: false
        onDelete: NO ACTION
        onUpdate: NO ACTION
        referencedColumnNames: number
        referencedTableName: testtable
        validate: true
- changeSet:
    id: 1704821709768-9
    author: tfernandez (generated)
    changes:
    - createProcedure:
        path: objects/storedprocedure/customProcedure.sql
        procedureName: customProcedure
        relativeToChangelogFile: true
{ "databaseChangeLog": [
  {
    "changeSet": {
      "id": "1704821676788-1",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTable": {
            "columns": [
              {
                "column": {
                  "defaultValue": "My text value",
                  "name": "text",
                  "type": "VARCHAR"
                }
              },
              {
                "column": {
                  "autoIncrement": true,
                  "constraints": {
                    "nullable": false
                  },
                  "name": "number",
                  "type": "INTEGER"
                }
              },
              {
                "column": {
                  "constraints": {
                    "nullable": false
                  },
                  "name": "date",
                  "type": "date"
                }
              }
            ]
            ,
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-2",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "insert": {
            "columns": [
              {
                "column": {
                  "name": "text",
                  "value": "one"
                }
              },
              {
                "column": {
                  "name": "number",
                  "valueNumeric": 1
                }
              },
              {
                "column": {
                  "name": "date",
                  "valueDate": "2024-01-09"
                }
              }
            ]
            ,
            "tableName": "testtable"
          }
        },
        {
          "insert": {
            "columns": [
              {
                "column": {
                  "name": "text",
                  "value": "three"
                }
              },
              {
                "column": {
                  "name": "number",
                  "valueNumeric": 2
                }
              },
              {
                "column": {
                  "name": "date",
                  "valueDate": "2024-01-09"
                }
              }
            ]
            ,
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-3",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createFunction": {
            "functionName": "customfunction",
            "path": "objects/function/customfunction-bcd8b0c2.sql",
            "relativeToChangelogFile": true
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-4",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTable": {
            "columns": [
              {
                "column": {
                  "autoIncrement": true,
                  "constraints": {
                    "nullable": false
                  },
                  "name": "id",
                  "type": "INTEGER"
                }
              },
              {
                "column": {
                  "constraints": {
                    "nullable": false
                  },
                  "name": "foreignid",
                  "type": "INTEGER"
                }
              }
            ]
            ,
            "tableName": "foreigntable"
          }
        }
      ]
      
    }
  },
  {
    "changeSet": {
      "id": "1704822683055-1",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "addCheckConstraint": {
            "constraintBody": "((number > 0))",
            "constraintName": "testtable_check",
            "disabled": false,
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  {
    "changeSet": {
      "id": "1704821676788-5",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createTrigger": {
            "disabled": false,
            "path": "objects/trigger/testtable_customtrigger-41365cf7.sql",
            "relativeToChangelogFile": true,
            "tableName": "testtable",
            "triggerName": "customtrigger"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-6",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "addUniqueConstraint": {
            "columnNames": "number",
            "constraintName": "testtable_un",
            "tableName": "testtable"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-7",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createView": {
            "fullDefinition": false,
            "selectQuery": "SELECT id,\n    foreignid\n   FROM foreigntable;",
            "viewName": "customview"
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-8",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "addForeignKeyConstraint": {
            "baseColumnNames": "foreignid",
            "baseTableName": "foreigntable",
            "constraintName": "fk_foreigntable",
            "deferrable": false,
            "initiallyDeferred": false,
            "onDelete": "NO ACTION",
            "onUpdate": "NO ACTION",
            "referencedColumnNames": "number",
            "referencedTableName": "testtable",
            "validate": true
          }
        }
      ]
      
    }
  },
  
  {
    "changeSet": {
      "id": "1704821676788-9",
      "author": "tfernandez (generated)",
      "changes": [
        {
          "createProcedure": {
            "path": "objects/storedprocedure/customProcedure.sql",
            "procedureName": "customProcedure",
            "relativeToChangelogFile": true
          }
        }
      ]
      
    }
  }
  
]}
--liquibase formatted sql

--changeset tfernandez:1704821730934-1
CREATE TABLE "testtable" ("text" VARCHAR DEFAULT 'My text value', "number" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, "date" date NOT NULL);

--changeset tfernandez:1704821730934-2
INSERT INTO "testtable" ("text", "number", "date") VALUES ('one', 1, '2024-01-09');
INSERT INTO "testtable" ("text", "number", "date") VALUES ('three', 2, '2024-01-09');

--changeset tfernandez:1704821730934-3 splitStatements:false
CREATE OR REPLACE FUNCTION "public".customfunction()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
BEGIN
	IF NEW.text <> OLD.text THEN
		 INSERT INTO testtable (text,number,date)
		 VALUES(new.text,new.number,new.date);
	END IF;

	RETURN NEW;
END;
$function$;

--changeset tfernandez:1704821730934-4
CREATE TABLE "foreigntable" ("id" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, "foreignid" INTEGER NOT NULL);

--changeset tfernandez:1704822632841-1
ALTER TABLE "testtable" ADD CONSTRAINT "testtable_check" CHECK (((number > 0)));

--changeset tfernandez:1704821730934-5 splitStatements:false
CREATE TRIGGER customtrigger BEFORE UPDATE ON "public".testtable FOR EACH ROW EXECUTE FUNCTION customfunction();

--changeset tfernandez:1704821730934-6
ALTER TABLE "testtable" ADD CONSTRAINT "testtable_un" UNIQUE ("number");

--changeset tfernandez:1704821730934-7
CREATE VIEW "customview" AS SELECT id,
    foreignid
   FROM foreigntable;

--changeset tfernandez:1704821730934-8
ALTER TABLE "foreigntable" ADD CONSTRAINT "fk_foreigntable" FOREIGN KEY ("foreignid") REFERENCES "testtable" ("number") ON UPDATE NO ACTION ON DELETE NO ACTION;

--changeset tfernandez:1704821730934-9 splitStatements:false
CREATE OR REPLACE PROCEDURE public."customProcedure"()
 LANGUAGE plpgsql
AS $procedure$
	BEGIN
		insert into public.testtable (text,date) values ('first',CURRENT_DATE);
	END;
$procedure$;

Parameters

Global parameters

Attribute Definition Requirement

--license-key=<string>

Your Liquibase Pro license key

Required

Command parameters

Attribute Definition Requirement

--url=<string>

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required

--author=<string>

Specifies the author for changesets in the generated changelog.

Optional

--changelog-file=<string>

Changelog file to write results

Optional

--context-filter=<string>

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

--data-output-directory=<string>

Specifies a directory to send the data output of the command as a CSV file.

Optional

--default-catalog-name=<string>

Name of the default catalog to use for the database connection

Optional

--default-schema-name=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional

--diff-types=<string>

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

--driver=<string>

The JDBC driver class

Optional

--driver-properties-file=<string>

The JDBC driver properties file

Optional

--exclude-objects=<string>

Objects to exclude from diff

Optional

--include-catalog=<true|false>

If true, the catalog will be included in generated changesets. Default: false

Optional

--include-objects=<string>

Objects to include in diff

Optional

--include-schema=<true|false>

If true, the schema will be included in generated changesets. Default: false

Optional

--include-tablespace=<true|false>

Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.

Optional *

--label-filter=<string>

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

--output-schemas=<string>

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

--overwrite-output-file=<true|false>

Determines whether generate-changelog can overwrite an existing changelog, including one specified in --changelog-file. Default: false.

Optional

--password=<string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

--replace-if-exists-types=<string>

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

--run-on-change-types=<string>

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

--schemas=<string>

Specifies database schemas you want to include

Optional

--skip-object-sorting=<true|false>

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

--username=<string>

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Global parameters

Attribute Definition Requirement

globalArgs: { license-key: "<string>" }

Your Liquibase Pro license key

Required

Command parameters

Attribute Definition Requirement

cmdArgs: { url: "<string>" }

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required

cmdArgs: { author: "<string>" }

Specifies the author for changesets in the generated changelog.

Optional

cmdArgs: { changelog-file: "<string>" }

Changelog file to write results

Optional

cmdArgs: { context-filter: "<string>" }

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

cmdArgs: { data-output-directory: "<string>" }

Specifies a directory to send the data output of the command as a CSV file.

Optional

cmdArgs: { default-catalog-name: "<string>" }

Name of the default catalog to use for the database connection

Optional

cmdArgs: { default-schema-name: "<string>" }

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional

cmdArgs: { diff-types: "<string>" }

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

cmdArgs: { driver: "<string>" }

The JDBC driver class

Optional

cmdArgs: { driver-properties-file: "<string>" }

The JDBC driver properties file

Optional

cmdArgs: { exclude-objects: "<string>" }

Objects to exclude from diff

Optional

cmdArgs: { include-catalog: "<true|false>" }

If true, the catalog will be included in generated changesets. Default: false

Optional

cmdArgs: { include-objects: "<string>" }

Objects to include in diff

Optional

cmdArgs: { include-schema: "<true|false>" }

If true, the schema will be included in generated changesets. Default: false

Optional

cmdArgs: { include-tablespace: "<true|false>" }

Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.

Optional *

cmdArgs: { label-filter: "<string>" }

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

cmdArgs: { output-schemas: "<string>" }

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

cmdArgs: { overwrite-output-file: "<true|false>" }

Determines whether generate-changelog can overwrite an existing changelog, including one specified in --changelog-file. Default: false.

Optional

cmdArgs: { password: "<string>" }

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

cmdArgs: { replace-if-exists-types: "<string>" }

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

cmdArgs: { run-on-change-types: "<string>" }

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

cmdArgs: { schemas: "<string>" }

Specifies database schemas you want to include

Optional

cmdArgs: { skip-object-sorting: "<true|false>" }

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

cmdArgs: { username: "<string>" }

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Global parameters

Attribute Definition Requirement

liquibase.licenseKey: <string>

Your Liquibase Pro license key

Required

Command parameters

Attribute Definition Requirement

liquibase.command.url: <string>

liquibase.command.generateChangelog.url: <string>

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required

liquibase.command.author: <string>

liquibase.command.generateChangelog.author: <string>

Specifies the author for changesets in the generated changelog.

Optional

liquibase.command.changelogFile: <string>

liquibase.command.generateChangelog.changelogFile: <string>

Changelog file to write results

Optional

liquibase.command.contextFilter: <string>

liquibase.command.generateChangelog.contextFilter: <string>

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

liquibase.command.dataOutputDirectory: <string>

liquibase.command.generateChangelog.dataOutputDirectory: <string>

Specifies a directory to send the data output of the command as a CSV file.

Optional

liquibase.command.defaultCatalogName: <string>

liquibase.command.generateChangelog.defaultCatalogName: <string>

Name of the default catalog to use for the database connection

Optional

liquibase.command.defaultSchemaName: <string>

liquibase.command.generateChangelog.defaultSchemaName: <string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional

liquibase.command.diffTypes: <string>

liquibase.command.generateChangelog.diffTypes: <string>

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

liquibase.command.driver: <string>

liquibase.command.generateChangelog.driver: <string>

The JDBC driver class

Optional

liquibase.command.driverPropertiesFile: <string>

liquibase.command.generateChangelog.driverPropertiesFile: <string>

The JDBC driver properties file

Optional

liquibase.command.excludeObjects: <string>

liquibase.command.generateChangelog.excludeObjects: <string>

Objects to exclude from diff

Optional

liquibase.command.includeCatalog: <true|false>

liquibase.command.generateChangelog.includeCatalog: <true|false>

If true, the catalog will be included in generated changesets. Default: false

Optional

liquibase.command.includeObjects: <string>

liquibase.command.generateChangelog.includeObjects: <string>

Objects to include in diff

Optional

liquibase.command.includeSchema: <true|false>

liquibase.command.generateChangelog.includeSchema: <true|false>

If true, the schema will be included in generated changesets. Default: false

Optional

liquibase.command.includeTablespace: <true|false>

liquibase.command.generateChangelog.includeTablespace: <true|false>

Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.

Optional *

liquibase.command.labelFilter: <string>

liquibase.command.generateChangelog.labelFilter: <string>

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

liquibase.command.outputSchemas: <string>

liquibase.command.generateChangelog.outputSchemas: <string>

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

liquibase.command.overwriteOutputFile: <true|false>

liquibase.command.generateChangelog.overwriteOutputFile: <true|false>

Determines whether generate-changelog can overwrite an existing changelog, including one specified in --changelog-file. Default: false.

Optional

liquibase.command.password: <string>

liquibase.command.generateChangelog.password: <string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

liquibase.command.replaceIfExistsTypes: <string>

liquibase.command.generateChangelog.replaceIfExistsTypes: <string>

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

liquibase.command.runOnChangeTypes: <string>

liquibase.command.generateChangelog.runOnChangeTypes: <string>

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

liquibase.command.schemas: <string>

liquibase.command.generateChangelog.schemas: <string>

Specifies database schemas you want to include

Optional

liquibase.command.skipObjectSorting: <true|false>

liquibase.command.generateChangelog.skipObjectSorting: <true|false>

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

liquibase.command.username: <string>

liquibase.command.generateChangelog.username: <string>

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Global parameters

Attribute Definition Requirement

JAVA_OPTS=-Dliquibase.licenseKey=<string>

Your Liquibase Pro license key

Required

Command parameters

Attribute Definition Requirement

JAVA_OPTS=-Dliquibase.command.url=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.url=<string>

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required

JAVA_OPTS=-Dliquibase.command.author=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.author=<string>

Specifies the author for changesets in the generated changelog.

Optional

JAVA_OPTS=-Dliquibase.command.changelogFile=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.changelogFile=<string>

Changelog file to write results

Optional

JAVA_OPTS=-Dliquibase.command.contextFilter=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.contextFilter=<string>

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

JAVA_OPTS=-Dliquibase.command.dataOutputDirectory=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.dataOutputDirectory=<string>

Specifies a directory to send the data output of the command as a CSV file.

Optional

JAVA_OPTS=-Dliquibase.command.defaultCatalogName=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.defaultCatalogName=<string>

Name of the default catalog to use for the database connection

Optional

JAVA_OPTS=-Dliquibase.command.defaultSchemaName=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.defaultSchemaName=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional

JAVA_OPTS=-Dliquibase.command.diffTypes=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.diffTypes=<string>

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

JAVA_OPTS=-Dliquibase.command.driver=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.driver=<string>

The JDBC driver class

Optional

JAVA_OPTS=-Dliquibase.command.driverPropertiesFile=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.driverPropertiesFile=<string>

The JDBC driver properties file

Optional

JAVA_OPTS=-Dliquibase.command.excludeObjects=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.excludeObjects=<string>

Objects to exclude from diff

Optional

JAVA_OPTS=-Dliquibase.command.includeCatalog=<true|false>

JAVA_OPTS=-Dliquibase.command.generateChangelog.includeCatalog=<true|false>

If true, the catalog will be included in generated changesets. Default: false

Optional

JAVA_OPTS=-Dliquibase.command.includeObjects=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.includeObjects=<string>

Objects to include in diff

Optional

JAVA_OPTS=-Dliquibase.command.includeSchema=<true|false>

JAVA_OPTS=-Dliquibase.command.generateChangelog.includeSchema=<true|false>

If true, the schema will be included in generated changesets. Default: false

Optional

JAVA_OPTS=-Dliquibase.command.includeTablespace=<true|false>

JAVA_OPTS=-Dliquibase.command.generateChangelog.includeTablespace=<true|false>

Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.

Optional *

JAVA_OPTS=-Dliquibase.command.labelFilter=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.labelFilter=<string>

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

JAVA_OPTS=-Dliquibase.command.outputSchemas=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.outputSchemas=<string>

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

JAVA_OPTS=-Dliquibase.command.overwriteOutputFile=<true|false>

JAVA_OPTS=-Dliquibase.command.generateChangelog.overwriteOutputFile=<true|false>

Determines whether generate-changelog can overwrite an existing changelog, including one specified in --changelog-file. Default: false.

Optional

JAVA_OPTS=-Dliquibase.command.password=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.password=<string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

JAVA_OPTS=-Dliquibase.command.replaceIfExistsTypes=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.replaceIfExistsTypes=<string>

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

JAVA_OPTS=-Dliquibase.command.runOnChangeTypes=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.runOnChangeTypes=<string>

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

JAVA_OPTS=-Dliquibase.command.schemas=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.schemas=<string>

Specifies database schemas you want to include

Optional

JAVA_OPTS=-Dliquibase.command.skipObjectSorting=<true|false>

JAVA_OPTS=-Dliquibase.command.generateChangelog.skipObjectSorting=<true|false>

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

JAVA_OPTS=-Dliquibase.command.username=<string>

JAVA_OPTS=-Dliquibase.command.generateChangelog.username=<string>

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Global parameters

Attribute Definition Requirement

LIQUIBASE_LICENSE_KEY=<string>

Your Liquibase Pro license key

Required

Command parameters

Attribute Definition Requirement

LIQUIBASE_COMMAND_URL=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_URL=<string>

The JDBC database connection URL. See Using JDBC URL in Liquibase.

Required

LIQUIBASE_COMMAND_AUTHOR=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_AUTHOR=<string>

Specifies the author for changesets in the generated changelog.

Optional

LIQUIBASE_COMMAND_CHANGELOG_FILE=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_CHANGELOG_FILE=<string>

Changelog file to write results

Optional

LIQUIBASE_COMMAND_CONTEXT_FILTER=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_CONTEXT_FILTER=<string>

Specifies the context filter to generate and apply to all changesets in your changelog. Useful to set many contexts quickly. Similar to the set-contexts command. Available in Liquibase 4.24.0 and later.

Contexts are tags you can add to changesets to control which changesets will be executed in any particular migration run.

After generating changesets with contexts, to deploy specific changes according to these contexts, you must run a command that specifies a context filter. For example, update --context-filter=<xyz>.

Optional

LIQUIBASE_COMMAND_DATA_OUTPUT_DIRECTORY=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DATA_OUTPUT_DIRECTORY=<string>

Specifies a directory to send the data output of the command as a CSV file.

Optional

LIQUIBASE_COMMAND_DEFAULT_CATALOG_NAME=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DEFAULT_CATALOG_NAME=<string>

Name of the default catalog to use for the database connection

Optional

LIQUIBASE_COMMAND_DEFAULT_SCHEMA_NAME=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DEFAULT_SCHEMA_NAME=<string>

Name of the default schema to use for the database connection. If defaultSchemaName is set, then objects do not have to be fully qualified. This means you can refer to just mytable instead of myschema.mytable.

Tip: In Liquibase v4.23.0+, camelCase for defaultSchemaName works successfully. If you are on an earlier version, camelCase may not work as expected.

Note: The syntax liquibase.command.defaultSchemaName is valid for v4.19.0+. For prior versions, use defaultSchemaName.

Optional

LIQUIBASE_COMMAND_DIFF_TYPES=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DIFF_TYPES=<string>

Specifies the types of objects to compare. Specify multiple values as a comma-separated list (without spaces). Valid values are: catalogs, checkconstraints, columns, data, databasepackage, databasepackagebody, foreignkeys, functions, indexes, primarykeys, sequences, storedprocedures, tables, triggers, uniqueconstraints, views.

If null, default types are columns, foreignkeys, indexes, primarykeys, tables, uniqueconstraints, views.

Note: The diff types checkconstraints, databasepackage, databasepackagebody, functions, storedprocedures, and triggers require a valid Liquibase Pro license key to use.

Optional

LIQUIBASE_COMMAND_DRIVER=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DRIVER=<string>

The JDBC driver class

Optional

LIQUIBASE_COMMAND_DRIVER_PROPERTIES_FILE=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_DRIVER_PROPERTIES_FILE=<string>

The JDBC driver properties file

Optional

LIQUIBASE_COMMAND_EXCLUDE_OBJECTS=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_EXCLUDE_OBJECTS=<string>

Objects to exclude from diff

Optional

LIQUIBASE_COMMAND_INCLUDE_CATALOG=<true|false>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_INCLUDE_CATALOG=<true|false>

If true, the catalog will be included in generated changesets. Default: false

Optional

LIQUIBASE_COMMAND_INCLUDE_OBJECTS=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_INCLUDE_OBJECTS=<string>

Objects to include in diff

Optional

LIQUIBASE_COMMAND_INCLUDE_SCHEMA=<true|false>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_INCLUDE_SCHEMA=<true|false>

If true, the schema will be included in generated changesets. Default: false

Optional

LIQUIBASE_COMMAND_INCLUDE_TABLESPACE=<true|false>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_INCLUDE_TABLESPACE=<true|false>

Includes the tablespace of tables and indexes in a generated changesets if the value is true. The default value is false.

Optional *

LIQUIBASE_COMMAND_LABEL_FILTER=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_LABEL_FILTER=<string>

Specifies the label filter to generate and apply to all changesets in your changelog. Useful to set many labels quickly. Similar to the set-labels command. Available in Liquibase 4.24.0 and later.

Labels are tags you can add to changesets to control which changeset will be executed in any migration run.

After generating changesets with labels, to deploy specific changes according to these labels, you must run a command that specifies a label filter. For example, update --label-filter=<xyz>.

Optional

LIQUIBASE_COMMAND_OUTPUT_SCHEMAS=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_OUTPUT_SCHEMAS=<string>

Lets you replace the schemas in the output changelog. This is a CSV list. The parameter size must match --schemas. If you have three items names in --schemas, you must also have three items in --output-schemas.

Example: liquibase generate-changelog --schemas=a,b,c --output-schemas=d,e,f

Optional

LIQUIBASE_COMMAND_OVERWRITE_OUTPUT_FILE=<true|false>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_OVERWRITE_OUTPUT_FILE=<true|false>

Determines whether generate-changelog can overwrite an existing changelog, including one specified in --changelog-file. Default: false.

Optional

LIQUIBASE_COMMAND_PASSWORD=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_PASSWORD=<string>

Password to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

LIQUIBASE_COMMAND_REPLACE_IF_EXISTS_TYPES=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_REPLACE_IF_EXISTS_TYPES=<string>

Specify Change Types you want to target. Liquibase sets replaceIfExists="true" on these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

LIQUIBASE_COMMAND_RUN_ON_CHANGE_TYPES=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_RUN_ON_CHANGE_TYPES=<string>

Specify Change Types you want to target. Liquibase sets runOnChange="true" on changesets containing solely these Change Types: createFunction, createPackage, createPackageBody, createProcedure, createTrigger, and createView. Liquibase 4.26.0+. Default: <none>.

Optional

LIQUIBASE_COMMAND_SCHEMAS=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_SCHEMAS=<string>

Specifies database schemas you want to include

Optional

LIQUIBASE_COMMAND_SKIP_OBJECT_SORTING=<true|false>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_SKIP_OBJECT_SORTING=<true|false>

Liquibase 4.27.0+. Specifies how Liquibase sorts a list of objects in your database to generate a changelog. When true, Liquibase skips object sorting, so your objects are sorted according to the order returned by your database. This can be useful on databases that have a lot of packages or procedures that are linked to each other. When false, Liquibase sorts objects by dependency. This may avoid dependency errors. Default: false.

Note: If you set this parameter to true, Liquibase may create objects in the wrong order (such as a view on a table before the table itself), so you may have to manually reorganize the generated changelog file.

Optional

LIQUIBASE_COMMAND_USERNAME=<string>

LIQUIBASE_COMMAND_GENERATE_CHANGELOG_USERNAME=<string>

Username to connect to the target database.

Tip: It is a best practice to store sensitive data in a Secrets Management tool with Liquibase Pro.

Optional

Note: The username and password attributes are not required for connections and systems which use alternate means of authentication. Also, you can specify database credentials as part of the url attribute.

* --include-tablespace only captures the tablespace if it was specified in the create table statement.

Database objects supported by Liquibase

You can use the following object types in Liquibase:

Object type --diff-types syntax Liquibase edition
Catalog catalogs Liquibase Open Source
Column columns Liquibase Open Source
Data data Liquibase Open Source
Foreign key foreignkeys Liquibase Open Source
Index indexes Liquibase Open Source
NOT NULL constraint N/A Liquibase Open Source
Primary key primarykeys Liquibase Open Source
Schema N/A Liquibase Open Source
Sequence sequences Liquibase Open Source
Table tables Liquibase Open Source
Unique constraint uniqueconstraints Liquibase Open Source
View views Liquibase Open Source
Check constraint checkconstraints Liquibase Pro
Function functions Liquibase Pro
Package databasepackage Liquibase Pro
Package body databasepackagebody Liquibase Pro
Stored procedure storedprocedures Liquibase Pro
Trigger triggers Liquibase Pro

Liquibase Pro stored logic behavior

While Liquibase Open Source 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 subdirectories for each of the stored logic types:

  • package
  • packagebody
  • function
  • stored procedure
  • trigger

Note: Some database platforms may not support all of these stored logic types.

The generate-changelog command will not create the Objects directory if:

  • You don't have a valid Liquibase Pro license key.
  • Stored logic is not present in the database.
  • The target database does not support the generate-changelog command and stored logic objects.
  • The changelog file is written in formatted SQL. The Objects folder can only be created when generating XML, JSON, or YAML changelogs.
  • There is a pre-existing directory called Objects that was created outside Liquibase.

If your database contains Stored Logic objects, you may have issues attempting to run the generate-changelog command more than once, even with a new changelog name, because the stored logic files already exist in the Objects directory.

To generate a newer version of the changelog file with stored logic objects based on the current database state, you need to delete, rename, or move the Objects directory that was created by running the generate-changelog command previously. Then, you can run the generate-changelog command again.

Note: If there is a pre-existing Objects directory that is not related to Liquibase, you need to delete, rename, or move it to run the generate-changelog command.

If you want to track the history of stored logic objects, use the diff-changelog command. The diff-changelog command structures stored logic files into timestamped directories every time you run the command.

Related links