Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
Transcript
30 slides
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
More Decks by Jan Tvrdík
See All by Jan Tvrdík
Runtime Types in TypeScript
jantvrdik
0
93
How to Write Parser in PHP
jantvrdik
0
110
Nextras Mail Panel
jantvrdik
0
180
Writing reliable migrations with Nextras Migrations
jantvrdik
1
720
Other Decks in Programming
See All in Programming
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
440
Kotlin Fest 2026: Kotlin コンパイラに Contribute してみよう! - Kotlin/Wasm で深い再帰を書けるようにした話
ternbusty
1
420
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
190
JavaScriptはシングルバイナリの夢を見るか / Does JavaScript Dream of a Single Binary?
ssssota
0
390
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
120
SODA - FACT BOOK(JP)
sodainc
1
40k
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
250
Stage 3でも仕様は変わる。アプリケーション開発者のためのTC39プロセスの読み方
bicstone
1
310
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
430
Promiseの向こう側へコンテキストを届ける ― proposal-async-context
seriseri
0
210
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
130
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
400
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.5k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.2k
The Language of Interfaces
destraynor
163
27k
Chasing Engaging Ingredients in Design
codingconduct
0
410
Scaling GitHub
holman
464
140k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
What's in a price? How to price your products and services
michaelherold
247
13k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
340
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k