Guides
Test data
Write fixtures per scenario, and seed or purge them safely on dev, test and staging databases.
One-time setup per database
Run supabase/test-data/env.sql in every environment (the monorepo template has it in its first migration), then set the value:
SQL Editor
INSERT INTO public._env (name) VALUES ('dev') -- or 'test' / 'staging' / 'production'
ON CONFLICT (id) DO UPDATE SET name = excluded.name;
Writing fixtures
When a change adds tables or RPCs, or its scenarios need data, its tasks include "extend seed + purge". Each fixture is a section tagged with its scenarios and ZOMBIES category:
supabase/test-data/seed.sql
-- @fixture invoices.R2.S3 @boundary
SELECT public.create_invoice(p_codigo => 'TEST_INV_EDGE', p_fecha => current_date - 15, …);
| Tag | Data to create |
|---|---|
@zero | a parent with no children |
@one / @simple | one ordinary record per main entity |
@many | several records: lists, totals, ordering |
@boundary | limits, period edges, rounding edges |
@interface | one record per role / scope |
@exception | inactive, cancelled, invalid states |
Every table the seed writes to must be cleaned by purge.sql, children first. agent-kit qa gaps lists scenarios without fixtures and fixtures naming unknown scenarios.
Applying
SQL Editor (supported): run purge.sql, then seed.sql, each as a whole file.
From a terminal — the agent shows the command and runs it only after you approve:
Terminal
supabase db query --linked -f supabase/test-data/purge.sql # --local or --db-url "<url>"
supabase db query --linked -f supabase/test-data/seed.sql
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f supabase/test-data/seed.sql
Never use
supabase db reset to reset test data on a shared database: it rebuilds the whole database. purge.sql removes only the test rows.