Your SlideShare is downloading. ×
0
PHP Barcelona Conference - 30th October 2010
Harrie Verveer
Database Version Control Without Pain
zaterdag 30 oktober 2010
Oh hai!
2
HarrieVerveer
aka Hairy
Dutchy
I live in a town called “Goes”
Software engineer at
ibuildings since 2004
Vlissin...
http://www.mediawiki.org/wiki/File:Europe_satellite_orthographic.jpghttp://www.mediawiki.org/wiki/File:Europe_satellite_or...
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
zaterdag 30 oktober 2010
Database Version Control
What’s the problem?
8
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/1207911
zaterdag 30 oktober 2010
http://en.wikipedia.org/wiki/File:STS120LaunchHiRes.jpg
zaterdag 30 oktober 2010
http://www.flickr.com/photos/kt/1217157/
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/1255121
zaterdag 30 oktober 2010
Why Database Version Control
13
zaterdag 30 oktober 2010
Simple Patching Strategy
14
The basic idea
zaterdag 30 oktober 2010
Simple patching strategy
15
zaterdag 30 oktober 2010
Example patch file
16
patch-001.sql
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/314594
zaterdag 30 oktober 2010
Simple patching strategy
18
Development
Write code
Write DB patches
Apply patches to own DB
Update
Apply patches Commit
za...
Fixing patches
19
patch-002.sql
zaterdag 30 oktober 2010
Fixing patches
19
patch-002.sql
zaterdag 30 oktober 2010
Fixing patches
19
patch-002.sql
zaterdag 30 oktober 2010
Fixing patches
20
patch-003.sql
zaterdag 30 oktober 2010
Fixing patches
20
patch-003.sql
Never modify a patch file once
it’s under version control
zaterdag 30 oktober 2010
Undo patch files
21
undo-001.sql
zaterdag 30 oktober 2010
http://www.freefoto.com/preview/41-07-7
zaterdag 30 oktober 2010
Bonus points
Install.sql
23
zaterdag 30 oktober 2010
Bonus points
Initial dummy content
24
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/643214
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/946855
zaterdag 30 oktober 2010
Automating the process
Faster & Safer
27
zaterdag 30 oktober 2010
Typical patch script
28
zaterdag 30 oktober 2010
Typical patch script
29
update.sh
zaterdag 30 oktober 2010
Branches
Merge problems
30
zaterdag 30 oktober 2010
Branches
31
Trunk
patch-001.sql
patch-002.sql
patch-003.sql
zaterdag 30 oktober 2010
Trunk
patch-001.sql
patch-002.sql
patch-003.sql
create branch
patch-004.sql
patch-005.sql
patch-004.sql
patch-005.sql
Bran...
Trunk
patch-001.sql
patch-002.sql
patch-003.sql
create branch
patch-004.sql
patch-005.sql
patch-004.sql
patch-005.sql
Bran...
Branches
33
Trunk
patch-001.sql
patch-002.sql
patch-003.sql
create branch
patch-004.sql
patch-005.sql
patch-004.sql
patch-...
Separate sequence
db/patches/trunk/
patch-001.sql
patch-002.sql
patch-003.sql
34
db/patches/branchA/
patch-001.sql
patch-0...
Separate sequence
db/patches/trunk/
patch-001.sql
patch-002.sql
patch-003.sql
34
db/patches/branchA/
patch-001.sql
patch-0...
Patchfile naming
35
patch_20100611_1430.sql
zaterdag 30 oktober 2010
Patch log
36
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/692740
zaterdag 30 oktober 2010
There is no silver bullet
Why it can’t exist
38
zaterdag 30 oktober 2010
http://www.flickr.com/photos/eschipul/4160817135/
zaterdag 30 oktober 2010
Comparing tables
40
Table in DB 1Table in DB 1
column 1 int
column 2 varchar(255)
column 3 varchar(255)
Table in DB 2Table...
Comparing tables
41
Table in DB 1Table in DB 1
id int
name varchar(255)
city varchar(255)
Table in DB 2Table in DB 2
id in...
Comparing tables
42
Table in DB 1Table in DB 1
id int
firstname varchar(255)
lname varchar(255)
Table in DB 2Table in DB 2
...
43
To synchronize two database
structures without unexpected
dataloss, communicating all steps
needed to get from A to B i...
Phing & DB Deploy
44
zaterdag 30 oktober 2010
Phing & DB Deploy
45Cartoon by Oliver Widder - http://geekandpoke.typepad.com/
zaterdag 30 oktober 2010
46
http://phing.info/
zaterdag 30 oktober 2010
Phing
47
zaterdag 30 oktober 2010
48
zaterdag 30 oktober 2010
DB Deploy
49
zaterdag 30 oktober 2010
Phing & DB Deploy
50
zaterdag 30 oktober 2010
DB Deploy
51
db/patches/1-create_user_table.sql
zaterdag 30 oktober 2010
DB Deploy
52
changelog table:
zaterdag 30 oktober 2010
DB Deploy
52
changelog table:
zaterdag 30 oktober 2010
DB Deploy
53
PHP
zaterdag 30 oktober 2010
DB Deploy
54
SQL
zaterdag 30 oktober 2010
DB Deploy
55
Features
zaterdag 30 oktober 2010
Liquibase
The most complete solution I know
56
zaterdag 30 oktober 2010
Liquibase
57
www.liquibase.org
zaterdag 30 oktober 2010
Liquibase
58
zaterdag 30 oktober 2010
Liquibase
59
zaterdag 30 oktober 2010
Liquibase
60
zaterdag 30 oktober 2010
Liquibase
Updating
Reverting
Tagging
Generate XML
Diff
61
zaterdag 30 oktober 2010
http://www.sxc.hu/photo/1241520
zaterdag 30 oktober 2010
Liquibase
Branches
63
zaterdag 30 oktober 2010
Liquibase
DBMS Support
64
zaterdag 30 oktober 2010
Liquibase
Documentation
65
zaterdag 30 oktober 2010
Liquibase
Java
66
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Zend Framework specific solution
67
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Zend Framework
Proposed by Rob Allen in 2006
Recently implemented
http://github.com/akrabat/Akra...
Writing the patch
69
scripts/migrations/001-CreateUserTable.php
zaterdag 30 oktober 2010
Writing the patch
70
scripts/migrations/001-CreateUserTable.php
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
PHP Patches
71
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Easy syntax if you know ZF
72
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Easy to install, easy to use
73
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Easy to install, easy to use
73
zaterdag 30 oktober 2010
Akrabat DB Schema Manager
Branch merging
74
zaterdag 30 oktober 2010
Doctrine Migrations
Doctrine ORM specific solution
75
zaterdag 30 oktober 2010
Doctrine Migrations
76
http://www.doctrine-project.org/
zaterdag 30 oktober 2010
Doctrine Migrations Patch
77
zaterdag 30 oktober 2010
Doctrine Migrations
78
Update-to-version
./doctrine migrate
zaterdag 30 oktober 2010
YAML
79
zaterdag 30 oktober 2010
YAML
79
./doctrine generate-migrations-diff
zaterdag 30 oktober 2010
Doctrine Migrations
80
zaterdag 30 oktober 2010
Doctrine Migrations
81
Generate patches
zaterdag 30 oktober 2010
Doctrine Migrations
82
Useful if you’re already using Doctrine
ORM
zaterdag 30 oktober 2010
Summary
83
zaterdag 30 oktober 2010
Summary
Patchfiles
• Automating
• Branch merging
• Why there is no silver bullet
Phing + DB Deploy
http://phing.info
http:...
Questions ?
85
zaterdag 30 oktober 2010
86
Contact me
Harrie Verveer
Software Engineer at Ibuildings
Blog:
www.harrieverveer.com
E-mail:
harrie@ibuildings.nl
Skyp...
Upcoming SlideShare
Loading in...5
×

Database version control without pain - the PHP Barcelona version

6,602

Published on

The slides for the talk "database version control without pain" as presented at PHP Barcelona, October 30th 2010

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
  • Hey !
    I suggest you have a look at the GPL neXtep designer, an alternate solution to the ones you presented here. It offers a full-featured database development on top of a version control repository, offerring some amazing features in terms of database delivery automation, merge, design.
    All information available at :
    http://www.nextep-softwares.com

    Kind regards,
    Christophe
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
6,602
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
84
Comments
1
Likes
8
Embeds 0
No embeds

No notes for slide

Transcript of "Database version control without pain - the PHP Barcelona version"

  1. 1. PHP Barcelona Conference - 30th October 2010 Harrie Verveer Database Version Control Without Pain zaterdag 30 oktober 2010
  2. 2. Oh hai! 2 HarrieVerveer aka Hairy Dutchy I live in a town called “Goes” Software engineer at ibuildings since 2004 Vlissingen (Flushing) office zaterdag 30 oktober 2010
  3. 3. http://www.mediawiki.org/wiki/File:Europe_satellite_orthographic.jpghttp://www.mediawiki.org/wiki/File:Europe_satellite_orthographic.jpg zaterdag 30 oktober 2010
  4. 4. zaterdag 30 oktober 2010
  5. 5. zaterdag 30 oktober 2010
  6. 6. zaterdag 30 oktober 2010
  7. 7. zaterdag 30 oktober 2010
  8. 8. zaterdag 30 oktober 2010
  9. 9. zaterdag 30 oktober 2010
  10. 10. zaterdag 30 oktober 2010
  11. 11. Database Version Control What’s the problem? 8 zaterdag 30 oktober 2010
  12. 12. http://www.sxc.hu/photo/1207911 zaterdag 30 oktober 2010
  13. 13. http://en.wikipedia.org/wiki/File:STS120LaunchHiRes.jpg zaterdag 30 oktober 2010
  14. 14. http://www.flickr.com/photos/kt/1217157/ zaterdag 30 oktober 2010
  15. 15. http://www.sxc.hu/photo/1255121 zaterdag 30 oktober 2010
  16. 16. Why Database Version Control 13 zaterdag 30 oktober 2010
  17. 17. Simple Patching Strategy 14 The basic idea zaterdag 30 oktober 2010
  18. 18. Simple patching strategy 15 zaterdag 30 oktober 2010
  19. 19. Example patch file 16 patch-001.sql zaterdag 30 oktober 2010
  20. 20. http://www.sxc.hu/photo/314594 zaterdag 30 oktober 2010
  21. 21. Simple patching strategy 18 Development Write code Write DB patches Apply patches to own DB Update Apply patches Commit zaterdag 30 oktober 2010
  22. 22. Fixing patches 19 patch-002.sql zaterdag 30 oktober 2010
  23. 23. Fixing patches 19 patch-002.sql zaterdag 30 oktober 2010
  24. 24. Fixing patches 19 patch-002.sql zaterdag 30 oktober 2010
  25. 25. Fixing patches 20 patch-003.sql zaterdag 30 oktober 2010
  26. 26. Fixing patches 20 patch-003.sql Never modify a patch file once it’s under version control zaterdag 30 oktober 2010
  27. 27. Undo patch files 21 undo-001.sql zaterdag 30 oktober 2010
  28. 28. http://www.freefoto.com/preview/41-07-7 zaterdag 30 oktober 2010
  29. 29. Bonus points Install.sql 23 zaterdag 30 oktober 2010
  30. 30. Bonus points Initial dummy content 24 zaterdag 30 oktober 2010
  31. 31. http://www.sxc.hu/photo/643214 zaterdag 30 oktober 2010
  32. 32. http://www.sxc.hu/photo/946855 zaterdag 30 oktober 2010
  33. 33. Automating the process Faster & Safer 27 zaterdag 30 oktober 2010
  34. 34. Typical patch script 28 zaterdag 30 oktober 2010
  35. 35. Typical patch script 29 update.sh zaterdag 30 oktober 2010
  36. 36. Branches Merge problems 30 zaterdag 30 oktober 2010
  37. 37. Branches 31 Trunk patch-001.sql patch-002.sql patch-003.sql zaterdag 30 oktober 2010
  38. 38. Trunk patch-001.sql patch-002.sql patch-003.sql create branch patch-004.sql patch-005.sql patch-004.sql patch-005.sql Branch A Merge Branches 32 zaterdag 30 oktober 2010
  39. 39. Trunk patch-001.sql patch-002.sql patch-003.sql create branch patch-004.sql patch-005.sql patch-004.sql patch-005.sql Branch A Merge Branches 32 patch-006.sql patch-007.sql zaterdag 30 oktober 2010
  40. 40. Branches 33 Trunk patch-001.sql patch-002.sql patch-003.sql create branch patch-004.sql patch-005.sql patch-004.sql patch-005.sql Branch B create branch patch-002.sql patch-003.sql Branch A Merge patch-004.sql Merge patch-005.sql Merge Merge zaterdag 30 oktober 2010
  41. 41. Separate sequence db/patches/trunk/ patch-001.sql patch-002.sql patch-003.sql 34 db/patches/branchA/ patch-001.sql patch-002.sql zaterdag 30 oktober 2010
  42. 42. Separate sequence db/patches/trunk/ patch-001.sql patch-002.sql patch-003.sql 34 db/patches/branchA/ patch-001.sql patch-002.sql Trunk version 3 BranchA version 2 zaterdag 30 oktober 2010
  43. 43. Patchfile naming 35 patch_20100611_1430.sql zaterdag 30 oktober 2010
  44. 44. Patch log 36 zaterdag 30 oktober 2010
  45. 45. http://www.sxc.hu/photo/692740 zaterdag 30 oktober 2010
  46. 46. There is no silver bullet Why it can’t exist 38 zaterdag 30 oktober 2010
  47. 47. http://www.flickr.com/photos/eschipul/4160817135/ zaterdag 30 oktober 2010
  48. 48. Comparing tables 40 Table in DB 1Table in DB 1 column 1 int column 2 varchar(255) column 3 varchar(255) Table in DB 2Table in DB 2 column 1 int column 2 varchar(255) column 4 varchar(255) zaterdag 30 oktober 2010
  49. 49. Comparing tables 41 Table in DB 1Table in DB 1 id int name varchar(255) city varchar(255) Table in DB 2Table in DB 2 id int name varchar(255) website varchar(255) zaterdag 30 oktober 2010
  50. 50. Comparing tables 42 Table in DB 1Table in DB 1 id int firstname varchar(255) lname varchar(255) Table in DB 2Table in DB 2 id int firstname varchar(255) lastname varchar(255) zaterdag 30 oktober 2010
  51. 51. 43 To synchronize two database structures without unexpected dataloss, communicating all steps needed to get from A to B is inevitable. zaterdag 30 oktober 2010
  52. 52. Phing & DB Deploy 44 zaterdag 30 oktober 2010
  53. 53. Phing & DB Deploy 45Cartoon by Oliver Widder - http://geekandpoke.typepad.com/ zaterdag 30 oktober 2010
  54. 54. 46 http://phing.info/ zaterdag 30 oktober 2010
  55. 55. Phing 47 zaterdag 30 oktober 2010
  56. 56. 48 zaterdag 30 oktober 2010
  57. 57. DB Deploy 49 zaterdag 30 oktober 2010
  58. 58. Phing & DB Deploy 50 zaterdag 30 oktober 2010
  59. 59. DB Deploy 51 db/patches/1-create_user_table.sql zaterdag 30 oktober 2010
  60. 60. DB Deploy 52 changelog table: zaterdag 30 oktober 2010
  61. 61. DB Deploy 52 changelog table: zaterdag 30 oktober 2010
  62. 62. DB Deploy 53 PHP zaterdag 30 oktober 2010
  63. 63. DB Deploy 54 SQL zaterdag 30 oktober 2010
  64. 64. DB Deploy 55 Features zaterdag 30 oktober 2010
  65. 65. Liquibase The most complete solution I know 56 zaterdag 30 oktober 2010
  66. 66. Liquibase 57 www.liquibase.org zaterdag 30 oktober 2010
  67. 67. Liquibase 58 zaterdag 30 oktober 2010
  68. 68. Liquibase 59 zaterdag 30 oktober 2010
  69. 69. Liquibase 60 zaterdag 30 oktober 2010
  70. 70. Liquibase Updating Reverting Tagging Generate XML Diff 61 zaterdag 30 oktober 2010
  71. 71. http://www.sxc.hu/photo/1241520 zaterdag 30 oktober 2010
  72. 72. Liquibase Branches 63 zaterdag 30 oktober 2010
  73. 73. Liquibase DBMS Support 64 zaterdag 30 oktober 2010
  74. 74. Liquibase Documentation 65 zaterdag 30 oktober 2010
  75. 75. Liquibase Java 66 zaterdag 30 oktober 2010
  76. 76. Akrabat DB Schema Manager Zend Framework specific solution 67 zaterdag 30 oktober 2010
  77. 77. Akrabat DB Schema Manager Zend Framework Proposed by Rob Allen in 2006 Recently implemented http://github.com/akrabat/Akrabat 68 zaterdag 30 oktober 2010
  78. 78. Writing the patch 69 scripts/migrations/001-CreateUserTable.php zaterdag 30 oktober 2010
  79. 79. Writing the patch 70 scripts/migrations/001-CreateUserTable.php zaterdag 30 oktober 2010
  80. 80. Akrabat DB Schema Manager PHP Patches 71 zaterdag 30 oktober 2010
  81. 81. Akrabat DB Schema Manager Easy syntax if you know ZF 72 zaterdag 30 oktober 2010
  82. 82. Akrabat DB Schema Manager Easy to install, easy to use 73 zaterdag 30 oktober 2010
  83. 83. Akrabat DB Schema Manager Easy to install, easy to use 73 zaterdag 30 oktober 2010
  84. 84. Akrabat DB Schema Manager Branch merging 74 zaterdag 30 oktober 2010
  85. 85. Doctrine Migrations Doctrine ORM specific solution 75 zaterdag 30 oktober 2010
  86. 86. Doctrine Migrations 76 http://www.doctrine-project.org/ zaterdag 30 oktober 2010
  87. 87. Doctrine Migrations Patch 77 zaterdag 30 oktober 2010
  88. 88. Doctrine Migrations 78 Update-to-version ./doctrine migrate zaterdag 30 oktober 2010
  89. 89. YAML 79 zaterdag 30 oktober 2010
  90. 90. YAML 79 ./doctrine generate-migrations-diff zaterdag 30 oktober 2010
  91. 91. Doctrine Migrations 80 zaterdag 30 oktober 2010
  92. 92. Doctrine Migrations 81 Generate patches zaterdag 30 oktober 2010
  93. 93. Doctrine Migrations 82 Useful if you’re already using Doctrine ORM zaterdag 30 oktober 2010
  94. 94. Summary 83 zaterdag 30 oktober 2010
  95. 95. Summary Patchfiles • Automating • Branch merging • Why there is no silver bullet Phing + DB Deploy http://phing.info http://dbdeploy.com Liquibase http://www.liquibase.org 84 Akrabat DB Schema Manager http://akrabat.com http://github.com/akrabat/Akrabat Doctrine Migrations http://www.doctrine-project.org zaterdag 30 oktober 2010
  96. 96. Questions ? 85 zaterdag 30 oktober 2010
  97. 97. 86 Contact me Harrie Verveer Software Engineer at Ibuildings Blog: www.harrieverveer.com E-mail: harrie@ibuildings.nl Skype: harrie-ibuildings Twitter: @harrieverveer zaterdag 30 oktober 2010
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×