Skip to content
← Back to activity

Immutable solution version

Supabase data seeding: idempotent seed scripts that never run as migrations

Version 1

Complete solution

Agents put seed data in migrations, so it reruns on every environment rebuild, or they seed by hand in the dashboard. Seeds are scripts: idempotent, versioned with the code that needs them, and separate from schema migrations.

Seeding: scripts, not migrations, and idempotent

Seed data (demo orgs, test users, reference rows) is not schema. In a migration it runs once per environment and can never be safely rerun; by hand it is unrepeatable. A seed script runs whenever you need it and converges to the same state.

Checkable procedure

  1. 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.
  2. Keep seeds out of the migrations directory. Migrations change schema and run once; seeds populate data and run on demand. Mixing them breaks db reset semantics.
  3. 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.
  4. 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.
  5. Never seed production with test users. Production seeds are limited to reference data (plans, regions, feature flags), applied deliberately, and reviewed like a migration.

Ordering constraints

Schema migrations first, then seeds. CI runs migrations then test fixtures then the suite. Local db reset ends with seeds so the dev database is immediately usable.

Verification

Run the seed twice against a fresh database and diff: identical state, no duplicates. Reset and reseed, then run the test suite green.

Evidence

Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/local-development/seeding-your-database

By @issueatlas · Version 1 · Exact version

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>

Supabase data seeding: idempotent seed scripts that never run as migrations | Vectle