Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Database Migrations in PHP (Posobota #66)
Search
Vladimír Kriška
October 25, 2014
Programming
0
110
Database Migrations in PHP (Posobota #66)
Vladimír Kriška
October 25, 2014
Tweet
Share
More Decks by Vladimír Kriška
See All by Vladimír Kriška
Twelve-Factor app with Docker
ujovlado
0
89
Design a REST API you will love to work with
ujovlado
0
730
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
460
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
350
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
110
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
69
CSS Flexbox (WebElement #35)
ujovlado
0
140
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
150
Don't underestimate CSS (WebElement #30)
ujovlado
0
560
Other Decks in Programming
See All in Programming
SwiftUI API Design Lessons
niw
1
290
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
4
1.1k
Making TCPSocket.new "Happy"!
coe401_
1
1.6k
Defying Front-End Inertia: Inertia.js on Rails
skryukov
0
490
Java 24まとめ / Java 24 summary
kishida
3
500
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
170
エンジニアが挑む、限界までの越境
nealle
1
230
Exit 8 for SwiftUI
ojun9
0
130
Dissecting and Reconstructing Ruby Syntactic Structures
ydah
1
740
DataStoreをテストする
mkeeda
0
290
State of Namespace
tagomoris
4
1.8k
Building Scalable Mobile Projects: Fast Builds, High Reusability and Clear Ownership
cyrilmottier
2
290
Featured
See All Featured
The Invisible Side of Design
smashingmag
299
50k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Gamification - CAS2011
davidbonilla
81
5.2k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Cost Of JavaScript in 2023
addyosmani
49
7.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
Facilitating Awesome Meetings
lara
54
6.3k
Fireside Chat
paigeccino
37
3.4k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Transcript
Database Migrations in PHP Posobota #66 Vladimír Kriška @ujovlado
My experience • Paradox: first company I worked with was
the closest to migrations • Then it went only worse • no migrations • single file migrations • Yii framework database migrations
Pros • Exact version of schema with creation and application
date • CLI interface (automation) • Easy rollback, going through history
Cons • Need to regenerate/change model
Other options/ideas • Generate migrations directly from model (no SQL
writing) • With each change create DB dump with file per table, than version in Git
Other tools • Phinx • Sqitch (Perl) • Doctrine, Phalcon,
Propel, CakePHP • and many others …
Migrations in Yii • Two main commands • yiic migrate
up • yiic migrate down • And also: history, new, to, mark
Example • let’s do some shit …
Tips/tricks • DB schema has to be versioned - no
matter how • If you don’t know how to do it, choose solution from some framework • Don’t write own tool for migrations • Start with migrations ASAP
• Always write down migrations • Try to avoid shortcut
methods (they disallow c&p from migration) • Don’t mix schema and data migrations • Write short migrations • Don’t change applied migrations
THE END Thanks!