20
Database migrations Flyway and Liquibase Lars Östling [email protected] @larsostling

Database migrations with Flyway and Liquibase

Embed Size (px)

Citation preview

Page 1: Database migrations with Flyway and Liquibase

Database migrations Flyway and Liquibase

Lars Ö[email protected]

@larsostling

Page 2: Database migrations with Flyway and Liquibase

Agenda

• Database migrations

• Flyway

• Liquibase

• Conclusions

Page 3: Database migrations with Flyway and Liquibase

Back in the day…

• Big up-front design

• Long development cycles

• Scary updates

Page 4: Database migrations with Flyway and Liquibase

In an agile world…

• Short iterations

• Continuous integration /delivery / deployment

• Delivery pipe-lines

• We do it for code …

• … what about the database?

Page 5: Database migrations with Flyway and Liquibase
Page 6: Database migrations with Flyway and Liquibase

The challenge• Frequent database updates

• Managing multiple sql files

• What has been applied and what has not?

• Keeping code and database in sync …

• … throughout all environments

Page 7: Database migrations with Flyway and Liquibase

The solutionAutomated database migrations:

• Recreate database from scratch

• Make it clear at all times what state a database is in

• Migrate in a deterministic way from current version of the database to a newer one

Page 8: Database migrations with Flyway and Liquibase
Page 9: Database migrations with Flyway and Liquibase

What is Flyway?

• Agile database migration framework for Java

• Open Source Apache 2.0 license

• Started in 2010

• Status ‘Adopt’ on thoughtworks technology radar

• http://www.flywaydb.org

Page 10: Database migrations with Flyway and Liquibase

Demohttps://github.com/larsostling/database-migrations-demo

Page 11: Database migrations with Flyway and Liquibase

Short recap

• Schema version table

• Convention over configuration

• Sql and java migrations

• Supereasy to setup

Page 12: Database migrations with Flyway and Liquibase
Page 13: Database migrations with Flyway and Liquibase

What is Liquibase?

• Agile database migration framework for Java

• Open Source Apache 2.0 license

• Started in 2006

• http://www.liquibase.org

Page 14: Database migrations with Flyway and Liquibase

Demohttps://github.com/larsostling/database-migrations-demo

Page 15: Database migrations with Flyway and Liquibase

Short recap

• Uses structured DSL to describe database changes

• Databasechangelog table

• Supports rollback

• generateChangeLog

Page 16: Database migrations with Flyway and Liquibase

Flyway vs. Liquibase

• SQL vs. XML

• Multiple files vs. single file

• No rollback vs. rollback

• KISS vs. less KISS

Page 17: Database migrations with Flyway and Liquibase

Some advice

• Migrate on application startup

• Change sets do not change

• People and processes

Page 18: Database migrations with Flyway and Liquibase

Lessons learned

• Stop worrying about database changes

• Pick a framework and start using it

Page 19: Database migrations with Flyway and Liquibase

Q & A

Page 20: Database migrations with Flyway and Liquibase

Thanks!Lars Östling

[email protected]@larsostling