Using Liquibase with MaxDB
The purpose of this document is to guide you through the process of creating a new Liquibase project with MaxDB. 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 MaxDB.
Before using Liquibase with your database, ensure you have:
- Installed Liquibase.
- Created a Liquibase project folder to store all Liquibase files.
- Created a new Liquibase properties file or are using the existing
liquibase.propertiesfile included in the installation package. For more information, see Specifying Properties in a Connection Profile.
- Download the JDBC driver JAR file for MaxDB.
- Download the latest Liquibase MaxDB extension JAR file.
- Place the two JAR files in the
To create a Liquibase project with MaxDB on your machine, begin with the following steps:
- In your project folder, create a new text file called
dbchangelog.sql. Add the following code snippet:
- Edit the newly created Liquibase properties file to add the following properties:
--liquibase formatted sql
changelog-file: dbchangelog.sql url: jdbc:sapdb://localhost:7200/MaxDB1 username: user1 password: password
Tip: To apply a Liquibase Pro key to your project, add the following property to the Liquibase properties file:
liquibaseProLicenseKey: <paste code here>
- Add a changeset to the changelog – changeset are uniquely identified by
idattributes. Liquibase attempts to execute each changeset in a transaction that is committed at the end. In the
dbchangelog.sqlfile line 3 add a new “department” create table change set as follows:
--liquibase formatted sql --changeset bob:1 CREATE TABLE DEPARTMENT ("ID" INTEGER, "NAME" CHAR(20), "ACTIVE" BOOLEAN);
- 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.
- 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
liquibase --username=test --password=test --changelog-file=<changelog.xml> status
liquibase --changelog-file=<changelog.xml> update-sql liquibase --changelog-file=<changelog.xml> update
From SQL Developer Tool User Interface, check your database changes under “user1 schema”. You should see a new “department” table added to the database. For example:
SELECT * FROM "public"."department";