Flyway

1,832 views

Published on

Flyway: The agile database migration framework for Java

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,832
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
72
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Flyway

  1. 1. Flyway The agile database migration framework for Java Kaunas JUG Saulius Tvarijonas · saulius.tvarijonas@gmail.com
  2. 2. Why migration tool? ● Multiple environments (dev[1..*], staging, prod) ● Multiple developers
  3. 3. Questions? ● What is current state of database? ● Has script already applied or not? ● Has quick fix to production applied to test environment also? ● How do you set up a new database instance?
  4. 4. How it works? ● Metadata table SCHEMA_VERSION ● Each change is recorded in metadata table ● Scans classpath for available migrations. SQL or Java. ● The migrations are then sorted based on their version number and applied in order
  5. 5. How it works?
  6. 6. How it works?
  7. 7. Preparing an existing database ● Create an initial migration script that will recreate your current state and give it a low version number ● Use flyway:init to create the metadata table and set this script as the current version
  8. 8. Preparing existing database
  9. 9. Design Goals ● Cooperation between DEV and DBA ● Use full power of the DB ● Almost no lock-in ● Automatic so you can forget about it
  10. 10. It just works ● Keep it simple ● Convention over configuration ● Zero required dependencies
  11. 11. Versions and naming Examples of valid versions: ● 1 ● 001 ● 5.2 ● 5_2 (5.2 at runtime) ● 1.2.3.4.5.6.7.8.9 ● 205.68 ● 20130115113556 ● 2013.1.15.11.35.56 ● 2013.01.15.11.35.56
  12. 12. Commands INFO MIGRATE CLEAN INIT VALIDATE REPAIR
  13. 13. Integrations ● Java API (also works on Android) for migrating the database on application startup ● Maven plugin, Gradle plugin, SBT plugin, Ant tasks or the Command-line client
  14. 14. Databases Oracle SQL Server SQL Azure DB2 MySQL (inc. Amazon RDS) MariaDB Google Cloud SQL PostgreSQL (inc. Amazon RDS and Heroku) H2 Hsql Derby SQLite
  15. 15. Architecture
  16. 16. Java
  17. 17. Maven
  18. 18. Apply to production
  19. 19. The Fear of DDL
  20. 20. DML ⇔ DDL
  21. 21. Cluster on start-up
  22. 22. When SQL isn’t enough ● Advanced text formatting ● BLOB
  23. 23. Java Migrations
  24. 24. Recommended
  25. 25. Java Forever Thank You!

×