Database version control DPC version

  • 4,430 views
Uploaded on

Slides as used on the Dutch PHP Conference 2010

Slides as used on the Dutch PHP Conference 2010

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,430
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
94
Comments
0
Likes
8

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

































































  • ORM = Object Relations Mapper








Transcript

  • 1. Database Version Control Without Pain Harrie Verveer June 11th 2010
  • 2. Database Version Control What’s the problem? 2
  • 3. http://www.sxc.hu/photo/754535
  • 4. http://www.sxc.hu/photo/1207911
  • 5. http://en.wikipedia.org/wiki/File:STS120LaunchHiRes.jpg
  • 6. http://www.sxc.hu/photo/1255121
  • 7. Why Database Version Control 7
  • 8. Simple Patching Strategy The basic idea 8
  • 9. Simple patching strategy 9
  • 10. Example patch file patch-001.sql 10
  • 11. http://www.sxc.hu/photo/1214820
  • 12. Simple patching strategy Development Write code Write DB patches Apply patches to own DB Apply patches Commit Update 12
  • 13. Fixing patches patch-002.sql 13
  • 14. Fixing patches patch-002.sql 13
  • 15. Fixing patches patch-002.sql 13
  • 16. Fixing patches patch-003.sql 14
  • 17. Fixing patches patch-003.sql Never modify a patch file once it’s under version control 14
  • 18. Undo patch files undo-001.sql 15
  • 19. http://www.freefoto.com/preview/41-07-7
  • 20. Bonus points Install.sql 17
  • 21. Bonus points Initial dummy content 18
  • 22. http://www.sxc.hu/photo/643214
  • 23. http://www.sxc.hu/photo/946855
  • 24. Automating the process Faster & Safer 21
  • 25. http://www.sxc.hu/photo/314594
  • 26. Typical patch script 23
  • 27. Typical patch script update.sh 24
  • 28. http://www.sxc.hu/photo/1196126
  • 29. Branches Merge problems 26
  • 30. Branches Trunk patch-001.sql patch-002.sql patch-003.sql 27
  • 31. 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
  • 32. 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
  • 33. 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
  • 34. Separate sequence db/patches/trunk/ db/patches/branchA/ patch-001.sql patch-001.sql patch-002.sql patch-002.sql patch-003.sql 30
  • 35. 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
  • 36. Patchfile naming patch_20100611_1430.sql 31
  • 37. Patch log 32
  • 38. http://www.sxc.hu/photo/692740
  • 39. Phing & DB Deploy Avoiding the NIH syndrome 34
  • 40. http://phing.info/ 35
  • 41. Phing 36
  • 42. 37
  • 43. DB Deploy 38
  • 44. DB Deploy db/patches/1-create_user_table.sql 39
  • 45. Phing & DB Deploy 40
  • 46. DB Deploy changelog table: 41
  • 47. DB Deploy changelog table: 41
  • 48. DB Deploy PHP 42
  • 49. DB Deploy SQL 43
  • 50. DB Deploy Features 44
  • 51. Liquibase A different approach 45
  • 52. Liquibase www.liquibase.org 46
  • 53. Liquibase 47
  • 54. Liquibase 48
  • 55. Liquibase 49
  • 56. Liquibase Updating Reverting Tagging Generate XML Diff 50
  • 57. http://www.sxc.hu/photo/1241520
  • 58. Liquibase Branches 52
  • 59. Liquibase DBMS Support 53
  • 60. Liquibase Documentation 54
  • 61. Liquibase Java 55
  • 62. Akrabat DB Schema Manager Zend Framework specific solution 56
  • 63. 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
  • 64. Writing the patch scripts/migrations/001-CreateUserTable.php 58
  • 65. Writing the patch scripts/migrations/001-CreateUserTable.php 59
  • 66. Akrabat DB Schema Manager PHP Patches 60
  • 67. Akrabat DB Schema Manager Easy syntax if you know ZF 61
  • 68. Akrabat DB Schema Manager Easy to use 62
  • 69. Akrabat DB Schema Manager Branch merging 63
  • 70. Doctrine Migrations 64
  • 71. Doctrine Migrations http://www.doctrine-project.org/ 65
  • 72. Doctrine Migrations 66
  • 73. Doctrine Migrations Update-to-version 67
  • 74. Doctrine Migrations Generate patches 68
  • 75. Doctrine Migrations Useful if you’re already using Doctrine ORM 69
  • 76. Summary 70
  • 77. 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
  • 78. Questions ? 72
  • 79. Contact me Harrie Verveer Software Engineer at Ibuildings E-mail: harrie@ibuildings.nl Skype: harrie-ibuildings Twitter: @harrieverveer http://joind.in/1544 73