Stage 2 · Lesson 10 of 11
Schema migrations
Without an , you manage changes with a dedicated tool such as golang-migrate, goose or Atlas. Each is a numbered SQL file, often with an up part and a down part to undo it. You commit it next to the code that needs it.
The tool records which migrations have run in each database, so every environment reaches the same schema. can read the same migration files to learn your tables. Run migrations as a separate deploy step rather than at every app start, so several copies of the app do not race each other. Never edit a migration that has already run elsewhere.
Common trapa in one step, such as renaming a column the running code still reads. Instead, add the new column, copy the data, switch the code, then drop the old one.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Relational Database Design and Modeling
Design Gurus · Intermediate · $98 one-time
The modelling and normalisation decisions that stay with a codebase for years
- CourseFreeCS50's Introduction to Databases with SQL
Harvard University · Beginner
Free course from querying through schema design, indexes, transactions and scaling
Practise
Also worth your time
- Database Indexing Explained: B-Tree, Hash, Bitmap, R-Tree, and When to Use Each (opens in a new tab)Read
B-tree and composite indexes, plus the leftmost-prefix rule that trips people up
What sits under your queries: storage engines, transactions and isolation levels