SlideShare a Scribd company logo
1 of 79
Database Version Control Without Pain




                           Harrie Verveer
                          June 11th 2010
Database Version Control
What’s the problem?




                           2
http://www.sxc.hu/photo/754535
http://www.sxc.hu/photo/1207911
http://en.wikipedia.org/wiki/File:STS120LaunchHiRes.jpg
http://www.sxc.hu/photo/1255121
Why Database Version Control




                               7
Simple Patching Strategy
The basic idea




                           8
Simple patching strategy




                           9
Example patch file

patch-001.sql




                     10
http://www.sxc.hu/photo/1214820
Simple patching strategy

                      Development
                            Write code
                        Write DB patches
                     Apply patches to own DB




     Apply patches                             Commit




                          Update


                                                        12
Fixing patches

patch-002.sql




                 13
Fixing patches

patch-002.sql




                 13
Fixing patches

patch-002.sql




                 13
Fixing patches

patch-003.sql




                 14
Fixing patches

patch-003.sql




     Never modify a patch file once
       it’s under version control


                                      14
Undo patch files

undo-001.sql




                   15
http://www.freefoto.com/preview/41-07-7
Bonus points




               Install.sql




                             17
Bonus points




         Initial dummy content




                                 18
http://www.sxc.hu/photo/643214
http://www.sxc.hu/photo/946855
Automating the process
Faster & Safer




                         21
http://www.sxc.hu/photo/314594
Typical patch script




                       23
Typical patch script

update.sh




                       24
http://www.sxc.hu/photo/1196126
Branches
Merge problems




                 26
Branches
Trunk
    patch-001.sql

    patch-002.sql


    patch-003.sql




                    27
Branches
Trunk
    patch-001.sql

    patch-002.sql


    patch-003.sql
                         Branch A
         create branch

    patch-004.sql
                               patch-004.sql
    patch-005.sql

                               patch-005.sql
             Merge




                                               28
Branches
Trunk
    patch-001.sql

    patch-002.sql


    patch-003.sql
                         Branch A
         create branch

    patch-004.sql
                                               patch-006.sql
                               patch-004.sql
    patch-005.sql
                                               patch-007.sql
                               patch-005.sql
             Merge




                                                               28
Branches
Trunk
    patch-001.sql                             Branch A
                         create branch
    patch-002.sql

                                                    patch-002.sql
    patch-003.sql
                         Branch B
         create branch
                                                    patch-003.sql
              Merge

                                   patch-004.sql    patch-004.sql
    patch-004.sql
                                   patch-005.sql

    patch-005.sql                     Merge


                                                    patch-005.sql
                                      Merge
             Merge


                                                                    29
Separate sequence

db/patches/trunk/   db/patches/branchA/

patch-001.sql       patch-001.sql
patch-002.sql       patch-002.sql
patch-003.sql




                                          30
Separate sequence

db/patches/trunk/           db/patches/branchA/

patch-001.sql               patch-001.sql
patch-002.sql               patch-002.sql
patch-003.sql


                     Trunk version    3
                    BranchA version   2




                                                  30
Patchfile naming




       patch_20100611_1430.sql




                                 31
Patch log




            32
http://www.sxc.hu/photo/692740
Phing & DB Deploy
Avoiding the NIH syndrome




                            34
http://phing.info/




                     35
Phing




        36
37
DB Deploy




            38
DB Deploy

db/patches/1-create_user_table.sql




                                     39
Phing & DB Deploy




                    40
DB Deploy

changelog table:




                   41
DB Deploy

changelog table:




                   41
DB Deploy




            PHP




                  42
DB Deploy




            SQL




                  43
DB Deploy




            Features




                       44
Liquibase
A different approach




                       45
Liquibase




            www.liquibase.org




                                46
Liquibase




            47
Liquibase




            48
Liquibase




            49
Liquibase

  Updating
  Reverting
  Tagging
  Generate XML
  Diff




                 50
http://www.sxc.hu/photo/1241520
Liquibase




            Branches




                       52
Liquibase




            DBMS Support




                           53
Liquibase




            Documentation




                            54
Liquibase




            Java




                   55
Akrabat DB Schema Manager
Zend Framework specific solution




                                   56
Akrabat DB Schema Manager

  Zend Framework
  Proposed by Rob Allen in 2006
  Recently implemented
  Might be in ZF in the near future

http://github.com/akrabat/Akrabat




                                      57
Writing the patch

scripts/migrations/001-CreateUserTable.php




                                             58
Writing the patch

scripts/migrations/001-CreateUserTable.php




                                             59
Akrabat DB Schema Manager




              PHP Patches




                            60
Akrabat DB Schema Manager




      Easy syntax if you know ZF




                                   61
Akrabat DB Schema Manager




              Easy to use




                            62
Akrabat DB Schema Manager




            Branch merging




                             63
Doctrine Migrations




                      64
Doctrine Migrations




         http://www.doctrine-project.org/




                                            65
Doctrine Migrations




                      66
Doctrine Migrations




            Update-to-version




                                67
Doctrine Migrations




             Generate patches




                                68
Doctrine Migrations




 Useful if you’re already using Doctrine
                   ORM




                                           69
Summary




          70
Summary

 Patchfiles                 Akrabat DB Schema Manager
                            http://akrabat.com
 • Automating
                            http://github.com/akrabat/Akrabat
 • Branch merging

                            Doctrine Migrations
 Phing + DB Deploy          http://www.doctrine-project.org
 http://phing.info
 http://dbdeploy.com


 Liquibase
 http://www.liquibase.org




                                                                71
Questions ?




              72
Contact me

Harrie Verveer
Software Engineer at Ibuildings


E-mail:
harrie@ibuildings.nl


Skype:
harrie-ibuildings


Twitter:
@harrieverveer




               http://joind.in/1544
                                      73

More Related Content

What's hot

Database Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event SchedulersDatabase Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
 

What's hot (20)

MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 
Towards Holistic Continuous Software Performance Assessment
Towards Holistic Continuous Software Performance AssessmentTowards Holistic Continuous Software Performance Assessment
Towards Holistic Continuous Software Performance Assessment
 
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
Oracle Enterprise Manager 12c:  The Oracle Monitoring tool of choice – Why yo...Oracle Enterprise Manager 12c:  The Oracle Monitoring tool of choice – Why yo...
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
 
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio  in a nutshell - MySQL InnoDB ClusterMySQL Group Replicatio  in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
 
Java MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationJava MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & Optimization
 
Awr doag
Awr doagAwr doag
Awr doag
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
 
Database Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event SchedulersDatabase Automation with MySQL Triggers and Event Schedulers
Database Automation with MySQL Triggers and Event Schedulers
 
MySQL Replication Performance in the Cloud
MySQL Replication Performance in the CloudMySQL Replication Performance in the Cloud
MySQL Replication Performance in the Cloud
 
Best New Features of Oracle Database 12c
Best New Features of Oracle Database 12cBest New Features of Oracle Database 12c
Best New Features of Oracle Database 12c
 
Advanced Oracle Troubleshooting
Advanced Oracle TroubleshootingAdvanced Oracle Troubleshooting
Advanced Oracle Troubleshooting
 
Best practices for share point solution deployment
Best practices for share point solution deploymentBest practices for share point solution deployment
Best practices for share point solution deployment
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
 
SPSD SharePoint Solution Deployer
SPSD SharePoint Solution DeployerSPSD SharePoint Solution Deployer
SPSD SharePoint Solution Deployer
 
DBCC - Dubi Lebel
DBCC - Dubi LebelDBCC - Dubi Lebel
DBCC - Dubi Lebel
 
Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9Pitfalls of migrating projects to JDK 9
Pitfalls of migrating projects to JDK 9
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and How
 

Viewers also liked

Viewers also liked (6)

Database version control - pf congres version
Database version control - pf congres versionDatabase version control - pf congres version
Database version control - pf congres version
 
Database version control without pain - the PHP Barcelona version
Database version control without pain - the PHP Barcelona versionDatabase version control without pain - the PHP Barcelona version
Database version control without pain - the PHP Barcelona version
 
Database Change Management
Database Change ManagementDatabase Change Management
Database Change Management
 
Database version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 versionDatabase version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 version
 
Database versioning with liquibase
Database versioning with liquibaseDatabase versioning with liquibase
Database versioning with liquibase
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...
 

Similar to Database version control DPC version

Lo extraction part 2 database update logic
Lo extraction   part 2 database update logicLo extraction   part 2 database update logic
Lo extraction part 2 database update logic
JNTU University
 
6212883126866262792 performance testing_cloud
6212883126866262792 performance testing_cloud6212883126866262792 performance testing_cloud
6212883126866262792 performance testing_cloud
Locuto Riorama
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)
Steve Min
 
Mysql 57-upcoming-changes
Mysql 57-upcoming-changesMysql 57-upcoming-changes
Mysql 57-upcoming-changes
Morgan Tocker
 

Similar to Database version control DPC version (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Lo extraction part 2 database update logic
Lo extraction   part 2 database update logicLo extraction   part 2 database update logic
Lo extraction part 2 database update logic
 
Continuous Delivery Applied
Continuous Delivery AppliedContinuous Delivery Applied
Continuous Delivery Applied
 
Continuous Delivery Applied (Agile Richmond)
Continuous Delivery Applied (Agile Richmond)Continuous Delivery Applied (Agile Richmond)
Continuous Delivery Applied (Agile Richmond)
 
Continuous Delivery Applied
Continuous Delivery AppliedContinuous Delivery Applied
Continuous Delivery Applied
 
JavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control systemJavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control system
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
6212883126866262792 performance testing_cloud
6212883126866262792 performance testing_cloud6212883126866262792 performance testing_cloud
6212883126866262792 performance testing_cloud
 
Reporting Large Environment Zabbix Database
Reporting Large Environment Zabbix DatabaseReporting Large Environment Zabbix Database
Reporting Large Environment Zabbix Database
 
Alain Ganuchaud - Reporting Large Environment Zabbix Database
Alain Ganuchaud - Reporting Large Environment Zabbix DatabaseAlain Ganuchaud - Reporting Large Environment Zabbix Database
Alain Ganuchaud - Reporting Large Environment Zabbix Database
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 
the State of the Dolphin - October 2020
the State of the Dolphin - October 2020the State of the Dolphin - October 2020
the State of the Dolphin - October 2020
 
[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)[SSA] 03.newsql database (2014.02.05)
[SSA] 03.newsql database (2014.02.05)
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
Mysql 57-upcoming-changes
Mysql 57-upcoming-changesMysql 57-upcoming-changes
Mysql 57-upcoming-changes
 
CISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 DevelopmentCISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 Development
 
MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Database version control DPC version

Editor's Notes

  1. ORM = Object Relations Mapper