Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Database Migrations in PHP (Posobota #66)
Vladimír Kriška
October 25, 2014
Programming
0
49
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
11
Design a REST API you will love to work with
ujovlado
0
480
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
230
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
130
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
47
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
33
CSS Flexbox (WebElement #35)
ujovlado
0
81
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
68
Don't underestimate CSS (WebElement #30)
ujovlado
0
460
Other Decks in Programming
See All in Programming
TDX22: User-Mode DB Ops
ca_peterson
3
1.1k
mrubyを1300円のボードで動かそう
yuuu
0
180
Cloud Bigtable を使いこなす秘訣 2022
kusahana
0
230
How to get satisfaction from ungrateful work: A journey into updating Kotlin
syrinet
0
120
Get Ready for Jakarta EE 10
ivargrimstad
0
1.9k
A technique to implement DSL in Ruby
okuramasafumi
0
510
SRE NEXT 2022: Sensible Incident Management for Software Startups
takanabe
2
230
Testing, how hard can it be? (Droidcon Lisbon 2022)
dpreussler
3
200
Loom is Blooming
josepaumard
3
510
実録mruby組み込み体験
coe401_
0
100
확장 가능한 테라폼 코드 관리 (Scalable Terraform Code Management)
posquit0
1
310
How useEvent would change our applications
koba04
1
1.3k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
180k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
Why Our Code Smells
bkeepers
PRO
324
54k
KATA
mclloyd
7
8.6k
Infographics Made Easy
chrislema
233
17k
Imperfection Machines: The Place of Print at Facebook
scottboms
253
11k
The Invisible Side of Design
smashingmag
289
48k
Fashionably flexible responsive web design (full day workshop)
malarkey
396
62k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
GraphQLとの向き合い方2022年版
quramy
16
8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
350
21k
Fantastic passwords and where to find them - at NoRuKo
philnash
25
1.5k
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!