SlideShare uma empresa Scribd logo
1 de 95
Using Doctrine Migrations

                            by Dennis Benkert
Dennis Who?!




               2
Dennis Who?!




               2
Dennis Who?!




               2
Dennis Who?!




               2
Dennis Who?!




               2
Agenda




         3
Agenda


         Migrating by Hand




                             3
Agenda


         Migrating by Hand
         Doctrine Migrations




                               3
Agenda


          Migrating by Hand
         Doctrine Migrations
         Migrations and sf CLI




                                 3
Agenda


           Migrating by Hand
          Doctrine Migrations
         Migrations and sf CLI
         Things to keep in mind


                                  3
So, you want to change your live
   servers DB schema, right?!



                                   4
But migrating your database by hand is hard work
                                                   5
Migrating by Hand


                    6
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
Migrating by Hand


schema.yml




                    Live DB



  Dev DB
                              7
What‘s so bad about it?




                          8
What‘s so bad about it?


            Error Prone




                          8
What‘s so bad about it?


            Error Prone
            No Rollback




                          8
What‘s so bad about it?


            Error Prone
           No Rollback
          Not Comfortable



                            8
Wouldn‘t it be cool if database changes were a bit
                               like SCM revisions?




                                                     9
Doctrine Migrations


                      10
Migration Process




schema.yml

                    Migration File
                                     11
Migration Process




schema.yml

                    Migration File
                                     11
Migration Process




schema.yml

                    Migration File
                                     11
Migration Process




             Compare



schema.yml

                       Migration File
                                        11
Migration Process




             Compare



schema.yml

                       Migration File
                                        11
Migration Process




             Compare

                   Generate
schema.yml

                              Migration File
                                               11
Migration Process




             Compare

                   Generate
schema.yml

                              Migration File
                                               11
Migration Process




             Compare

                   Generate
schema.yml

                              Migration File
                                               11
Migration Process



                          Migrate

             Compare

                   Generate
schema.yml

                              Migration File
                                               11
Migration Files


 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

     public function down()
     {
         $this->removeColumn('blog_post', 'tags');
     }
 }




                                                                         12
Migration Files


 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

     public function down()
     {
         $this->removeColumn('blog_post', 'tags');
     }
 }




                                                                         12
Migration Files
     Used for upgrading

 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

      public function down()
      {
          $this->removeColumn('blog_post', 'tags');
      }
 }




                                                                         12
Migration Files
     Used for upgrading

 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

      public function down()
      {
          $this->removeColumn('blog_post', 'tags');
      }
 }




                                                                         12
Migration Files
     Used for upgrading

 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

      public function down()
      {
          $this->removeColumn('blog_post', 'tags');
      }
 }



                                Used for downgrading
                                                                         12
Migration Files
     Used for upgrading

 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

      public function down()
      {
          $this->removeColumn('blog_post', 'tags');
      }
 }



                                Used for downgrading
                                                                         12
Migration Files
     Used for upgrading
                                         Table / Data Manipulation
 class VersionXX extends Doctrine_Migration_Base
 {
     public function up()
     {
         $this->addColumn('blog_post', 'tags', 'string', '255', array(
              ));
     }

      public function down()
      {
          $this->removeColumn('blog_post', 'tags');
      }
 }



                                Used for downgrading
                                                                         12
How Migrations work

          migration_version

             version (int)




                              13
How Migrations work

          migration_version

             version (int)




                              13
How Migrations work

          migration_version

             version (int)




              Current version stored
                in your database

                                       13
How Migrations work


    4


   3


       2

           1          14
How Migrations work


    4


   3


       2

           1          14
How Migrations work


    4          getVersion



   3


       2

           1                14
How Migrations work


    4          getVersion



   3


       2

           1                14
How Migrations work


    4          getVersion

                  Version =1

   3


       2

           1                   14
How Migrations work


    4          getVersion

                  Version =1

   3


       2

           1                   14
How Migrations work


    4             getVersion

                     Version =1

   3
           up()

       2

             1                    14
How Migrations work


    4             getVersion

                     Version =1

   3
           up()

       2

             1                    14
How Migrations work


    4             getVersion

           up()      Version =1

   3
           up()

       2

             1                    14
How Migrations work


    4             getVersion

           up()      Version =1

   3
           up()

       2

             1                    14
How Migrations work

             up()   getVersion
    4

           up()        Version =1

   3
           up()

       2

             1                      14
How Migrations work

             up()   getVersion
    4

           up()        Version =1

   3
           up()

       2

             1                      14
How Migrations work

             up()   getVersion
    4

           up()        Version =1

   3                   setVersion(4)
           up()

       2

             1                         14
Migrations and sf CLI


                        15
Migrations and sf CLI

        symfony   doctrine:generate-migrations-models
        symfony   doctrine:generate-migrations-db
        symfony   doctrine:generate-migrations-diff
        symfony   doctrine:migrate




                                                        16
Migrations and sf CLI

        symfony   doctrine:generate-migrations-models
        symfony   doctrine:generate-migrations-db
        symfony   doctrine:generate-migrations-diff
        symfony   doctrine:migrate




         Available in other tasks, too




                                                        16
Migrations and sf CLI

        symfony   doctrine:generate-migrations-models
        symfony   doctrine:generate-migrations-db
        symfony   doctrine:generate-migrations-diff
        symfony   doctrine:migrate




         Available in other tasks, too
          Even works with plugins




                                                        16
Migrations and sf CLI

        symfony   doctrine:generate-migrations-models
        symfony   doctrine:generate-migrations-db
        symfony   doctrine:generate-migrations-diff
        symfony   doctrine:migrate




         Available in other tasks, too
          Even works with plugins
            (only in sf, sorry Matthew :P)




                                                        16
Migrations and sf CLI


        symfony doctrine:generate-migrations-models




                                                      17
Migrations and sf CLI


        symfony doctrine:generate-migrations-models




     Compares Model files and schema.yml




                                                      17
Migrations and sf CLI


        symfony doctrine:generate-migrations-models




     Compares Model files and schema.yml
     Good when starting without schema




                                                      17
Migrations and sf CLI


        symfony doctrine:generate-migrations-db




                                                  18
Migrations and sf CLI


          symfony doctrine:generate-migrations-db




      Compares DB tables and schema.yml




                                                    18
Migrations and sf CLI


          symfony doctrine:generate-migrations-db




      Compares DB tables and schema.yml
       Good when starting with schema




                                                    18
Creating a Migration Diff


                        Before
 BlogPost:
   # [...]
   columns:
     title:    { type: string(255), notnull: true }
     # [...]




                                                      19
Creating a Migration Diff


                         After
 BlogPost:
   # [...]
   columns:
     title:    { type: string(255), notnull: true }
     # [...]
     tags:     { type: string(255) }




                                                      20
Migrations and sf CLI


        symfony doctrine:generate-migrations-diff




                                                    21
Migrations and sf CLI


           symfony doctrine:generate-migrations-diff




   Compares changed schema.yml and Model files




                                                       21
Migrations and sf CLI


           symfony doctrine:generate-migrations-diff




   Compares changed schema.yml and Model files
      Good when already using Migrations




                                                       21
Migrating using sf CLI

           symfony   doctrine:migrate
           symfony   doctrine:build-model
           symfony   doctrine:build-filters
           symfony   doctrine:build-forms




                                              22
Migrating using sf CLI

           symfony   doctrine:migrate
           symfony   doctrine:build-model
           symfony   doctrine:build-filters
           symfony   doctrine:build-forms




          That‘s the obvious way




                                              22
Migrating using sf CLI


          symfony doctrine:migrate
          symfony doctrine:build --all-classes




                                                 23
Migrating using sf CLI


          symfony doctrine:migrate
          symfony doctrine:build --all-classes




             That‘s the nice way




                                                 23
Migrating using sf CLI


       symfony doctrine:build --all-classes --and-migrate




                                                            24
Migrating using sf CLI


       symfony doctrine:build --all-classes --and-migrate




             That‘s the cool sf 1.3 way




                                                            24
Things to keep in mind


                         25
Big vs. small Migrations



          aka. „Complete Migrations“
   vs. „Wild West Cowboy Style Migrations“




                                             26
Big vs. small Migrations




                           27
Big vs. small Migrations


         Small Migrations more Agile




                                       27
Big vs. small Migrations


         Small Migrations more Agile
          Really need to be Agile?!




                                       27
Big vs. small Migrations


         Small Migrations more Agile
          Really need to be Agile?!
         Small Migrations more dirty




                                       27
Big vs. small Migrations


         Small Migrations more Agile
           Really need to be Agile?!
         Small Migrations more dirty
       Big Migrations more complicated




                                         27
Keep in mind


     Run a diff before building the model




                                            28
Keep in mind


      Run a diff before building the model



    After migrating you can‘t generate the diff!




                                                   28
Keep in mind


       Keep Data Migrations simple




                                     29
Keep in mind


         Keep Data Migrations simple



      Migrate the Data as easy as possible!




                                              29
Keep in mind


  Version get‘s updated after all Migrations are run




                                                       30
Keep in mind


  Version get‘s updated after all Migrations are run



    You have to fix problems by hand if they fail.




                                                       30
Thank you!


             31
Credits
         Thanks to:
         - Ryan Weaver for his presentation about Doctrine
         ...Migrations
         - Samim for the designs and the artworks.


Picture „Von A nach B“ - photocase.com © Anna-Lena Thamm : cydonna

Creative Commons stuff used:
- „Application, Mime, Vnd.sun.xml.draw“ icon by „New Mooon“ - http://www.iconfinder.net/
icondetails/28957/128/
- „Application, Sqlite2, X“ icon by „New Mooon“ - http://www.iconfinder.net/icondetails/
28899/128/
- „Application, Php, X “ icon by „New Mooon“ - http://www.iconfinder.net/icondetails/28894/128/



                                                                                          32

Mais conteúdo relacionado

Semelhante a symfony Live 2010 - Using Doctrine Migrations

Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)Axel Fontaine
 
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 JavaAxel Fontaine
 
Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)Patrick Crowley
 
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 ...Alan Pinstein
 
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...Philip Stehlik
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best PracticesBurt Beckwith
 
Using Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize DatabasesUsing Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize DatabasesBryce Embry
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...HostedbyConfluent
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfKarsten Dambekalns
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallssam2sung2
 
Come Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayCome Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayJoris Kuipers
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011Mats Kindahl
 
Immutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkitImmutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkit어형 이
 
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architectureOpenStack Korea Community
 

Semelhante a symfony Live 2010 - Using Doctrine Migrations (20)

Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
 
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
 
Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)
 
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 ...
 
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
 
Using Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize DatabasesUsing Doctrine Migrations to Synchronize Databases
Using Doctrine Migrations to Synchronize Databases
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
 
Containers 101
Containers 101Containers 101
Containers 101
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using Surf
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
Offline Html5 3days
Offline Html5 3daysOffline Html5 3days
Offline Html5 3days
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Upgrading 11i E-business Suite to R12 E-business Suite
Upgrading 11i E-business Suite to R12 E-business SuiteUpgrading 11i E-business Suite to R12 E-business Suite
Upgrading 11i E-business Suite to R12 E-business Suite
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
Come Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with FlywayCome Fly With Me: Database Migration Patterns with Flyway
Come Fly With Me: Database Migration Patterns with Flyway
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011
 
Immutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkitImmutable kubernetes architecture by linuxkit
Immutable kubernetes architecture by linuxkit
 
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
[OpenInfra Days Korea 2018] Day 2 - E4 - 딥다이브: immutable Kubernetes architecture
 
Migrate in Drupal 8
Migrate in Drupal 8Migrate in Drupal 8
Migrate in Drupal 8
 

Mais de D

Monitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandMonitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandD
 
Introduction to Docker & CoreOS - Symfony User Group Cologne
Introduction to Docker & CoreOS - Symfony User Group CologneIntroduction to Docker & CoreOS - Symfony User Group Cologne
Introduction to Docker & CoreOS - Symfony User Group CologneD
 
The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013D
 
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013D
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...D
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…D
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...D
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012D
 
Cologne Web Performance Optimization Group Web - Varnish
Cologne Web Performance Optimization Group Web - VarnishCologne Web Performance Optimization Group Web - Varnish
Cologne Web Performance Optimization Group Web - VarnishD
 
symfony live 2010 - Using symfony events to create clean class interfaces
symfony live 2010 - Using symfony events to create clean class interfacessymfony live 2010 - Using symfony events to create clean class interfaces
symfony live 2010 - Using symfony events to create clean class interfacesD
 
symfony and immobilienscout24.de - Dennis Benkert
symfony and immobilienscout24.de - Dennis Benkertsymfony and immobilienscout24.de - Dennis Benkert
symfony and immobilienscout24.de - Dennis BenkertD
 
symfony and immobilienscout24.de - Rob Bors
symfony and immobilienscout24.de - Rob Borssymfony and immobilienscout24.de - Rob Bors
symfony and immobilienscout24.de - Rob BorsD
 
Railslove Lightningtalk 20 02 09 - Web Debug Toolbars
Railslove Lightningtalk 20 02 09 - Web Debug ToolbarsRailslove Lightningtalk 20 02 09 - Web Debug Toolbars
Railslove Lightningtalk 20 02 09 - Web Debug ToolbarsD
 

Mais de D (13)

Monitoring und Metriken im Wunderland
Monitoring und Metriken im WunderlandMonitoring und Metriken im Wunderland
Monitoring und Metriken im Wunderland
 
Introduction to Docker & CoreOS - Symfony User Group Cologne
Introduction to Docker & CoreOS - Symfony User Group CologneIntroduction to Docker & CoreOS - Symfony User Group Cologne
Introduction to Docker & CoreOS - Symfony User Group Cologne
 
The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013The Dog Ate My Deployment - PHP Uncoference September 2013
The Dog Ate My Deployment - PHP Uncoference September 2013
 
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...Dennis Benkert -  The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012What mom never told you about bundle configurations - Symfony Live Paris 2012
What mom never told you about bundle configurations - Symfony Live Paris 2012
 
Cologne Web Performance Optimization Group Web - Varnish
Cologne Web Performance Optimization Group Web - VarnishCologne Web Performance Optimization Group Web - Varnish
Cologne Web Performance Optimization Group Web - Varnish
 
symfony live 2010 - Using symfony events to create clean class interfaces
symfony live 2010 - Using symfony events to create clean class interfacessymfony live 2010 - Using symfony events to create clean class interfaces
symfony live 2010 - Using symfony events to create clean class interfaces
 
symfony and immobilienscout24.de - Dennis Benkert
symfony and immobilienscout24.de - Dennis Benkertsymfony and immobilienscout24.de - Dennis Benkert
symfony and immobilienscout24.de - Dennis Benkert
 
symfony and immobilienscout24.de - Rob Bors
symfony and immobilienscout24.de - Rob Borssymfony and immobilienscout24.de - Rob Bors
symfony and immobilienscout24.de - Rob Bors
 
Railslove Lightningtalk 20 02 09 - Web Debug Toolbars
Railslove Lightningtalk 20 02 09 - Web Debug ToolbarsRailslove Lightningtalk 20 02 09 - Web Debug Toolbars
Railslove Lightningtalk 20 02 09 - Web Debug Toolbars
 

Último

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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 Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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?Igalia
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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?
 

symfony Live 2010 - Using Doctrine Migrations

  • 1. Using Doctrine Migrations by Dennis Benkert
  • 7. Agenda 3
  • 8. Agenda Migrating by Hand 3
  • 9. Agenda Migrating by Hand Doctrine Migrations 3
  • 10. Agenda Migrating by Hand Doctrine Migrations Migrations and sf CLI 3
  • 11. Agenda Migrating by Hand Doctrine Migrations Migrations and sf CLI Things to keep in mind 3
  • 12. So, you want to change your live servers DB schema, right?! 4
  • 13. But migrating your database by hand is hard work 5
  • 15. Migrating by Hand schema.yml Live DB Dev DB 7
  • 16. Migrating by Hand schema.yml Live DB Dev DB 7
  • 17. Migrating by Hand schema.yml Live DB Dev DB 7
  • 18. Migrating by Hand schema.yml Live DB Dev DB 7
  • 19. Migrating by Hand schema.yml Live DB Dev DB 7
  • 20. Migrating by Hand schema.yml Live DB Dev DB 7
  • 21. What‘s so bad about it? 8
  • 22. What‘s so bad about it? Error Prone 8
  • 23. What‘s so bad about it? Error Prone No Rollback 8
  • 24. What‘s so bad about it? Error Prone No Rollback Not Comfortable 8
  • 25. Wouldn‘t it be cool if database changes were a bit like SCM revisions? 9
  • 27. Migration Process schema.yml Migration File 11
  • 28. Migration Process schema.yml Migration File 11
  • 29. Migration Process schema.yml Migration File 11
  • 30. Migration Process Compare schema.yml Migration File 11
  • 31. Migration Process Compare schema.yml Migration File 11
  • 32. Migration Process Compare Generate schema.yml Migration File 11
  • 33. Migration Process Compare Generate schema.yml Migration File 11
  • 34. Migration Process Compare Generate schema.yml Migration File 11
  • 35. Migration Process Migrate Compare Generate schema.yml Migration File 11
  • 36. Migration Files class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } 12
  • 37. Migration Files class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } 12
  • 38. Migration Files Used for upgrading class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } 12
  • 39. Migration Files Used for upgrading class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } 12
  • 40. Migration Files Used for upgrading class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } Used for downgrading 12
  • 41. Migration Files Used for upgrading class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } Used for downgrading 12
  • 42. Migration Files Used for upgrading Table / Data Manipulation class VersionXX extends Doctrine_Migration_Base { public function up() { $this->addColumn('blog_post', 'tags', 'string', '255', array( )); } public function down() { $this->removeColumn('blog_post', 'tags'); } } Used for downgrading 12
  • 43. How Migrations work migration_version version (int) 13
  • 44. How Migrations work migration_version version (int) 13
  • 45. How Migrations work migration_version version (int) Current version stored in your database 13
  • 46. How Migrations work 4 3 2 1 14
  • 47. How Migrations work 4 3 2 1 14
  • 48. How Migrations work 4 getVersion 3 2 1 14
  • 49. How Migrations work 4 getVersion 3 2 1 14
  • 50. How Migrations work 4 getVersion Version =1 3 2 1 14
  • 51. How Migrations work 4 getVersion Version =1 3 2 1 14
  • 52. How Migrations work 4 getVersion Version =1 3 up() 2 1 14
  • 53. How Migrations work 4 getVersion Version =1 3 up() 2 1 14
  • 54. How Migrations work 4 getVersion up() Version =1 3 up() 2 1 14
  • 55. How Migrations work 4 getVersion up() Version =1 3 up() 2 1 14
  • 56. How Migrations work up() getVersion 4 up() Version =1 3 up() 2 1 14
  • 57. How Migrations work up() getVersion 4 up() Version =1 3 up() 2 1 14
  • 58. How Migrations work up() getVersion 4 up() Version =1 3 setVersion(4) up() 2 1 14
  • 60. Migrations and sf CLI symfony doctrine:generate-migrations-models symfony doctrine:generate-migrations-db symfony doctrine:generate-migrations-diff symfony doctrine:migrate 16
  • 61. Migrations and sf CLI symfony doctrine:generate-migrations-models symfony doctrine:generate-migrations-db symfony doctrine:generate-migrations-diff symfony doctrine:migrate Available in other tasks, too 16
  • 62. Migrations and sf CLI symfony doctrine:generate-migrations-models symfony doctrine:generate-migrations-db symfony doctrine:generate-migrations-diff symfony doctrine:migrate Available in other tasks, too Even works with plugins 16
  • 63. Migrations and sf CLI symfony doctrine:generate-migrations-models symfony doctrine:generate-migrations-db symfony doctrine:generate-migrations-diff symfony doctrine:migrate Available in other tasks, too Even works with plugins (only in sf, sorry Matthew :P) 16
  • 64. Migrations and sf CLI symfony doctrine:generate-migrations-models 17
  • 65. Migrations and sf CLI symfony doctrine:generate-migrations-models Compares Model files and schema.yml 17
  • 66. Migrations and sf CLI symfony doctrine:generate-migrations-models Compares Model files and schema.yml Good when starting without schema 17
  • 67. Migrations and sf CLI symfony doctrine:generate-migrations-db 18
  • 68. Migrations and sf CLI symfony doctrine:generate-migrations-db Compares DB tables and schema.yml 18
  • 69. Migrations and sf CLI symfony doctrine:generate-migrations-db Compares DB tables and schema.yml Good when starting with schema 18
  • 70. Creating a Migration Diff Before BlogPost: # [...] columns: title: { type: string(255), notnull: true } # [...] 19
  • 71. Creating a Migration Diff After BlogPost: # [...] columns: title: { type: string(255), notnull: true } # [...] tags: { type: string(255) } 20
  • 72. Migrations and sf CLI symfony doctrine:generate-migrations-diff 21
  • 73. Migrations and sf CLI symfony doctrine:generate-migrations-diff Compares changed schema.yml and Model files 21
  • 74. Migrations and sf CLI symfony doctrine:generate-migrations-diff Compares changed schema.yml and Model files Good when already using Migrations 21
  • 75. Migrating using sf CLI symfony doctrine:migrate symfony doctrine:build-model symfony doctrine:build-filters symfony doctrine:build-forms 22
  • 76. Migrating using sf CLI symfony doctrine:migrate symfony doctrine:build-model symfony doctrine:build-filters symfony doctrine:build-forms That‘s the obvious way 22
  • 77. Migrating using sf CLI symfony doctrine:migrate symfony doctrine:build --all-classes 23
  • 78. Migrating using sf CLI symfony doctrine:migrate symfony doctrine:build --all-classes That‘s the nice way 23
  • 79. Migrating using sf CLI symfony doctrine:build --all-classes --and-migrate 24
  • 80. Migrating using sf CLI symfony doctrine:build --all-classes --and-migrate That‘s the cool sf 1.3 way 24
  • 81. Things to keep in mind 25
  • 82. Big vs. small Migrations aka. „Complete Migrations“ vs. „Wild West Cowboy Style Migrations“ 26
  • 83. Big vs. small Migrations 27
  • 84. Big vs. small Migrations Small Migrations more Agile 27
  • 85. Big vs. small Migrations Small Migrations more Agile Really need to be Agile?! 27
  • 86. Big vs. small Migrations Small Migrations more Agile Really need to be Agile?! Small Migrations more dirty 27
  • 87. Big vs. small Migrations Small Migrations more Agile Really need to be Agile?! Small Migrations more dirty Big Migrations more complicated 27
  • 88. Keep in mind Run a diff before building the model 28
  • 89. Keep in mind Run a diff before building the model After migrating you can‘t generate the diff! 28
  • 90. Keep in mind Keep Data Migrations simple 29
  • 91. Keep in mind Keep Data Migrations simple Migrate the Data as easy as possible! 29
  • 92. Keep in mind Version get‘s updated after all Migrations are run 30
  • 93. Keep in mind Version get‘s updated after all Migrations are run You have to fix problems by hand if they fail. 30
  • 95. Credits Thanks to: - Ryan Weaver for his presentation about Doctrine ...Migrations - Samim for the designs and the artworks. Picture „Von A nach B“ - photocase.com © Anna-Lena Thamm : cydonna Creative Commons stuff used: - „Application, Mime, Vnd.sun.xml.draw“ icon by „New Mooon“ - http://www.iconfinder.net/ icondetails/28957/128/ - „Application, Sqlite2, X“ icon by „New Mooon“ - http://www.iconfinder.net/icondetails/ 28899/128/ - „Application, Php, X “ icon by „New Mooon“ - http://www.iconfinder.net/icondetails/28894/128/ 32