title: Migration Runner Stepper description: Step five migrations into an empty database under four conditions: healthy, an early return, a rerun of a file that is not safe to repeat, and a competing startup SQL path. Then diagnose four hidden runs from the schema and the log. image: /sims/migration-runner-stepper/migration-runner-stepper.png og:image: /sims/migration-runner-stepper/migration-runner-stepper.png twitter:image: /sims/migration-runner-stepper/migration-runner-stepper.png social: cards: false status: built
Migration Runner Stepper¶
Run the Migration Runner Stepper MicroSim Fullscreen
About This MicroSim¶
Migrations fail in quiet ways. A run can stop early with no error. A rerun can trip over a file that isn't safe to repeat. A second path, such as SQL the server runs at startup, can change the schema behind the migration tool's back.
This sim runs five illustrative migration files against an empty database under each of these conditions. You watch the files, the schema, the tracking table (__drizzle_migrations) and the log. Then the Diagnose mode hides the condition and asks you to name it from what it left behind.
Learning objective (Analyze: diagnose): Diagnose, from the final schema and the migration log, which of four failure conditions caused a production database to differ from the schema in code.
How to Use¶
- Pick a condition from the list and press Step to apply one change at a time, or Run all. You can also click the file list to step.
- Watch the database panel: filled squares are present, hollow ones are missing. The tracking table lists what the tool recorded.
- Try all four conditions. Then tick Check applied count against files and run B again. The server now refuses to start.
- Press Diagnose for four rounds with the condition hidden. The log shows only what the migration tool and the server wrote. Pick A, B, C or D.
- A wrong answer replays the real condition step by step. Press Exit diagnose to go back to exploring.
Iframe Embed Code¶
You can add this MicroSim to any web page by adding this to your HTML:
<iframe src="https://arunbatchu.github.io/good-enough-engineering/sims/migration-runner-stepper/main.html"
height="594px"
width="100%"
scrolling="no"></iframe>
Lesson Plan¶
Grade Level¶
Adult professional (Good Enough Engineering)
Duration¶
10-15 minutes
Prerequisites¶
Schema, migration, migration tool, tracking table, migration ordering, idempotent migration, competing migration paths and early return, from the chapter sections before the sim.
Activities¶
- Exploration (5 min): Run conditions A to D and write one sentence on how each one leaves the schema.
- Guided Practice (5 min): Turn on the applied-count check and run B and D. Discuss why refusing to start is better than starting with missing tables.
- Assessment (5 min): Complete the four diagnosis rounds and reach 3 of 4. Then list every path that can change your own app's schema.
Common Misconceptions¶
- If the server started without errors, all migrations ran.
- Running a migration twice is always harmless.
- Two ways of changing the schema are safer than one.
Assessment¶
- Names the hidden condition in 3 of 4 diagnosis rounds on the first attempt.
- Points to the clue in the log or schema that gave each condition away.
- Explains what the applied-count check changes for condition B.
References¶
- Drizzle ORM documentation: Migrations - how drizzle-kit writes and applies migration files.
- PostgreSQL documentation: ALTER TABLE - ADD COLUMN IF NOT EXISTS makes a migration safe to repeat.