Deploying Changes to DB2 on z/OS using SQL Scripts

Step 1: Create an SQL Folder

In the Liquibase project folder that you created, create a folder named sql_files to store SQL scripts that Liquibase will track, version, and deploy.

The directory structure should look like this:

$LB_HOME/db2_zos/sql_files

Step 2: Setup the changelog

This is a one-time step to configure a change log to point to the SQL folder that will contain SQL scripts. Create and save a file in the Liquibase project directory you created ($LB_HOME/db2_zos). The file should be named db2zosChangeLog.xml.

The contents of db2zosChangeLog.xml should be as follows:

<?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.1.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd">	
<includeAll path="sql_files"/>
</databaseChangeLog>

Step 3: Add an SQL Script to the SQL Folder

With a liquibase.properties file from the tutorial setup and the newly created db2zosChangeLog.xml, we are now ready to start adding SQL scripts to the sql_files folder. Liquibase will order the scripts in the folder alphanumerically.

Create a file named 001_create_person_table.sql with the following and save it in the sql_files folder:

create table PERSON (
ID int not null,
FNAME varchar(100) not null
);

We are now ready to deploy the script! Open the command line and navigate to $LB_HOME/db2_zos. Run $LB_HOME/liquibase update if on a UNIX system or $LB_HOME\liquibase.bat update if on Windows.

You will see that your database now contains a table called PERSON.

Step 4: Check your Database

You will notice two other tables are created as well:

Common Command Line Arguments

Use can use command line arguments to override the default options at runtime. The following are common command line arguments:

Command line argument Action
--changeLogFile=<path and filename> Specify the XML changelog
--url=<value> Specify a database URL
--defaultsFile=<path to file.properties> Specify the properties file (default: ./liquibase.properties)