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
More Decks by Jan Tvrdík
See All by Jan Tvrdík
Runtime Types in TypeScript
jantvrdik
0
70
How to Write Parser in PHP
jantvrdik
0
110
Nextras Mail Panel
jantvrdik
0
180
Writing reliable migrations with Nextras Migrations
jantvrdik
1
710
Other Decks in Programming
See All in Programming
すこし踏み込む CancellationToken
htkym
2
1.7k
Domain-Driven Transformation
hschwentner
2
2.3k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
300
ActionController meets Protocol Buffers
sorah
0
520
Jetpack Compose Mechanisms
skydoves
3
820
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
210
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Docker and Python
trallard
47
4.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Code Reviewing Like a Champion
maltzj
529
40k
From π to Pie charts
rasagy
1
400
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Designing for humans not robots
tammielis
254
26k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
540
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
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