Nov 15 2012 - Agile Database Development

Download Report

Transcript Nov 15 2012 - Agile Database Development

Agile Database Development
with Java
Flyway and Liquibase
Agenda
•
•
•
•
Overview
Flyway Demos
Liquibase Demos
Questions
• https://bitbucket.org/asaikali/tjug-agile-databases.git
The Goals
• Develop and push code into production on a
regular schedule
– monthly, weekly, daily, hourly, continuously
• Make integration tests that use to the
database easy to write and maintain
The Problem
• Frequent deployment into production means
frequent changes to the .sql files
• How to manage the numerous .sql file?
• How to tell if a .sql file has been applied to a
database or not?
• How to build a process to move .sql changes
trough dev, qa, dba’s … etc.
• How to make the db setup trivial for integration
tests
• Diagrams: http://flywaydb.org/getstarted/whyDatabaseMigrations.html
The Solution
What Is Flyway
•
•
•
•
•
•
•
A java agile database migration framework
Inspired by Ruby on Rails migrations
Open Source Apache 2.0 license
Very nicely documented
Super Easy To Learn and Use
Developed by Axel Fontaine
http://www.flywaydb.org/
Flyway Demos
• Best way to see how flyway works is to
examine some demos that show Flyway in
Action
Flyway Demos
• Demo 1 & 2: Basic Idea
– Diagrams http://flywaydb.org/getstarted/howFlywayWorks.html
• Demo 3 : SQL Migrations
– Diagrams http://flywaydb.org/documentation/migration/migrationSql.html
• Demo 4 : Java Migrations
– Diagrams http://flywaydb.org/documentation/migration/migrationJava.html
• Demo 5 : Testing Extension
Flyway High Lights
•
•
•
•
•
•
•
•
•
•
Simple Easy To use
Automatic Migration on Startup
Convention over Configuration
Plain Old SQL Migrations
Java Migrations
Cluster Safe
Maven and Ant Support
Fail fast
Schema clean
Command line tools
What is liquibase
•
•
•
•
•
A java agile database migration framework
Open Source Apache 2.0 license
Very nicely documented
http://www.liquibase.org/
Uses XML DSL for capturing chages
Liquibase Demo
• Update database
– mvn liquibase:update
• Rollback
– mvn -Dliquibase.rollbackCount=1
liquibase:rollback
Liquibase Features
• Record database refactorings using an XML
DSL that is database independent
• Liquibase converts the XML files into SQL for
the database it is running against
• Roll forward
• Roll back
Summary
• Doing agile database development with Java is
easy
• Flyway and Liquibase are worth using
• A framework for doing database migration is
essential.
Questions?