---
title: "Test data"
description: "Write fixtures per scenario, and seed or purge them safely on dev, test and staging databases."
canonical_url: "https://razcue-agent-kit.vercel.app/en/guides/test-data"
---
# 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 [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:

```sql [supabase/test-data/seed.sql]
-- @fixture invoices.R2.S3 @boundary
SELECT public.create_invoice(p_codigo => 'TEST_INV_EDGE', p_fecha => current_date - 15, …);
```

<table>
<thead>
  <tr>
    <th>
      Tag
    </th>
    
    <th>
      Data to create
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        @zero
      </code>
    </td>
    
    <td>
      a parent with no children
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @one
      </code>
      
       / <code>
        @simple
      </code>
    </td>
    
    <td>
      one ordinary record per main entity
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @many
      </code>
    </td>
    
    <td>
      several records: lists, totals, ordering
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @boundary
      </code>
    </td>
    
    <td>
      limits, period edges, rounding edges
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @interface
      </code>
    </td>
    
    <td>
      one record per role / scope
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        @exception
      </code>
    </td>
    
    <td>
      inactive, cancelled, invalid states
    </td>
  </tr>
</tbody>
</table>

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:

```bash [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
```

<warning>

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.

</warning>


## Sitemap

See the full [sitemap](https://razcue-agent-kit.vercel.app/sitemap.md) for all pages.
