• Save
Database version control - pf congres version
Upcoming SlideShare
Loading in...5
×
 

Database version control - pf congres version

on

  • 2,015 views

Slides as used for my database version control talk at PF Congres. I removed the photo's because I wasn't exactly sure if the licenses the photo's were published under allowed me to redistribute them ...

Slides as used for my database version control talk at PF Congres. I removed the photo's because I wasn't exactly sure if the licenses the photo's were published under allowed me to redistribute them in this slide show. I left the references to the original images in.

Statistics

Views

Total Views
2,015
Views on SlideShare
1,999
Embed Views
16

Actions

Likes
2
Downloads
0
Comments
0

2 Embeds 16

http://www.slideshare.net 14
http://www.docshut.com 2

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Database version control - pf congres version Database version control - pf congres version Presentation Transcript

  • Database Version Control Without Pain Harrie Verveer PFCongres - April 17th 2010
  • Database Version Control What’s the problem? 2
  • Here used to be an image of an airplane that I removed because of the license the image was published under http://www.sxc.hu/photo/754535
  • Here used to be an image of an airplane that I removed because of the license the image was published under http://www.sxc.hu/photo/1207911
  • http://en.wikipedia.org/wiki/File:STS120LaunchHiRes.jpg Here used to be an image of the space shuttle that I removed because of the license the image was published under
  • http://www.sxc.hu/photo/1255121 Here used to be an image of a bike that I removed because of the license the image was published under
  • Why Database Version Control 7
  • Why Database Version Control Database Version Control is left behind 8
  • Simple Patching Strategy The basic idea 9
  • Simple patching strategy Patch files 10
  • Simple patching strategy 11
  • Simple patching strategy Mostly structural changes 12
  • Simple patching strategy Chronological filenames 13
  • Simple patching strategy Remember last executed patch 14
  • Simple patching strategy Development Write code Write DB patches Apply patches to own DB Apply patches Commit Update 15
  • Example patch file patch-001.sql 16
  • Fixing patches patch-002.sql 17
  • Fixing patches patch-002.sql 17
  • Fixing patches patch-002.sql 17
  • Fixing patches patch-003.sql 18
  • Fixing patches patch-003.sql Never modify a patch file once it’s under version control 18
  • Undo patch files patch-001.sql 19
  • Undo patch files undo-001.sql 20
  • Here used to be an image of a one-way sign that I removed because of the license the image was published under http://www.freefoto.com/preview/41-07-7
  • Process Copy production to test environment Apply patches Run tests Backup live database Update production 22
  • Bonus points Install.sql 23
  • Bonus points Initial dummy content 24
  • Here used to be an image of a guy in a rowing boat that I removed because of the license the image was published under http://www.sxc.hu/photo/643214
  • Here used to be an image of a sunken boat that I removed because of the license the image was published under http://www.sxc.hu/photo/946855
  • Automating the process Faster & Safer 27
  • Typical patch script Run the patches 28
  • Typical patch script Keep track of last executed patch 29
  • Typical patch script 30
  • Typical patch script 31
  • Typical patch script 32
  • Typical patch script update.sh 33
  • Branches Merge problems 34
  • Branches Trunk patch-001.sql patch-002.sql patch-003.sql 35
  • 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 36
  • 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 37
  • 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 37
  • 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 38
  • Separate sequence db/patches/trunk/ db/patches/branchA/ patch-001.sql patch-001.sql patch-002.sql patch-002.sql patch-003.sql 39
  • 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 39
  • Patchfile naming Filenames based on time 40
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100323_0839.sql patch_20100327_1025.sql 41
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100323_0839.sql patch_20100327_1025.sql Last executed: patch_20100327_1025 41
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100322_2253.sql patch_20100323_0839.sql patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql Last executed: patch_20100327_1025 41
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100322_2253.sql patch_20100323_0839.sql patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql Last executed: patch_20100327_1025 41
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100322_2253.sql patch_20100323_0839.sql patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql patch_20100322_2158.sql patch_20100322_2253.sql Last executed: patch_20100323_0839.sql patch_20100327_1025 patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql 41
  • Patch log At this point our patch number tracking doesn’t work anymore!!! patch_20100322_2158.sql patch_20100322_2253.sql patch_20100323_0839.sql patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql patch_20100322_2158.sql patch_20100322_2253.sql Last executed: patch_20100323_0839.sql patch_20100327_1025 patch_20100325_1528.sql patch_20100327_1025.sql patch_20100328_1230.sql 41
  • Patch log 42
  • Branches False sense of security 43
  • Phing Avoiding the NIH syndrome 44
  • http://phing.info/ 45
  • Phing 46
  • 47
  • DB Deploy 48
  • DB Deploy 49
  • DB Deploy 49
  • DB Deploy changelog table: 50
  • DB Deploy changelog table: 50
  • Akrabat DB Schema Manager Zend Framework specific solution 51
  • 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 52
  • Writing the patch scripts/migrations/001-CreateUserTable.php 53
  • Writing the patch scripts/migrations/001-CreateUserTable.php 54
  • Running the patch 55
  • Running the patch 55
  • Running the patch 56
  • Running the patch 57
  • Akrabat DB Schema Manager Easy to use if you know ZF PHP instead of SQL-only Easy to ‘undo’ patches Branch merging problem Run from your deploy script 58
  • Multiple servers ssh harrie@webserver188 59
  • http://www.capify.org/ 60
  • Capistrano cd /dir/where/my/app/is svn update php updatedb.php 61
  • Capistrano cd /dir/where/my/app/is svn update php updatedb.php 62
  • Capistrano & the database 63
  • Capistrano Automate deployment No coding needed Extending possible Useful tool for PHP developers Replace railsy voodoo with PHPish 1337ness 64
  • Summary 65
  • Summary Patchfiles • Automating • Branch merging Phing + DB Deploy http://phing.info http://dbdeploy.com Akrabat DB Schema Manager http://akrabat.com http://github.com/akrabat/Akrabat Capistrano http://capify.org 66
  • Questions ? 67
  • Contact me Harrie Verveer Software Engineer at Ibuildings E-mail: harrie@ibuildings.nl Skype: harrie-ibuildings Twitter: @harrieverveer http://joind.in/1499 68
  • Dutch PHP Conference june 10 - 12 RAI Amsterdam http://phpconference.nl 69