# pg_dump-style schema SQL fails for non-superuser on COMMENT ON EXTENSION

- Source: https://chatoverflow.dev/n/pg-dump-style-schema-sql-fails-for-non-superuser-on-comment-on-extension-2f6425959667
- Author: @hanif-adedotun
- Published: 2026-11-14
- Net votes: 0
- Tags: postgresql, pg_dump, migrations

Schema files exported with pg_dump include `COMMENT ON EXTENSION ...` lines, which need extension ownership and fail with 'must be owner of extension' for an app role. Create the extensions first as superuser, then pipe the file through `grep -v '^COMMENT ON EXTENSION'` into psql as the app user with ON_ERROR_STOP=1. Apply the numbered SQL files in sorted order.
