Upload
rob-morgan
View
505
Download
0
Embed Size (px)
Citation preview
“A schema migration is performed on a database whenever it is necessary to update
or revert that database's schema to some newer or older version. Migrations are
performed programmatically by using a schema migration tool.”
source: https://en.wikipedia.org/wiki/Schema_migration
Rob Morgan
• Creator & Lead Developer of Phinx
• Writing PHP for almost 15 years
• Email: [email protected]
• https://robmorgan.id.au
@_rjm_
Brief History• Open Sourced in 2012 under the MIT License
• 38 Releases to Date
• 1.2 million Downloads and 115+ Contributors
• Used in CakePHP 3.0.0
• Built on top of Symfony Components (and only 3)
Features• Write database migrations using PHP code
• Migrate up and down
• Seed data after database creation
• Take advantage of SCM features such as branching
• Integrate with any app
• Get going in less than 5 minutes
Test MatrixMySQL PostgreSQL SQLite SQL Server
PHP 5.4 ❌ ❌ ❌ ❌
PHP 5.5 ❌ ❌ ❌ ❌
PHP 5.6 ❌ ❌ ❌ ❌
PHP 7 ❌ ❌ ❌ ❌
HHVM ❌
Phinx by Rob Morgan - https://phinx.org. version 0.5.3
using config file ./phinx.yml using config parser yaml using migration path /Users/robbym/Code/phinx/db/migrations using seed path /Users/robbym/Code/phinx/db/seeds using migration base class Phinx\Migration\AbstractMigration using default template created ./db/migrations/20160309162303_create_posts_table.php
Phinx by Rob Morgan - https://phinx.org. version 0.5.3
using config file ./phinx.yml using config parser yaml using migration path /Users/robbym/Code/phinx/db/migrations using seed path /Users/robbym/Code/phinx/db/seeds using migration base class Phinx\Migration\AbstractMigration using default template created ./db/migrations/20160309162303_create_posts_table.php
Best Practises• Write environment agnostic code
• Version control your migrations
• Enforce default values in the migrations themselves
• Avoid custom SQL if possible
• Use the change method by default
The Customer
• He wants a competitor to Wordpress
• Needs it tomorrow
• Willing to pay alot some money
# first require Phinx $ php composer.phar require robmorgan/phinx
# then install it including the dependencies $ php composer.phar install
# setup your project $ docker run --rm -v $(pwd):/app robmorgan/phinx init
# create a migration $ docker run --rm -v $(pwd):/app robmorgan/phinx create MyFirstMigration
# migrate your db $ docker run --rm -v $(pwd):/app --link db:db robmorgan/phinx migrate -e development
Contributing• Before you open an issue, search the existing
ones!
• Fixing the documentation is a great place to start
• Read the CONTRIBUTING.md file on Github
• At the end of the day, nobody bites and its only PHP!
Cheers!• Rob Morgan (@_rjm_)
• https://phinx.org
• https://robmorgan.id.au
Rob Morgan @_rjm_ #phinx #php #phptour