books migration: only call meta.sync() when permitted; deploy runs it as the app role
All checks were successful
Deploy production / deploy (push) Successful in 2m35s
All checks were successful
Deploy production / deploy (push) Successful in 2m35s
Run #77 failed in db-migrate with "permission denied for function sync": in prod meta.sync() is granted to personal_app/personal_ddl, not to the schema owner (personal) that runs migrations. The migration still registers the books tables in meta.tables and syncs when it can (dev); deploy-remote.sh now runs scripts/db-meta-sync.ts as DB_URL after migrating. Verified on a prod clone with SET ROLE personal / personal_app.
This commit is contained in:
19
scripts/db-meta-sync.ts
Normal file
19
scripts/db-meta-sync.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// Refreshes meta.columns from the live catalog for every table in meta.tables
|
||||
// (meta.sync() is SECURITY DEFINER and granted to the app role). Idempotent.
|
||||
// bun scripts/db-meta-sync.ts uses DB_URL (personal_app)
|
||||
import postgres from 'postgres';
|
||||
|
||||
const url = process.env.DB_URL;
|
||||
if (!url) throw new Error('Set DB_URL (app role)');
|
||||
const client = postgres(url, { max: 1, connect_timeout: 10, onnotice: () => {} });
|
||||
try {
|
||||
const [registry] = await client`select to_regprocedure('meta.sync(integer)') is not null as ok`;
|
||||
if (!registry.ok) {
|
||||
console.log('meta.sync() not present; skipping');
|
||||
} else {
|
||||
const [row] = await client`select meta.sync() as added`;
|
||||
console.log(`meta.sync(): ${row.added} column(s) added`);
|
||||
}
|
||||
} finally {
|
||||
await client.end();
|
||||
}
|
||||
Reference in New Issue
Block a user