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

More Related Content

What's hot (20)

PDF
MySQL Group Replication
Kenny Gryp
 
PDF
Towards Holistic Continuous Software Performance Assessment
Vincenzo Ferme
 
PPTX
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
Jeff Kayser
 
PDF
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
Frederic Descamps
 
PDF
Java MySQL Connector & Connection Pool Features & Optimization
Kenny Gryp
 
PPTX
Awr doag
Marcin Przepiórowski
 
PDF
Oracle Database SQL Tuning Concept
Chien Chung Shen
 
PPTX
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa
 
PDF
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
 
PPTX
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
 
PDF
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
 
PDF
MySQL Replication Performance in the Cloud
Vitor Oliveira
 
PPTX
Best New Features of Oracle Database 12c
Pini Dibask
 
PDF
Advanced Oracle Troubleshooting
Hector Martinez
 
PPT
Best practices for share point solution deployment
Salaudeen Rajack
 
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
PDF
SPSD SharePoint Solution Deployer
Matthias Einig
 
PPTX
DBCC - Dubi Lebel
sqlserver.co.il
 
PDF
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
PPTX
Managed Beans: When, Why and How
Russell Maher
 
MySQL Group Replication
Kenny Gryp
 
Towards Holistic Continuous Software Performance Assessment
Vincenzo Ferme
 
Oracle Enterprise Manager 12c: The Oracle Monitoring tool of choice – Why yo...
Jeff Kayser
 
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
Frederic Descamps
 
Java MySQL Connector & Connection Pool Features & Optimization
Kenny Gryp
 
Oracle Database SQL Tuning Concept
Chien Chung Shen
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Kyle Hailey
 
Database Automation with MySQL Triggers and Event Schedulers
Abdul Rahman Sherzad
 
MySQL Replication Performance in the Cloud
Vitor Oliveira
 
Best New Features of Oracle Database 12c
Pini Dibask
 
Advanced Oracle Troubleshooting
Hector Martinez
 
Best practices for share point solution deployment
Salaudeen Rajack
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
SPSD SharePoint Solution Deployer
Matthias Einig
 
DBCC - Dubi Lebel
sqlserver.co.il
 
Pitfalls of migrating projects to JDK 9
Pavel Bucek
 
Managed Beans: When, Why and How
Russell Maher
 

Viewers also liked (6)

KEY
Database version control - pf congres version
Harrie Verveer
 
PDF
Database version control without pain - the PHP Barcelona version
Harrie Verveer
 
PPTX
Database Change Management
Kate Semizhon
 
PDF
Database version control without pain - the PHPNW10 version
Harrie Verveer
 
PPTX
Database versioning with liquibase
Return on Intelligence
 
PDF
Leveraging Open Source for Database Development: Database Version Control wit...
All Things Open
 
Database version control - pf congres version
Harrie Verveer
 
Database version control without pain - the PHP Barcelona version
Harrie Verveer
 
Database Change Management
Kate Semizhon
 
Database version control without pain - the PHPNW10 version
Harrie Verveer
 
Database versioning with liquibase
Return on Intelligence
 
Leveraging Open Source for Database Development: Database Version Control wit...
All Things Open
 
Ad

Similar to Database version control DPC version (20)

PPT
Evolutionary Database Design
Andrei Solntsev
 
PDF
Gaelyk - Web Apps In Practically No Time
Saltmarch Media
 
KEY
Simple SQL Change Management with Sqitch
David Wheeler
 
PDF
Database Refactoring
Anton Keks
 
PPT
Less03 db dbca
Amit Bhalla
 
PDF
Not so blind SQL Injection
Francisco Ribeiro
 
PDF
orical
Gowri Shankar
 
KEY
Sane SQL Change Management with Sqitch
David Wheeler
 
PDF
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
 
PPT
Build Automation of PHP Applications
Pavan Kumar N
 
PDF
Trunk and branches for database configuration management
scmsupport
 
PPT
Db trends final
Craig Mullins
 
PDF
Business Intelligence Release Management Best Practices
John Heaton
 
PPTX
Meetup Oracle Database MAD_BCN: 1.3 Gestión del ciclo de vida de Oracle Datab...
avanttic Consultoría Tecnológica
 
PPTX
Summer training oracle
Arshit Rai
 
PDF
BADCamp 2008 DB Sync
Shaun Haber
 
PDF
php_mysql_tutorial
tutorialsruby
 
PDF
php_mysql_tutorial
tutorialsruby
 
PDF
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
Evolutionary Database Design
Andrei Solntsev
 
Gaelyk - Web Apps In Practically No Time
Saltmarch Media
 
Simple SQL Change Management with Sqitch
David Wheeler
 
Database Refactoring
Anton Keks
 
Less03 db dbca
Amit Bhalla
 
Not so blind SQL Injection
Francisco Ribeiro
 
Sane SQL Change Management with Sqitch
David Wheeler
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
 
Build Automation of PHP Applications
Pavan Kumar N
 
Trunk and branches for database configuration management
scmsupport
 
Db trends final
Craig Mullins
 
Business Intelligence Release Management Best Practices
John Heaton
 
Meetup Oracle Database MAD_BCN: 1.3 Gestión del ciclo de vida de Oracle Datab...
avanttic Consultoría Tecnológica
 
Summer training oracle
Arshit Rai
 
BADCamp 2008 DB Sync
Shaun Haber
 
php_mysql_tutorial
tutorialsruby
 
php_mysql_tutorial
tutorialsruby
 
Bar Camp Auckland - Mongo DB Presentation BCA4
John Ballinger
 
Ad

Recently uploaded (20)

PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Designing Production-Ready AI Agents
Kunal Rai
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Database version control DPC version

Editor's Notes

  • #67: ORM = Object Relations Mapper