Repair ownership
Databases
Repair ownership
Reassign ownership of a database’s objects to the owner role after a restore.
POST
Repair ownership
Reassigns ownership of every table, sequence, view, and materialized view in the database to the database’s owner role. Idempotent — safe to run multiple times.
When to use this
Call this endpoint after you’ve restored apg_dump into your database and then see permission denied for table X (Postgres SQLSTATE 42501) when your application connects.
Why it happens: Legacy or out-of-band restores can preserve object owners
that differ from the limited tenant owner. The staged DBHost restore path runs
customer dump content as the limited owner and validates ownership before swap;
it does not execute customer dump content as PostgreSQL superuser.
New restores triggered through DBHost automatically run this repair step at the end. This endpoint exists for:
- Databases that were restored before the automatic repair existed.
- Clean-up after out-of-band
psql/pg_restoreactivity. - Any situation where your app role hits
permission deniedon tables you expect to own.
Path parameters
What it does
For the target database only:ALTER SCHEMA public OWNER TO <owner>+ grantsUSAGE, CREATE.- Iterates every non-system schema and issues
ALTER TABLE/SEQUENCE/VIEW/MATERIALIZED VIEW ... OWNER TO <owner>. - Regrants the SQL-explorer role
SELECTon the restored tables so the dashboard explorer keeps working.
Response
200 OK