Reload schema and rotate secret
base_reload_schema refreshes the Data API's schema cache after DDL run outside base_run_sql; base_rotate_secret replaces the secret key immediately.
Reload schema and rotate secret
Two maintenance tools for a database that already has the Data API enabled.
base_reload_schema
base_reload_schema({ database })
PostgREST caches the database's schema. If you run DDL — a new table
or column — over the direct or pooler connection, or over
base_run_sql, that change may not be visible to the Data API right
away. Calling base_reload_schema refreshes the cache without waiting
for it to notice on its own.
Calling it before the Data API is enabled for that database returns a
clear error telling you to run base_enable_api first, rather than a
confusing one.
base_rotate_secret
base_rotate_secret({ database, confirm })
Rotates the database's Data API secret key. confirm must exactly
equal database, or the call fails before anything rotates. The new
secret key is returned once — save it immediately, since it can't be
retrieved again — and the old secret key stops working immediately, not
after some grace period.
Rotate this whenever the secret key may have leaked: it bypasses row-level security entirely, so treat it the same way you'd treat a compromised server credential anywhere else.