@pgpm/metaschema-modules 0.23.0 → 0.26.1
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 +1 -1
- package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +77 -0
- package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +10 -0
- package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +44 -0
- package/deploy/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +28 -0
- package/deploy/schemas/metaschema_modules_public/tables/{encrypted_secrets_module → config_secrets_user_module}/table.sql +4 -4
- package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +52 -0
- package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +135 -49
- package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +85 -0
- package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +68 -0
- package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +73 -0
- package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +44 -0
- package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +11 -1
- package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +50 -0
- package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +65 -0
- package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +51 -0
- package/deploy/schemas/metaschema_modules_public/tables/realtime_module/table.sql +2 -2
- package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +44 -0
- package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +17 -9
- package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +44 -0
- package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +1 -1
- package/deploy/schemas/metaschema_modules_public/tables/{secrets_module → user_state_module}/table.sql +4 -4
- package/metaschema-modules.control +1 -1
- package/package.json +4 -4
- package/pgpm.plan +15 -3
- package/revert/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/events_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/namespace_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/user_state_module/table.sql +7 -0
- package/sql/{metaschema-modules--0.15.5.sql → metaschema-modules--0.26.0.sql} +884 -213
- package/verify/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/billing_module/table.sql +2 -0
- package/verify/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +9 -0
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +10 -0
- package/verify/schemas/metaschema_modules_public/tables/events_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +22 -0
- package/verify/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +14 -0
- package/verify/schemas/metaschema_modules_public/tables/profiles_module/table.sql +2 -1
- package/verify/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +10 -0
- package/verify/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +10 -0
- package/verify/schemas/metaschema_modules_public/tables/user_state_module/table.sql +7 -0
- package/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -64
- package/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -43
- package/revert/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/secrets_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/secrets_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -18
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ The package provides metadata tables for the following modules:
|
|
|
95
95
|
- **permissions_module**: Permission system configuration
|
|
96
96
|
- **memberships_module**: Membership management settings
|
|
97
97
|
- **membership_types_module**: Membership type definitions
|
|
98
|
-
- **
|
|
98
|
+
- **events_module**: User level configurations
|
|
99
99
|
|
|
100
100
|
### Security
|
|
101
101
|
- **encrypted_secrets_module**: Encrypted secrets configuration
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/agent_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.agent_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
-- Schema references (if uuid_nil, resolved from schema name or default)
|
|
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
|
+
thread_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
message_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
|
+
task_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
19
|
+
prompts_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
knowledge_table_id uuid DEFAULT NULL,
|
|
21
|
+
|
|
22
|
+
-- Table names (input to the generator)
|
|
23
|
+
thread_table_name text NOT NULL DEFAULT 'agent_thread',
|
|
24
|
+
message_table_name text NOT NULL DEFAULT 'agent_message',
|
|
25
|
+
task_table_name text NOT NULL DEFAULT 'agent_task',
|
|
26
|
+
prompts_table_name text NOT NULL DEFAULT 'agent_prompt',
|
|
27
|
+
knowledge_table_name text NOT NULL DEFAULT 'agent_knowledge',
|
|
28
|
+
|
|
29
|
+
-- Feature flags
|
|
30
|
+
has_knowledge boolean NOT NULL DEFAULT false,
|
|
31
|
+
|
|
32
|
+
-- API routing (get-or-create: if set, schema is added to this API; if NULL, no API is added)
|
|
33
|
+
api_name text DEFAULT 'agent',
|
|
34
|
+
|
|
35
|
+
-- Multi-tenant scope
|
|
36
|
+
membership_type int DEFAULT NULL,
|
|
37
|
+
|
|
38
|
+
-- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
|
|
39
|
+
entity_table_id uuid NULL,
|
|
40
|
+
|
|
41
|
+
-- Configurable security policies (NULL = use defaults based on membership_type)
|
|
42
|
+
policies jsonb NULL,
|
|
43
|
+
|
|
44
|
+
-- Knowledge RAG config (dimensions, chunk_size, chunk_strategy, search_indexes, etc.)
|
|
45
|
+
-- NULL = use sensible defaults (768d, 1000 chars, paragraph, bm25)
|
|
46
|
+
knowledge_config jsonb NULL,
|
|
47
|
+
|
|
48
|
+
-- Custom RLS policies for knowledge table (provisions.knowledge.policies)
|
|
49
|
+
-- NULL = use defaults (AuthzEntityMembership or AuthzAppMembership)
|
|
50
|
+
knowledge_policies jsonb NULL,
|
|
51
|
+
|
|
52
|
+
-- Per-table provisions overrides from blueprint config.
|
|
53
|
+
-- Keys are table keys (thread, message, task, prompt, knowledge).
|
|
54
|
+
-- When a key is present, the module trigger skips default security for that table;
|
|
55
|
+
-- secure_table_provision applies the custom grants/policies instead.
|
|
56
|
+
provisions jsonb NULL,
|
|
57
|
+
|
|
58
|
+
-- Constraints
|
|
59
|
+
CONSTRAINT agent_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
60
|
+
CONSTRAINT agent_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
61
|
+
CONSTRAINT agent_module_private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
62
|
+
CONSTRAINT agent_module_thread_table_fkey FOREIGN KEY (thread_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
63
|
+
CONSTRAINT agent_module_message_table_fkey FOREIGN KEY (message_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
64
|
+
CONSTRAINT agent_module_task_table_fkey FOREIGN KEY (task_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
65
|
+
CONSTRAINT agent_module_prompts_table_fkey FOREIGN KEY (prompts_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
66
|
+
CONSTRAINT agent_module_knowledge_table_fkey FOREIGN KEY (knowledge_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
67
|
+
CONSTRAINT agent_module_entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
CREATE INDEX agent_module_database_id_idx ON metaschema_modules_public.agent_module ( database_id );
|
|
71
|
+
|
|
72
|
+
-- Unique constraint on (database_id, membership_type) using COALESCE to handle NULLs.
|
|
73
|
+
-- NULL membership_type = app-level, non-NULL = entity-scoped.
|
|
74
|
+
-- Only one agent module per scope.
|
|
75
|
+
CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module ( database_id, COALESCE(membership_type, -1) );
|
|
76
|
+
|
|
77
|
+
COMMIT;
|
|
@@ -27,6 +27,14 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
27
27
|
balances_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
28
28
|
balances_table_name text NOT NULL DEFAULT '',
|
|
29
29
|
|
|
30
|
+
-- Meter credits table: append-only credit grants for billing meters
|
|
31
|
+
meter_credits_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
32
|
+
meter_credits_table_name text NOT NULL DEFAULT '',
|
|
33
|
+
|
|
34
|
+
-- Meter sources table: maps billing meters to typed daily summary table columns
|
|
35
|
+
meter_sources_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
36
|
+
meter_sources_table_name text NOT NULL DEFAULT '',
|
|
37
|
+
|
|
30
38
|
-- Generated functions
|
|
31
39
|
record_usage_function text NOT NULL DEFAULT '',
|
|
32
40
|
|
|
@@ -39,6 +47,8 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
39
47
|
CONSTRAINT plan_subscriptions_table_fkey FOREIGN KEY (plan_subscriptions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
40
48
|
CONSTRAINT ledger_table_fkey FOREIGN KEY (ledger_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
41
49
|
CONSTRAINT balances_table_fkey FOREIGN KEY (balances_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
50
|
+
CONSTRAINT meter_credits_table_fkey FOREIGN KEY (meter_credits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
51
|
+
CONSTRAINT meter_sources_table_fkey FOREIGN KEY (meter_sources_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
42
52
|
CONSTRAINT billing_module_database_id_unique UNIQUE (database_id)
|
|
43
53
|
);
|
|
44
54
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/compute_log_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.compute_log_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
-- Compute log table (partitioned by completed_at)
|
|
15
|
+
compute_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
compute_log_table_name text NOT NULL DEFAULT '',
|
|
17
|
+
|
|
18
|
+
-- Pre-aggregated daily rollup table
|
|
19
|
+
usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
usage_daily_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
-- Partition lifecycle configuration
|
|
23
|
+
"interval" text NOT NULL DEFAULT '1 month',
|
|
24
|
+
retention text NOT NULL DEFAULT '12 months',
|
|
25
|
+
premake int NOT NULL DEFAULT 2,
|
|
26
|
+
|
|
27
|
+
-- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
|
|
28
|
+
scope text NOT NULL DEFAULT 'app',
|
|
29
|
+
actor_fk_table_id uuid NULL,
|
|
30
|
+
entity_fk_table_id uuid NULL,
|
|
31
|
+
|
|
32
|
+
prefix text NULL,
|
|
33
|
+
|
|
34
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
35
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
36
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
37
|
+
CONSTRAINT compute_log_table_fkey FOREIGN KEY (compute_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
38
|
+
CONSTRAINT usage_daily_table_fkey FOREIGN KEY (usage_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
39
|
+
CONSTRAINT compute_log_module_database_id_prefix_unique UNIQUE NULLS NOT DISTINCT (database_id, prefix)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
CREATE INDEX compute_log_module_database_id_idx ON metaschema_modules_public.compute_log_module ( database_id );
|
|
43
|
+
|
|
44
|
+
COMMIT;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/config_secrets_org_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.config_secrets_org_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
table_name text NOT NULL DEFAULT 'org_secrets',
|
|
15
|
+
--
|
|
16
|
+
|
|
17
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
18
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
19
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX config_secrets_org_module_database_id_idx ON metaschema_modules_public.config_secrets_org_module ( database_id );
|
|
23
|
+
CREATE INDEX config_secrets_org_module_schema_id_idx ON metaschema_modules_public.config_secrets_org_module ( schema_id );
|
|
24
|
+
CREATE INDEX config_secrets_org_module_table_id_idx ON metaschema_modules_public.config_secrets_org_module ( table_id );
|
|
25
|
+
|
|
26
|
+
COMMENT ON TABLE metaschema_modules_public.config_secrets_org_module IS 'Config row for the config_secrets_org_module, which provisions an organization-scoped encrypted key-value secrets store with manage_secrets permission and entity-membership RLS.';
|
|
27
|
+
|
|
28
|
+
COMMIT;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_modules_public/tables/
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/config_secrets_user_module/table to pg
|
|
2
2
|
|
|
3
3
|
-- requires: schemas/metaschema_modules_public/schema
|
|
4
4
|
|
|
5
5
|
BEGIN;
|
|
6
6
|
|
|
7
|
-
CREATE TABLE metaschema_modules_public.
|
|
7
|
+
CREATE TABLE metaschema_modules_public.config_secrets_user_module (
|
|
8
8
|
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
9
|
database_id uuid NOT NULL,
|
|
10
10
|
|
|
11
11
|
--
|
|
12
12
|
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
13
|
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
-
table_name text NOT NULL DEFAULT '
|
|
14
|
+
table_name text NOT NULL DEFAULT 'user_secrets',
|
|
15
15
|
--
|
|
16
16
|
|
|
17
17
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
@@ -19,6 +19,6 @@ CREATE TABLE metaschema_modules_public.encrypted_secrets_module (
|
|
|
19
19
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
CREATE INDEX
|
|
22
|
+
CREATE INDEX config_secrets_user_module_database_id_idx ON metaschema_modules_public.config_secrets_user_module ( database_id );
|
|
23
23
|
|
|
24
24
|
COMMIT;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/db_usage_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.db_usage_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
-- DB table stats log (partitioned — per-table reads/writes/size from pg_stat_user_tables)
|
|
15
|
+
table_stats_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
table_stats_log_table_name text NOT NULL DEFAULT '',
|
|
17
|
+
|
|
18
|
+
-- DB table stats daily rollup
|
|
19
|
+
table_stats_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
table_stats_daily_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
-- DB query stats log (partitioned — query execution time from pg_stat_statements)
|
|
23
|
+
query_stats_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
24
|
+
query_stats_log_table_name text NOT NULL DEFAULT '',
|
|
25
|
+
|
|
26
|
+
-- DB query stats daily rollup
|
|
27
|
+
query_stats_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
28
|
+
query_stats_daily_table_name text NOT NULL DEFAULT '',
|
|
29
|
+
|
|
30
|
+
-- Partition lifecycle configuration
|
|
31
|
+
"interval" text NOT NULL DEFAULT '1 month',
|
|
32
|
+
retention text NOT NULL DEFAULT '12 months',
|
|
33
|
+
premake int NOT NULL DEFAULT 2,
|
|
34
|
+
|
|
35
|
+
-- Scope configuration: 'app' = per-app usage, 'platform' = tenant metering (database_id RLS)
|
|
36
|
+
scope text NOT NULL DEFAULT 'app',
|
|
37
|
+
|
|
38
|
+
prefix text NULL,
|
|
39
|
+
|
|
40
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
41
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
42
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
43
|
+
CONSTRAINT table_stats_log_table_fkey FOREIGN KEY (table_stats_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
44
|
+
CONSTRAINT table_stats_daily_table_fkey FOREIGN KEY (table_stats_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
45
|
+
CONSTRAINT query_stats_log_table_fkey FOREIGN KEY (query_stats_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
46
|
+
CONSTRAINT query_stats_daily_table_fkey FOREIGN KEY (query_stats_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
47
|
+
CONSTRAINT db_usage_module_database_id_prefix_unique UNIQUE NULLS NOT DISTINCT (database_id, prefix)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
CREATE INDEX db_usage_module_database_id_idx ON metaschema_modules_public.db_usage_module ( database_id );
|
|
51
|
+
|
|
52
|
+
COMMIT;
|
|
@@ -47,16 +47,34 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
|
|
|
47
47
|
|
|
48
48
|
has_levels boolean NOT NULL DEFAULT false,
|
|
49
49
|
|
|
50
|
-
has_storage boolean NOT NULL DEFAULT false,
|
|
51
|
-
|
|
52
50
|
has_invites boolean NOT NULL DEFAULT false,
|
|
53
51
|
|
|
52
|
+
has_invite_achievements boolean NOT NULL DEFAULT false,
|
|
53
|
+
|
|
54
54
|
-- =========================================================================
|
|
55
|
-
-- Storage configuration:
|
|
56
|
-
--
|
|
55
|
+
-- Storage configuration: JSON array of storage module definitions.
|
|
56
|
+
-- Each element provisions a separate storage module with its own tables,
|
|
57
|
+
-- RLS policies, and feature flags. Presence triggers provisioning
|
|
58
|
+
-- (same inference model as namespaces, functions, agents).
|
|
59
|
+
-- NULL = do not provision. '[{}]' = provision one default storage module.
|
|
57
60
|
-- =========================================================================
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
storage jsonb DEFAULT NULL,
|
|
63
|
+
|
|
64
|
+
-- =========================================================================
|
|
65
|
+
-- Module configuration arrays: presence triggers provisioning.
|
|
66
|
+
-- Each is a JSON array of module definitions (like storage).
|
|
67
|
+
-- NULL = do not provision. '[{}]' = provision one default instance.
|
|
68
|
+
-- Each element may include "key" (discriminator) and "policies" (override).
|
|
69
|
+
-- =========================================================================
|
|
70
|
+
|
|
71
|
+
namespaces jsonb DEFAULT NULL,
|
|
72
|
+
|
|
73
|
+
functions jsonb DEFAULT NULL,
|
|
74
|
+
|
|
75
|
+
graphs jsonb DEFAULT NULL,
|
|
76
|
+
|
|
77
|
+
agents jsonb DEFAULT NULL,
|
|
60
78
|
|
|
61
79
|
-- =========================================================================
|
|
62
80
|
-- Escape hatch: skip default entity table RLS policies
|
|
@@ -103,6 +121,26 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
|
|
|
103
121
|
|
|
104
122
|
out_invites_module_id uuid DEFAULT NULL,
|
|
105
123
|
|
|
124
|
+
out_namespace_module_id uuid DEFAULT NULL,
|
|
125
|
+
|
|
126
|
+
out_namespaces_table_id uuid DEFAULT NULL,
|
|
127
|
+
|
|
128
|
+
out_namespace_events_table_id uuid DEFAULT NULL,
|
|
129
|
+
|
|
130
|
+
out_function_module_id uuid DEFAULT NULL,
|
|
131
|
+
|
|
132
|
+
out_definitions_table_id uuid DEFAULT NULL,
|
|
133
|
+
|
|
134
|
+
out_invocations_table_id uuid DEFAULT NULL,
|
|
135
|
+
|
|
136
|
+
out_execution_logs_table_id uuid DEFAULT NULL,
|
|
137
|
+
|
|
138
|
+
out_graph_module_id uuid DEFAULT NULL,
|
|
139
|
+
|
|
140
|
+
out_graphs_table_id uuid DEFAULT NULL,
|
|
141
|
+
|
|
142
|
+
out_agent_module_id uuid DEFAULT NULL,
|
|
143
|
+
|
|
106
144
|
-- =========================================================================
|
|
107
145
|
-- Constraints
|
|
108
146
|
-- =========================================================================
|
|
@@ -197,24 +235,27 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_profiles I
|
|
|
197
235
|
When true, creates profile tables and applies profiles security.';
|
|
198
236
|
|
|
199
237
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_levels IS
|
|
200
|
-
'Whether to provision
|
|
238
|
+
'Whether to provision events_module for this type. Defaults to false.
|
|
201
239
|
Levels provide gamification/achievement tracking for members.
|
|
202
240
|
When true, creates level steps, achievements, and level tables with security.';
|
|
203
241
|
|
|
204
|
-
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_storage IS
|
|
205
|
-
'Whether to provision storage_module for this type. Defaults to false.
|
|
206
|
-
When true, creates {prefix}_buckets and {prefix}_files tables
|
|
207
|
-
with entity-scoped RLS (AuthzEntityMembership) using the entity''s membership_type.
|
|
208
|
-
Storage tables get owner_id FK to the entity table, so files are owned by the entity.';
|
|
209
|
-
|
|
210
242
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invites IS
|
|
211
243
|
'Whether to provision invites_module for this type. Defaults to false.
|
|
212
244
|
When true, the trigger inserts a row into invites_module which in turn
|
|
213
245
|
(via insert_invites_module BEFORE INSERT) creates {prefix}_invites and
|
|
214
246
|
{prefix}_claimed_invites tables plus the submit_{prefix}_invite_code() function.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
247
|
+
Re-provisioning is idempotent: the UNIQUE (database_id, membership_type) constraint
|
|
248
|
+
on invites_module combined with ON CONFLICT DO NOTHING in the fan-out makes
|
|
249
|
+
repeated INSERTs safe.';
|
|
250
|
+
|
|
251
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invite_achievements IS
|
|
252
|
+
'Whether to auto-attach an EventTracker to the claimed_invites table for invite-based
|
|
253
|
+
achievements. Defaults to false. Requires has_invites=true AND has_levels=true.
|
|
254
|
+
When true, the trigger calls event_tracker() on the claimed_invites table with
|
|
255
|
+
event_name=''invite_claimed'', actor_field=''sender_id'', events=[''INSERT''],
|
|
256
|
+
crediting the SENDER (inviter) when someone claims their invite code.
|
|
257
|
+
Developers can then define achievements in the blueprint achievements[] section
|
|
258
|
+
that reference the ''invite_claimed'' event (e.g., "Invite 5 friends" = count: 5).';
|
|
218
259
|
|
|
219
260
|
-- =============================================================================
|
|
220
261
|
-- Escape hatch
|
|
@@ -283,50 +324,95 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_installed_
|
|
|
283
324
|
'Output: array of installed module labels (e.g. ARRAY[''permissions_module:data_room'', ''memberships_module:data_room'', ''invites_module:data_room'']).
|
|
284
325
|
Populated by the trigger. Useful for verifying which modules were provisioned.';
|
|
285
326
|
|
|
286
|
-
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.
|
|
287
|
-
'Optional
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
storage_config := ''{"buckets": [{"name": "documents", "is_public": false, "allowed_mime_types": ["application/pdf"]}], "provisions": {"files": {"nodes": [{"$type": "SearchBm25", "data": {"source_fields": ["description"]}}]}}}''::jsonb';
|
|
327
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage IS
|
|
328
|
+
'Optional JSON array of storage module definitions. Presence triggers provisioning
|
|
329
|
+
(same inference model as namespaces, functions, agents).
|
|
330
|
+
Each element provisions a separate storage module with its own tables
|
|
331
|
+
({prefix}_{storage_key}_buckets/files), RLS policies, and feature flags.
|
|
332
|
+
NULL = do not provision storage. ''[{}]'' = provision one default storage module.
|
|
333
|
+
Each array element recognizes (all optional):
|
|
334
|
+
- storage_key (text) module discriminator, max 16 chars, lowercase snake_case.
|
|
335
|
+
Defaults to ''default'' (omitted from table names).
|
|
336
|
+
Non-default keys become infixes: {prefix}_{key}_buckets.
|
|
337
|
+
- upload_url_expiry_seconds (integer) presigned PUT URL expiry override
|
|
338
|
+
- download_url_expiry_seconds (integer) presigned GET URL expiry override
|
|
339
|
+
- default_max_file_size (bigint) global max file size in bytes for this module
|
|
340
|
+
- allowed_origins (text[]) default CORS origins for all buckets in this module
|
|
341
|
+
- restrict_reads (boolean) require read_files permission for SELECT on files
|
|
342
|
+
- has_path_shares (boolean) enable virtual filesystem + path share policies
|
|
343
|
+
- has_versioning (boolean) enable file version chains
|
|
344
|
+
- has_content_hash (boolean) enable content hash for dedup
|
|
345
|
+
- has_custom_keys (boolean) allow client-provided S3 keys
|
|
346
|
+
- has_audit_log (boolean) enable file events audit table
|
|
347
|
+
- has_confirm_upload (boolean) enable HeadObject confirmation flow
|
|
348
|
+
- confirm_upload_delay (interval) delay before first confirmation attempt
|
|
349
|
+
- buckets (jsonb[]) array of initial bucket definitions to seed.
|
|
350
|
+
Each bucket: { name (required), description, is_public, allowed_mime_types, max_file_size, allowed_origins }
|
|
351
|
+
- provisions (jsonb object) per-table customization keyed by "files" or "buckets".
|
|
352
|
+
Each value: { nodes, fields, grants, use_rls, policies }.
|
|
353
|
+
Example (single module, backward compat):
|
|
354
|
+
storage := ''[{"buckets": [{"name": "documents"}]}]''::jsonb
|
|
355
|
+
Example (multi-module):
|
|
356
|
+
storage := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"storage_key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
|
|
317
357
|
|
|
318
358
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_storage_module_id IS
|
|
319
|
-
'Output: the UUID of the storage_module row created for this entity type. Populated by the trigger when
|
|
359
|
+
'Output: the UUID of the storage_module row created for this entity type. Populated by the trigger when storage is non-NULL and non-empty.';
|
|
320
360
|
|
|
321
361
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_buckets_table_id IS
|
|
322
|
-
'Output: the UUID of the generated buckets table (e.g. data_room_buckets). Populated by the trigger when
|
|
362
|
+
'Output: the UUID of the generated buckets table (e.g. data_room_buckets). Populated by the trigger when storage is non-NULL and non-empty.';
|
|
323
363
|
|
|
324
364
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_files_table_id IS
|
|
325
|
-
'Output: the UUID of the generated files table (e.g. data_room_files). Populated by the trigger when
|
|
365
|
+
'Output: the UUID of the generated files table (e.g. data_room_files). Populated by the trigger when storage is non-NULL and non-empty.';
|
|
326
366
|
|
|
327
367
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_invites_module_id IS
|
|
328
368
|
'Output: the UUID of the invites_module row created for this entity type. Populated by the trigger when has_invites=true.
|
|
329
369
|
NULL when has_invites=false, or when re-provisioning hits ON CONFLICT DO NOTHING
|
|
330
370
|
(i.e. the invites_module row was created in a previous run).';
|
|
331
371
|
|
|
372
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.namespaces IS
|
|
373
|
+
'Optional JSON array of namespace module definitions. Presence triggers provisioning.
|
|
374
|
+
NULL = do not provision namespaces. ''[{}]'' = provision one default namespace module.
|
|
375
|
+
Each element recognizes (all optional):
|
|
376
|
+
- key (text) module discriminator. Defaults to ''default''.
|
|
377
|
+
- policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_namespace_security().
|
|
378
|
+
Creates {prefix}_namespaces (or {prefix}_{key}_namespaces for non-default keys)
|
|
379
|
+
with entity-scoped RLS (AuthzEntityMembership) and a rename proxy trigger.
|
|
380
|
+
Registers manage_namespaces permission bit on first provision.
|
|
381
|
+
Example: namespaces := ''[{}]''::jsonb';
|
|
382
|
+
|
|
383
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.functions IS
|
|
384
|
+
'Optional JSON array of function module definitions. Presence triggers provisioning.
|
|
385
|
+
NULL = do not provision functions. ''[{}]'' = provision one default function module.
|
|
386
|
+
Each element recognizes (all optional):
|
|
387
|
+
- key (text) module discriminator. Defaults to ''default''.
|
|
388
|
+
- policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_function_security().
|
|
389
|
+
Creates {prefix}_function_definitions (or {prefix}_{key}_function_definitions for non-default keys)
|
|
390
|
+
with entity-scoped RLS and a job trigger dispatching function:provision tasks.
|
|
391
|
+
Registers manage_functions + invoke_functions permission bits on first provision.
|
|
392
|
+
Example: functions := ''[{}]''::jsonb';
|
|
393
|
+
|
|
394
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.graphs IS
|
|
395
|
+
'Optional JSON array of graph module definitions. Presence triggers provisioning.
|
|
396
|
+
NULL = do not provision graphs. ''[{}]'' = provision one default graph module.
|
|
397
|
+
Each element recognizes (all optional):
|
|
398
|
+
- key (text) module discriminator. Defaults to ''default''.
|
|
399
|
+
- policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_graph_security().
|
|
400
|
+
Registers manage_graphs + execute_graphs permission bits on first provision.
|
|
401
|
+
Graph module requires a merkle_store_module_id dependency, so entity_type_provision
|
|
402
|
+
only registers permissions here. The graph module itself must be provisioned
|
|
403
|
+
separately with the merkle store dependency resolved.
|
|
404
|
+
Example: graphs := ''[{}]''::jsonb';
|
|
405
|
+
|
|
406
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespace_module_id IS
|
|
407
|
+
'Output: the UUID of the namespace_module row created (or found) for this entity type.
|
|
408
|
+
Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
|
|
409
|
+
|
|
410
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespaces_table_id IS
|
|
411
|
+
'Output: the UUID of the generated namespaces table (e.g. data_room_namespaces).
|
|
412
|
+
Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
|
|
413
|
+
|
|
414
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespace_events_table_id IS
|
|
415
|
+
'Output: the UUID of the generated namespace_events partitioned table (e.g. data_room_namespace_events).
|
|
416
|
+
Monthly partitioned, 12-month retention. Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
|
|
417
|
+
|
|
332
418
|
COMMIT;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/events_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.events_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
--
|
|
15
|
+
|
|
16
|
+
events_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
events_table_name text NOT NULL DEFAULT '',
|
|
18
|
+
|
|
19
|
+
event_aggregates_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
event_aggregates_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
event_types_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
23
|
+
event_types_table_name text NOT NULL DEFAULT '',
|
|
24
|
+
|
|
25
|
+
levels_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
26
|
+
levels_table_name text NOT NULL DEFAULT '',
|
|
27
|
+
|
|
28
|
+
level_requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
29
|
+
level_requirements_table_name text NOT NULL DEFAULT '',
|
|
30
|
+
|
|
31
|
+
level_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
32
|
+
level_grants_table_name text NOT NULL DEFAULT '',
|
|
33
|
+
|
|
34
|
+
achievement_rewards_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
35
|
+
achievement_rewards_table_name text NOT NULL DEFAULT '',
|
|
36
|
+
|
|
37
|
+
record_event text NOT NULL DEFAULT '',
|
|
38
|
+
remove_event text NOT NULL DEFAULT '',
|
|
39
|
+
tg_event text NOT NULL DEFAULT '',
|
|
40
|
+
tg_event_toggle text NOT NULL DEFAULT '',
|
|
41
|
+
tg_event_toggle_bool text NOT NULL DEFAULT '',
|
|
42
|
+
tg_event_bool text NOT NULL DEFAULT '',
|
|
43
|
+
upsert_aggregate text NOT NULL DEFAULT '',
|
|
44
|
+
tg_update_aggregates text NOT NULL DEFAULT '',
|
|
45
|
+
prune_events text NOT NULL DEFAULT '',
|
|
46
|
+
steps_required text NOT NULL DEFAULT '',
|
|
47
|
+
level_achieved text NOT NULL DEFAULT '',
|
|
48
|
+
tg_check_achievements text NOT NULL DEFAULT '',
|
|
49
|
+
grant_achievement text NOT NULL DEFAULT '',
|
|
50
|
+
tg_achievement_reward text NOT NULL DEFAULT '',
|
|
51
|
+
|
|
52
|
+
-- Partition lifecycle configuration for events table
|
|
53
|
+
"interval" text NOT NULL DEFAULT '1 month',
|
|
54
|
+
retention text DEFAULT '12 months',
|
|
55
|
+
premake int NOT NULL DEFAULT 2,
|
|
56
|
+
|
|
57
|
+
prefix text NULL,
|
|
58
|
+
|
|
59
|
+
membership_type int NOT NULL,
|
|
60
|
+
-- if this is NOT NULL, then we add entity_id
|
|
61
|
+
-- e.g. limits to the app itself are considered global owned by app and no explicit owner
|
|
62
|
+
entity_table_id uuid NULL,
|
|
63
|
+
|
|
64
|
+
-- required tables
|
|
65
|
+
actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
69
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
70
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
71
|
+
|
|
72
|
+
CONSTRAINT events_table_fkey FOREIGN KEY (events_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
73
|
+
CONSTRAINT event_aggregates_table_fkey FOREIGN KEY (event_aggregates_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
74
|
+
CONSTRAINT event_types_table_fkey FOREIGN KEY (event_types_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
75
|
+
CONSTRAINT levels_table_fkey FOREIGN KEY (levels_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
76
|
+
CONSTRAINT level_requirements_table_fkey FOREIGN KEY (level_requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
77
|
+
CONSTRAINT level_grants_table_fkey FOREIGN KEY (level_grants_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
78
|
+
CONSTRAINT achievement_rewards_table_fkey FOREIGN KEY (achievement_rewards_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
79
|
+
CONSTRAINT entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
80
|
+
CONSTRAINT actor_table_fkey FOREIGN KEY (actor_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
CREATE INDEX events_module_database_id_idx ON metaschema_modules_public.events_module ( database_id );
|
|
84
|
+
|
|
85
|
+
COMMIT;
|