PostgreSQL · infra · fg-0274

'permission denied for schema public' when an app role runs migrations on PostgreSQL 15 or later

If you see ERROR: permission denied for schema public, the cause and the fix for PostgreSQL are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
ERROR: permission denied for schema publicCREATE TABLE works as the database owner or a superuser but not as the app roleThe same migration succeeds against a PostgreSQL 14 server
Cause
PostgreSQL 15 removed the default CREATE privilege for PUBLIC on the public schema in new clusters and new databases, and made pg_database_owner its owner. Upgraded clusters and restored dumps keep the old grants, so environments disagree.
Fix
Make the app role own the database, or grant CREATE on the schema to it explicitly.
Apply
ALTER DATABASE app OWNER TO app_user; -- or GRANT USAGE, CREATE ON SCHEMA public TO app_user;
Affected
PostgreSQL 15 and later (October 2022), new clusters and newly created databases
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun