2. Database Change Management
As SCM (Source Change Management)
solutions (GIT, SVN, etc.) controls the
changes of source, DCM (Database
Changes Management) controls the
changes in database between different
versions of the source
2
3. The Liquibase solution
Each database change-set resides in a
text file along with a change unique ID
and being controlled by the SCM
solution (GIT, etc.).
Liquibase change-set can be either in
sql, xml, json or yaml format.
3
7. Example YAML change-setdatabaseChangeLog:
- changeSet:
id: 1
author: yorammi
changes:
- createTable:
tableName: fullstackers
columns:
- column:
name: id
type: int
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: name
type: varchar(50)
7
8. Liquibase supported databases
Liquibase supports:
MySQL, PostgreSQL, Oracle,
Sql Server, Sybase_Enterprise,
Sybase_Anywhere, DB2,
Apache_Derby, HSQL, H2, Informix,
Firebird and SQLite.
It also support some other databases
(such as SAP MaxDB) as extensions.8
9. Running Liquibase
Liquibase can run in many environments:
Command-line, ANT, Maven, Gradle,
Spring, servlet listener and JEE CDI.
In this presentation maven plugin is
shown.
9
10. Maven Liquibase Plugin
Liquibase Maven Plugin contains many
goals but its main goal is the
liquibase:update goal that will be
used in the following example.
10
15. Change-set baseline file
--liquibase formatted sql
--changeset yorammi:base_line
create table fullstackers (
id int primary key,
name varchar(255)
);
--rollback drop table fullstackers;
15
16. Example change-set file
--liquibase formatted sql
--changeset yorammi:change_1 context:test
insert into fullstackers (id, name) values (1, ‘yorammi′);
16
17. Liquibase special tables
Liquibase adds 2 tables to the schema:
DATABASECHANGELOGLOCK
DATABASECHANGELOG
The DATABASECHANGELOG contains
information about each changelog
including id, author, path to file,
execution-time, context and more