Using Liquibase with Teradata

The purpose of this document is to guide you through the process of creating a new Liquibase project with Teradata. In this tutorial, you will generate an example project and follow the instructions to apply and learn concepts associated with creating new Liquibase projects with Teradata.

Prerequisites

Tutorial

To create a Liquibase project with Teradata on your machine, begin with the following steps:

  1. Create a new project folder and name it LiquibaseProj.
  2. In your LiquibaseProj folder, create a new text file and name it dbchangelog.sql.
  3. Open the dbchangelog.sql file and update the changelog file with the following code snippet:
--liquibase formatted sql
  1. In your LiquibaseProj folder, create a new text file and name it liquibase.properties.
  2. Edit the liquibase.properties file to add the following properties:
  3. changeLogFile: dbchangelog.sql
    url: jdbc:teradata://hostname/DATABASE=myDatabase
    username: myUserName
    password: myPassword
    driver: com.teradata.jdbc.TeraDriver

Note: If you already have a Liquibase Pro key and want to apply it to your project, add the following property to your liquibase.properties. Ex: liquibaseProLicenseKey: <paste code here>.

  1. Add a changeset to the changelogchangeset are uniquely identified by author and id attributes. Liquibase attempts to execute each changeset in a transaction that is committed at the end. In the dbchangelog.sql file line 3 add a new “DEPARTMENT” create table change set as follows:
  2. 
    --liquibase formatted sql
    
    --changeset bob:1
    CREATE TABLE "DEPARTMENT" ("ID" INT, "NAME" CHAR(11), "LOCATION" CHAR(25));
  3. Open the command line, and navigate to the LiquibaseProj directory.
    Run the following command: liquibase update
  4. From a SQL Client Tool, check your database changes. You should see a new “DEPARTMENT” table added to the database. For example:
SELECT * FROM "myDatabase"."DEPARTMENT";
ID NAME LOCATION
NULL NULL NULL

Also, you should see two more tables:

  • DATABASECHANGELOG tracking table – This table keeps a record of all the changesets that were deployed. This way, next time when you deploy again, the changesets in the changelog will be compared with the DATABASECHANGELOG tracking table and only the new changesets that were not found in the DATABASECHANGELOG will be deployed. You will notice that a new row was created in that table with the changeset information we have just deployed. For this example:
ID AUTHOR FILENAME DATEEXECUTED ORDEREXECUTED EXECTYPE MDSUM
1 bob dbchangelog.sql date&time 1 EXECUTED checksumvalue
  • DATABASECHANGELOGLOCK – This table is used internally by Liquibase to manage access to the changelog table during deployment.