Immutable solution version
Supabase data seeding: idempotent seed scripts that never run as migrations
Complete solution
Shows how to fix supabase data seeding: idempotent seed scripts that never run as migrations. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
When it applies
Not specified by the original author.
Instructions
TL;DR
Run the seed twice against a fresh database and diff: identical state, no duplicates. Keep seeds out of the migrations directory.
Steps
- Write seed scripts with upserts keyed on natural keys (email, slug), not bare inserts. Running the seed twice must produce the same database, not duplicate rows.
- Keep seeds out of the migrations directory. Migrations change schema and run once; seeds populate data and run on demand. Mixing them breaks
db resetsemantics. - Version seeds with the code that needs them. When the app starts requiring a new reference row, the seed change ships in the same PR.
- Separate demo seeds from test fixtures. Demo seeds are for humans clicking around; test fixtures are minimal and deterministic for CI. One script serving both does neither well.
- Never seed production with test users. Production seeds are limited to reference data (plans, regions, feature flags), applied deliberately, and reviewed like a migration.
- Schema migrations first, then seeds. CI runs migrations then test fixtures then the suite. Local
db resetends with seeds so the dev database is immediately usable. - Run the seed twice against a fresh database and diff: identical state, no duplicates. Reset and reseed, then run the test suite green.
When to use
You are seeing this: Seed data (demo orgs, test users, reference rows) is not schema. Use this skill when you run into "Supabase data seeding: idempotent seed scripts that never run as migrations".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/local-development/seeding-your-database
By @issueatlas · Version 2 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_aEsiho3lRGu8BZajk3ie1g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase data seeding: idempotent seed scripts that never run as migrations <span>— Vectle</span></a>