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
Writing Readable Migrations with Nextras Migrat...
Search
Jan Tvrdík
October 12, 2017
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Writing Readable Migrations with Nextras Migrations
Jan Tvrdík
October 12, 2017
More Decks by Jan Tvrdík
See All by Jan Tvrdík
Runtime Types in TypeScript
jantvrdik
0
62
How to Write Parser in PHP
jantvrdik
0
100
Nextras Mail Panel
jantvrdik
0
170
Writing reliable migrations with Nextras Migrations
jantvrdik
1
710
Other Decks in Programming
See All in Programming
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
130
dRuby over BLE
makicamel
2
410
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
210
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
220
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
240
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
160
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.7k
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
260
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
540
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
継続モナドとリアクティブプログラミング
yukikurage
3
370
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
280
Featured
See All Featured
Practical Orchestrator
shlominoach
191
11k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
340
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
460
Claude Code のすすめ
schroneko
67
230k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
240
Agile that works and the tools we love
rasmusluckow
331
22k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
230
How to Ace a Technical Interview
jacobian
281
24k
Facilitating Awesome Meetings
lara
57
7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
First, design no harm
axbom
PRO
2
1.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Transcript
Jan Tvrdík
None
but not limited to database snapshot approach mostly not usable
delta approach is hard to get right
None
None
None
None
None
Business Critical Code
doctrine:migrations:diff \ --formatted
None
None
queries wrapped in strings strings wrapped in method calls method
calls wrapped in a method body method body wrapped in a class
let's give each migration a descriptive name let's make the
content match the name let's remove all the noise by using SQL
None
None
easy to write code completion works well easy to format
„Reformat Code“ just works easy to read no noise & well formatted easy to test „Run“ just works „Copy & Paste“ just works no limitations
migrations/ ├── 001.sql ├── 002.sql └── ... +---------+----------+---------------------+----+ | file
| checksum | executed | ok | +---------+----------+---------------------+----+ | 001.sql | 78634... | 2015-08-28 17:05:03 | 1 | | 002.sql | dda40... | 2015-08-28 17:05:03 | 1 | | 003.sql | 5b9c6... | 2015-08-28 17:05:03 | 1 | +---------+----------+---------------------+----+
order is strictly defined new migrations can be only at
the end you must always „rebase“ your migrations once executed migration cannot be changed
migrations/ ├── structures/ │ ├── 2015-07-21-170126-init.sql │ └── 2015-07-22-144133-photo-description.sql ├──
basic-data/ │ └── ... └── dummy-data/ └── ...
S B P D L Structures Basic data Dummy data
Production Localhost
structures DDL only + DML required for DDL basic data
DML for tables in 2 (countries, languages…) dummy data for testing app on localhost w/o strict rules because not used on production
Symfony commands migrations:continue migrations:reset migrations:create
simple web interface when CLI is not available
PHP 5.4+ databases PostgreSQL MySQL DBALs Nextras DBAL Nette Database
Doctrine DBAL dibi
SQL executes all queries in *.sql file PHP for complex
migrations
extensions: migrations: Nextras\Migrations\Bridges\NetteDI\MigrationsExtension migrations: dir: %appDir%/../migrations # base directory driver:
pgsql # pgsql or mysql dbal: doctrine # nextras, nette, doctrine or dibi diffGenerator: doctrine ignoredQueriesFile: "%appDir%/../migrations/ignored.sql"
new \Nextras\Migrations\Bridges\SymfonyBundle\NextrasMigrationsBundle(); nextras_migrations: dir: "%kernel.root_dir%/migrations" driver: pgsql # pgsql or
mysql dbal: nextras # nextras, nette, doctrine or dibi diff_generator: doctrine ignored_queries_file: "%kernel.root_dir%/migrations/ignored.sql"
https://github.com/nextras/migrations https://nextras.org/migrations/docs/
Twitter + GitHub @JanTvrdik nextras.org