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
100
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
78
Design a REST API you will love to work with
ujovlado
0
720
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
450
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
350
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
100
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
62
CSS Flexbox (WebElement #35)
ujovlado
0
130
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
140
Don't underestimate CSS (WebElement #30)
ujovlado
0
550
Other Decks in Programming
See All in Programming
AWS Step Functions は CDK で書こう!
konokenj
5
930
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
9
1.6k
The Clean ArchitectureがWebフロントエンドでしっくりこないのは何故か / Why The Clean Architecture does not fit with Web Frontend
twada
PRO
62
20k
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
770
Jakarta EE meets AI
ivargrimstad
0
840
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
1.2k
高セキュリティ・高耐障害性・サブシステム化。そして2億円
tasukulab280
2
370
もう少しテストを書きたいんじゃ〜 #phpstudy
o0h
PRO
21
4.4k
読まないコードリーディング術
hisaju
1
140
Better Code Design in PHP
afilina
0
190
Your Architecture as a Crime Scene:Forensic Analysis @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
130
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
1
260
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Facilitating Awesome Meetings
lara
53
6.3k
Speed Design
sergeychernyshev
28
820
Code Reviewing Like a Champion
maltzj
521
39k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Embracing the Ebb and Flow
colly
84
4.6k
The Cult of Friendly URLs
andyhume
78
6.2k
The Pragmatic Product Professional
lauravandoore
32
6.4k
4 Signs Your Business is Dying
shpigford
183
22k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
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!