Your SlideShare is downloading. ×
Axel Fontaine        FLYWAYTHE AGILE DATABASE MIGRATION    FRAMEWORK FOR JAVA
Axel Fontaine                               @axelfontaine                                         axelfontaine.comSoftware...
aboutquestions
THE PLAN
addAgeToAccount.sql
??   DB
DEV                                                                                              PROD                     ...
Problems for the DBA  • Little understanding of context  • Coordination with app deployer  • Monkey work  • Poor use of ex...
Problems for DEV  • Late review of changes  • Manual step with friction  • Less likely to change DB structure  • Code and ...
Goals                               Goals• Cooperation between DEV and DBA• Use full power of the DB• (Almost) no lock-in•...
flywaydb.org
3years old
25 000downloads in 2012
Keeping it simple    (saying no)
6               commandsclean   info    migrate   validate   init   repair
APIClasspath                                Metadata    Database-     +       Migration                                  T...
Flyway flyway = new Flyway();flyway.setDataSource(myDataSource);flyway.migrate();mvn flyway:migrate<flyway:migrate />flywa...
Empty DB
Empty DB   Version 1
Empty DB   Version 1   Version 2
And what about  the DBA?
VSDML        DDL
DEV      Migrate   PROD        on      Startup
Demo
When sql isn’t enough…
Java Migrationspublic class V1_2__Another_user implements JdbcMigration {    public void migrate(Connection conn) throws E...
When greenfieldisn’t an option…
Existing Production Database                                align             DEV         TEST           PROD         V1__...
Existing Production Database                                align             DEV         TEST           PROD         V1__...
Existing Production Database                                align                 DEV     TEST           PROD       migrat...
Existing Production Database                                align                 DEV     TEST           PROD       migrat...
Existing Production Database                                          align                 DEV         TEST              ...
Existing Production Database           DEV             TEST         PROD                      V2__Changes.sql
Existing Production Database           DEV              TEST        PROD                      migrate                     ...
Existing Production Database           DEV             TEST         PROD                      V2__Changes.sql
Backwards-compatible migrations
ExampleRename column Surname -> Last_Name
Surname             Last_Name          Surname                ALTER TABLE … RENAME COLUMN
Last_Name                       Last_NameSurname                       Last_Name          ALTER TABLE …                  D...
Last_NameLast_Name        DROP TRIGGER …        ALTER TABLE …          DROP COLUMN Surname
Roadmap   2.2       2.3       3.0 Q2 2013   Q3 2013   Q4 2013
flywaydb.org
1 day course Effective DatabaseMigrations with Flywayflywaydb.org/support/training.html
@axelfontaineAxel Fontaine                          axelfontaine.comSoftware Development Expert   business@axelfontaine.com
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Flyway (33rd Degree)
Upcoming SlideShare
Loading in...5
×

Flyway (33rd Degree)

11,438

Published on

My talk from the 33rd Degree conference 2013 in Warsaw

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
11,438
On Slideshare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Plain Old SQLConvention Over ConfigurationFail fastZero-required dependenciesJava 5+ and JDBC driverDeceivingly simple, yet surprisingly powerful
  • Transcript of "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

    ×