supabase-schema-migrations
Skill827 starsChanged 3 months agoMITView on GitHub
Use for any NextBase Supabase schema, RLS, function, trigger, enum, index, extension, generated database type, or migration change and enforce this repository's schema-first generated-migration workflow.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- nextbase-architectureSkill
- nextbase-auth-ssrSkill
- nextbase-cache-componentsSkill
- nextbase-database-testingSkill
- nextbase-safe-actions-dataSkill
- nextbase-testingSkill
- nextbase-ui-patternsSkill
- next-cache-components-optimizerSkill
- safe-action-advancedSkill
- safe-action-clientSkill
- safe-action-hooksSkill
- safe-action-middlewareSkill
- safe-action-testingSkill
- shadcnSkill
- supabase-postgres-best-practicesSkill
- supabaseSkill
- turborepoSkill
- vercel-composition-patternsSkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 12
Never manually create migration files in apps/database/supabase/migrations.
- Distinctive: line 13
Never manually edit generated migration files.
- Distinctive: line 14
Never paste hand-written SQL directly into a migration file.
- Distinctive: line 16
Read generated migrations for review only.
- Very specific: line 22
Start the local stack from the root with pnpm database#start.
- Distinctive: line 25
If it is wrong, fix the declarative schema, discard only the newly generated migration, and generate it again.
- Distinctive: line 28
Run the relevant lint, typecheck, test, and build commands for consumers.
- Distinctive: line 41
Add behavioral pgTap coverage for authorization changes.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Supabase Schema Migrations
Load the vendored supabase and supabase-postgres-best-practices skills. Current Supabase documentation and the installed CLI are authoritative for command flags.
Hard Boundary
- Never manually create migration files in
apps/database/supabase/migrations. - Never manually edit generated migration files.
- Never paste hand-written SQL directly into a migration file.
- Make schema changes first in
apps/database/supabase/schemas/*.sql. - Read generated migrations for review only. If generated SQL is wrong, fix the declarative schema and regenerate.
Schema-First Workflow
- Inspect neighboring files in
apps/database/supabase/schemasand the existing migration history. - Edit or add the appropriate declarative schema file. Keep stable object ordering to reduce diff churn.
- Start the local stack from the root with
pnpm database#start. - From
apps/database, generate the migration withpnpm supabase db diff -f <descriptive_name>. - Review the generated SQL for accidental drops, policy churn, missing grants, destructive conversions, ordering problems, and unrelated changes.
- If it is wrong, fix the declarative schema, discard only the newly generated migration, and generate it again. Do not patch generated SQL.
- Apply and validate the local schema as appropriate, then run
pnpm --dir apps/database test-db. - From the root, run
pnpm gen-types-local. The only generated TypeScript destination isapps/web/src/lib/database.types.ts. - Run the relevant lint, typecheck, test, and build commands for consumers.
RLS and Security Review
For every exposed table or function, verify:
- RLS is enabled and forced where the design requires it.
USINGandWITH CHECKcover every intended role and operation.- Ownership derives from
auth.uid()or another trusted server value. - Foreign keys used by policies and common joins have appropriate indexes.
- Functions use deliberate invoker/definer semantics, a safe
search_path, and explicit execute grants. - Grants and schema exposure do not broaden access unintentionally.
Add behavioral pgTap coverage for authorization changes; policy-name assertions alone are insufficient.
Diff Limitations
Some operations are not represented safely by schema diff. If the desired change cannot be expressed by this workflow, stop and explain the limitation. Do not work around it by hand-authoring or editing a migration unless the repository rule itself is explicitly changed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

