@pgpm/metaschema-modules 0.26.2 → 0.26.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +1 -1
- package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +35 -24
- package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +13 -0
- package/deploy/schemas/metaschema_modules_public/tables/billing_provider_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +7 -2
- package/deploy/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +82 -0
- package/deploy/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +11 -2
- package/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +0 -4
- package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +14 -4
- package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +14 -27
- package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +10 -8
- package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +10 -3
- package/deploy/schemas/metaschema_modules_public/tables/i18n_module/table.sql +31 -0
- package/deploy/schemas/metaschema_modules_public/tables/identity_providers_module/table.sql +35 -3
- package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +7 -2
- package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +12 -10
- package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +10 -4
- package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +13 -6
- package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +3 -2
- package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +13 -12
- package/deploy/schemas/metaschema_modules_public/tables/notifications_module/table.sql +8 -0
- package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +12 -5
- package/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/plans_module/table.sql +16 -0
- package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +10 -4
- package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +8 -0
- package/deploy/schemas/metaschema_modules_public/tables/realtime_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +7 -2
- package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +19 -14
- package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +7 -2
- package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +42 -0
- package/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +34 -0
- package/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +4 -0
- package/deploy/schemas/metaschema_modules_public/tables/webauthn_credentials_module/table.sql +4 -0
- package/metaschema-modules.control +1 -1
- package/package.json +3 -3
- package/pgpm.plan +4 -0
- package/revert/schemas/metaschema_modules_public/tables/agent_chat_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/i18n_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
- package/sql/{metaschema-modules--0.26.1.sql → metaschema-modules--0.26.3.sql} +318 -62
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/i18n_module/table.sql +9 -0
- package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +3 -1
- package/verify/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
package/Makefile
CHANGED
|
@@ -17,43 +17,49 @@ CREATE TABLE metaschema_modules_public.agent_module (
|
|
|
17
17
|
message_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
18
|
task_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
19
19
|
prompts_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
-
|
|
20
|
+
plan_table_id uuid DEFAULT NULL,
|
|
21
|
+
agent_table_id uuid DEFAULT NULL,
|
|
22
|
+
persona_table_id uuid DEFAULT NULL,
|
|
23
|
+
resource_table_id uuid DEFAULT NULL,
|
|
21
24
|
|
|
22
25
|
-- Table names (input to the generator)
|
|
23
26
|
thread_table_name text NOT NULL DEFAULT 'agent_thread',
|
|
24
27
|
message_table_name text NOT NULL DEFAULT 'agent_message',
|
|
25
28
|
task_table_name text NOT NULL DEFAULT 'agent_task',
|
|
26
29
|
prompts_table_name text NOT NULL DEFAULT 'agent_prompt',
|
|
27
|
-
|
|
30
|
+
plan_table_name text NOT NULL DEFAULT 'agent_plan',
|
|
31
|
+
agent_table_name text NOT NULL DEFAULT 'agent',
|
|
32
|
+
persona_table_name text NOT NULL DEFAULT 'agent_persona',
|
|
33
|
+
resource_table_name text NOT NULL DEFAULT 'agent_resource',
|
|
28
34
|
|
|
29
35
|
-- Feature flags
|
|
30
|
-
|
|
36
|
+
has_plans boolean NOT NULL DEFAULT false,
|
|
37
|
+
has_resources boolean NOT NULL DEFAULT false,
|
|
38
|
+
has_agents boolean NOT NULL DEFAULT false,
|
|
39
|
+
shared boolean NOT NULL DEFAULT false,
|
|
31
40
|
|
|
32
|
-
-- API routing (
|
|
41
|
+
-- API routing (configurable per-module)
|
|
33
42
|
api_name text DEFAULT 'agent',
|
|
43
|
+
private_api_name text DEFAULT NULL,
|
|
34
44
|
|
|
35
|
-
--
|
|
36
|
-
membership_type
|
|
45
|
+
-- Scope: determines the security level for this module instance.
|
|
46
|
+
-- Resolved to a membership_type integer at trigger time via membership_types table.
|
|
47
|
+
scope text NOT NULL DEFAULT 'app',
|
|
37
48
|
|
|
38
|
-
--
|
|
39
|
-
--
|
|
40
|
-
|
|
41
|
-
-- Max 16 chars, lowercase snake_case.
|
|
42
|
-
key text NOT NULL DEFAULT 'default',
|
|
49
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
50
|
+
-- Override to create multiple module instances at the same scope.
|
|
51
|
+
prefix text NOT NULL DEFAULT '',
|
|
43
52
|
|
|
44
53
|
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
45
54
|
entity_table_id uuid NULL,
|
|
46
55
|
|
|
47
|
-
-- Configurable security policies (NULL = use defaults based on
|
|
56
|
+
-- Configurable security policies (NULL = use defaults based on scope)
|
|
48
57
|
policies jsonb NULL,
|
|
49
58
|
|
|
50
|
-
--
|
|
51
|
-
-- NULL = use sensible defaults (768d, 1000
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-- Custom RLS policies for knowledge table (provisions.knowledge.policies)
|
|
55
|
-
-- NULL = use defaults (AuthzEntityMembership or AuthzAppMembership)
|
|
56
|
-
knowledge_policies jsonb NULL,
|
|
59
|
+
-- Resource configuration array (dimensions, chunk_size, chunk_strategy, etc.)
|
|
60
|
+
-- NULL = use sensible defaults (768d, 1000 chunk_size, paragraph strategy)
|
|
61
|
+
-- Example: [{"dimensions": 1536, "chunk_size": 500, "chunk_strategy": "sentence"}]
|
|
62
|
+
resources jsonb NULL,
|
|
57
63
|
|
|
58
64
|
-- Per-table provisions overrides from blueprint config.
|
|
59
65
|
-- Keys are table keys (thread, message, task, prompt, knowledge).
|
|
@@ -61,6 +67,10 @@ CREATE TABLE metaschema_modules_public.agent_module (
|
|
|
61
67
|
-- secure_table_provision applies the custom grants/policies instead.
|
|
62
68
|
provisions jsonb NULL,
|
|
63
69
|
|
|
70
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
71
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
72
|
+
default_permissions text[] DEFAULT NULL,
|
|
73
|
+
|
|
64
74
|
-- Constraints
|
|
65
75
|
CONSTRAINT agent_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
66
76
|
CONSTRAINT agent_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -69,15 +79,16 @@ CREATE TABLE metaschema_modules_public.agent_module (
|
|
|
69
79
|
CONSTRAINT agent_module_message_table_fkey FOREIGN KEY (message_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
70
80
|
CONSTRAINT agent_module_task_table_fkey FOREIGN KEY (task_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
71
81
|
CONSTRAINT agent_module_prompts_table_fkey FOREIGN KEY (prompts_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
72
|
-
CONSTRAINT
|
|
82
|
+
CONSTRAINT agent_module_plan_table_fkey FOREIGN KEY (plan_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
83
|
+
CONSTRAINT agent_module_agent_table_fkey FOREIGN KEY (agent_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
84
|
+
CONSTRAINT agent_module_persona_table_fkey FOREIGN KEY (persona_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
85
|
+
CONSTRAINT agent_module_resource_table_fkey FOREIGN KEY (resource_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
73
86
|
CONSTRAINT agent_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
74
87
|
);
|
|
75
88
|
|
|
76
89
|
CREATE INDEX agent_module_database_id_idx ON metaschema_modules_public.agent_module ( database_id );
|
|
77
90
|
|
|
78
|
-
-- Unique constraint
|
|
79
|
-
|
|
80
|
-
-- multiple agent modules for the same scope (e.g. 'support' + 'internal').
|
|
81
|
-
CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module ( database_id, COALESCE(membership_type, -1), key );
|
|
91
|
+
-- Unique constraint: one agent module per database per scope per prefix.
|
|
92
|
+
CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module ( database_id, scope, prefix );
|
|
82
93
|
|
|
83
94
|
COMMIT;
|
|
@@ -35,11 +35,23 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
35
35
|
meter_sources_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
36
36
|
meter_sources_table_name text NOT NULL DEFAULT '',
|
|
37
37
|
|
|
38
|
+
-- Meter defaults table: app-scope default meter catalog seeded at provision time
|
|
39
|
+
meter_defaults_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
40
|
+
meter_defaults_table_name text NOT NULL DEFAULT '',
|
|
41
|
+
|
|
38
42
|
-- Generated functions
|
|
39
43
|
record_usage_function text NOT NULL DEFAULT '',
|
|
40
44
|
|
|
41
45
|
prefix text NULL,
|
|
42
46
|
|
|
47
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
48
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
49
|
+
default_permissions text[] DEFAULT NULL,
|
|
50
|
+
|
|
51
|
+
-- API routing (configurable per-module)
|
|
52
|
+
api_name text DEFAULT 'usage',
|
|
53
|
+
private_api_name text DEFAULT NULL,
|
|
54
|
+
|
|
43
55
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
44
56
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
45
57
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -49,6 +61,7 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
49
61
|
CONSTRAINT balances_table_fkey FOREIGN KEY (balances_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
50
62
|
CONSTRAINT meter_credits_table_fkey FOREIGN KEY (meter_credits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
51
63
|
CONSTRAINT meter_sources_table_fkey FOREIGN KEY (meter_sources_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
64
|
+
CONSTRAINT meter_defaults_table_fkey FOREIGN KEY (meter_defaults_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
52
65
|
CONSTRAINT billing_module_database_id_unique UNIQUE (database_id)
|
|
53
66
|
);
|
|
54
67
|
|
|
@@ -42,6 +42,10 @@ CREATE TABLE metaschema_modules_public.billing_provider_module (
|
|
|
42
42
|
|
|
43
43
|
prefix text NULL,
|
|
44
44
|
|
|
45
|
+
-- API routing (configurable per-module)
|
|
46
|
+
api_name text DEFAULT NULL,
|
|
47
|
+
private_api_name text DEFAULT NULL,
|
|
48
|
+
|
|
45
49
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
46
50
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
47
51
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.compute_log_module (
|
|
|
24
24
|
retention text NOT NULL DEFAULT '12 months',
|
|
25
25
|
premake int NOT NULL DEFAULT 2,
|
|
26
26
|
|
|
27
|
-
-- Scope configuration: 'app' = per-app usage (actor_id RLS)
|
|
27
|
+
-- Scope configuration: 'app' = per-app usage (actor_id RLS)
|
|
28
28
|
scope text NOT NULL DEFAULT 'app',
|
|
29
29
|
actor_fk_table_id uuid NULL,
|
|
30
30
|
entity_fk_table_id uuid NULL,
|
|
31
31
|
|
|
32
|
-
prefix
|
|
32
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
33
|
+
prefix text NOT NULL DEFAULT '',
|
|
34
|
+
|
|
35
|
+
-- API routing (configurable per-module)
|
|
36
|
+
api_name text DEFAULT 'usage',
|
|
37
|
+
private_api_name text DEFAULT NULL,
|
|
33
38
|
|
|
34
39
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
35
40
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/config_secrets_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.config_secrets_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
-- Schema references (resolved by BEFORE INSERT trigger when uuid_nil)
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
|
|
15
|
+
-- Generated table IDs (populated by the generator)
|
|
16
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
config_definitions_table_id uuid NULL DEFAULT NULL,
|
|
18
|
+
|
|
19
|
+
-- Table name (input — bare name without scope prefix).
|
|
20
|
+
-- The trigger prepends the scope prefix automatically.
|
|
21
|
+
table_name text NOT NULL DEFAULT 'secrets',
|
|
22
|
+
|
|
23
|
+
-- API routing (get-or-create: if set, schema is added to this API)
|
|
24
|
+
api_name text DEFAULT 'config',
|
|
25
|
+
private_api_name text DEFAULT NULL,
|
|
26
|
+
|
|
27
|
+
-- Scope: determines the security level for this module instance.
|
|
28
|
+
-- Resolved to a membership_type integer at trigger time via membership_types table.
|
|
29
|
+
-- 'app' = app-level (AuthzAppMembership, admin-only secrets + config)
|
|
30
|
+
-- 'org' = org-scoped (AuthzEntityMembership, per-org secrets with manage_secrets permission)
|
|
31
|
+
-- custom entity type names for entity-scoped secrets
|
|
32
|
+
-- Note: user-scoped credentials are handled by user_credentials_module (separate module)
|
|
33
|
+
scope text NOT NULL DEFAULT 'app',
|
|
34
|
+
|
|
35
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
36
|
+
-- Override to create multiple module instances at the same scope.
|
|
37
|
+
prefix text NOT NULL DEFAULT '',
|
|
38
|
+
|
|
39
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
40
|
+
entity_table_id uuid NULL,
|
|
41
|
+
|
|
42
|
+
-- Configurable security policies (NULL = use defaults based on scope).
|
|
43
|
+
-- When provided, replaces the default policy set in the security function.
|
|
44
|
+
-- Accepts a JSON array of policy objects:
|
|
45
|
+
-- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
|
|
46
|
+
policies jsonb NULL,
|
|
47
|
+
|
|
48
|
+
-- Per-table provisions overrides from blueprint config.
|
|
49
|
+
-- Keys are table keys (secrets, config_definitions).
|
|
50
|
+
-- When a key is present, the module trigger skips default security for that table;
|
|
51
|
+
-- secure_table_provision applies the custom grants/policies instead.
|
|
52
|
+
provisions jsonb NULL,
|
|
53
|
+
|
|
54
|
+
-- Feature flags
|
|
55
|
+
|
|
56
|
+
-- When true, also creates a plaintext config table ({prefix}_config) and
|
|
57
|
+
-- a config definitions registry table ({prefix}_config_definitions).
|
|
58
|
+
-- Only meaningful for app-level scope (scope = 'app').
|
|
59
|
+
has_config boolean NOT NULL DEFAULT false,
|
|
60
|
+
|
|
61
|
+
-- Constraints
|
|
62
|
+
CONSTRAINT config_secrets_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
63
|
+
CONSTRAINT config_secrets_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
64
|
+
CONSTRAINT config_secrets_module_private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
65
|
+
CONSTRAINT config_secrets_module_table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
66
|
+
CONSTRAINT config_secrets_module_config_defs_table_fkey FOREIGN KEY (config_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
67
|
+
CONSTRAINT config_secrets_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
CREATE INDEX config_secrets_module_database_id_idx ON metaschema_modules_public.config_secrets_module ( database_id );
|
|
71
|
+
CREATE INDEX config_secrets_module_schema_id_idx ON metaschema_modules_public.config_secrets_module ( schema_id );
|
|
72
|
+
CREATE INDEX config_secrets_module_table_id_idx ON metaschema_modules_public.config_secrets_module ( table_id );
|
|
73
|
+
|
|
74
|
+
-- Unique constraint: one config_secrets module per database per scope per prefix.
|
|
75
|
+
CREATE UNIQUE INDEX config_secrets_module_unique_scope ON metaschema_modules_public.config_secrets_module ( database_id, scope, prefix );
|
|
76
|
+
|
|
77
|
+
COMMENT ON TABLE metaschema_modules_public.config_secrets_module IS
|
|
78
|
+
'Entity-aware PGP-encrypted key-value config/secrets module. Supports app-level (admin-only)
|
|
79
|
+
and org-scoped (per-org secrets with manage_secrets permission) via the scope column.
|
|
80
|
+
User-scoped bcrypt credentials are handled by user_credentials_module.';
|
|
81
|
+
|
|
82
|
+
COMMIT;
|
|
@@ -14,6 +14,10 @@ CREATE TABLE metaschema_modules_public.config_secrets_org_module (
|
|
|
14
14
|
table_name text NOT NULL DEFAULT 'org_secrets',
|
|
15
15
|
--
|
|
16
16
|
|
|
17
|
+
-- API routing (configurable per-module)
|
|
18
|
+
api_name text DEFAULT 'config',
|
|
19
|
+
private_api_name text DEFAULT NULL,
|
|
20
|
+
|
|
17
21
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
18
22
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
19
23
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
package/deploy/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql
CHANGED
|
@@ -17,6 +17,10 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
|
|
|
17
17
|
config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
18
|
--
|
|
19
19
|
|
|
20
|
+
-- API routing (configurable per-module)
|
|
21
|
+
api_name text DEFAULT 'config',
|
|
22
|
+
private_api_name text DEFAULT NULL,
|
|
23
|
+
|
|
20
24
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
21
25
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
22
26
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -16,6 +16,10 @@ CREATE TABLE metaschema_modules_public.connected_accounts_module (
|
|
|
16
16
|
|
|
17
17
|
table_name text NOT NULL,
|
|
18
18
|
|
|
19
|
+
-- API routing (configurable per-module)
|
|
20
|
+
api_name text DEFAULT 'auth',
|
|
21
|
+
private_api_name text DEFAULT NULL,
|
|
22
|
+
|
|
19
23
|
--
|
|
20
24
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
21
25
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -17,6 +17,10 @@ CREATE TABLE metaschema_modules_public.crypto_addresses_module (
|
|
|
17
17
|
table_name text NOT NULL,
|
|
18
18
|
crypto_network text NOT NULL DEFAULT 'BTC',
|
|
19
19
|
|
|
20
|
+
-- API routing (configurable per-module)
|
|
21
|
+
api_name text DEFAULT 'auth',
|
|
22
|
+
private_api_name text DEFAULT NULL,
|
|
23
|
+
|
|
20
24
|
--
|
|
21
25
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
22
26
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -32,10 +32,19 @@ CREATE TABLE metaschema_modules_public.db_usage_module (
|
|
|
32
32
|
retention text NOT NULL DEFAULT '12 months',
|
|
33
33
|
premake int NOT NULL DEFAULT 2,
|
|
34
34
|
|
|
35
|
-
-- Scope configuration: 'app' = per-app usage
|
|
35
|
+
-- Scope configuration: 'app' = per-app usage
|
|
36
36
|
scope text NOT NULL DEFAULT 'app',
|
|
37
37
|
|
|
38
|
-
prefix
|
|
38
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
39
|
+
prefix text NOT NULL DEFAULT '',
|
|
40
|
+
|
|
41
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
42
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
43
|
+
default_permissions text[] DEFAULT NULL,
|
|
44
|
+
|
|
45
|
+
-- API routing (configurable per-module)
|
|
46
|
+
api_name text DEFAULT 'usage',
|
|
47
|
+
private_api_name text DEFAULT NULL,
|
|
39
48
|
|
|
40
49
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
41
50
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -16,6 +16,10 @@ CREATE TABLE metaschema_modules_public.emails_module (
|
|
|
16
16
|
|
|
17
17
|
table_name text NOT NULL,
|
|
18
18
|
|
|
19
|
+
-- API routing (configurable per-module)
|
|
20
|
+
api_name text DEFAULT 'auth',
|
|
21
|
+
private_api_name text DEFAULT NULL,
|
|
22
|
+
|
|
19
23
|
--
|
|
20
24
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
21
25
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -137,10 +137,6 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
|
|
|
137
137
|
|
|
138
138
|
out_secret_definitions_table_id uuid DEFAULT NULL,
|
|
139
139
|
|
|
140
|
-
out_requirements_table_id uuid DEFAULT NULL,
|
|
141
|
-
|
|
142
|
-
out_config_requirements_table_id uuid DEFAULT NULL,
|
|
143
|
-
|
|
144
140
|
out_graph_module_id uuid DEFAULT NULL,
|
|
145
141
|
|
|
146
142
|
out_graphs_table_id uuid DEFAULT NULL,
|
|
@@ -54,17 +54,27 @@ CREATE TABLE metaschema_modules_public.events_module (
|
|
|
54
54
|
retention text DEFAULT '12 months',
|
|
55
55
|
premake int NOT NULL DEFAULT 2,
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
-- Scope: determines the security level for this module instance.
|
|
58
|
+
scope text NOT NULL DEFAULT 'app',
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
61
|
+
prefix text NOT NULL DEFAULT '',
|
|
62
|
+
|
|
63
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
62
64
|
entity_table_id uuid NULL,
|
|
63
65
|
|
|
64
66
|
-- required tables
|
|
65
67
|
actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
66
68
|
|
|
67
69
|
|
|
70
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
71
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
72
|
+
default_permissions text[] DEFAULT NULL,
|
|
73
|
+
|
|
74
|
+
-- API routing (configurable per-module)
|
|
75
|
+
api_name text DEFAULT 'usage',
|
|
76
|
+
private_api_name text DEFAULT NULL,
|
|
77
|
+
|
|
68
78
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
69
79
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
70
80
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -21,9 +21,6 @@ CREATE TABLE metaschema_modules_public.function_module (
|
|
|
21
21
|
invocations_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
22
22
|
execution_logs_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
23
23
|
secret_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
24
|
-
requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
25
|
-
config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
26
|
-
config_requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
27
24
|
|
|
28
25
|
-- Table names (input to the generator — bare names without scope prefix).
|
|
29
26
|
-- The trigger prepends the scope prefix automatically.
|
|
@@ -31,43 +28,38 @@ CREATE TABLE metaschema_modules_public.function_module (
|
|
|
31
28
|
invocations_table_name text NOT NULL DEFAULT 'function_invocations',
|
|
32
29
|
execution_logs_table_name text NOT NULL DEFAULT 'function_execution_logs',
|
|
33
30
|
secret_definitions_table_name text NOT NULL DEFAULT 'secret_definitions',
|
|
34
|
-
requirements_table_name text NOT NULL DEFAULT 'function_secret_requirements',
|
|
35
|
-
config_requirements_table_name text NOT NULL DEFAULT 'function_config_requirements',
|
|
36
31
|
|
|
37
32
|
-- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
|
|
38
33
|
api_name text,
|
|
39
34
|
private_api_name text,
|
|
40
35
|
|
|
41
|
-
--
|
|
42
|
-
|
|
36
|
+
-- Scope: determines the security level for this module instance.
|
|
37
|
+
-- Resolved to a membership_type integer at trigger time via membership_types table.
|
|
38
|
+
scope text NOT NULL DEFAULT 'app',
|
|
43
39
|
|
|
44
|
-
--
|
|
45
|
-
--
|
|
46
|
-
|
|
47
|
-
-- (e.g. prefix='app' + 'function_definitions' → 'app_function_definitions').
|
|
48
|
-
prefix text NULL,
|
|
49
|
-
|
|
50
|
-
-- Module key discriminator: allows multiple function modules per scope.
|
|
51
|
-
-- 'default' is omitted from table names, any other value becomes
|
|
52
|
-
-- an infix: {prefix}_{key}_function_definitions.
|
|
53
|
-
-- Max 16 chars, lowercase snake_case.
|
|
54
|
-
key text NOT NULL DEFAULT 'default',
|
|
40
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
41
|
+
-- Override to create multiple module instances at the same scope.
|
|
42
|
+
prefix text NOT NULL DEFAULT '',
|
|
55
43
|
|
|
56
44
|
-- Entity table for RLS (NULL for app-level functions, entity table for entity-scoped functions)
|
|
57
45
|
entity_table_id uuid NULL,
|
|
58
46
|
|
|
59
|
-
-- Configurable security policies (NULL = use defaults based on
|
|
47
|
+
-- Configurable security policies (NULL = use defaults based on scope).
|
|
60
48
|
-- When provided, replaces the default policy set in apply_function_security.
|
|
61
49
|
-- Accepts a JSON array of policy objects:
|
|
62
50
|
-- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
|
|
63
51
|
policies jsonb NULL,
|
|
64
52
|
|
|
65
53
|
-- Per-table provisions overrides from blueprint config.
|
|
66
|
-
-- Keys are table keys (definitions, invocations, execution_logs, secret_definitions
|
|
54
|
+
-- Keys are table keys (definitions, invocations, execution_logs, secret_definitions).
|
|
67
55
|
-- When a key is present, the module trigger skips default security for that table;
|
|
68
56
|
-- secure_table_provision applies the custom grants/policies instead.
|
|
69
57
|
provisions jsonb NULL,
|
|
70
58
|
|
|
59
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
60
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
61
|
+
default_permissions text[] DEFAULT NULL,
|
|
62
|
+
|
|
71
63
|
-- Constraints
|
|
72
64
|
CONSTRAINT function_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
73
65
|
CONSTRAINT function_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -76,17 +68,12 @@ CREATE TABLE metaschema_modules_public.function_module (
|
|
|
76
68
|
CONSTRAINT function_module_invocations_table_fkey FOREIGN KEY (invocations_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
77
69
|
CONSTRAINT function_module_execution_logs_table_fkey FOREIGN KEY (execution_logs_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
78
70
|
CONSTRAINT function_module_secret_defs_table_fkey FOREIGN KEY (secret_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
79
|
-
CONSTRAINT function_module_requirements_table_fkey FOREIGN KEY (requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
80
|
-
CONSTRAINT function_module_config_defs_table_fkey FOREIGN KEY (config_definitions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
81
|
-
CONSTRAINT function_module_config_reqs_table_fkey FOREIGN KEY (config_requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
82
71
|
CONSTRAINT function_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
83
72
|
);
|
|
84
73
|
|
|
85
74
|
CREATE INDEX function_module_database_id_idx ON metaschema_modules_public.function_module ( database_id );
|
|
86
75
|
|
|
87
|
-
-- Unique constraint
|
|
88
|
-
|
|
89
|
-
-- multiple function modules for the same scope (e.g. 'webhooks' + 'automations').
|
|
90
|
-
CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module ( database_id, COALESCE(membership_type, -1), key );
|
|
76
|
+
-- Unique constraint: one function module per database per scope per prefix.
|
|
77
|
+
CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module ( database_id, scope, prefix );
|
|
91
78
|
|
|
92
79
|
COMMIT;
|
|
@@ -17,8 +17,10 @@ CREATE TABLE metaschema_modules_public.graph_module (
|
|
|
17
17
|
public_schema_name text,
|
|
18
18
|
private_schema_name text,
|
|
19
19
|
|
|
20
|
-
--
|
|
21
|
-
|
|
20
|
+
-- Scope: determines the security level for this module instance.
|
|
21
|
+
scope text NOT NULL DEFAULT 'app',
|
|
22
|
+
|
|
23
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
22
24
|
prefix text NOT NULL DEFAULT '',
|
|
23
25
|
|
|
24
26
|
-- Reference to the Merkle store this graph module depends on
|
|
@@ -33,12 +35,8 @@ CREATE TABLE metaschema_modules_public.graph_module (
|
|
|
33
35
|
api_name text,
|
|
34
36
|
private_api_name text,
|
|
35
37
|
|
|
36
|
-
--
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-- Multi-tenant scoping (entity-aware module pattern)
|
|
40
|
-
membership_type int DEFAULT NULL, -- NULL = database-root, non-NULL = entity-scoped
|
|
41
|
-
entity_table_id uuid NULL, -- Entity table for entity-scoped RLS
|
|
38
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
39
|
+
entity_table_id uuid NULL,
|
|
42
40
|
|
|
43
41
|
-- Configurable security policies (NULL = use defaults).
|
|
44
42
|
-- Accepts a JSON array of policy objects:
|
|
@@ -51,6 +49,10 @@ CREATE TABLE metaschema_modules_public.graph_module (
|
|
|
51
49
|
-- secure_table_provision applies the custom grants/policies instead.
|
|
52
50
|
provisions jsonb NULL,
|
|
53
51
|
|
|
52
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
53
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
54
|
+
default_permissions text[] DEFAULT NULL,
|
|
55
|
+
|
|
54
56
|
-- Timestamps
|
|
55
57
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
56
58
|
|
|
@@ -23,11 +23,14 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
|
|
|
23
23
|
chart_edge_grants_table_name text NOT NULL DEFAULT '',
|
|
24
24
|
|
|
25
25
|
-- Required external table references
|
|
26
|
-
entity_table_id uuid NOT NULL, -- Organizations table (
|
|
26
|
+
entity_table_id uuid NOT NULL, -- Organizations table (entity-scoped)
|
|
27
27
|
users_table_id uuid NOT NULL, -- Users table
|
|
28
|
+
|
|
29
|
+
-- Scope: determines the security level for this module instance.
|
|
30
|
+
scope text NOT NULL DEFAULT 'org',
|
|
28
31
|
|
|
29
|
-
--
|
|
30
|
-
prefix text NOT NULL DEFAULT '
|
|
32
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
33
|
+
prefix text NOT NULL DEFAULT '',
|
|
31
34
|
|
|
32
35
|
-- Resolved names for RLS parser lookups
|
|
33
36
|
private_schema_name text NOT NULL DEFAULT '',
|
|
@@ -39,6 +42,10 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
|
|
|
39
42
|
get_managers_function text NOT NULL DEFAULT '',
|
|
40
43
|
is_manager_of_function text NOT NULL DEFAULT '',
|
|
41
44
|
|
|
45
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
46
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
47
|
+
default_permissions text[] DEFAULT NULL,
|
|
48
|
+
|
|
42
49
|
-- Timestamps
|
|
43
50
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
44
51
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/i18n_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.i18n_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
-- Schema references (populated by the insert trigger)
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
|
|
15
|
+
-- Settings table (populated by the generator)
|
|
16
|
+
settings_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
|
|
18
|
+
-- API routing (configurable per-module)
|
|
19
|
+
api_name text DEFAULT NULL,
|
|
20
|
+
private_api_name text DEFAULT NULL,
|
|
21
|
+
|
|
22
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
23
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
24
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
25
|
+
CONSTRAINT settings_table_fkey FOREIGN KEY (settings_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX i18n_module_database_id_idx ON metaschema_modules_public.i18n_module ( database_id );
|
|
29
|
+
CREATE UNIQUE INDEX i18n_module_unique_per_db ON metaschema_modules_public.i18n_module ( database_id );
|
|
30
|
+
|
|
31
|
+
COMMIT;
|
|
@@ -15,11 +15,30 @@ CREATE TABLE metaschema_modules_public.identity_providers_module (
|
|
|
15
15
|
|
|
16
16
|
table_name text NOT NULL DEFAULT 'identity_providers',
|
|
17
17
|
|
|
18
|
-
--
|
|
18
|
+
-- API routing (configurable per-module)
|
|
19
|
+
api_name text DEFAULT 'auth',
|
|
20
|
+
private_api_name text DEFAULT NULL,
|
|
21
|
+
|
|
22
|
+
-- Entity-aware scope: determines which config_secrets_module table
|
|
23
|
+
-- the rotate_identity_provider_{prefix}_secret proc targets.
|
|
24
|
+
-- 'app' = app_secrets (AuthzAppMembership, admin-only)
|
|
25
|
+
-- 'org' = org_secrets (AuthzEntityMembership, per-org)
|
|
26
|
+
-- Future entity types are also supported via the membership_types table.
|
|
27
|
+
scope text NOT NULL DEFAULT 'app',
|
|
28
|
+
|
|
29
|
+
-- Table name prefix for the generated rotate proc.
|
|
30
|
+
-- Auto-derived from scope by the trigger when empty.
|
|
31
|
+
-- e.g. scope='app' → prefix='app' → rotate_identity_provider_app_secret
|
|
32
|
+
prefix text NOT NULL DEFAULT '',
|
|
33
|
+
|
|
34
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
35
|
+
entity_table_id uuid NULL,
|
|
36
|
+
|
|
19
37
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
20
38
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
21
39
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
22
|
-
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
40
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
41
|
+
CONSTRAINT entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
23
42
|
);
|
|
24
43
|
|
|
25
44
|
CREATE INDEX identity_providers_module_database_id_idx ON metaschema_modules_public.identity_providers_module ( database_id );
|
|
@@ -27,7 +46,20 @@ CREATE INDEX identity_providers_module_schema_id_idx ON metaschema_modules_publi
|
|
|
27
46
|
CREATE INDEX identity_providers_module_private_schema_id_idx ON metaschema_modules_public.identity_providers_module ( private_schema_id );
|
|
28
47
|
CREATE INDEX identity_providers_module_table_id_idx ON metaschema_modules_public.identity_providers_module ( table_id );
|
|
29
48
|
|
|
30
|
-
|
|
49
|
+
-- One install per database per scope
|
|
50
|
+
CREATE UNIQUE INDEX identity_providers_module_unique_scope ON metaschema_modules_public.identity_providers_module ( database_id, scope );
|
|
51
|
+
|
|
52
|
+
COMMENT ON TABLE metaschema_modules_public.identity_providers_module IS
|
|
53
|
+
'Entity-aware config row for the identity_providers_module, which provisions a per-database
|
|
54
|
+
identity_providers table holding OAuth2 / OIDC (and future SAML) provider definitions.
|
|
55
|
+
The scope column determines which config_secrets_module table the rotate proc targets
|
|
56
|
+
(app_secrets for app scope, org_secrets for org scope). When scope = platform,
|
|
57
|
+
the secrets table gets a database_id column and platform-level RLS via
|
|
58
|
+
AuthzRelatedEntityMembership through database.owner_id.
|
|
59
|
+
Scoping matrix:
|
|
60
|
+
scope=app → per-database flat, in-app admin manages
|
|
61
|
+
scope=platform → per-database, platform admin manages (generate:constructive)
|
|
62
|
+
scope=org → per-org tenant, org admin manages';
|
|
31
63
|
COMMENT ON COLUMN metaschema_modules_public.identity_providers_module.private_schema_id IS 'Private schema that hosts SECURITY DEFINER admin helpers which write to identity_providers (create / update / enable / disable / rotate-secret / delete) and the per-app quota check.';
|
|
32
64
|
|
|
33
65
|
COMMIT;
|