Liquibase is a development tool that allows you to apply changes to the EDB database using the Liquibase CLI and view them on the Liquibase Hub.

Creating a project on Liquibase Hub

Create a project for the target database instance on the Liquibase Hub. All data related to the target database is stored in this project.

  1. Log in to the Liquibase Hub console.

  2. Create a Project on the Liquibase Hub. Select Projects > Create Project.

  3. On the Create Project page, enter the name and description of the project.

  4. Select Create Project.

Create Project page

Applying database changes

These examples show how to apply database changes using Liquibase changesets, including:

See the Liquibase documentation for available change types.

Note

All Liquibase commands in the examples are executed from the directory where Liquibase Pro is installed.

The initial database objects and data for these examples are created using this sample script:

CREATE SEQUENCE sal_seq MINVALUE 1 START WITH 1 INCREMENT BY 1 NOCACHE;

CREATE TABLE tp_sales_db (
salesman_id INT4,
salesman_name VARCHAR2(30),
sales_region VARCHAR2(30),
sales_amount INT4 DEFAULT sal_seq.nextval,
deptno INT4
);

CREATE TABLE tp_department_db
(
deptno INT4 Primary Key,
dname VARCHAR(50),
location VARCHAR(100)
);
INSERT INTO tp_sales_db VALUES (100,';Person 1';,';CITY 1';,DEFAULT,10);
INSERT INTO tp_department_db VALUES (10,';Development';,';Pakistan';);

Updating tables

  1. Create a changelog file using one of the following options for creating a changelog file:

    • Create the file manually. See the following changelog file example. (For detailed information on changelogs, see the changelog documentation from Liquibase.)

      xml version="1.0" encoding="UTF-8"?>
      <databaseChangeLog
         xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         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.2.xsd
      http://www.liquibase.org/xml/ns/pro
      http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.2.xsd " changeLogId="9e43abe4-
      4a9b-4d38-a485-c68af935bc44">
      <changeSet author="kashif" id="100">
      <insert catalogName="edb"
       dbms="postgresql"
       schemaName="public"
       tableName="tp_department_db">
      <column name="deptno" value="20"/>
      <column name="dname" value="QMG"/>
      <column name="location" value="India"/>
      </insert>
      <insert catalogName="edb"
       dbms="postgresql"
       schemaName="public"
       tableName="tp_department_db">
      <column name="deptno" value="30"/>
      <column name="dname" value="CM"/>
      <column name="location" value="Pakistan"/>
      </insert>
      <update catalogName="edb"
      schemaName="public"
      tableName="tp_department_db">
      <column name="dname" value="UPDATED NAME...."/>
      <where>deptno=30</where>
      </update>
      <delete catalogName="edb"
       chemaName="public"
       tableName="tp_department_db">
      <where>deptno=10</where>
      </delete>
      <rollback>
      DELETE FROM public.tp_department_db WHERE deptno=20;
      DELETE FROM public.tp_department_db WHERE deptno=30;
      INSERT INTO public.tp_department_db (deptno, dname, location) VALUES ('10',
      'Development', 'Pakistan');
      </rollback>
      </changeSet>
      </databaseChangeLog>
    • Generate a sample file and update it with your changes. Generate the sample changelog file using this command:

      ./liquibase --changeLogFile=edb_dbchangelog.xml generateChangeLog

Note

Before the command runs, Liquibase takes a snapshot of the database, which is an essential step in the process.

  1. For each database change, add a changeset entry to the changelog file. For detailed information on changesets, see the changeset documentation from Liquibase.

  2. Register the changelog with the Liquibase Hub and provide the project name:

    ./liquibase registerChangeLog

    Sample output:

    Sample Output from Registering Changelog

  3. Update the table in the target database:

    ./liquibase update

Rolling back changes

Roll back changes made to the table using the rollbackCount command. For example, this command uses the sample changelog file:

./liquibase rollbackCount 1

Viewing database changes on Liquibase Hub

To view the details of the changes made on the target database, select a changelog link. For example, select dbchangelog.xml to see its details.

Viewing Database Changes On Liquibase Hub

The diagram shows the details for the selected changeset.

Changeset details


Could this page be better? Report a problem or suggest an addition!