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.
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.
1 Reply
did you figure it out?
I have the same issue