@pgpm/metaschema-modules 0.26.3 → 0.26.6
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/README.md +19 -4
- 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_invocation_module/table.sql +67 -0
- package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +14 -33
- 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 +17 -8
- package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +8 -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 +11 -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 +4 -4
- package/pgpm.plan +5 -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/function_invocation_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.5.sql} +565 -262
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/function_invocation_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
|
@@ -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;
|
|
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.inference_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,
|
|
@@ -21,13 +21,19 @@ CREATE TABLE metaschema_modules_public.invites_module (
|
|
|
21
21
|
claimed_invites_table_name text NOT NULL DEFAULT '',
|
|
22
22
|
submit_invite_code_function text NOT NULL DEFAULT '',
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
-- Scope: determines the security level for this module instance.
|
|
25
|
+
scope text NOT NULL DEFAULT 'app',
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
28
|
+
prefix text NOT NULL DEFAULT '',
|
|
29
|
+
|
|
30
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
29
31
|
entity_table_id uuid NULL,
|
|
30
32
|
|
|
33
|
+
-- API routing (configurable per-module)
|
|
34
|
+
api_name text DEFAULT 'admin',
|
|
35
|
+
private_api_name text DEFAULT NULL,
|
|
36
|
+
|
|
31
37
|
--
|
|
32
38
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
33
39
|
CONSTRAINT invites_table_fkey FOREIGN KEY (invites_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -41,12 +47,8 @@ CREATE TABLE metaschema_modules_public.invites_module (
|
|
|
41
47
|
|
|
42
48
|
CREATE INDEX invites_module_database_id_idx ON metaschema_modules_public.invites_module ( database_id );
|
|
43
49
|
|
|
44
|
-
-- Unique constraint
|
|
45
|
-
-- entity_type_provision fan-out can use ON CONFLICT DO NOTHING for idempotent
|
|
46
|
-
-- re-provisioning. invites_module is always entity-scoped (membership_type
|
|
47
|
-
-- is NOT NULL on this table), so no COALESCE-NULL trick is needed here,
|
|
48
|
-
-- unlike storage_module which supports an app-level singleton row.
|
|
50
|
+
-- Unique constraint: one invites module per database per scope per prefix.
|
|
49
51
|
CREATE UNIQUE INDEX invites_module_unique_scope
|
|
50
|
-
ON metaschema_modules_public.invites_module (database_id,
|
|
52
|
+
ON metaschema_modules_public.invites_module (database_id, scope, prefix);
|
|
51
53
|
|
|
52
54
|
COMMIT;
|
|
@@ -61,16 +61,22 @@ CREATE TABLE metaschema_modules_public.limits_module (
|
|
|
61
61
|
limit_check_soft_function text NOT NULL DEFAULT '',
|
|
62
62
|
limit_aggregate_check_soft_function text NOT NULL DEFAULT '',
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
-- Scope: determines the security level for this module instance.
|
|
65
|
+
scope text NOT NULL DEFAULT 'app',
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
68
|
+
prefix text NOT NULL DEFAULT '',
|
|
69
|
+
|
|
70
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
69
71
|
entity_table_id uuid NULL,
|
|
70
72
|
|
|
71
73
|
-- required tables
|
|
72
74
|
actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
73
75
|
|
|
76
|
+
-- API routing (configurable per-module)
|
|
77
|
+
api_name text DEFAULT 'usage',
|
|
78
|
+
private_api_name text DEFAULT NULL,
|
|
79
|
+
|
|
74
80
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
75
81
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
76
82
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -41,15 +41,16 @@ CREATE TABLE metaschema_modules_public.memberships_module (
|
|
|
41
41
|
owner_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
42
42
|
owner_grants_table_name text NOT NULL DEFAULT '',
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
-- Scope: determines the security level for this module instance.
|
|
45
|
+
scope text NOT NULL DEFAULT 'app',
|
|
45
46
|
|
|
46
|
-
--
|
|
47
|
-
|
|
47
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
48
|
+
prefix text NOT NULL DEFAULT '',
|
|
49
|
+
|
|
50
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
48
51
|
entity_table_id uuid NULL,
|
|
49
52
|
entity_table_owner_id uuid NULL,
|
|
50
53
|
|
|
51
|
-
prefix text NULL,
|
|
52
|
-
|
|
53
54
|
-- Populated by memberships_module generator when get_organization_id is created
|
|
54
55
|
get_org_fn text NULL,
|
|
55
56
|
|
|
@@ -63,8 +64,14 @@ CREATE TABLE metaschema_modules_public.memberships_module (
|
|
|
63
64
|
|
|
64
65
|
member_profiles_table_id uuid NULL,
|
|
65
66
|
|
|
66
|
-
--
|
|
67
|
-
|
|
67
|
+
-- Audit tables for permission defaults (created by memberships_module when has_permissions=true)
|
|
68
|
+
permission_default_permissions_table_id uuid NULL,
|
|
69
|
+
permission_default_grants_table_id uuid NULL,
|
|
70
|
+
|
|
71
|
+
-- API routing (configurable per-module)
|
|
72
|
+
api_name text DEFAULT 'admin',
|
|
73
|
+
private_api_name text DEFAULT NULL,
|
|
74
|
+
|
|
68
75
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
69
76
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
70
77
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -83,7 +90,9 @@ CREATE TABLE metaschema_modules_public.memberships_module (
|
|
|
83
90
|
CONSTRAINT default_limits_table_fkey FOREIGN KEY (default_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
84
91
|
|
|
85
92
|
CONSTRAINT permissions_table_fkey FOREIGN KEY (permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
86
|
-
CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
93
|
+
CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
94
|
+
|
|
95
|
+
CONSTRAINT memberships_module_unique UNIQUE (database_id, scope, prefix)
|
|
87
96
|
);
|
|
88
97
|
|
|
89
98
|
CREATE INDEX memberships_module_database_id_idx ON metaschema_modules_public.memberships_module ( database_id );
|
|
@@ -30,8 +30,14 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
|
|
|
30
30
|
api_name text,
|
|
31
31
|
private_api_name text,
|
|
32
32
|
|
|
33
|
-
-- Scope
|
|
34
|
-
|
|
33
|
+
-- Scope: 'app' for app-level, 'platform' for database-scoped with
|
|
34
|
+
-- RLS through metaschema_public.database ownership.
|
|
35
|
+
scope text NOT NULL DEFAULT 'app',
|
|
36
|
+
|
|
37
|
+
-- Function name prefix override: NULL (default) inherits from `prefix`;
|
|
38
|
+
-- '' (empty string) generates unprefixed function names (e.g., get_all instead of function_graph_get_all);
|
|
39
|
+
-- any other value is used as-is. Tables always keep their prefix regardless of this setting.
|
|
40
|
+
function_prefix text DEFAULT NULL,
|
|
35
41
|
|
|
36
42
|
-- Timestamps
|
|
37
43
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
@@ -28,19 +28,18 @@ CREATE TABLE metaschema_modules_public.namespace_module (
|
|
|
28
28
|
api_name text,
|
|
29
29
|
private_api_name text,
|
|
30
30
|
|
|
31
|
-
--
|
|
32
|
-
|
|
31
|
+
-- Scope: determines the security level for this module instance.
|
|
32
|
+
-- Resolved to a membership_type integer at trigger time via membership_types table.
|
|
33
|
+
scope text NOT NULL DEFAULT 'app',
|
|
33
34
|
|
|
34
|
-
--
|
|
35
|
-
--
|
|
36
|
-
|
|
37
|
-
-- Max 16 chars, lowercase snake_case.
|
|
38
|
-
key text NOT NULL DEFAULT 'default',
|
|
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 '',
|
|
39
38
|
|
|
40
39
|
-- Entity table for RLS (NULL for app-level namespaces, entity table for entity-scoped namespaces)
|
|
41
40
|
entity_table_id uuid NULL,
|
|
42
41
|
|
|
43
|
-
-- Configurable security policies (NULL = use defaults based on
|
|
42
|
+
-- Configurable security policies (NULL = use defaults based on scope).
|
|
44
43
|
-- When provided, replaces the default policy set in apply_namespace_security.
|
|
45
44
|
-- Accepts a JSON array of policy objects:
|
|
46
45
|
-- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
|
|
@@ -52,6 +51,10 @@ CREATE TABLE metaschema_modules_public.namespace_module (
|
|
|
52
51
|
-- secure_table_provision applies the custom grants/policies instead.
|
|
53
52
|
provisions jsonb NULL,
|
|
54
53
|
|
|
54
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
55
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
56
|
+
default_permissions text[] DEFAULT NULL,
|
|
57
|
+
|
|
55
58
|
-- Constraints
|
|
56
59
|
CONSTRAINT namespace_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
57
60
|
CONSTRAINT namespace_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -63,9 +66,7 @@ CREATE TABLE metaschema_modules_public.namespace_module (
|
|
|
63
66
|
|
|
64
67
|
CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module ( database_id );
|
|
65
68
|
|
|
66
|
-
-- Unique constraint
|
|
67
|
-
|
|
68
|
-
-- multiple namespace modules for the same scope (e.g. 'config' + 'content').
|
|
69
|
-
CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, COALESCE(membership_type, -1), key );
|
|
69
|
+
-- Unique constraint: one namespace module per database per scope per prefix.
|
|
70
|
+
CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, scope, prefix );
|
|
70
71
|
|
|
71
72
|
COMMIT;
|
|
@@ -19,6 +19,7 @@ CREATE TABLE metaschema_modules_public.notifications_module (
|
|
|
19
19
|
preferences_table_id uuid,
|
|
20
20
|
channels_table_id uuid,
|
|
21
21
|
delivery_log_table_id uuid,
|
|
22
|
+
suppressions_table_id uuid,
|
|
22
23
|
|
|
23
24
|
owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
24
25
|
|
|
@@ -36,6 +37,14 @@ CREATE TABLE metaschema_modules_public.notifications_module (
|
|
|
36
37
|
has_digest_metadata boolean NOT NULL DEFAULT false,
|
|
37
38
|
has_subscriptions boolean NOT NULL DEFAULT false,
|
|
38
39
|
|
|
40
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
41
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
42
|
+
default_permissions text[] DEFAULT NULL,
|
|
43
|
+
|
|
44
|
+
-- API routing (configurable per-module)
|
|
45
|
+
api_name text DEFAULT 'notifications',
|
|
46
|
+
private_api_name text DEFAULT NULL,
|
|
47
|
+
|
|
39
48
|
--
|
|
40
49
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
41
50
|
CONSTRAINT notifications_table_fkey FOREIGN KEY (notifications_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -43,6 +52,7 @@ CREATE TABLE metaschema_modules_public.notifications_module (
|
|
|
43
52
|
CONSTRAINT preferences_table_fkey FOREIGN KEY (preferences_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
44
53
|
CONSTRAINT channels_table_fkey FOREIGN KEY (channels_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
45
54
|
CONSTRAINT delivery_log_table_fkey FOREIGN KEY (delivery_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
55
|
+
CONSTRAINT suppressions_table_fkey FOREIGN KEY (suppressions_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
46
56
|
CONSTRAINT owner_table_fkey FOREIGN KEY (owner_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
47
57
|
CONSTRAINT user_settings_table_fkey FOREIGN KEY (user_settings_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
48
58
|
CONSTRAINT organization_settings_table_fkey FOREIGN KEY (organization_settings_table_id) REFERENCES metaschema_public.table (id) ON DELETE SET NULL,
|
|
@@ -57,6 +67,7 @@ COMMENT ON CONSTRAINT read_state_table_fkey ON metaschema_modules_public.notific
|
|
|
57
67
|
COMMENT ON CONSTRAINT preferences_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName preferencesTableByPreferencesTableId\n@omit manyToMany';
|
|
58
68
|
COMMENT ON CONSTRAINT channels_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName channelsTableByChannelsTableId\n@omit manyToMany';
|
|
59
69
|
COMMENT ON CONSTRAINT delivery_log_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName deliveryLogTableByDeliveryLogTableId\n@omit manyToMany';
|
|
70
|
+
COMMENT ON CONSTRAINT suppressions_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName suppressionsTableBySuppressionsTableId';
|
|
60
71
|
COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.notifications_module IS E'@omit manyToMany';
|
|
61
72
|
COMMENT ON CONSTRAINT user_settings_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName userSettingsTableByUserSettingsTableId\n@omit manyToMany';
|
|
62
73
|
COMMENT ON CONSTRAINT organization_settings_table_fkey ON metaschema_modules_public.notifications_module IS E'@fieldName organizationSettingsTableByOrganizationSettingsTableId\n@omit manyToMany';
|
|
@@ -42,16 +42,19 @@ CREATE TABLE metaschema_modules_public.permissions_module (
|
|
|
42
42
|
-- Existing databases are unaffected; this only changes the default for
|
|
43
43
|
-- newly inserted permissions_module rows.
|
|
44
44
|
bitlen int NOT NULL DEFAULT 64,
|
|
45
|
-
|
|
46
|
-
--
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
-- Scope: determines the security level for this module instance.
|
|
47
|
+
scope text NOT NULL DEFAULT 'app',
|
|
48
|
+
|
|
49
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
50
|
+
prefix text NOT NULL DEFAULT '',
|
|
51
|
+
|
|
52
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
48
53
|
entity_table_id uuid NULL,
|
|
49
54
|
|
|
50
55
|
-- required tables
|
|
51
56
|
actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
52
57
|
|
|
53
|
-
prefix text NULL,
|
|
54
|
-
|
|
55
58
|
--
|
|
56
59
|
|
|
57
60
|
get_padded_mask text NOT NULL DEFAULT '',
|
|
@@ -61,6 +64,10 @@ CREATE TABLE metaschema_modules_public.permissions_module (
|
|
|
61
64
|
|
|
62
65
|
--
|
|
63
66
|
|
|
67
|
+
-- API routing (configurable per-module)
|
|
68
|
+
api_name text DEFAULT 'admin',
|
|
69
|
+
private_api_name text DEFAULT NULL,
|
|
70
|
+
|
|
64
71
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
65
72
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
66
73
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -16,6 +16,10 @@ CREATE TABLE metaschema_modules_public.phone_numbers_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,
|
|
@@ -25,12 +25,26 @@ CREATE TABLE metaschema_modules_public.plans_module (
|
|
|
25
25
|
-- Plan overrides table: per-entity custom limit overrides
|
|
26
26
|
plan_overrides_table_id uuid NULL,
|
|
27
27
|
|
|
28
|
+
-- Plan meter limits table: maps plan → meter slug → billing quota
|
|
29
|
+
plan_meter_limits_table_id uuid NULL,
|
|
30
|
+
|
|
31
|
+
-- Plan caps table: maps plan → cap name → cap value (feature flags)
|
|
32
|
+
plan_caps_table_id uuid NULL,
|
|
33
|
+
|
|
28
34
|
-- Generated apply_plan functions (one per limits scope)
|
|
29
35
|
apply_plan_function text NOT NULL DEFAULT '',
|
|
30
36
|
apply_plan_aggregate_function text NOT NULL DEFAULT '',
|
|
31
37
|
|
|
38
|
+
-- Generated apply functions for billing and caps (set when respective modules are installed)
|
|
39
|
+
apply_billing_plan_function text NULL,
|
|
40
|
+
apply_plan_caps_function text NULL,
|
|
41
|
+
|
|
32
42
|
prefix text NULL,
|
|
33
43
|
|
|
44
|
+
-- API routing (configurable per-module)
|
|
45
|
+
api_name text DEFAULT 'usage',
|
|
46
|
+
private_api_name text DEFAULT NULL,
|
|
47
|
+
|
|
34
48
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
35
49
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
36
50
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -38,6 +52,8 @@ CREATE TABLE metaschema_modules_public.plans_module (
|
|
|
38
52
|
CONSTRAINT plan_limits_table_fkey FOREIGN KEY (plan_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
39
53
|
CONSTRAINT plan_pricing_table_fkey FOREIGN KEY (plan_pricing_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
40
54
|
CONSTRAINT plan_overrides_table_fkey FOREIGN KEY (plan_overrides_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
55
|
+
CONSTRAINT plan_meter_limits_table_fkey FOREIGN KEY (plan_meter_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
56
|
+
CONSTRAINT plan_caps_table_fkey FOREIGN KEY (plan_caps_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
41
57
|
CONSTRAINT plans_module_database_id_unique UNIQUE (database_id)
|
|
42
58
|
);
|
|
43
59
|
|
|
@@ -31,7 +31,11 @@ CREATE TABLE metaschema_modules_public.profiles_module (
|
|
|
31
31
|
profile_templates_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
32
32
|
profile_templates_table_name text NOT NULL DEFAULT '',
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
-- Scope: determines the security level for this module instance.
|
|
35
|
+
scope text NOT NULL DEFAULT 'app',
|
|
36
|
+
|
|
37
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
38
|
+
prefix text NOT NULL DEFAULT '',
|
|
35
39
|
|
|
36
40
|
-- Entity table for org/group scoped profiles (NULL for app-level)
|
|
37
41
|
entity_table_id uuid NULL,
|
|
@@ -41,8 +45,10 @@ CREATE TABLE metaschema_modules_public.profiles_module (
|
|
|
41
45
|
permissions_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
42
46
|
memberships_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
-- API routing (configurable per-module)
|
|
49
|
+
api_name text DEFAULT 'admin',
|
|
50
|
+
private_api_name text DEFAULT NULL,
|
|
51
|
+
|
|
46
52
|
--
|
|
47
53
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
48
54
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -57,7 +63,7 @@ CREATE TABLE metaschema_modules_public.profiles_module (
|
|
|
57
63
|
CONSTRAINT permissions_table_fkey FOREIGN KEY (permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
58
64
|
CONSTRAINT memberships_table_fkey FOREIGN KEY (memberships_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
59
65
|
|
|
60
|
-
CONSTRAINT profiles_module_unique UNIQUE (database_id,
|
|
66
|
+
CONSTRAINT profiles_module_unique UNIQUE (database_id, scope, prefix)
|
|
61
67
|
);
|
|
62
68
|
|
|
63
69
|
CREATE INDEX profiles_module_database_id_idx ON metaschema_modules_public.profiles_module ( database_id );
|
|
@@ -30,6 +30,14 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
|
|
|
30
30
|
|
|
31
31
|
prefix text NULL,
|
|
32
32
|
|
|
33
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
34
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
35
|
+
default_permissions text[] DEFAULT NULL,
|
|
36
|
+
|
|
37
|
+
-- API routing (configurable per-module)
|
|
38
|
+
api_name text DEFAULT 'usage',
|
|
39
|
+
private_api_name text DEFAULT NULL,
|
|
40
|
+
|
|
33
41
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
34
42
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
35
43
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -27,6 +27,10 @@ CREATE TABLE metaschema_modules_public.realtime_module (
|
|
|
27
27
|
notify_channel text NULL,
|
|
28
28
|
|
|
29
29
|
-- Constraints
|
|
30
|
+
-- API routing (configurable per-module)
|
|
31
|
+
api_name text DEFAULT 'realtime',
|
|
32
|
+
private_api_name text DEFAULT NULL,
|
|
33
|
+
|
|
30
34
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
31
35
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
32
36
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -22,6 +22,10 @@ CREATE TABLE metaschema_modules_public.rls_module (
|
|
|
22
22
|
"current_role" text NOT NULL DEFAULT 'current_user',
|
|
23
23
|
current_role_id text NOT NULL DEFAULT 'current_user_id',
|
|
24
24
|
|
|
25
|
+
-- API routing (configurable per-module)
|
|
26
|
+
api_name text DEFAULT 'auth',
|
|
27
|
+
private_api_name text DEFAULT NULL,
|
|
28
|
+
|
|
25
29
|
--
|
|
26
30
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
27
31
|
CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.storage_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,
|
|
@@ -17,19 +17,18 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
17
17
|
files_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
18
|
|
|
19
19
|
-- Table names (input to the generator)
|
|
20
|
-
buckets_table_name text NOT NULL DEFAULT '
|
|
21
|
-
files_table_name text NOT NULL DEFAULT '
|
|
20
|
+
buckets_table_name text NOT NULL DEFAULT 'buckets',
|
|
21
|
+
files_table_name text NOT NULL DEFAULT 'files',
|
|
22
22
|
|
|
23
|
-
--
|
|
24
|
-
|
|
23
|
+
-- Scope: determines the security level for this module instance.
|
|
24
|
+
-- Resolved to a membership_type integer at trigger time via membership_types table.
|
|
25
|
+
scope text NOT NULL DEFAULT 'app',
|
|
25
26
|
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
|
|
29
|
-
-- Max 16 chars, lowercase snake_case, cannot be 'buckets'/'files'/'bucket'/'file'.
|
|
30
|
-
key text NOT NULL DEFAULT 'default',
|
|
27
|
+
-- Table name prefix. Auto-derived from scope by the trigger when empty.
|
|
28
|
+
-- Override to create multiple module instances at the same scope.
|
|
29
|
+
prefix text NOT NULL DEFAULT '',
|
|
31
30
|
|
|
32
|
-
-- Configurable security policies (NULL = use defaults based on
|
|
31
|
+
-- Configurable security policies (NULL = use defaults based on scope).
|
|
33
32
|
-- When provided, replaces the default policy set in apply_storage_security.
|
|
34
33
|
-- Accepts a JSON array of policy objects:
|
|
35
34
|
-- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
|
|
@@ -87,7 +86,15 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
87
86
|
-- Generated table ID for file_events (populated by the generator when has_audit_log=true)
|
|
88
87
|
file_events_table_id uuid NULL DEFAULT NULL,
|
|
89
88
|
|
|
89
|
+
-- Default permissions: permission names auto-granted to new members.
|
|
90
|
+
-- NULL uses the module's built-in defaults; explicit array overrides them.
|
|
91
|
+
default_permissions text[] DEFAULT NULL,
|
|
92
|
+
|
|
90
93
|
-- Constraints
|
|
94
|
+
-- API routing (configurable per-module)
|
|
95
|
+
api_name text DEFAULT 'admin',
|
|
96
|
+
private_api_name text DEFAULT NULL,
|
|
97
|
+
|
|
91
98
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
92
99
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
93
100
|
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -100,9 +107,7 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
100
107
|
|
|
101
108
|
CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module ( database_id );
|
|
102
109
|
|
|
103
|
-
-- Unique constraint
|
|
104
|
-
|
|
105
|
-
-- multiple storage modules for the same entity type (e.g. 'default' + 'fn').
|
|
106
|
-
CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, COALESCE(membership_type, -1), key );
|
|
110
|
+
-- Unique constraint: one storage module per database per scope per prefix.
|
|
111
|
+
CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, scope, prefix );
|
|
107
112
|
|
|
108
113
|
COMMIT;
|
|
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.transfer_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,
|