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
93
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
63
Design a REST API you will love to work with
ujovlado
0
700
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
430
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
330
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
85
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
50
CSS Flexbox (WebElement #35)
ujovlado
0
110
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
120
Don't underestimate CSS (WebElement #30)
ujovlado
0
530
Other Decks in Programming
See All in Programming
快速入門可觀測性
blueswen
0
330
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
42 best practices for Symfony, a decade later
tucksaun
1
180
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
660
CSC305 Lecture 25
javiergs
PRO
0
130
Jakarta EE meets AI
ivargrimstad
0
230
命名をリントする
chiroruxx
1
380
useSyncExternalStoreを使いまくる
ssssota
6
1k
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
MCP with Cloudflare Workers
yusukebe
2
220
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
4 Signs Your Business is Dying
shpigford
181
21k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
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!