SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

PDF
MySQL Group Replication
Kenny Gryp
65 slides6.7K views
PDF
Towards Holistic Continuous Software Performance Assessment
Vincenzo Ferme
92 slides590 views
PPTX
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
Jeff Kayser
173 slides5.5K views
PDF
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
Frederic Descamps
192 slides2.5K views
PDF
Java MySQL Connector & Connection Pool Features & Optimization
Kenny Gryp
92 slides6.7K views
PPTX
Awr doag
Marcin Przepiórowski
46 slides793 views
PDF
Oracle Database SQL Tuning Concept
Chien Chung Shen
83 slides2.4K views
PPTX
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa
82 slides1.9K views
PDF
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
28 slides6.5K views
PPTX
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
43 slides1.1K views
PDF
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
42 slides4.1K views
PDF
MySQL Replication Performance in the Cloud
Vitor Oliveira
36 slides224 views
PPTX
Best New Features of Oracle Database 12c
Pini Dibask
72 slides20.6K views
PDF
Advanced Oracle Troubleshooting
Hector Martinez
42 slides2.4K views
PPT
Best practices for share point solution deployment
Salaudeen Rajack
31 slides9.1K views
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
40 slides1.5K views
PDF
SPSD SharePoint Solution Deployer
Matthias Einig
21 slides13.6K views
PPTX
DBCC - Dubi Lebel
sqlserver.co.il
49 slides1.3K views
PDF
Pitfalls of migrating projects to JDK 9
Pavel Bucek
44 slides3K views
PPTX
Managed Beans: When, Why and How
Russell Maher
72 slides3K views
MySQL Group Replication
Kenny Gryp
65 slides6.7K views
Towards Holistic Continuous Software Performance Assessment
Vincenzo Ferme
92 slides590 views
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
Jeff Kayser
173 slides5.5K views
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
Frederic Descamps
192 slides2.5K views
Java MySQL Connector & Connection Pool Features & Optimization
Kenny Gryp
92 slides6.7K views
Awr doag
Marcin Przepiórowski
46 slides793 views
Oracle Database SQL Tuning Concept
Chien Chung Shen
83 slides2.4K views
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa
82 slides1.9K views
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
28 slides6.5K views
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
43 slides1.1K views
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
42 slides4.1K views
MySQL Replication Performance in the Cloud
Vitor Oliveira
36 slides224 views
Best New Features of Oracle Database 12c
Pini Dibask
72 slides20.6K views
Advanced Oracle Troubleshooting
Hector Martinez
42 slides2.4K views
Best practices for share point solution deployment
Salaudeen Rajack
31 slides9.1K views
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
40 slides1.5K views
SPSD SharePoint Solution Deployer
Matthias Einig
21 slides13.6K views
DBCC - Dubi Lebel
sqlserver.co.il
49 slides1.3K views
Pitfalls of migrating projects to JDK 9
Pavel Bucek
44 slides3K views
Managed Beans: When, Why and How
Russell Maher
72 slides3K views

Viewers also liked (6)

KEY
Database version control - pf congres version
Harrie Verveer
82 slides1.2K views
PDF
Database version control without pain - the PHP Barcelona version
Harrie Verveer
97 slides4.6K views
PPTX
Database Change Management
Kate Semizhon
6 slides548 views
PDF
Database version control without pain - the PHPNW10 version
Harrie Verveer
98 slides2.4K views
PPTX
Database versioning with liquibase
Return on Intelligence
16 slides2.9K views
PDF
Leveraging Open Source for Database Development: Database Version Control wit...
All Things Open
32 slides438 views
Database version control - pf congres version
Harrie Verveer
82 slides1.2K views
Database version control without pain - the PHP Barcelona version
Harrie Verveer
97 slides4.6K views
Database Change Management
Kate Semizhon
6 slides548 views
Database version control without pain - the PHPNW10 version
Harrie Verveer
98 slides2.4K views
Database versioning with liquibase
Return on Intelligence
16 slides2.9K views
Leveraging Open Source for Database Development: Database Version Control wit...
All Things Open
32 slides438 views
Ad

Similar to Database version control DPC version (20)

PPT
Evolutionary Database Design
Andrei Solntsev
21 slides1.2K views
PDF
Gaelyk - Web Apps In Practically No Time
Saltmarch Media
45 slides408 views
KEY
Simple SQL Change Management with Sqitch
David Wheeler
260 slides9.9K views
PDF
Database Refactoring
Anton Keks
40 slides14.2K views
PPT
Less03 db dbca
Amit Bhalla
23 slides2.5K views
PDF
Not so blind SQL Injection
Francisco Ribeiro
96 slides10.1K views
PDF
orical
Gowri Shankar
37 slides1.9K views
KEY
Sane SQL Change Management with Sqitch
David Wheeler
297 slides3.8K views
PDF
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
32 slides5.2K views
PPT
Build Automation of PHP Applications
Pavan Kumar N
28 slides7K views
PDF
Trunk and branches for database configuration management
scmsupport
11 slides10.7K views
PPT
Db trends final
Craig Mullins
65 slides2.3K views
PDF
Flywaydb
Manuel de la Peña Peña
60 slides1.6K views
PDF
Business Intelligence Release Management Best Practices
John Heaton
17 slides2K views
PPTX
Meetup Oracle Database MAD_BCN: 1.3 Gestión del ciclo de vida de Oracle Datab...
avanttic Consultoría Tecnológica
43 slides405 views
PPTX
Summer training oracle
Arshit Rai
26 slides1.4K views
PDF
BADCamp 2008 DB Sync
Shaun Haber
85 slides695 views
PDF
php_mysql_tutorial
tutorialsruby
64 slides2.3K views
PDF
php_mysql_tutorial
tutorialsruby
64 slides1K views
PDF
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
20 slides951 views
Evolutionary Database Design
Andrei Solntsev
21 slides1.2K views
Gaelyk - Web Apps In Practically No Time
Saltmarch Media
45 slides408 views
Simple SQL Change Management with Sqitch
David Wheeler
260 slides9.9K views
Database Refactoring
Anton Keks
40 slides14.2K views
Less03 db dbca
Amit Bhalla
23 slides2.5K views
Not so blind SQL Injection
Francisco Ribeiro
96 slides10.1K views
orical
Gowri Shankar
37 slides1.9K views
Sane SQL Change Management with Sqitch
David Wheeler
297 slides3.8K views
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
32 slides5.2K views
Build Automation of PHP Applications
Pavan Kumar N
28 slides7K views
Trunk and branches for database configuration management
scmsupport
11 slides10.7K views
Db trends final
Craig Mullins
65 slides2.3K views
Flywaydb
Manuel de la Peña Peña
60 slides1.6K views
Business Intelligence Release Management Best Practices
John Heaton
17 slides2K views
Meetup Oracle Database MAD_BCN: 1.3 Gestión del ciclo de vida de Oracle Datab...
avanttic Consultoría Tecnológica
43 slides405 views
Summer training oracle
Arshit Rai
26 slides1.4K views
BADCamp 2008 DB Sync
Shaun Haber
85 slides695 views
php_mysql_tutorial
tutorialsruby
64 slides2.3K views
php_mysql_tutorial
tutorialsruby
64 slides1K views
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
20 slides951 views
Ad

Recently uploaded (20)

PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
7 slides14 views
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
19 slides12 views
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
47 slides194 views
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
17 slides131 views
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
59 slides12 views
PDF
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
12 slides17 views
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
59 slides11 views
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
69 slides122 views
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
10 slides46 views
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
6 slides63 views
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
8 slides0 views
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
15 slides21 views
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
10 slides27 views
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
41 slides53 views
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
11 slides14 views
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
113 slides16 views
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
4 slides11 views
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
47 slides126 views
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
11 slides32 views
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
23 slides11 views
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
7 slides14 views
The Future of AI & Machine Learning.pptx
pritsen4700
19 slides12 views
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
47 slides194 views
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
17 slides131 views
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
59 slides12 views
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
12 slides17 views
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
59 slides11 views
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
69 slides122 views
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
10 slides46 views
Market Insight : ETH Dominance Returns
CIFDAQ
6 slides63 views
What-is-the-World-Wide-Web -- Introduction
tonifi9488
8 slides0 views
Brief History of Internet - Early Days of Internet
sutharharshit158
15 slides21 views
introduction to computer hardware and sofeware
chauhanshraddha2007
10 slides27 views
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
41 slides53 views
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
11 slides14 views
Per Axbom: The spectacular lies of maps
Nexer Digital
113 slides16 views
Researching The Best Chat SDK Providers in 2025
Ray Fields
4 slides11 views
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
47 slides126 views
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
11 slides32 views
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
23 slides11 views

Database version control DPC version

Editor's Notes

  • #67: ORM = Object Relations Mapper