PermDock
Concepts

Seeds

defineSeeds separates role defaults, which ship in a migration, from fixture rows, which stay in supabase/seeds.

defineSeeds(policy, { defaults, fixtures }) is the seed data permdock generate writes. Defaults and fixtures are different files.

Defaults

defaults.roles is a role key, a scope and the permission references that role holds. Generate writes those rows into the role_permissions migration, or into the role_permissions view when rls.seeds is "view". A default that names an unknown role, scope or permission is doctor PD097.

Fixtures

fixtures holds users, tenants, memberships, custom roles and rows. Generate writes them to supabase/seeds/permdock.sql. A migration or a schema file that contains the fixture marker is PD097.

The CLI prints this block and does not edit supabase/config.toml:

[db.seed]
sql_paths = ['./seeds/permdock.sql']

Add that block so supabase db reset loads the fixtures. Without it, PD097 warns.

Per backend

BackendDefaultsFixtures
Supabase, rls.seeds: "function"select <schema>.seed() after deploysupabase/seeds/permdock.sql
Supabase, rls.seeds: "view"the role_permissions viewsupabase/seeds/permdock.sql
Drizzle or Prismathe defaults migration the rls() plugin writesnot applied; the app's own seed owns rows
MemorynonememorySources and memoryPostgrestSources in tests
pgTAPnonerolePersonas(seeds) and rls verify --kind pgtap --personas roles

Fixture rows never go in a schema file. The view cannot take hand-added role_permissions rows.

Last updated on

On this page