© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•10mo ago•
2 replies
davecancode

Declarative Schema - Migrations keep creating/dropping things like policies

I'm following the guide here:
https://supabase.com/docs/guides/local-development/declarative-database-schemas

Using the example in the link above, I'm defining my "employees.sql" schema file like:
-- enum type definitions used in table (create statements - new ones only, specific to this table)
-- table definition
-- comments for columns
-- enable row level security (alter table statement)
-- policies
-- functions
-- triggers
-- indexes

Note: above is just an example - I have different tables that I can't share here. The above are actual valid sql in my files.

I follow the process described in the link above:
1. Update the schema .sql files
2. supabase stop
3. supabase diff to generate a migration

Every time I create a migration it will do weird things like:
- adds a bunch of grant statements for various roles,
- creates duplicate policies
- creates duplicate indexes
- etc.
- it does this across a variety of previously created tables... sometimes its the same statements for the same tables, sometimes it's random stuff

Note: I'm not making any schema changes in the studio. Just declarative schema changes + migrations.
Note: I'm not doing any of the discouraged things described in the linked doc like DML, View Ownership, altering policy statements, column privileges, etc.

Is there a definitive process to follow?
Is there a way to correct the state?

Goal is to have clean declarative schema that generates clean migrations that reflect ONLY the changes I've just made prior to creating the migration.
Declarative database schemas | Supabase Docs
Manage your database schemas in one place and generate versioned migrations.
Declarative database schemas | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Declarative schema and MCP
SupabaseSSupabase / help-and-questions
2mo ago
Declarative schema creating/replacing functions already applied(syntax differences)
SupabaseSSupabase / help-and-questions
2mo ago
trouble setting up declarative schema
SupabaseSSupabase / help-and-questions
5mo ago
Bucket Policies keep on error
SupabaseSSupabase / help-and-questions
4y ago