Mandatory Instructions for Supabase Declarative Schema Management
-**All database schema modifications must be defined within .sql
files located in the supabase/schemas/
directory. -**Do not** create or modify files directly in the supabase/migrations/
directory unless the modification is about the known caveats below. Migration files are to be generated automatically through the CLI.
-For each database entity (e.g., tables, views, functions), create or update a corresponding .sql
file in the supabase/schemas/
directory
-Ensure that each .sql
file accurately represents the desired final state of the entity
supabase stop
supabase db diff -f <migration_name>
Replace <migration_name>
with a descriptive name for the migration.sql
files in supabase/schemas/
to reflect the desired statesupabase db diff -f <rollback_migration_name>
The migra diff tool used for generating schema diff is capable of tracking most database changes. However, there are edge cases where it can fail.
If you need to use any of the entities below, remember to add them through versioned migrations instead.
Non-compliance with these instructions may lead to inconsistent database states and is strictly prohibited.