Using Liquibase with Firebird
The purpose of this document is to guide you through the process of creating a new Liquibase project with Firebird. 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 Firebird.
Prerequisites
- Ensure that you have installed the latest version of Liquibase. If not, go to https://www.liquibase.org/download to install it.
- Ensure that the Liquibase executable location is in the PATH environment variable.
- Go to https://github.com/FirebirdSQL/jaybird/releases/download/v3.0.6/Jaybird-3.0.6-JDK_1.8.zip to download the jdbc jar driver file.
Note: Place your jar file in the Liquibase/lib
install directory or in any other known directory so you can locate it easily.
Tutorial
To create a Liquibase project with Firebird, perform the following steps:
- Create a new project folder and name it
LiquibaseFirebird
. - In your
LiquibaseFirebird
folder, create a new text file and name itliquibase.properties
.
Note: For more information about the liquibase.properties
file, see Creating and configuring a liquibase.properties file.
- Edit the
liquibase.properties
file to add the following properties:
changeLogFile: dbchangelog.xml
url: jdbc:firebirdsql://localhost:3050//firebird/data/testdb
username: user1
password: password
driver: org.firebirdsql.jdbc.FBDriver
classpath: ../../Liquibase/lib/jaybird-full-3.0.6.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:firebirdsql://<IP/host>:<port>//<server/path/to/database>
- If you placed your jdbc driver file in the
Liquibase/lib
install directory, there is no need to specify theclasspath
property in theliquibase.properties
file. Otherwise, put the path to your drivers as it is shown in the preceding example. - If you already have a Liquibase Pro key and want to apply it to your project, add the following property to your
liquibase.properties
file:
liquibaseProLicenseKey: <paste license key>
- 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 changelog. Liquibase provides a changelog template located at
$LIQUIBASE_HOME/examples/xml/blank.changelog.xml
. Copy theblank.changelog.xml
file to yourLiquibaseFirebird
folder and rename it todbchangelog.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:
<?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"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
</databaseChangeLog>
Note: The preceding changelog is XML format. The corresponding SQL changelog statement looks like the following:
--liquibase formatted sql
- Verify the project configuration. Run the
status
command to verify that the configuration is complete. Open a command prompt and navigate to the project folderLiquibaseFirebird
. Run the command as follows:
liquibase status
- Verify that the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables were created. From a database UI Tool, check your new Liquibase tables.
DATABASECHANGELOG tracking table. This table keeps a record of all the changesets that were deployed. When you add changesets to your changelog and run the update
command, 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.
DATABASECHANGELOGLOCK tracking table. This table is used internally by Liquibase to manage access to the changelog table during deployment.
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 changeset.
Troubleshooting issues with the update
command
If you run the update
command to deploy your changesets and receive the error message related to the DATABASECHANGELOGLOCK table issue, manually create the DATABASECHANGELOGLOCK table using SMALLINT
type instead of BOOLEAN
:
CREATE TABLE DATABASECHANGELOGLOCK (ID VARCHAR(255) NOT NULL, LOCKED SMALLINT NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR(255));