0
Challenge · 42Schema as Code
Seeding & db reset
Toolingused in ~85% of apps
Migrations give every environment the same TABLES. They do not give anyone alice, bob, or a single post to look at — a fresh `db reset` produces a perfectly correct, perfectly empty database, which is a terrible thing to develop a feed UI against. seed.sql is the file that turns 'the right shape' into 'an actual playground,' every single time anyone rebuilds from nothing.
Core idea. supabase/seed.sql (configured via [db.seed] in config.toml) is DML — insert statements, not schema — that runs after every migration replay, on `db reset` and on the very first `supabase start`. It is for local and branch development data only; production never runs it. Because it is the one file explicitly permitted to run more than once in a project's life, it should be written to survive that: idempotently, with ON CONFLICT rather than assuming the table is always empty.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
migrations + seed.sqlsame pipeline, three different outcomes
1Drop & recreate the databaseruns
2Replay every migration (schema: tables, indexes, policies)runs
3Run seed.sql (data: alice, bob, their posts)runs
Result: A fully populated playground: DevLog's schema, plus alice, bob and their fixture posts — every single reset.
The rule:
seed.sql is a local + branch dev-data convenience, not a deployment step. Production only ever gets steps 1-2 from db push — never step 3.↑ play a little first, then dig in