The purpose of this document is to guide you through the process of creating a new Liquibase project with H2 on a Windows machine.
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 an H2 database.
liquibase.batfile’s path is set to a location in the
To create a Liquibase project with an H2 database on your Windows machine:
LiquibaseH2folder, Right-click then select New > Text Document to create an empty text file.
Note: Changelog files contain a sequence of changeSets, each of which make small changes to the structure of your database. Instead of creating an empty changelog file in step 2, you can also use an existing database to generate a changelog. For more information see the Database Changelog File topic.
In this tutorial, you will need to modify your changelog by adding a template.
To add this changelog template:
Next we will create a
liquibase.properties file. To create the file:
LiquibaseH2folder, Right-click and select New > Text Document to create a new text file.
liquibase.propertiesfile to add the following properties:
Note: In this
liquibase.propertiesfile example, the driver jar file is
h2-1.4.200.jarunder the classpath: property. Please rename it to match the one that you have previously downloaded accordingly.
Now we will manually add a changeSet to the changelog file. Remember, when adding ChangeSets, they are uniquely identified by author and id attributes. Liquibase attempts to execute each changeSet in a transaction that is committed at the end.
To add additional changeSets:
myChangeLog.xmlfile line 9 to 20 add a new department create table changeSet as follows:
Note: This create table changeSet is XML format. The corresponding SQL statement should look like the following:
From a database UI Tool, for example: DBeaver check your database changes.
You should see a new “department” table added to the database.
You should also see two more tables: