Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions graphql/server/src/middleware/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ const toRlsModule = (row: RlsModuleRow | null): RlsModule | undefined => {

const toRlsModuleFromSettings = (row: RlsModuleData | null): RlsModule | undefined => {
if (!row) return undefined;
// If metaschema_public.function rows are missing (e.g. trigger was skipped
// during migration), the LEFT JOINs resolve NULL. Return undefined so the
// caller falls back to the legacy api_modules lookup.
if (!row.authenticate || !row.authenticate_schema) return undefined;
return {
authenticate: row.authenticate,
authenticateStrict: row.authenticate_strict,
Expand Down
1 change: 1 addition & 0 deletions pgpm/export/src/export-graphql-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const exportGraphQLMeta = async ({
queryAndParse('database'),
queryAndParse('database_extension'),
queryAndParse('schema'),
queryAndParse('function'),
queryAndParse('table'),
queryAndParse('field'),
queryAndParse('policy'),
Expand Down
1 change: 1 addition & 0 deletions pgpm/export/src/export-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const exportMeta = async ({ opts, dbname, database_id }: ExportMetaParams
await queryAndParse('database', `SELECT * FROM metaschema_public.database WHERE id = $1 ORDER BY id`);
await queryAndParse('database_extension', `SELECT * FROM metaschema_public.database_extension WHERE database_id = $1 ORDER BY id`);
await queryAndParse('schema', `SELECT * FROM metaschema_public.schema WHERE database_id = $1 ORDER BY id`);
await queryAndParse('function', `SELECT * FROM metaschema_public.function WHERE database_id = $1 ORDER BY id`);
await queryAndParse('table', `SELECT * FROM metaschema_public.table WHERE database_id = $1 ORDER BY id`);
await queryAndParse('field', `SELECT * FROM metaschema_public.field WHERE database_id = $1 ORDER BY id`);
await queryAndParse('policy', `SELECT * FROM metaschema_public.policy WHERE database_id = $1 ORDER BY id`);
Expand Down
11 changes: 11 additions & 0 deletions pgpm/export/src/export-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ SET session_replication_role TO DEFAULT;`;
export const META_TABLE_ORDER = [
'database',
'schema',
'function',
'table',
'field',
'policy',
Expand Down Expand Up @@ -243,6 +244,16 @@ export const META_TABLE_CONFIG: Record<string, TableConfig> = {
is_public: 'boolean'
}
},
function: {
schema: 'metaschema_public',
table: 'function',
fields: {
id: 'uuid',
database_id: 'uuid',
schema_id: 'uuid',
name: 'text'
}
},
table: {
schema: 'metaschema_public',
table: 'table',
Expand Down
Loading