You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a copy of a troubleshooting article on Supabase's docs site. It may be missing some details from the original. View the original article.
If you encounter a permission denied for database postgres error during migrations, it typically occurs when executing CREATE SCHEMA or similar commands after a SET ROLE statement.
Why this happens
Postgres 15 and later versions remove default CREATE privileges from the PUBLIC role. This means custom roles do not automatically have permission to create objects in the database, even if the session was initiated by the postgres user.
How to resolve the issue
To resolve this, you must grant the CREATE privilege on the database to the specific role used in your migration script. Run the following command in the SQL editor:
GRANT CREATE ON DATABASE postgres TO example_role;
Replace example_role with the name of the role being assumed during the migration (for example, the owner role of your schemas).
Related
If this happened via a REST/GraphQL request instead of a direct connection or migration script, see Database API 42501 errors instead — that guide covers a different set of causes specific to the Data API.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
This is a copy of a troubleshooting article on Supabase's docs site. It may be missing some details from the original. View the original article.
If you encounter a
permission denied for database postgreserror during migrations, it typically occurs when executingCREATE SCHEMAor similar commands after aSET ROLEstatement.Why this happens
Postgres 15 and later versions remove default
CREATEprivileges from thePUBLICrole. This means custom roles do not automatically have permission to create objects in the database, even if the session was initiated by thepostgresuser.How to resolve the issue
To resolve this, you must grant the
CREATEprivilege on the database to the specific role used in your migration script. Run the following command in the SQL editor:Replace
example_rolewith the name of the role being assumed during the migration (for example, the owner role of your schemas).Related
If this happened via a REST/GraphQL request instead of a direct connection or migration script, see Database API 42501 errors instead — that guide covers a different set of causes specific to the Data API.
All reactions