SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
KEEPING YOUR DATABASE AND PHP IN SYNC

MAGGIE NELSON
MAY 22, 2008
dev   prod
dev   prod
dev   qa   prod
dev   qa   staging   prod
dev1
 (new stuff)




   dev2             qa1         staging   prod
  (new stuff)    (new stuff)




   dev3             qa2
(maintenance)   (maintenance)
new stuff




                                 trunk




maintenance   1.0         2.0   3.0
PHP and DB are separate
=         +

    PHP




=         +

    PHP
releaseNumber.sql
release 2.0


                                  +

                     PHP




cut 2.0 release at         run release.2.0.sql
                                                 install 2.0 code
svn revision 207               in database
reverting release 2.0


                              +

                    PHP




     revert to previous
                                      ???
  version of code (prior to
                                  in database
      svn revision 207)
new stuff




     r203             r207                   r415
                                                     trunk

   1-203      204-207              208-415




maintenance     1.0          2.0                    3.0
releaseNumber.undo.sql
reverting release 2.0


                              +

                    PHP




     revert to previous
                                  run release.2.0.undo.sql
                                       ???
  version of code (prior to
                                   in database
                                         in database
      svn revision 207)
Frequent database changes during
release cycle
Frequent changes from dev -> QA




        dev             qa             staging          prod

                                                 run statements from
  update QA with     figure out last update
                                                 release.2.0.0.sql since
freshest PHP code   ran from release.2.0.sql
                                                    last DB updates
releaseNumber.sql
releaseNumber.sql
Communication between developers
dev1
 (new stuff)




   dev2             qa1         staging   prod
  (new stuff)    (new stuff)




   dev3             qa2
(maintenance)   (maintenance)
devs making DB changes




                     dev1                dev2


                                                run statements from
 update devX with    figure out last update
                                                release.2.0.0.sql since
freshest PHP code   ran from release.2.0.sql
                                                   last DB updates
dev1 writes new code



                       database   YES   dev1 sends e-mail to dev2 with
dev1 commits code
                       changes?         instructions for the DB change


                           NO
                                                    dev2         NO
 dev2: svn up to get
                                                   checks                    dev2: svn up
     new code
                                                   email?

                                                         YES
                                                  dev2 reads
                                                 instructions



                                                      dev2
   dev2 has new          YES                         follows     NO      dev2 environment is
                                                  instructions
       code                                        correctly?                  broken


                                                                             EPIC FAIL
releaseNumber.sql
DB deltas
DB deltas as XML
dev1 writes new code




     database      YES    encapsulate DB
     changes?            change in a delta



           NO

 dev1 commits code




 dev2: svn up to get     run script to check for    new      YES run script to parse and
     new code                  new deltas          deltas?           apply new deltas



                                                       NO
   dev2 has new
       code
Stored procedures
Calling stored procedures from PHP
Oracle example - pkg header
Oracle example - pkg body
friend_pkg
                 db/Friend/pkg.sql
 (header)


friend_pkg
              db/Friend/pkg_body.sql
   (body)




  models      models/FriendModel.php



  views        views/addFriend.phtml



                    controllers/
controllers
               FriendController.php
Stored procedures in deltas
Reference, don’t copy
svn cat -r[some_revision] Friend/pkg.sql >> runThis.sql
svn cat -r[some_revision] Friend/pkg_body.sql >> runThis.sql




                                [some_revision] ??
encapsulate DB changes (DDL + DML) in a delta
               (e.g. delta7.xml)



             make stored procedure changes




          reference stored procedure changes in the delta




                              make PHP changes



                          commit PHP changes, stored procedure
                             changes and the new delta7.xml
svn log -r PREV:HEAD delta7.sql

------------------------------------------------------------------------
r107 | maggie_n | 2008-02-25 15:13:50 -0500 (Mon, 25 Feb 2008) | 15 lines
svn log -r PREV:HEAD delta7.sql --xml


<?xml version=quot;1.0quot;?>
<log>
<logentry
  revision=quot;107quot;>
<author>maggie_n</author>
<date>2008-02-25T20:13:50.097229Z</date>
<msg>My awesome delta number 7.</msg></logentry>
</log>


$deltaSvnRevision = $myXml->logentry[0][‘revision’];
Automagically...
Communication between development
branches
dev1
 (new stuff)




   dev2             qa1         staging   prod
  (new stuff)    (new stuff)




   dev3             qa2
(maintenance)   (maintenance)
new stuff




                                                trunk




maintenance   1.0         2.0                  3.0

                                svn:external    deltas
svn:externals


http://svn.example.com/svn/myapp/
   trunk
   branch/
      new_stuff/
      1.0/
      2.0/
      3.0/
   deltas/
create new deltas directory parallel to trunk and
                    branches



            in trunk or branch you’re working in:
                 svn propedit svn:externals .



                       edit file that opens, add:
             deltas http://svn.example.com/myapp/deltas



                                   save and exit



                                            svn up
                                          svn commit
new stuff




                                                         trunk




maintenance   1.0              2.0                      3.0

                                         svn:external    deltas

                          deltas 1-...
central file to associate delta 2 branch/trunk

trunk:                  branches/1.0
  - delta1               - delta1
  - delta2
                        branches/2.0
branches/new_stuff       - delta1
 - delta3                - delta2
 - delta4
                        branches/3.0
                         - delta1
                         - delta2
                         - delta3
                         - delta4
new stuff




                                 trunk




maintenance   1.0         2.0   3.0
Summary




  PHP   +   DB   +   XML   +   svn   =   awesome!
Questions?
Thanks!




             more info:
          maggienelson.com

Mais conteúdo relacionado

Mais procurados

Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
Teja Bheemanapally
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchell
dpc
 
Oracle Real Application Cluster ( RAC )
Oracle Real Application Cluster ( RAC )Oracle Real Application Cluster ( RAC )
Oracle Real Application Cluster ( RAC )
varasteh65
 

Mais procurados (13)

Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
 
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
Kernel Recipes 2019 - Analyzing changes to the binary interface exposed by th...
 
Cassandra Internals Overview
Cassandra Internals OverviewCassandra Internals Overview
Cassandra Internals Overview
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchell
 
Redhat 6 & 7
Redhat 6 & 7Redhat 6 & 7
Redhat 6 & 7
 
Cloning 2
Cloning 2Cloning 2
Cloning 2
 
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.comComandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
 
Presentation
PresentationPresentation
Presentation
 
Rac questions
Rac questionsRac questions
Rac questions
 
Oracle Real Application Cluster ( RAC )
Oracle Real Application Cluster ( RAC )Oracle Real Application Cluster ( RAC )
Oracle Real Application Cluster ( RAC )
 
Genode Programming
Genode ProgrammingGenode Programming
Genode Programming
 
Fluentd meetup logging infrastructure in paa s
Fluentd meetup   logging infrastructure in paa sFluentd meetup   logging infrastructure in paa s
Fluentd meetup logging infrastructure in paa s
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 

Semelhante a Keeping Your Database and PHP in Sync

Subversion: A Getting Started Presentation
Subversion: A Getting Started PresentationSubversion: A Getting Started Presentation
Subversion: A Getting Started Presentation
Nap Ramirez
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for Java
Axel Fontaine
 

Semelhante a Keeping Your Database and PHP in Sync (20)

Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
 
Subversion
SubversionSubversion
Subversion
 
Subversion: A Getting Started Presentation
Subversion: A Getting Started PresentationSubversion: A Getting Started Presentation
Subversion: A Getting Started Presentation
 
Alm tce parallel development
Alm tce parallel developmentAlm tce parallel development
Alm tce parallel development
 
Flyway: The agile database migration framework for Java
Flyway: The agile database migration framework for JavaFlyway: The agile database migration framework for Java
Flyway: The agile database migration framework for Java
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
 
Version Control with SVN
Version Control with SVNVersion Control with SVN
Version Control with SVN
 
Kubernetes_Webinar_Slide_Deck.pdf
Kubernetes_Webinar_Slide_Deck.pdfKubernetes_Webinar_Slide_Deck.pdf
Kubernetes_Webinar_Slide_Deck.pdf
 
Handling Database Deployments
Handling Database DeploymentsHandling Database Deployments
Handling Database Deployments
 
Tauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change AutomationTauhid: SQL Server Database Change Automation
Tauhid: SQL Server Database Change Automation
 
Nodejs Session01
Nodejs Session01Nodejs Session01
Nodejs Session01
 
Os Harkins
Os HarkinsOs Harkins
Os Harkins
 
DockerCon SF 2015: Docker in the New York Times Newsroom
DockerCon SF 2015: Docker in the New York Times NewsroomDockerCon SF 2015: Docker in the New York Times Newsroom
DockerCon SF 2015: Docker in the New York Times Newsroom
 
SVN Tool Information : Best Practices
SVN Tool Information  : Best PracticesSVN Tool Information  : Best Practices
SVN Tool Information : Best Practices
 
Getting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydbGetting started with agile database migrations for java flywaydb
Getting started with agile database migrations for java flywaydb
 
SVN Information
SVN Information  SVN Information
SVN Information
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
 
Architecting the Future: Abstractions and Metadata - KCDC
Architecting the Future: Abstractions and Metadata - KCDCArchitecting the Future: Abstractions and Metadata - KCDC
Architecting the Future: Abstractions and Metadata - KCDC
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Keeping Your Database and PHP in Sync

  • 1. KEEPING YOUR DATABASE AND PHP IN SYNC MAGGIE NELSON MAY 22, 2008
  • 2. dev prod
  • 3. dev prod
  • 4. dev qa prod
  • 5. dev qa staging prod
  • 6. dev1 (new stuff) dev2 qa1 staging prod (new stuff) (new stuff) dev3 qa2 (maintenance) (maintenance)
  • 7. new stuff trunk maintenance 1.0 2.0 3.0
  • 8. PHP and DB are separate
  • 9. = + PHP = + PHP
  • 11. release 2.0 + PHP cut 2.0 release at run release.2.0.sql install 2.0 code svn revision 207 in database
  • 12. reverting release 2.0 + PHP revert to previous ??? version of code (prior to in database svn revision 207)
  • 13. new stuff r203 r207 r415 trunk 1-203 204-207 208-415 maintenance 1.0 2.0 3.0
  • 15. reverting release 2.0 + PHP revert to previous run release.2.0.undo.sql ??? version of code (prior to in database in database svn revision 207)
  • 16. Frequent database changes during release cycle
  • 17. Frequent changes from dev -> QA dev qa staging prod run statements from update QA with figure out last update release.2.0.0.sql since freshest PHP code ran from release.2.0.sql last DB updates
  • 21. dev1 (new stuff) dev2 qa1 staging prod (new stuff) (new stuff) dev3 qa2 (maintenance) (maintenance)
  • 22. devs making DB changes dev1 dev2 run statements from update devX with figure out last update release.2.0.0.sql since freshest PHP code ran from release.2.0.sql last DB updates
  • 23. dev1 writes new code database YES dev1 sends e-mail to dev2 with dev1 commits code changes? instructions for the DB change NO dev2 NO dev2: svn up to get checks dev2: svn up new code email? YES dev2 reads instructions dev2 dev2 has new YES follows NO dev2 environment is instructions code correctly? broken EPIC FAIL
  • 27. dev1 writes new code database YES encapsulate DB changes? change in a delta NO dev1 commits code dev2: svn up to get run script to check for new YES run script to parse and new code new deltas deltas? apply new deltas NO dev2 has new code
  • 30. Oracle example - pkg header
  • 31. Oracle example - pkg body
  • 32. friend_pkg db/Friend/pkg.sql (header) friend_pkg db/Friend/pkg_body.sql (body) models models/FriendModel.php views views/addFriend.phtml controllers/ controllers FriendController.php
  • 35. svn cat -r[some_revision] Friend/pkg.sql >> runThis.sql svn cat -r[some_revision] Friend/pkg_body.sql >> runThis.sql [some_revision] ??
  • 36. encapsulate DB changes (DDL + DML) in a delta (e.g. delta7.xml) make stored procedure changes reference stored procedure changes in the delta make PHP changes commit PHP changes, stored procedure changes and the new delta7.xml
  • 37. svn log -r PREV:HEAD delta7.sql ------------------------------------------------------------------------ r107 | maggie_n | 2008-02-25 15:13:50 -0500 (Mon, 25 Feb 2008) | 15 lines
  • 38. svn log -r PREV:HEAD delta7.sql --xml <?xml version=quot;1.0quot;?> <log> <logentry revision=quot;107quot;> <author>maggie_n</author> <date>2008-02-25T20:13:50.097229Z</date> <msg>My awesome delta number 7.</msg></logentry> </log> $deltaSvnRevision = $myXml->logentry[0][‘revision’];
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 46. dev1 (new stuff) dev2 qa1 staging prod (new stuff) (new stuff) dev3 qa2 (maintenance) (maintenance)
  • 47. new stuff trunk maintenance 1.0 2.0 3.0 svn:external deltas
  • 48. svn:externals http://svn.example.com/svn/myapp/ trunk branch/ new_stuff/ 1.0/ 2.0/ 3.0/ deltas/
  • 49. create new deltas directory parallel to trunk and branches in trunk or branch you’re working in: svn propedit svn:externals . edit file that opens, add: deltas http://svn.example.com/myapp/deltas save and exit svn up svn commit
  • 50. new stuff trunk maintenance 1.0 2.0 3.0 svn:external deltas deltas 1-...
  • 51. central file to associate delta 2 branch/trunk trunk: branches/1.0 - delta1 - delta1 - delta2 branches/2.0 branches/new_stuff - delta1 - delta3 - delta2 - delta4 branches/3.0 - delta1 - delta2 - delta3 - delta4
  • 52. new stuff trunk maintenance 1.0 2.0 3.0
  • 53. Summary PHP + DB + XML + svn = awesome!
  • 55. Thanks! more info: maggienelson.com