Using Liquibase Pro

Suggest edits

Liquibase is a development tool that allows changes to be applied to the EDB database using the Liquibase CLI and viewed on the Liquibase Hub.

Creating a Project on Liquibase Hub

Use the following steps to 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. Select the Projects menu.

  3. Create a Project on the Liquibase Hub by selecting Create Project.

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

  5. Select Create Project.

Create Project page

Applying Database Changes

This section provides examples of applying database changes using Liquibase changesets including:

Refer to 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, refer to 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 is run Liquibase will take 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, refer to the changeset documentation from Liquibase.

  2. To register the changelog with the Liquibase Hub and provide the project name, execute this command:

    ./liquibase registerChangeLog

Sample output:

IntegrationViews3

  1. To update the table in the target database, use this command:

    ./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 below shows the details for the selected changeset.

Changeset details


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