Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Flyway (33rd Degree)

13,520 views

Published on

My talk from the 33rd Degree conference 2013 in Warsaw

Published in: Technology
  • Be the first to comment

Flyway (33rd Degree)

  1. 1. Axel Fontaine FLYWAYTHE AGILE DATABASE MIGRATION FRAMEWORK FOR JAVA
  2. 2. Axel Fontaine @axelfontaine axelfontaine.comSoftware Development Expert business@axelfontaine.com • Independent consultant • Located in Munich • Founder of Flyway
  3. 3. aboutquestions
  4. 4. THE PLAN
  5. 5. addAgeToAccount.sql
  6. 6. ?? DB
  7. 7. DEV PROD ? http://digitalcitizen.ca/2009/06/22/simpsons-profile-pics-for-facebook-and-other-applications/
  8. 8. Problems for the DBA • Little understanding of context • Coordination with app deployer • Monkey work • Poor use of expertise • Poor working hours
  9. 9. Problems for DEV • Late review of changes • Manual step with friction • Less likely to change DB structure • Code and DB diverge • Incompatible with Continuous Deployment
  10. 10. Goals Goals• Cooperation between DEV and DBA• Use full power of the DB• (Almost) no lock-in• Automatic so you can forget about it• Descent working hours for everyone
  11. 11. flywaydb.org
  12. 12. 3years old
  13. 13. 25 000downloads in 2012
  14. 14. Keeping it simple (saying no)
  15. 15. 6 commandsclean info migrate validate init repair
  16. 16. APIClasspath Metadata Database- + Migration Table specificFilesystem Execution Management supportscanning
  17. 17. Flyway flyway = new Flyway();flyway.setDataSource(myDataSource);flyway.migrate();mvn flyway:migrate<flyway:migrate />flyway.cmd migrate
  18. 18. Empty DB
  19. 19. Empty DB Version 1
  20. 20. Empty DB Version 1 Version 2
  21. 21. And what about the DBA?
  22. 22. VSDML DDL
  23. 23. DEV Migrate PROD on Startup
  24. 24. Demo
  25. 25. When sql isn’t enough…
  26. 26. Java Migrationspublic class V1_2__Another_user implements JdbcMigration { public void migrate(Connection conn) throws Exception { try (PreparedStatement stmt = conn.prepareStatement(“…")) { stmt.execute(); } }}
  27. 27. When greenfieldisn’t an option…
  28. 28. Existing Production Database align DEV TEST PROD V1__Dump.sql
  29. 29. Existing Production Database align DEV TEST PROD V1__Dump.sql
  30. 30. Existing Production Database align DEV TEST PROD migrate V1__Dump.sql
  31. 31. Existing Production Database align DEV TEST PROD migrate V1__Dump.sql
  32. 32. Existing Production Database align DEV TEST PROD migrate V1__Dump.sql V2__Changes.sql
  33. 33. Existing Production Database DEV TEST PROD V2__Changes.sql
  34. 34. Existing Production Database DEV TEST PROD migrate V2__Changes.sql
  35. 35. Existing Production Database DEV TEST PROD V2__Changes.sql
  36. 36. Backwards-compatible migrations
  37. 37. ExampleRename column Surname -> Last_Name
  38. 38. Surname Last_Name Surname ALTER TABLE … RENAME COLUMN
  39. 39. Last_Name Last_NameSurname Last_Name ALTER TABLE … DROP TRIGGER … ADD COLUMN Last_Name ALTER TABLE … UPDATE … SET Last_Name = Surname DROP COLUMN Surname CREATE TRIGGER …
  40. 40. Last_NameLast_Name DROP TRIGGER … ALTER TABLE … DROP COLUMN Surname
  41. 41. Roadmap 2.2 2.3 3.0 Q2 2013 Q3 2013 Q4 2013
  42. 42. flywaydb.org
  43. 43. 1 day course Effective DatabaseMigrations with Flywayflywaydb.org/support/training.html
  44. 44. @axelfontaineAxel Fontaine axelfontaine.comSoftware Development Expert business@axelfontaine.com

×