continuous db changes delivery with liquibase
TRANSCRIPT
Continuous DB Changes Delivery With LiquibasePresented by Aidas Dragunas
Agenda• The short overview of Continuous Delivery process• The overview of Liquibase technology as one of open source
technologies, designed for DB changes migration• Live demonstration of how Liquibase could be used in Continuous
Delivery process
Continuous Delivery Overview How to continuously deliver application changes to the testing and production environment
Deployment automation stages
Commit CodePerform Unit &
Integration testing
Deploy to testing
environment
Perform Acceptance
testing
Deploy to production
environment
Continuous Integration
Continuous Delivery
Continuous Deployment
Continuous integration process
3
2
4
CI Server (Jenkins)
Development teamSCM repository
(GIT, SVN)
1
Notification
Binary repository (Nexus)
Continuous delivery process
25
4
3
CI Server (Jenkins)
Testing Environment
Development teamSCM repository
(GIT, SVN)
1
Notification
Binary repository (Nexus)
Continuous deployment process
2
4
5
3
7
6
CI Server (Jenkins)
Testing Environment
Development teamSCM repository
(GIT, SVN)
1
Stakeholders
Production Environment
Notification
Notification
Binary repository (Nexus)
Continuous delivery key notes• DB changes and web changes are committed into the SCM
repository together• DB changes are created and stored incrementally• DB changes are deployed incrementally• DB changes and web changes are deployed together
Liquibase OverviewOverview of Liquibase - one of DB changes deployment tools
Introduction• Purpose
• Provide structure to track and manage DB changes
• Deploy DB changes to the database
• Main keywords• Master Changelog• Incremental Changelog• Changeset
• Latest version• 3.4.2 (November 24, 2015)
• License• Liquibase - Apache 2.0• Datical DB - Commerce
version of Liquibase
• Principles• Manage DB changes in small chunks – Changesets• Store DB changes in Changelog files (preferably one Changeset in one file).• Use Changelog tables in the DB to track and manage DB changes
deployment process.
Features• Changeset descripton formats
• XML• SQL• JSON• YAML
• Changeset description types• Inside Changelog file• Outside Changelog file
• Changeset types• DB structure changes• Methods• Data changes
• Database types• Oracle• PostgreSQL• SQL Server• MySQL• Other
• Additional features• DB changes file generation• DB changes rollback• DB difference generation • DB documentation
• Plugins• Ant, Maven, Gradle (third
party provider)• Spring
Benefits• Flexible• Plugins for main deployment engines (Ant, Maven, Gradle)• Suitable for beginners and for experienced developers• Abiliy to load data and compile methods• Ability to rollback changes• Ability to review changes SQL file• Ability to generate documentation• Manually defining the order of changes • Supports various changelog formats• Supports the majority of database vendors
Drawbacks• Sometimes too complex, especially for datasets deployment• Manually defining the order of changes • Different plugins features for Gradle, Maven and Ant• Poorly formated output log• Change locks happen. When manual lock release should be
performed directly in the database• Limited by JDBC• Doesn‘t support Slonik files, so PostgreSQL built-in streaming
replication should be enabled
Liquibase vs FlywayFeature Liquibase Flyway
Incremental migration x x
Migration SQL preview x
Migration formats XML, SQL, YAML, JSON SQL, Java
Migration order management strategy
Manual Automatic
Migration rollback x
Repeated change execution
x
Context based change deployment
x
Documentation• http://www.liquibase.org/documentation/index.html• http://
www.datical.com/wp-content/uploads/2013/09/3-Technical-Brief-Datical-DB.pdf
Continuous Delivery With Liquibase DemoHow to continuously deliver DB changes to the PostgreSQL database using Liquibase
Solutions Pie
PostgreSQL
Jenkins/Nexus
Git
Maven/Ant/Gradle
Liquibase (Changelogs/Changesets)
Changelogs catalog structure• changes
• change-20151009142310• change.sql• change.xml
• change-20151009143745• ....• changelog.xml
• datasets• dataset-0001
• dataset.xml• dataset-0002• ....• changelog.xml
• methods• changelog.xml
• env• local.properties• development.properties• qa.properties• production.properties
• gradle• libs
Live Example
Questions?