Getting Started with Liquibase and YAML on Windows
After you install Liquibase, get started with our tutorial and learn how Liquibase works.
With Liquibase, SQL statements  are declared as Liquibase changesets  in a changelog file .
Liquibase  then uses the changelog to apply the changesets to target databases .
In this tutorial, you will use an example changelog to apply two rounds of updates to an H2 database that is included with the Liquibase installation files.
Applying updates to the database
- Copy the Liquibase
\examplesdirectory from the installation directory to another location on your machine.
- From a command line terminal, enter
<your path>\examples\start-h2to start the example H2 database. The database console opens automatically in a browser on port 9090.
- Open a new command line terminal and enter the following command:
cd <your path>\examples\yaml
Note: When prompted about the operation's report in Liquibase Hub, enter S to skip for now.
Liquibase applies the following updates, which are specified as Liquibase changesets in
- changeSet: id: 1 author: your.name changes: - createTable: tableName: person columns: - column: name: id type: int autoIncrement: true constraints: primaryKey: true nullable: false - column: name: name type: varchar(50) - changeSet: id: 2 author: your.name changes: - createTable: tableName: company columns: - column: name: id type: int autoIncrement: true constraints: primaryKey: true nullable: false - column: name: name type: varchar(50) - changeSet: id: 3 author: your.name changes: - addColumn: tableName: company columns: - column: name: country type: varchar(2)
author-id value pairs
your.name:2 prevent their respective changesets from accidentally being run multiple times as new changesets are added to the changelog for subsequent updates.
- From the database console, confirm that the
Objectview contains the
PERSONtables that were created during the previous step.
- Using a text editor, open
<your path>\examples\yaml\example-changelog.yamland add the following changesets to the end of the file:
Note: When you copy the changeset, put the
- changeset attribute at the beginning of a new line without any indentation.
- changeSet: id: 4 author: your.name changes: - addColumn: tableName: person columns: - column: name: country type: varchar(2)
- Save and close
- Enter the following command:
- Confirm the update by refreshing the database console and verifying that the
countrycolumn has been added to the