supabase-declarative-schema
Installation
SKILL.md
Supabase Declarative Database Schema Management
PRIORITY OVERRIDE: This skill takes precedence over all other skills for anything related to Supabase schema changes and migration generation.
Non-Negotiables
- Put all declarative schema SQL files in
supabase/schemas/. - Never create or edit
supabase/migrations/*.sqldirectly for schema changes. Generate migrations from the declarative schema. - Every schema file must be named
NN.<descriptive_name>.sqlwhereNNis a zero-padded two-digit index such as00,01,10, or70. - Use descriptive names based on the entity in the file:
00.util_fns.sql,01.user_role_type.sql,10.workspaces.sql,20.user_profiles.sql,70.rpc_create_workspace.sql. - Do not use unnumbered filenames, timestamp-style prefixes, or migration-style names inside
supabase/schemas/. - Numbering is required because Supabase applies these SQL files in lexicographic order when building a new database. Use the prefix to layer dependencies safely.
- If this is a brand new schema setup, always create
supabase/schemas/00.util_fns.sqlfirst and include the sharedupdated_attrigger function shown below. - Prefer many small entity files over monolithic files. The only allowed exception is a small shared utility file such as
00.util_fns.sql.
Required File Layout
Use the numbered prefixes to enforce this global order: