Using Liquibase with InterBase

The purpose of this document is to guide you through the process of creating a new Liquibase project with InterBase. In this tutorial, you will learn how to install the required database drivers and configure the Liquibase properties file to establish a database connection to InterBase.

InterBase is not one of the supported databases of Liquibase. However, Liquibase provides an extension for the basic database operations, including:

  • AddColumn
  • CreateTable
  • CreateView
  • DropColumn
  • DropPrimaryKey
  • GetViewDefinition (internal)
  • ModifyDataType
  • RenameColumn

Prerequisites

Before using Liquibase with your database, ensure you have:

  • Downloaded the InterBase DB extension for Liquibase.
  • Copied the JDBC driver for InterBase into the liquibase/lib directory so that it will automatically be located when executing Liquibase commands. You can also place it in any other known directory so you can locate it easily. The driver is automatically installed as a part of InterBase.
  • Note: Place the extension jar file in the liquibase/lib install directory.
    Also, if you use Maven, reference the dependency extension .jar file locally. For more information, see Configuring Liquibase Attributes in your Maven POM File.

Tutorial

To create a Liquibase project with InterBase, perform the following steps:

  1. Add the following properties to the newly created Liquibase properties file:
  2. changelog-file: dbchangelog.xml
    url: jdbc:interbase://localhost:3050/interbase/testdb.ib
    username: user1
    password: password
    driver: interbase.interclient.Driver
    classpath: ../../Liquibase_Drivers/interclient.jar

    Note: Specifying your password, take into account that Liquibase supports only the following special characters: ~ # $ % * ( ) - _ + [ ] { } . ?. Unsupported special characters are as follows: @ & / : < > " ' ` | ^ ! = , \ <spaces>.

    Use the following format for the url property:

    jdbc:interbase://<server>/<full_db_path>
    • If you placed the jar file in the liquibase/lib install directory, do not specify the classpath property in the Liquibase properties file. Otherwise, specify the driver path as shown in the preceding example.
    • To apply a Liquibase Pro key to your project, add the following property to the Liquibase properties file:
    • liquibaseProLicenseKey: <paste license key>
  3. Create a changelog file. The changelog files contain a sequence of changesets, each of which makes small changes to the structure of your database. For more information, see Working with changelogs. Liquibase provides a changelog template located at $LIQUIBASE_HOME/examples/xml/blank.changelog.xml.
  4. Copy the blank.changelog.xml file to your project folder and rename it to dbchangelog.xml. Each version of Liquibase will have an updated XML schema, so use the one that matches the version of Liquibase you have installed. The contents of the changelog will be similar to the following:
  5. <?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:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    	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.9.xsd
    		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-4.9.xsd">	
    <changeSet id="1" author="author name">
    <!--Insert XML change objects here https://www.liquibase.org/documentation/xml_format.html-->
    </changeSet>
    <changeSet id="2" author="author name">
    <!--Insert XML change objects here https://www.liquibase.org/documentation/xml_format.html-->
    </changeSet>
    </databaseChangeLog>

    Note: The preceding changelog is XML format. The corresponding SQL changelog statement looks like the following:

    --liquibase formatted sql
  1. Navigate to your project folder in the CLI and run the Liquibase status command to see whether the connection is successful. You can pass arguments in the CLI or keep them in the Liquibase properties file.
  2. liquibase --username=test --password=test --changelog-file=<changelog.xml> status
  3. Run your first update with the update command, which makes changes to your database. You can also run the update-sql command to inspect the SQL before running the update command.
  4. liquibase --changelog-file=<changelog.xml> update-sql
    liquibase --changelog-file=<changelog.xml> update

From a database UI tool, ensure that your database contains the table you added along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table.

Congratulations!

You have successfully configured your project and can begin creating changesets to migrate changes to your database. For more information on how to create changesets, see Changelog Formats.

See also