From e5017e3449c5e17045498dd116047421b50bf398 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sat, 9 May 2026 07:56:19 +0000 Subject: [PATCH 1/2] feat(export): add 6 new services_public settings tables to export Add database_settings, api_settings, rls_settings, cors_settings, pubkey_settings, and webauthn_settings to META_TABLE_CONFIG, META_TABLE_ORDER, exportMeta(), and exportGraphQLMeta(). These tables were added in constructive-db#1060 as part of the unified runtime settings architecture (constructive-planning#812). --- pgpm/export/src/export-graphql-meta.ts | 8 +- pgpm/export/src/export-meta.ts | 6 ++ pgpm/export/src/export-utils.ts | 107 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/pgpm/export/src/export-graphql-meta.ts b/pgpm/export/src/export-graphql-meta.ts index bfdb1a80f2..775f839d41 100644 --- a/pgpm/export/src/export-graphql-meta.ts +++ b/pgpm/export/src/export-graphql-meta.ts @@ -152,7 +152,13 @@ export const exportGraphQLMeta = async ({ queryAndParse('site_metadata'), queryAndParse('api_modules'), queryAndParse('api_extensions'), - queryAndParse('api_schemas') + queryAndParse('api_schemas'), + queryAndParse('database_settings'), + queryAndParse('api_settings'), + queryAndParse('rls_settings'), + queryAndParse('cors_settings'), + queryAndParse('pubkey_settings'), + queryAndParse('webauthn_settings') ]); // metaschema_modules_public tables diff --git a/pgpm/export/src/export-meta.ts b/pgpm/export/src/export-meta.ts index 7badc0d86b..3949413f60 100644 --- a/pgpm/export/src/export-meta.ts +++ b/pgpm/export/src/export-meta.ts @@ -161,6 +161,12 @@ export const exportMeta = async ({ opts, dbname, database_id }: ExportMetaParams await queryAndParse('api_modules', `SELECT * FROM services_public.api_modules WHERE database_id = $1 ORDER BY id`); await queryAndParse('api_extensions', `SELECT * FROM services_public.api_extensions WHERE database_id = $1 ORDER BY id`); await queryAndParse('api_schemas', `SELECT * FROM services_public.api_schemas WHERE database_id = $1 ORDER BY id`); + await queryAndParse('database_settings', `SELECT * FROM services_public.database_settings WHERE database_id = $1 ORDER BY id`); + await queryAndParse('api_settings', `SELECT * FROM services_public.api_settings WHERE database_id = $1 ORDER BY id`); + await queryAndParse('rls_settings', `SELECT * FROM services_public.rls_settings WHERE database_id = $1 ORDER BY id`); + await queryAndParse('cors_settings', `SELECT * FROM services_public.cors_settings WHERE database_id = $1 ORDER BY id`); + await queryAndParse('pubkey_settings', `SELECT * FROM services_public.pubkey_settings WHERE database_id = $1 ORDER BY id`); + await queryAndParse('webauthn_settings', `SELECT * FROM services_public.webauthn_settings WHERE database_id = $1 ORDER BY id`); // ============================================================================= // metaschema_modules_public tables diff --git a/pgpm/export/src/export-utils.ts b/pgpm/export/src/export-utils.ts index 4a3f62052d..378b29f59c 100644 --- a/pgpm/export/src/export-utils.ts +++ b/pgpm/export/src/export-utils.ts @@ -149,6 +149,12 @@ export const META_TABLE_ORDER = [ 'api_modules', 'api_extensions', 'api_schemas', + 'database_settings', + 'api_settings', + 'rls_settings', + 'cors_settings', + 'pubkey_settings', + 'webauthn_settings', 'rls_module', 'user_auth_module', 'memberships_module', @@ -559,6 +565,107 @@ export const META_TABLE_CONFIG: Record = { api_id: 'uuid' } }, + database_settings: { + schema: 'services_public', + table: 'database_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + enable_aggregates: 'boolean', + enable_postgis: 'boolean', + enable_search: 'boolean', + enable_direct_uploads: 'boolean', + enable_presigned_uploads: 'boolean', + enable_many_to_many: 'boolean', + enable_connection_filter: 'boolean', + enable_ltree: 'boolean', + enable_llm: 'boolean', + options: 'jsonb' + } + }, + api_settings: { + schema: 'services_public', + table: 'api_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + api_id: 'uuid', + enable_aggregates: 'boolean', + enable_postgis: 'boolean', + enable_search: 'boolean', + enable_direct_uploads: 'boolean', + enable_presigned_uploads: 'boolean', + enable_many_to_many: 'boolean', + enable_connection_filter: 'boolean', + enable_ltree: 'boolean', + enable_llm: 'boolean', + options: 'jsonb' + } + }, + rls_settings: { + schema: 'services_public', + table: 'rls_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + authenticate: 'text', + authenticate_strict: 'text', + authenticate_schema: 'text', + role_schema: 'text', + current_role_fn: 'text', + current_role_id_fn: 'text', + current_user_agent_fn: 'text', + current_ip_address_fn: 'text' + } + }, + cors_settings: { + schema: 'services_public', + table: 'cors_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + api_id: 'uuid', + allowed_origins: 'text[]' + } + }, + pubkey_settings: { + schema: 'services_public', + table: 'pubkey_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + schema: 'text', + crypto_network: 'text', + user_field: 'text', + sign_up_with_key: 'text', + sign_in_request_challenge: 'text', + sign_in_record_failure: 'text', + sign_in_with_challenge: 'text' + } + }, + webauthn_settings: { + schema: 'services_public', + table: 'webauthn_settings', + fields: { + id: 'uuid', + database_id: 'uuid', + schema: 'text', + credentials_schema: 'text', + credentials_table: 'text', + sessions_schema: 'text', + sessions_table: 'text', + session_credentials_table: 'text', + session_secrets_schema: 'text', + session_secrets_table: 'text', + rp_id: 'text', + rp_name: 'text', + origin_allowlist: 'text[]', + attestation_type: 'text', + require_user_verification: 'boolean', + resident_key: 'text', + challenge_expiry_seconds: 'int' + } + }, // ============================================================================= // metaschema_modules_public tables // ============================================================================= From 7d7b75926d89088640bc98989b76544a0b7c1495 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sat, 9 May 2026 16:53:51 +0000 Subject: [PATCH 2/2] feat(export): update settings table configs to use UUID FK fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rls_settings: schema/function text fields → uuid FK fields - pubkey_settings: schema/function text fields → uuid FK fields - webauthn_settings: schema/table/field text fields → uuid FK fields - Matches constructive-db PR #1060 schema changes for #816 and #817 --- pgpm/export/src/export-utils.ts | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/pgpm/export/src/export-utils.ts b/pgpm/export/src/export-utils.ts index 378b29f59c..49b680aa1c 100644 --- a/pgpm/export/src/export-utils.ts +++ b/pgpm/export/src/export-utils.ts @@ -608,14 +608,14 @@ export const META_TABLE_CONFIG: Record = { fields: { id: 'uuid', database_id: 'uuid', - authenticate: 'text', - authenticate_strict: 'text', - authenticate_schema: 'text', - role_schema: 'text', - current_role_fn: 'text', - current_role_id_fn: 'text', - current_user_agent_fn: 'text', - current_ip_address_fn: 'text' + authenticate_schema_id: 'uuid', + role_schema_id: 'uuid', + authenticate_function_id: 'uuid', + authenticate_strict_function_id: 'uuid', + current_role_function_id: 'uuid', + current_role_id_function_id: 'uuid', + current_user_agent_function_id: 'uuid', + current_ip_address_function_id: 'uuid' } }, cors_settings: { @@ -634,13 +634,13 @@ export const META_TABLE_CONFIG: Record = { fields: { id: 'uuid', database_id: 'uuid', - schema: 'text', + schema_id: 'uuid', crypto_network: 'text', user_field: 'text', - sign_up_with_key: 'text', - sign_in_request_challenge: 'text', - sign_in_record_failure: 'text', - sign_in_with_challenge: 'text' + sign_up_with_key_function_id: 'uuid', + sign_in_request_challenge_function_id: 'uuid', + sign_in_record_failure_function_id: 'uuid', + sign_in_with_challenge_function_id: 'uuid' } }, webauthn_settings: { @@ -649,14 +649,15 @@ export const META_TABLE_CONFIG: Record = { fields: { id: 'uuid', database_id: 'uuid', - schema: 'text', - credentials_schema: 'text', - credentials_table: 'text', - sessions_schema: 'text', - sessions_table: 'text', - session_credentials_table: 'text', - session_secrets_schema: 'text', - session_secrets_table: 'text', + schema_id: 'uuid', + credentials_schema_id: 'uuid', + sessions_schema_id: 'uuid', + session_secrets_schema_id: 'uuid', + credentials_table_id: 'uuid', + sessions_table_id: 'uuid', + session_credentials_table_id: 'uuid', + session_secrets_table_id: 'uuid', + user_field_id: 'uuid', rp_id: 'text', rp_name: 'text', origin_allowlist: 'text[]',