Overview
⬜ Liquibase premise: All database changes are stored in a
human readable yet trackable form and checked into source
control.
⬜ Liquibase allows you to:
⬜ Apply database changes systematically
⬜ Manage changes across environments/platforms
⬜ Rollback changes
⬜ Compare databases
⬜ Generate change documentation
Slide 4
Slide 4 text
Overview
⬜ Incremental changes to code are (in general) simple and atomic –
remove the previous version, install the new version
⬜ Database deployments are more tricky:
⬜ Can’t remove the schema and recreate it without wiping out data
⬜ Involves getting the database state from point in time A to point in time B
⬜ Order is important
⬜ Easy for environments to drift apart
⬜ Need to be able to determine the state of the database at any point in
time
Slide 5
Slide 5 text
Overview
Test
Prod
Add table
Column
Width = 4
Column
Width = 8
Run dml
Add table
Column
Width = 4
Column
Width = 8
Run dml
Slide 6
Slide 6 text
Overview
⬜ Liquibase uses a “changelog” which captures all database
changes
⬜ The changelog can be stored in source control (and versioned)
to bind a certain database version to a version of code
⬜ Changelogs are composed of “changesets” which are atomic
groups of operations that applied and rolled back in
increments
Gradle Plugin
⬜ Allows Liquibase XML to be written as Groovy DSL
⬜ Allows a single build file with multiple database definitions as
well as multiple changelog definitions
⬜ Allows mixing of Groovy and XML changelogs if desired
Slide 16
Slide 16 text
Liquibase Functionality
⬜ Status – Prints the current status of the target database and
what changesets (if any) need to be applied
⬜ Validate – Validates the changelog checking for errors, etc
⬜ Update – Migrates the database to the current state of the
changelog
⬜ UpdateSQL – Prints out the SQL that needs to be executed to
migrate the database to the current state of the changelog
Slide 17
Slide 17 text
Liquibase Functionality
⬜ Tag – Tags the current state of the database as a milestone
for rollback
⬜ Rollback – Rolls back a database to a specified tag
⬜ RollbackCount – Rolls back a database by specified number of
changesets
⬜ RollbackToDate – Rolls back a database to its state on a
specified date
Slide 18
Slide 18 text
Liquibase Functionality
⬜ RollbackSQL – Prints the SQL that needs to be executed to
rollback to the specified tag
⬜ UpdateTestingRollback – For each changeset, migrates the
database to include the changeset, rolls it back and migrates
again (tests rollback as part of the database migration)
⬜ GenerateChangeLog – Generates a change log from an
existing database (does not include stored procedures)
Slide 19
Slide 19 text
Liquibase Functionality
⬜ Diff – Diffs two databases to determine what’s different based
on the changelog.
⬜ Database contexts allow you to specify certain changesets
which should only be applied when a given context is in effect.