@pgpm/metaschema-modules 0.26.0 → 0.26.2

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.
Files changed (42) hide show
  1. package/Makefile +1 -1
  2. package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +83 -0
  3. package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +5 -0
  4. package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +44 -0
  5. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +5 -1
  6. package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +52 -0
  7. package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +107 -25
  8. package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +92 -0
  9. package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +73 -0
  10. package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +7 -2
  11. package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +3 -0
  12. package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +55 -0
  13. package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +71 -0
  14. package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +44 -0
  15. package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +11 -12
  16. package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +44 -0
  17. package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +1 -1
  18. package/metaschema-modules.control +1 -1
  19. package/package.json +3 -3
  20. package/pgpm.plan +10 -0
  21. package/revert/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
  22. package/revert/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +3 -0
  23. package/revert/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +3 -0
  24. package/revert/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
  25. package/revert/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
  26. package/revert/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
  27. package/revert/schemas/metaschema_modules_public/tables/namespace_module/table.sql +7 -0
  28. package/revert/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +3 -0
  29. package/revert/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +3 -0
  30. package/sql/{metaschema-modules--0.15.5.sql → metaschema-modules--0.26.1.sql} +760 -173
  31. package/verify/schemas/metaschema_modules_public/tables/agent_module/table.sql +7 -0
  32. package/verify/schemas/metaschema_modules_public/tables/billing_module/table.sql +2 -0
  33. package/verify/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +9 -0
  34. package/verify/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +10 -0
  35. package/verify/schemas/metaschema_modules_public/tables/function_module/table.sql +7 -0
  36. package/verify/schemas/metaschema_modules_public/tables/graph_module/table.sql +7 -0
  37. package/verify/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +3 -2
  38. package/verify/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +7 -0
  39. package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +12 -0
  40. package/verify/schemas/metaschema_modules_public/tables/profiles_module/table.sql +2 -1
  41. package/verify/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +10 -0
  42. package/verify/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +10 -0
@@ -37,11 +37,11 @@ CREATE TABLE metaschema_modules_public.connected_accounts_module (
37
37
  ON DELETE CASCADE,
38
38
  CONSTRAINT table_fkey
39
39
  FOREIGN KEY(table_id)
40
- REFERENCES metaschema_public.table (id)
40
+ REFERENCES metaschema_public."table" (id)
41
41
  ON DELETE CASCADE,
42
42
  CONSTRAINT owner_table_fkey
43
43
  FOREIGN KEY(owner_table_id)
44
- REFERENCES metaschema_public.table (id)
44
+ REFERENCES metaschema_public."table" (id)
45
45
  ON DELETE CASCADE,
46
46
  CONSTRAINT schema_fkey
47
47
  FOREIGN KEY(schema_id)
@@ -70,11 +70,11 @@ CREATE TABLE metaschema_modules_public.crypto_addresses_module (
70
70
  ON DELETE CASCADE,
71
71
  CONSTRAINT table_fkey
72
72
  FOREIGN KEY(table_id)
73
- REFERENCES metaschema_public.table (id)
73
+ REFERENCES metaschema_public."table" (id)
74
74
  ON DELETE CASCADE,
75
75
  CONSTRAINT owner_table_fkey
76
76
  FOREIGN KEY(owner_table_id)
77
- REFERENCES metaschema_public.table (id)
77
+ REFERENCES metaschema_public."table" (id)
78
78
  ON DELETE CASCADE,
79
79
  CONSTRAINT schema_fkey
80
80
  FOREIGN KEY(schema_id)
@@ -109,19 +109,19 @@ CREATE TABLE metaschema_modules_public.crypto_auth_module (
109
109
  ON DELETE CASCADE,
110
110
  CONSTRAINT secrets_table_fkey
111
111
  FOREIGN KEY(secrets_table_id)
112
- REFERENCES metaschema_public.table (id)
112
+ REFERENCES metaschema_public."table" (id)
113
113
  ON DELETE CASCADE,
114
114
  CONSTRAINT users_table_fkey
115
115
  FOREIGN KEY(users_table_id)
116
- REFERENCES metaschema_public.table (id)
116
+ REFERENCES metaschema_public."table" (id)
117
117
  ON DELETE CASCADE,
118
118
  CONSTRAINT sessions_table_fkey
119
119
  FOREIGN KEY(sessions_table_id)
120
- REFERENCES metaschema_public.table (id)
120
+ REFERENCES metaschema_public."table" (id)
121
121
  ON DELETE CASCADE,
122
122
  CONSTRAINT session_credentials_table_fkey
123
123
  FOREIGN KEY(session_credentials_table_id)
124
- REFERENCES metaschema_public.table (id)
124
+ REFERENCES metaschema_public."table" (id)
125
125
  ON DELETE CASCADE,
126
126
  CONSTRAINT schema_fkey
127
127
  FOREIGN KEY(schema_id)
@@ -161,11 +161,11 @@ CREATE TABLE metaschema_modules_public.denormalized_table_field (
161
161
  ON DELETE CASCADE,
162
162
  CONSTRAINT table_fkey
163
163
  FOREIGN KEY(table_id)
164
- REFERENCES metaschema_public.table (id)
164
+ REFERENCES metaschema_public."table" (id)
165
165
  ON DELETE CASCADE,
166
166
  CONSTRAINT ref_table_fkey
167
167
  FOREIGN KEY(ref_table_id)
168
- REFERENCES metaschema_public.table (id)
168
+ REFERENCES metaschema_public."table" (id)
169
169
  ON DELETE CASCADE,
170
170
  CONSTRAINT field_fkey
171
171
  FOREIGN KEY(field_id)
@@ -193,11 +193,11 @@ CREATE TABLE metaschema_modules_public.emails_module (
193
193
  ON DELETE CASCADE,
194
194
  CONSTRAINT table_fkey
195
195
  FOREIGN KEY(table_id)
196
- REFERENCES metaschema_public.table (id)
196
+ REFERENCES metaschema_public."table" (id)
197
197
  ON DELETE CASCADE,
198
198
  CONSTRAINT owner_table_fkey
199
199
  FOREIGN KEY(owner_table_id)
200
- REFERENCES metaschema_public.table (id)
200
+ REFERENCES metaschema_public."table" (id)
201
201
  ON DELETE CASCADE,
202
202
  CONSTRAINT schema_fkey
203
203
  FOREIGN KEY(schema_id)
@@ -217,6 +217,7 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
217
217
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
218
218
  table_id uuid NOT NULL DEFAULT uuid_nil(),
219
219
  table_name text NOT NULL DEFAULT 'user_secrets',
220
+ config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
220
221
  CONSTRAINT db_fkey
221
222
  FOREIGN KEY(database_id)
222
223
  REFERENCES metaschema_public.database (id)
@@ -227,7 +228,11 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
227
228
  ON DELETE CASCADE,
228
229
  CONSTRAINT table_fkey
229
230
  FOREIGN KEY(table_id)
230
- REFERENCES metaschema_public.table (id)
231
+ REFERENCES metaschema_public."table" (id)
232
+ ON DELETE CASCADE,
233
+ CONSTRAINT config_defs_table_fkey
234
+ FOREIGN KEY(config_definitions_table_id)
235
+ REFERENCES metaschema_public."table" (id)
231
236
  ON DELETE CASCADE
232
237
  );
233
238
 
@@ -254,23 +259,23 @@ CREATE TABLE metaschema_modules_public.invites_module (
254
259
  ON DELETE CASCADE,
255
260
  CONSTRAINT invites_table_fkey
256
261
  FOREIGN KEY(invites_table_id)
257
- REFERENCES metaschema_public.table (id)
262
+ REFERENCES metaschema_public."table" (id)
258
263
  ON DELETE CASCADE,
259
264
  CONSTRAINT emails_table_fkey
260
265
  FOREIGN KEY(emails_table_id)
261
- REFERENCES metaschema_public.table (id)
266
+ REFERENCES metaschema_public."table" (id)
262
267
  ON DELETE CASCADE,
263
268
  CONSTRAINT users_table_fkey
264
269
  FOREIGN KEY(users_table_id)
265
- REFERENCES metaschema_public.table (id)
270
+ REFERENCES metaschema_public."table" (id)
266
271
  ON DELETE CASCADE,
267
272
  CONSTRAINT entity_table_fkey
268
273
  FOREIGN KEY(entity_table_id)
269
- REFERENCES metaschema_public.table (id)
274
+ REFERENCES metaschema_public."table" (id)
270
275
  ON DELETE CASCADE,
271
276
  CONSTRAINT claimed_invites_table_fkey
272
277
  FOREIGN KEY(claimed_invites_table_id)
273
- REFERENCES metaschema_public.table (id)
278
+ REFERENCES metaschema_public."table" (id)
274
279
  ON DELETE CASCADE,
275
280
  CONSTRAINT schema_fkey
276
281
  FOREIGN KEY(schema_id)
@@ -319,7 +324,7 @@ CREATE TABLE metaschema_modules_public.events_module (
319
324
  tg_check_achievements text NOT NULL DEFAULT '',
320
325
  grant_achievement text NOT NULL DEFAULT '',
321
326
  tg_achievement_reward text NOT NULL DEFAULT '',
322
- "interval" text NOT NULL DEFAULT '1 month',
327
+ interval text NOT NULL DEFAULT '1 month',
323
328
  retention text DEFAULT '12 months',
324
329
  premake int NOT NULL DEFAULT 2,
325
330
  prefix text NULL,
@@ -340,39 +345,39 @@ CREATE TABLE metaschema_modules_public.events_module (
340
345
  ON DELETE CASCADE,
341
346
  CONSTRAINT events_table_fkey
342
347
  FOREIGN KEY(events_table_id)
343
- REFERENCES metaschema_public.table (id)
348
+ REFERENCES metaschema_public."table" (id)
344
349
  ON DELETE CASCADE,
345
350
  CONSTRAINT event_aggregates_table_fkey
346
351
  FOREIGN KEY(event_aggregates_table_id)
347
- REFERENCES metaschema_public.table (id)
352
+ REFERENCES metaschema_public."table" (id)
348
353
  ON DELETE CASCADE,
349
354
  CONSTRAINT event_types_table_fkey
350
355
  FOREIGN KEY(event_types_table_id)
351
- REFERENCES metaschema_public.table (id)
356
+ REFERENCES metaschema_public."table" (id)
352
357
  ON DELETE CASCADE,
353
358
  CONSTRAINT levels_table_fkey
354
359
  FOREIGN KEY(levels_table_id)
355
- REFERENCES metaschema_public.table (id)
360
+ REFERENCES metaschema_public."table" (id)
356
361
  ON DELETE CASCADE,
357
362
  CONSTRAINT level_requirements_table_fkey
358
363
  FOREIGN KEY(level_requirements_table_id)
359
- REFERENCES metaschema_public.table (id)
364
+ REFERENCES metaschema_public."table" (id)
360
365
  ON DELETE CASCADE,
361
366
  CONSTRAINT level_grants_table_fkey
362
367
  FOREIGN KEY(level_grants_table_id)
363
- REFERENCES metaschema_public.table (id)
368
+ REFERENCES metaschema_public."table" (id)
364
369
  ON DELETE CASCADE,
365
370
  CONSTRAINT achievement_rewards_table_fkey
366
371
  FOREIGN KEY(achievement_rewards_table_id)
367
- REFERENCES metaschema_public.table (id)
372
+ REFERENCES metaschema_public."table" (id)
368
373
  ON DELETE CASCADE,
369
374
  CONSTRAINT entity_table_fkey
370
375
  FOREIGN KEY(entity_table_id)
371
- REFERENCES metaschema_public.table (id)
376
+ REFERENCES metaschema_public."table" (id)
372
377
  ON DELETE CASCADE,
373
378
  CONSTRAINT actor_table_fkey
374
379
  FOREIGN KEY(actor_table_id)
375
- REFERENCES metaschema_public.table (id)
380
+ REFERENCES metaschema_public."table" (id)
376
381
  ON DELETE CASCADE
377
382
  );
378
383
 
@@ -425,59 +430,59 @@ CREATE TABLE metaschema_modules_public.limits_module (
425
430
  ON DELETE CASCADE,
426
431
  CONSTRAINT table_fkey
427
432
  FOREIGN KEY(table_id)
428
- REFERENCES metaschema_public.table (id)
433
+ REFERENCES metaschema_public."table" (id)
429
434
  ON DELETE CASCADE,
430
435
  CONSTRAINT default_table_fkey
431
436
  FOREIGN KEY(default_table_id)
432
- REFERENCES metaschema_public.table (id)
437
+ REFERENCES metaschema_public."table" (id)
433
438
  ON DELETE CASCADE,
434
439
  CONSTRAINT entity_table_fkey
435
440
  FOREIGN KEY(entity_table_id)
436
- REFERENCES metaschema_public.table (id)
441
+ REFERENCES metaschema_public."table" (id)
437
442
  ON DELETE CASCADE,
438
443
  CONSTRAINT actor_table_fkey
439
444
  FOREIGN KEY(actor_table_id)
440
- REFERENCES metaschema_public.table (id)
445
+ REFERENCES metaschema_public."table" (id)
441
446
  ON DELETE CASCADE,
442
447
  CONSTRAINT aggregate_table_fkey
443
448
  FOREIGN KEY(aggregate_table_id)
444
- REFERENCES metaschema_public.table (id)
449
+ REFERENCES metaschema_public."table" (id)
445
450
  ON DELETE CASCADE,
446
451
  CONSTRAINT limit_credits_table_fkey
447
452
  FOREIGN KEY(limit_credits_table_id)
448
- REFERENCES metaschema_public.table (id)
453
+ REFERENCES metaschema_public."table" (id)
449
454
  ON DELETE CASCADE,
450
455
  CONSTRAINT events_table_fkey
451
456
  FOREIGN KEY(events_table_id)
452
- REFERENCES metaschema_public.table (id)
457
+ REFERENCES metaschema_public."table" (id)
453
458
  ON DELETE CASCADE,
454
459
  CONSTRAINT credit_codes_table_fkey
455
460
  FOREIGN KEY(credit_codes_table_id)
456
- REFERENCES metaschema_public.table (id)
461
+ REFERENCES metaschema_public."table" (id)
457
462
  ON DELETE CASCADE,
458
463
  CONSTRAINT credit_code_items_table_fkey
459
464
  FOREIGN KEY(credit_code_items_table_id)
460
- REFERENCES metaschema_public.table (id)
465
+ REFERENCES metaschema_public."table" (id)
461
466
  ON DELETE CASCADE,
462
467
  CONSTRAINT credit_redemptions_table_fkey
463
468
  FOREIGN KEY(credit_redemptions_table_id)
464
- REFERENCES metaschema_public.table (id)
469
+ REFERENCES metaschema_public."table" (id)
465
470
  ON DELETE CASCADE,
466
471
  CONSTRAINT limit_caps_table_fkey
467
472
  FOREIGN KEY(limit_caps_table_id)
468
- REFERENCES metaschema_public.table (id)
473
+ REFERENCES metaschema_public."table" (id)
469
474
  ON DELETE CASCADE,
470
475
  CONSTRAINT limit_caps_defaults_table_fkey
471
476
  FOREIGN KEY(limit_caps_defaults_table_id)
472
- REFERENCES metaschema_public.table (id)
477
+ REFERENCES metaschema_public."table" (id)
473
478
  ON DELETE CASCADE,
474
479
  CONSTRAINT limit_warnings_table_fkey
475
480
  FOREIGN KEY(limit_warnings_table_id)
476
- REFERENCES metaschema_public.table (id)
481
+ REFERENCES metaschema_public."table" (id)
477
482
  ON DELETE CASCADE,
478
483
  CONSTRAINT limit_warning_state_table_fkey
479
484
  FOREIGN KEY(limit_warning_state_table_id)
480
- REFERENCES metaschema_public.table (id)
485
+ REFERENCES metaschema_public."table" (id)
481
486
  ON DELETE CASCADE
482
487
  );
483
488
 
@@ -499,7 +504,7 @@ CREATE TABLE metaschema_modules_public.membership_types_module (
499
504
  ON DELETE CASCADE,
500
505
  CONSTRAINT table_fkey
501
506
  FOREIGN KEY(table_id)
502
- REFERENCES metaschema_public.table (id)
507
+ REFERENCES metaschema_public."table" (id)
503
508
  ON DELETE CASCADE
504
509
  );
505
510
 
@@ -534,6 +539,7 @@ CREATE TABLE metaschema_modules_public.memberships_module (
534
539
  entity_table_id uuid NULL,
535
540
  entity_table_owner_id uuid NULL,
536
541
  prefix text NULL,
542
+ get_org_fn text NULL,
537
543
  actor_mask_check text NOT NULL DEFAULT '',
538
544
  actor_perm_check text NOT NULL DEFAULT '',
539
545
  entity_ids_by_mask text NULL,
@@ -554,31 +560,31 @@ CREATE TABLE metaschema_modules_public.memberships_module (
554
560
  ON DELETE CASCADE,
555
561
  CONSTRAINT memberships_table_fkey
556
562
  FOREIGN KEY(memberships_table_id)
557
- REFERENCES metaschema_public.table (id)
563
+ REFERENCES metaschema_public."table" (id)
558
564
  ON DELETE CASCADE,
559
565
  CONSTRAINT membership_defaults_table_fkey
560
566
  FOREIGN KEY(membership_defaults_table_id)
561
- REFERENCES metaschema_public.table (id)
567
+ REFERENCES metaschema_public."table" (id)
562
568
  ON DELETE CASCADE,
563
569
  CONSTRAINT membership_settings_table_fkey
564
570
  FOREIGN KEY(membership_settings_table_id)
565
- REFERENCES metaschema_public.table (id)
571
+ REFERENCES metaschema_public."table" (id)
566
572
  ON DELETE CASCADE,
567
573
  CONSTRAINT members_table_fkey
568
574
  FOREIGN KEY(members_table_id)
569
- REFERENCES metaschema_public.table (id)
575
+ REFERENCES metaschema_public."table" (id)
570
576
  ON DELETE CASCADE,
571
577
  CONSTRAINT grants_table_fkey
572
578
  FOREIGN KEY(grants_table_id)
573
- REFERENCES metaschema_public.table (id)
579
+ REFERENCES metaschema_public."table" (id)
574
580
  ON DELETE CASCADE,
575
581
  CONSTRAINT sprt_table_fkey
576
582
  FOREIGN KEY(sprt_table_id)
577
- REFERENCES metaschema_public.table (id)
583
+ REFERENCES metaschema_public."table" (id)
578
584
  ON DELETE CASCADE,
579
585
  CONSTRAINT entity_table_fkey
580
586
  FOREIGN KEY(entity_table_id)
581
- REFERENCES metaschema_public.table (id)
587
+ REFERENCES metaschema_public."table" (id)
582
588
  ON DELETE CASCADE,
583
589
  CONSTRAINT entity_table_owner_fkey
584
590
  FOREIGN KEY(entity_table_owner_id)
@@ -586,23 +592,23 @@ CREATE TABLE metaschema_modules_public.memberships_module (
586
592
  ON DELETE CASCADE,
587
593
  CONSTRAINT actor_table_fkey
588
594
  FOREIGN KEY(actor_table_id)
589
- REFERENCES metaschema_public.table (id)
595
+ REFERENCES metaschema_public."table" (id)
590
596
  ON DELETE CASCADE,
591
597
  CONSTRAINT limits_table_fkey
592
598
  FOREIGN KEY(limits_table_id)
593
- REFERENCES metaschema_public.table (id)
599
+ REFERENCES metaschema_public."table" (id)
594
600
  ON DELETE CASCADE,
595
601
  CONSTRAINT default_limits_table_fkey
596
602
  FOREIGN KEY(default_limits_table_id)
597
- REFERENCES metaschema_public.table (id)
603
+ REFERENCES metaschema_public."table" (id)
598
604
  ON DELETE CASCADE,
599
605
  CONSTRAINT permissions_table_fkey
600
606
  FOREIGN KEY(permissions_table_id)
601
- REFERENCES metaschema_public.table (id)
607
+ REFERENCES metaschema_public."table" (id)
602
608
  ON DELETE CASCADE,
603
609
  CONSTRAINT default_permissions_table_fkey
604
610
  FOREIGN KEY(default_permissions_table_id)
605
- REFERENCES metaschema_public.table (id)
611
+ REFERENCES metaschema_public."table" (id)
606
612
  ON DELETE CASCADE
607
613
  );
608
614
 
@@ -640,19 +646,19 @@ CREATE TABLE metaschema_modules_public.permissions_module (
640
646
  ON DELETE CASCADE,
641
647
  CONSTRAINT table_fkey
642
648
  FOREIGN KEY(table_id)
643
- REFERENCES metaschema_public.table (id)
649
+ REFERENCES metaschema_public."table" (id)
644
650
  ON DELETE CASCADE,
645
651
  CONSTRAINT default_table_fkey
646
652
  FOREIGN KEY(default_table_id)
647
- REFERENCES metaschema_public.table (id)
653
+ REFERENCES metaschema_public."table" (id)
648
654
  ON DELETE CASCADE,
649
655
  CONSTRAINT entity_table_fkey
650
656
  FOREIGN KEY(entity_table_id)
651
- REFERENCES metaschema_public.table (id)
657
+ REFERENCES metaschema_public."table" (id)
652
658
  ON DELETE CASCADE,
653
659
  CONSTRAINT actor_table_fkey
654
660
  FOREIGN KEY(actor_table_id)
655
- REFERENCES metaschema_public.table (id)
661
+ REFERENCES metaschema_public."table" (id)
656
662
  ON DELETE CASCADE
657
663
  );
658
664
 
@@ -672,11 +678,11 @@ CREATE TABLE metaschema_modules_public.phone_numbers_module (
672
678
  ON DELETE CASCADE,
673
679
  CONSTRAINT table_fkey
674
680
  FOREIGN KEY(table_id)
675
- REFERENCES metaschema_public.table (id)
681
+ REFERENCES metaschema_public."table" (id)
676
682
  ON DELETE CASCADE,
677
683
  CONSTRAINT owner_table_fkey
678
684
  FOREIGN KEY(owner_table_id)
679
- REFERENCES metaschema_public.table (id)
685
+ REFERENCES metaschema_public."table" (id)
680
686
  ON DELETE CASCADE,
681
687
  CONSTRAINT schema_fkey
682
688
  FOREIGN KEY(schema_id)
@@ -725,39 +731,39 @@ CREATE TABLE metaschema_modules_public.profiles_module (
725
731
  ON DELETE CASCADE,
726
732
  CONSTRAINT table_fkey
727
733
  FOREIGN KEY(table_id)
728
- REFERENCES metaschema_public.table (id)
734
+ REFERENCES metaschema_public."table" (id)
729
735
  ON DELETE CASCADE,
730
736
  CONSTRAINT profile_permissions_table_fkey
731
737
  FOREIGN KEY(profile_permissions_table_id)
732
- REFERENCES metaschema_public.table (id)
738
+ REFERENCES metaschema_public."table" (id)
733
739
  ON DELETE CASCADE,
734
740
  CONSTRAINT profile_grants_table_fkey
735
741
  FOREIGN KEY(profile_grants_table_id)
736
- REFERENCES metaschema_public.table (id)
742
+ REFERENCES metaschema_public."table" (id)
737
743
  ON DELETE CASCADE,
738
744
  CONSTRAINT profile_definition_grants_table_fkey
739
745
  FOREIGN KEY(profile_definition_grants_table_id)
740
- REFERENCES metaschema_public.table (id)
746
+ REFERENCES metaschema_public."table" (id)
741
747
  ON DELETE CASCADE,
742
748
  CONSTRAINT profile_templates_table_fkey
743
749
  FOREIGN KEY(profile_templates_table_id)
744
- REFERENCES metaschema_public.table (id)
750
+ REFERENCES metaschema_public."table" (id)
745
751
  ON DELETE CASCADE,
746
752
  CONSTRAINT entity_table_fkey
747
753
  FOREIGN KEY(entity_table_id)
748
- REFERENCES metaschema_public.table (id)
754
+ REFERENCES metaschema_public."table" (id)
749
755
  ON DELETE CASCADE,
750
756
  CONSTRAINT actor_table_fkey
751
757
  FOREIGN KEY(actor_table_id)
752
- REFERENCES metaschema_public.table (id)
758
+ REFERENCES metaschema_public."table" (id)
753
759
  ON DELETE CASCADE,
754
760
  CONSTRAINT permissions_table_fkey
755
761
  FOREIGN KEY(permissions_table_id)
756
- REFERENCES metaschema_public.table (id)
762
+ REFERENCES metaschema_public."table" (id)
757
763
  ON DELETE CASCADE,
758
764
  CONSTRAINT memberships_table_fkey
759
765
  FOREIGN KEY(memberships_table_id)
760
- REFERENCES metaschema_public.table (id)
766
+ REFERENCES metaschema_public."table" (id)
761
767
  ON DELETE CASCADE,
762
768
  CONSTRAINT profiles_module_unique
763
769
  UNIQUE (database_id, membership_type)
@@ -783,15 +789,15 @@ CREATE TABLE metaschema_modules_public.rls_module (
783
789
  ON DELETE CASCADE,
784
790
  CONSTRAINT session_credentials_table_fkey
785
791
  FOREIGN KEY(session_credentials_table_id)
786
- REFERENCES metaschema_public.table (id)
792
+ REFERENCES metaschema_public."table" (id)
787
793
  ON DELETE CASCADE,
788
794
  CONSTRAINT sessions_table_fkey
789
795
  FOREIGN KEY(sessions_table_id)
790
- REFERENCES metaschema_public.table (id)
796
+ REFERENCES metaschema_public."table" (id)
791
797
  ON DELETE CASCADE,
792
798
  CONSTRAINT users_table_fkey
793
799
  FOREIGN KEY(users_table_id)
794
- REFERENCES metaschema_public.table (id)
800
+ REFERENCES metaschema_public."table" (id)
795
801
  ON DELETE CASCADE,
796
802
  CONSTRAINT schema_fkey
797
803
  FOREIGN KEY(schema_id)
@@ -831,7 +837,7 @@ CREATE TABLE metaschema_modules_public.user_state_module (
831
837
  ON DELETE CASCADE,
832
838
  CONSTRAINT table_fkey
833
839
  FOREIGN KEY(table_id)
834
- REFERENCES metaschema_public.table (id)
840
+ REFERENCES metaschema_public."table" (id)
835
841
  ON DELETE CASCADE
836
842
  );
837
843
 
@@ -859,19 +865,19 @@ CREATE TABLE metaschema_modules_public.sessions_module (
859
865
  ON DELETE CASCADE,
860
866
  CONSTRAINT sessions_table_fkey
861
867
  FOREIGN KEY(sessions_table_id)
862
- REFERENCES metaschema_public.table (id)
868
+ REFERENCES metaschema_public."table" (id)
863
869
  ON DELETE CASCADE,
864
870
  CONSTRAINT session_credentials_table_fkey
865
871
  FOREIGN KEY(session_credentials_table_id)
866
- REFERENCES metaschema_public.table (id)
872
+ REFERENCES metaschema_public."table" (id)
867
873
  ON DELETE CASCADE,
868
874
  CONSTRAINT auth_settings_table_fkey
869
875
  FOREIGN KEY(auth_settings_table_id)
870
- REFERENCES metaschema_public.table (id)
876
+ REFERENCES metaschema_public."table" (id)
871
877
  ON DELETE CASCADE,
872
878
  CONSTRAINT users_table_fkey
873
879
  FOREIGN KEY(users_table_id)
874
- REFERENCES metaschema_public.table (id)
880
+ REFERENCES metaschema_public."table" (id)
875
881
  ON DELETE CASCADE
876
882
  );
877
883
 
@@ -894,7 +900,7 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
894
900
  sessions_table_id uuid NOT NULL DEFAULT uuid_nil(),
895
901
  session_credentials_table_id uuid NOT NULL DEFAULT uuid_nil(),
896
902
  audits_table_id uuid NOT NULL DEFAULT uuid_nil(),
897
- audits_table_name text NOT NULL DEFAULT 'audit_logs',
903
+ audits_table_name text NOT NULL DEFAULT 'audit_log_auth',
898
904
  sign_in_function text NOT NULL DEFAULT 'sign_in',
899
905
  sign_up_function text NOT NULL DEFAULT 'sign_up',
900
906
  sign_out_function text NOT NULL DEFAULT 'sign_out',
@@ -920,27 +926,27 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
920
926
  ON DELETE CASCADE,
921
927
  CONSTRAINT email_table_fkey
922
928
  FOREIGN KEY(emails_table_id)
923
- REFERENCES metaschema_public.table (id)
929
+ REFERENCES metaschema_public."table" (id)
924
930
  ON DELETE CASCADE,
925
931
  CONSTRAINT users_table_fkey
926
932
  FOREIGN KEY(users_table_id)
927
- REFERENCES metaschema_public.table (id)
933
+ REFERENCES metaschema_public."table" (id)
928
934
  ON DELETE CASCADE,
929
935
  CONSTRAINT secrets_table_fkey
930
936
  FOREIGN KEY(secrets_table_id)
931
- REFERENCES metaschema_public.table (id)
937
+ REFERENCES metaschema_public."table" (id)
932
938
  ON DELETE CASCADE,
933
939
  CONSTRAINT encrypted_table_fkey
934
940
  FOREIGN KEY(encrypted_table_id)
935
- REFERENCES metaschema_public.table (id)
941
+ REFERENCES metaschema_public."table" (id)
936
942
  ON DELETE CASCADE,
937
943
  CONSTRAINT sessions_table_fkey
938
944
  FOREIGN KEY(sessions_table_id)
939
- REFERENCES metaschema_public.table (id)
945
+ REFERENCES metaschema_public."table" (id)
940
946
  ON DELETE CASCADE,
941
947
  CONSTRAINT session_credentials_table_fkey
942
948
  FOREIGN KEY(session_credentials_table_id)
943
- REFERENCES metaschema_public.table (id)
949
+ REFERENCES metaschema_public."table" (id)
944
950
  ON DELETE CASCADE
945
951
  );
946
952
 
@@ -976,11 +982,11 @@ CREATE TABLE metaschema_modules_public.users_module (
976
982
  ON DELETE CASCADE,
977
983
  CONSTRAINT table_fkey
978
984
  FOREIGN KEY(table_id)
979
- REFERENCES metaschema_public.table (id)
985
+ REFERENCES metaschema_public."table" (id)
980
986
  ON DELETE CASCADE,
981
987
  CONSTRAINT type_table_fkey
982
988
  FOREIGN KEY(type_table_id)
983
- REFERENCES metaschema_public.table (id)
989
+ REFERENCES metaschema_public."table" (id)
984
990
  ON DELETE CASCADE
985
991
  );
986
992
 
@@ -1021,23 +1027,23 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
1021
1027
  ON DELETE CASCADE,
1022
1028
  CONSTRAINT chart_edges_table_fkey
1023
1029
  FOREIGN KEY(chart_edges_table_id)
1024
- REFERENCES metaschema_public.table (id)
1030
+ REFERENCES metaschema_public."table" (id)
1025
1031
  ON DELETE CASCADE,
1026
1032
  CONSTRAINT hierarchy_sprt_table_fkey
1027
1033
  FOREIGN KEY(hierarchy_sprt_table_id)
1028
- REFERENCES metaschema_public.table (id)
1034
+ REFERENCES metaschema_public."table" (id)
1029
1035
  ON DELETE CASCADE,
1030
1036
  CONSTRAINT chart_edge_grants_table_fkey
1031
1037
  FOREIGN KEY(chart_edge_grants_table_id)
1032
- REFERENCES metaschema_public.table (id)
1038
+ REFERENCES metaschema_public."table" (id)
1033
1039
  ON DELETE CASCADE,
1034
1040
  CONSTRAINT entity_table_fkey
1035
1041
  FOREIGN KEY(entity_table_id)
1036
- REFERENCES metaschema_public.table (id)
1042
+ REFERENCES metaschema_public."table" (id)
1037
1043
  ON DELETE CASCADE,
1038
1044
  CONSTRAINT users_table_fkey
1039
1045
  FOREIGN KEY(users_table_id)
1040
- REFERENCES metaschema_public.table (id)
1046
+ REFERENCES metaschema_public."table" (id)
1041
1047
  ON DELETE CASCADE,
1042
1048
  CONSTRAINT hierarchy_module_database_unique
1043
1049
  UNIQUE (database_id)
@@ -1063,7 +1069,7 @@ CREATE TABLE metaschema_modules_public.secure_table_provision (
1063
1069
  ON DELETE CASCADE,
1064
1070
  CONSTRAINT table_fkey
1065
1071
  FOREIGN KEY(table_id)
1066
- REFERENCES metaschema_public.table (id)
1072
+ REFERENCES metaschema_public."table" (id)
1067
1073
  ON DELETE CASCADE,
1068
1074
  CONSTRAINT schema_fkey
1069
1075
  FOREIGN KEY(schema_id)
@@ -1130,11 +1136,11 @@ CREATE TABLE metaschema_modules_public.relation_provision (
1130
1136
  ON DELETE CASCADE,
1131
1137
  CONSTRAINT source_table_fkey
1132
1138
  FOREIGN KEY(source_table_id)
1133
- REFERENCES metaschema_public.table (id)
1139
+ REFERENCES metaschema_public."table" (id)
1134
1140
  ON DELETE CASCADE,
1135
1141
  CONSTRAINT target_table_fkey
1136
1142
  FOREIGN KEY(target_table_id)
1137
- REFERENCES metaschema_public.table (id)
1143
+ REFERENCES metaschema_public."table" (id)
1138
1144
  ON DELETE CASCADE
1139
1145
  );
1140
1146
 
@@ -1457,9 +1463,9 @@ CREATE TABLE metaschema_modules_public.storage_module (
1457
1463
  buckets_table_name text NOT NULL DEFAULT 'app_buckets',
1458
1464
  files_table_name text NOT NULL DEFAULT 'app_files',
1459
1465
  membership_type int DEFAULT NULL,
1460
- storage_key text NOT NULL DEFAULT 'default',
1466
+ key text NOT NULL DEFAULT 'default',
1461
1467
  policies jsonb NULL,
1462
- skip_default_policy_tables text[] NOT NULL DEFAULT '{}',
1468
+ provisions jsonb NULL,
1463
1469
  entity_table_id uuid NULL,
1464
1470
  endpoint text NULL,
1465
1471
  public_url_prefix text NULL,
@@ -1496,29 +1502,29 @@ CREATE TABLE metaschema_modules_public.storage_module (
1496
1502
  ON DELETE CASCADE,
1497
1503
  CONSTRAINT buckets_table_fkey
1498
1504
  FOREIGN KEY(buckets_table_id)
1499
- REFERENCES metaschema_public.table (id)
1505
+ REFERENCES metaschema_public."table" (id)
1500
1506
  ON DELETE CASCADE,
1501
1507
  CONSTRAINT files_table_fkey
1502
1508
  FOREIGN KEY(files_table_id)
1503
- REFERENCES metaschema_public.table (id)
1509
+ REFERENCES metaschema_public."table" (id)
1504
1510
  ON DELETE CASCADE,
1505
1511
  CONSTRAINT entity_table_fkey
1506
1512
  FOREIGN KEY(entity_table_id)
1507
- REFERENCES metaschema_public.table (id)
1513
+ REFERENCES metaschema_public."table" (id)
1508
1514
  ON DELETE CASCADE,
1509
1515
  CONSTRAINT path_shares_table_fkey
1510
1516
  FOREIGN KEY(path_shares_table_id)
1511
- REFERENCES metaschema_public.table (id)
1517
+ REFERENCES metaschema_public."table" (id)
1512
1518
  ON DELETE CASCADE,
1513
1519
  CONSTRAINT file_events_table_fkey
1514
1520
  FOREIGN KEY(file_events_table_id)
1515
- REFERENCES metaschema_public.table (id)
1521
+ REFERENCES metaschema_public."table" (id)
1516
1522
  ON DELETE CASCADE
1517
1523
  );
1518
1524
 
1519
1525
  CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module (database_id);
1520
1526
 
1521
- CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module (database_id, (COALESCE(membership_type, -1)), storage_key);
1527
+ CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module (database_id, (COALESCE(membership_type, -1)), key);
1522
1528
 
1523
1529
  CREATE TABLE metaschema_modules_public.entity_type_provision (
1524
1530
  id uuid PRIMARY KEY DEFAULT uuidv7(),
@@ -1532,10 +1538,13 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
1532
1538
  has_limits boolean NOT NULL DEFAULT false,
1533
1539
  has_profiles boolean NOT NULL DEFAULT false,
1534
1540
  has_levels boolean NOT NULL DEFAULT false,
1535
- has_storage boolean NOT NULL DEFAULT false,
1536
1541
  has_invites boolean NOT NULL DEFAULT false,
1537
1542
  has_invite_achievements boolean NOT NULL DEFAULT false,
1538
- storage_config jsonb DEFAULT NULL,
1543
+ storage jsonb DEFAULT NULL,
1544
+ namespaces jsonb DEFAULT NULL,
1545
+ functions jsonb DEFAULT NULL,
1546
+ graphs jsonb DEFAULT NULL,
1547
+ agents jsonb DEFAULT NULL,
1539
1548
  skip_entity_policies boolean NOT NULL DEFAULT false,
1540
1549
  table_provision jsonb DEFAULT NULL,
1541
1550
  out_membership_type int DEFAULT NULL,
@@ -1547,6 +1556,19 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
1547
1556
  out_files_table_id uuid DEFAULT NULL,
1548
1557
  out_path_shares_table_id uuid DEFAULT NULL,
1549
1558
  out_invites_module_id uuid DEFAULT NULL,
1559
+ out_namespace_module_id uuid DEFAULT NULL,
1560
+ out_namespaces_table_id uuid DEFAULT NULL,
1561
+ out_namespace_events_table_id uuid DEFAULT NULL,
1562
+ out_function_module_id uuid DEFAULT NULL,
1563
+ out_definitions_table_id uuid DEFAULT NULL,
1564
+ out_invocations_table_id uuid DEFAULT NULL,
1565
+ out_execution_logs_table_id uuid DEFAULT NULL,
1566
+ out_secret_definitions_table_id uuid DEFAULT NULL,
1567
+ out_requirements_table_id uuid DEFAULT NULL,
1568
+ out_config_requirements_table_id uuid DEFAULT NULL,
1569
+ out_graph_module_id uuid DEFAULT NULL,
1570
+ out_graphs_table_id uuid DEFAULT NULL,
1571
+ out_agent_module_id uuid DEFAULT NULL,
1550
1572
  CONSTRAINT entity_type_provision_unique_prefix
1551
1573
  UNIQUE (database_id, prefix),
1552
1574
  CONSTRAINT entity_type_provision_db_fkey
@@ -1608,18 +1630,13 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_levels IS
1608
1630
  Levels provide gamification/achievement tracking for members.
1609
1631
  When true, creates level steps, achievements, and level tables with security.';
1610
1632
 
1611
- COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_storage IS 'Whether to provision storage_module for this type. Defaults to false.
1612
- When true, creates {prefix}_buckets and {prefix}_files tables
1613
- with entity-scoped RLS (AuthzEntityMembership) using the entity''s membership_type.
1614
- Storage tables get owner_id FK to the entity table, so files are owned by the entity.';
1615
-
1616
1633
  COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invites IS 'Whether to provision invites_module for this type. Defaults to false.
1617
1634
  When true, the trigger inserts a row into invites_module which in turn
1618
1635
  (via insert_invites_module BEFORE INSERT) creates {prefix}_invites and
1619
1636
  {prefix}_claimed_invites tables plus the submit_{prefix}_invite_code() function.
1620
- Symmetric counterpart of has_storage. Re-provisioning is idempotent: the
1621
- UNIQUE (database_id, membership_type) constraint on invites_module combined with
1622
- ON CONFLICT DO NOTHING in the fan-out makes repeated INSERTs safe.';
1637
+ Re-provisioning is idempotent: the UNIQUE (database_id, membership_type) constraint
1638
+ on invites_module combined with ON CONFLICT DO NOTHING in the fan-out makes
1639
+ repeated INSERTs safe.';
1623
1640
 
1624
1641
  COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invite_achievements IS 'Whether to auto-attach an EventTracker to the claimed_invites table for invite-based
1625
1642
  achievements. Defaults to false. Requires has_invites=true AND has_levels=true.
@@ -1682,14 +1699,16 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_entity_tab
1682
1699
  COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_installed_modules IS 'Output: array of installed module labels (e.g. ARRAY[''permissions_module:data_room'', ''memberships_module:data_room'', ''invites_module:data_room'']).
1683
1700
  Populated by the trigger. Useful for verifying which modules were provisioned.';
1684
1701
 
1685
- COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage_config IS 'Optional JSON array of storage module definitions. Each element provisions a separate
1686
- storage module with its own tables ({prefix}_{storage_key}_buckets/files), RLS policies,
1687
- and feature flags. Only used when has_storage = true; ignored otherwise.
1688
- NULL = provision a single default storage module with all defaults.
1702
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage IS 'Optional JSON array of storage module definitions. Presence triggers provisioning
1703
+ (same inference model as namespaces, functions, agents).
1704
+ Each element provisions a separate storage module with its own tables
1705
+ ({prefix}_{key}_buckets/files), RLS policies, and feature flags.
1706
+ NULL = do not provision storage. ''[{}]'' = provision one default storage module.
1689
1707
  Each array element recognizes (all optional):
1690
- - storage_key (text) module discriminator, max 16 chars, lowercase snake_case.
1708
+ - key (text) module discriminator, max 16 chars, lowercase snake_case.
1691
1709
  Defaults to ''default'' (omitted from table names).
1692
1710
  Non-default keys become infixes: {prefix}_{key}_buckets.
1711
+ (storage_key accepted for backward compat)
1693
1712
  - upload_url_expiry_seconds (integer) presigned PUT URL expiry override
1694
1713
  - download_url_expiry_seconds (integer) presigned GET URL expiry override
1695
1714
  - default_max_file_size (bigint) global max file size in bytes for this module
@@ -1707,20 +1726,60 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage_config
1707
1726
  - provisions (jsonb object) per-table customization keyed by "files" or "buckets".
1708
1727
  Each value: { nodes, fields, grants, use_rls, policies }.
1709
1728
  Example (single module, backward compat):
1710
- storage_config := ''[{"buckets": [{"name": "documents"}]}]''::jsonb
1729
+ storage := ''[{"buckets": [{"name": "documents"}]}]''::jsonb
1711
1730
  Example (multi-module):
1712
- storage_config := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"storage_key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
1731
+ storage := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
1713
1732
 
1714
- COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_storage_module_id IS 'Output: the UUID of the storage_module row created for this entity type. Populated by the trigger when has_storage=true.';
1733
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_storage_module_id IS '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.';
1715
1734
 
1716
- COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_buckets_table_id IS 'Output: the UUID of the generated buckets table (e.g. data_room_buckets). Populated by the trigger when has_storage=true.';
1735
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_buckets_table_id IS '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.';
1717
1736
 
1718
- COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_files_table_id IS 'Output: the UUID of the generated files table (e.g. data_room_files). Populated by the trigger when has_storage=true.';
1737
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_files_table_id IS '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.';
1719
1738
 
1720
1739
  COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_invites_module_id IS 'Output: the UUID of the invites_module row created for this entity type. Populated by the trigger when has_invites=true.
1721
1740
  NULL when has_invites=false, or when re-provisioning hits ON CONFLICT DO NOTHING
1722
1741
  (i.e. the invites_module row was created in a previous run).';
1723
1742
 
1743
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.namespaces IS 'Optional JSON array of namespace module definitions. Presence triggers provisioning.
1744
+ NULL = do not provision namespaces. ''[{}]'' = provision one default namespace module.
1745
+ Each element recognizes (all optional):
1746
+ - key (text) module discriminator. Defaults to ''default''.
1747
+ - policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_namespace_security().
1748
+ Creates {prefix}_namespaces (or {prefix}_{key}_namespaces for non-default keys)
1749
+ with entity-scoped RLS (AuthzEntityMembership) and a rename proxy trigger.
1750
+ Registers manage_namespaces permission bit on first provision.
1751
+ Example: namespaces := ''[{}]''::jsonb';
1752
+
1753
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.functions IS 'Optional JSON array of function module definitions. Presence triggers provisioning.
1754
+ NULL = do not provision functions. ''[{}]'' = provision one default function module.
1755
+ Each element recognizes (all optional):
1756
+ - key (text) module discriminator. Defaults to ''default''.
1757
+ - policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_function_security().
1758
+ Creates {prefix}_function_definitions (or {prefix}_{key}_function_definitions for non-default keys)
1759
+ with entity-scoped RLS and a job trigger dispatching function:provision tasks.
1760
+ Registers manage_functions + invoke_functions permission bits on first provision.
1761
+ Example: functions := ''[{}]''::jsonb';
1762
+
1763
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.graphs IS 'Optional JSON array of graph module definitions. Presence triggers provisioning.
1764
+ NULL = do not provision graphs. ''[{}]'' = provision one default graph module.
1765
+ Each element recognizes (all optional):
1766
+ - key (text) module discriminator. Defaults to ''default''.
1767
+ - policies (jsonb array) RLS policy overrides. NULL = apply defaults from apply_graph_security().
1768
+ Registers manage_graphs + execute_graphs permission bits on first provision.
1769
+ Graph module requires a merkle_store_module_id dependency, so entity_type_provision
1770
+ only registers permissions here. The graph module itself must be provisioned
1771
+ separately with the merkle store dependency resolved.
1772
+ Example: graphs := ''[{}]''::jsonb';
1773
+
1774
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespace_module_id IS 'Output: the UUID of the namespace_module row created (or found) for this entity type.
1775
+ Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
1776
+
1777
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespaces_table_id IS 'Output: the UUID of the generated namespaces table (e.g. data_room_namespaces).
1778
+ Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
1779
+
1780
+ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_namespace_events_table_id IS 'Output: the UUID of the generated namespace_events partitioned table (e.g. data_room_namespace_events).
1781
+ Monthly partitioned, 12-month retention. Populated by the trigger when namespaces is non-NULL. NULL otherwise.';
1782
+
1724
1783
  CREATE TABLE metaschema_modules_public.rate_limits_module (
1725
1784
  id uuid PRIMARY KEY DEFAULT uuidv7(),
1726
1785
  database_id uuid NOT NULL,
@@ -1741,15 +1800,15 @@ CREATE TABLE metaschema_modules_public.rate_limits_module (
1741
1800
  ON DELETE CASCADE,
1742
1801
  CONSTRAINT rate_limit_settings_table_fkey
1743
1802
  FOREIGN KEY(rate_limit_settings_table_id)
1744
- REFERENCES metaschema_public.table (id)
1803
+ REFERENCES metaschema_public."table" (id)
1745
1804
  ON DELETE CASCADE,
1746
1805
  CONSTRAINT ip_rate_limits_table_fkey
1747
1806
  FOREIGN KEY(ip_rate_limits_table_id)
1748
- REFERENCES metaschema_public.table (id)
1807
+ REFERENCES metaschema_public."table" (id)
1749
1808
  ON DELETE CASCADE,
1750
1809
  CONSTRAINT rate_limits_table_fkey
1751
1810
  FOREIGN KEY(rate_limits_table_id)
1752
- REFERENCES metaschema_public.table (id)
1811
+ REFERENCES metaschema_public."table" (id)
1753
1812
  ON DELETE CASCADE,
1754
1813
  CONSTRAINT rate_limits_module_database_id_uniq
1755
1814
  UNIQUE (database_id)
@@ -1781,11 +1840,11 @@ CREATE TABLE metaschema_modules_public.devices_module (
1781
1840
  ON DELETE CASCADE,
1782
1841
  CONSTRAINT user_devices_table_fkey
1783
1842
  FOREIGN KEY(user_devices_table_id)
1784
- REFERENCES metaschema_public.table (id)
1843
+ REFERENCES metaschema_public."table" (id)
1785
1844
  ON DELETE CASCADE,
1786
1845
  CONSTRAINT device_settings_table_fkey
1787
1846
  FOREIGN KEY(device_settings_table_id)
1788
- REFERENCES metaschema_public.table (id)
1847
+ REFERENCES metaschema_public."table" (id)
1789
1848
  ON DELETE CASCADE,
1790
1849
  CONSTRAINT devices_module_database_id_uniq
1791
1850
  UNIQUE (database_id)
@@ -1814,11 +1873,11 @@ CREATE TABLE metaschema_modules_public.session_secrets_module (
1814
1873
  ON DELETE CASCADE,
1815
1874
  CONSTRAINT table_fkey
1816
1875
  FOREIGN KEY(table_id)
1817
- REFERENCES metaschema_public.table (id)
1876
+ REFERENCES metaschema_public."table" (id)
1818
1877
  ON DELETE CASCADE,
1819
1878
  CONSTRAINT sessions_table_fkey
1820
1879
  FOREIGN KEY(sessions_table_id)
1821
- REFERENCES metaschema_public.table (id)
1880
+ REFERENCES metaschema_public."table" (id)
1822
1881
  ON DELETE CASCADE
1823
1882
  );
1824
1883
 
@@ -1848,11 +1907,11 @@ CREATE TABLE metaschema_modules_public.webauthn_credentials_module (
1848
1907
  ON DELETE CASCADE,
1849
1908
  CONSTRAINT table_fkey
1850
1909
  FOREIGN KEY(table_id)
1851
- REFERENCES metaschema_public.table (id)
1910
+ REFERENCES metaschema_public."table" (id)
1852
1911
  ON DELETE CASCADE,
1853
1912
  CONSTRAINT owner_table_fkey
1854
1913
  FOREIGN KEY(owner_table_id)
1855
- REFERENCES metaschema_public.table (id)
1914
+ REFERENCES metaschema_public."table" (id)
1856
1915
  ON DELETE CASCADE,
1857
1916
  CONSTRAINT schema_fkey
1858
1917
  FOREIGN KEY(schema_id)
@@ -1897,27 +1956,27 @@ CREATE TABLE metaschema_modules_public.webauthn_auth_module (
1897
1956
  ON DELETE CASCADE,
1898
1957
  CONSTRAINT users_table_fkey
1899
1958
  FOREIGN KEY(users_table_id)
1900
- REFERENCES metaschema_public.table (id)
1959
+ REFERENCES metaschema_public."table" (id)
1901
1960
  ON DELETE CASCADE,
1902
1961
  CONSTRAINT credentials_table_fkey
1903
1962
  FOREIGN KEY(credentials_table_id)
1904
- REFERENCES metaschema_public.table (id)
1963
+ REFERENCES metaschema_public."table" (id)
1905
1964
  ON DELETE CASCADE,
1906
1965
  CONSTRAINT sessions_table_fkey
1907
1966
  FOREIGN KEY(sessions_table_id)
1908
- REFERENCES metaschema_public.table (id)
1967
+ REFERENCES metaschema_public."table" (id)
1909
1968
  ON DELETE CASCADE,
1910
1969
  CONSTRAINT session_credentials_table_fkey
1911
1970
  FOREIGN KEY(session_credentials_table_id)
1912
- REFERENCES metaschema_public.table (id)
1971
+ REFERENCES metaschema_public."table" (id)
1913
1972
  ON DELETE CASCADE,
1914
1973
  CONSTRAINT session_secrets_table_fkey
1915
1974
  FOREIGN KEY(session_secrets_table_id)
1916
- REFERENCES metaschema_public.table (id)
1975
+ REFERENCES metaschema_public."table" (id)
1917
1976
  ON DELETE CASCADE,
1918
1977
  CONSTRAINT auth_settings_table_fkey
1919
1978
  FOREIGN KEY(auth_settings_table_id)
1920
- REFERENCES metaschema_public.table (id)
1979
+ REFERENCES metaschema_public."table" (id)
1921
1980
  ON DELETE CASCADE
1922
1981
  );
1923
1982
 
@@ -1936,7 +1995,7 @@ CREATE TABLE metaschema_modules_public.identity_providers_module (
1936
1995
  ON DELETE CASCADE,
1937
1996
  CONSTRAINT table_fkey
1938
1997
  FOREIGN KEY(table_id)
1939
- REFERENCES metaschema_public.table (id)
1998
+ REFERENCES metaschema_public."table" (id)
1940
1999
  ON DELETE CASCADE,
1941
2000
  CONSTRAINT schema_fkey
1942
2001
  FOREIGN KEY(schema_id)
@@ -1984,35 +2043,35 @@ CREATE TABLE metaschema_modules_public.notifications_module (
1984
2043
  ON DELETE CASCADE,
1985
2044
  CONSTRAINT notifications_table_fkey
1986
2045
  FOREIGN KEY(notifications_table_id)
1987
- REFERENCES metaschema_public.table (id)
2046
+ REFERENCES metaschema_public."table" (id)
1988
2047
  ON DELETE CASCADE,
1989
2048
  CONSTRAINT read_state_table_fkey
1990
2049
  FOREIGN KEY(read_state_table_id)
1991
- REFERENCES metaschema_public.table (id)
2050
+ REFERENCES metaschema_public."table" (id)
1992
2051
  ON DELETE CASCADE,
1993
2052
  CONSTRAINT preferences_table_fkey
1994
2053
  FOREIGN KEY(preferences_table_id)
1995
- REFERENCES metaschema_public.table (id)
2054
+ REFERENCES metaschema_public."table" (id)
1996
2055
  ON DELETE SET NULL,
1997
2056
  CONSTRAINT channels_table_fkey
1998
2057
  FOREIGN KEY(channels_table_id)
1999
- REFERENCES metaschema_public.table (id)
2058
+ REFERENCES metaschema_public."table" (id)
2000
2059
  ON DELETE SET NULL,
2001
2060
  CONSTRAINT delivery_log_table_fkey
2002
2061
  FOREIGN KEY(delivery_log_table_id)
2003
- REFERENCES metaschema_public.table (id)
2062
+ REFERENCES metaschema_public."table" (id)
2004
2063
  ON DELETE SET NULL,
2005
2064
  CONSTRAINT owner_table_fkey
2006
2065
  FOREIGN KEY(owner_table_id)
2007
- REFERENCES metaschema_public.table (id)
2066
+ REFERENCES metaschema_public."table" (id)
2008
2067
  ON DELETE CASCADE,
2009
2068
  CONSTRAINT user_settings_table_fkey
2010
2069
  FOREIGN KEY(user_settings_table_id)
2011
- REFERENCES metaschema_public.table (id)
2070
+ REFERENCES metaschema_public."table" (id)
2012
2071
  ON DELETE SET NULL,
2013
2072
  CONSTRAINT organization_settings_table_fkey
2014
2073
  FOREIGN KEY(organization_settings_table_id)
2015
- REFERENCES metaschema_public.table (id)
2074
+ REFERENCES metaschema_public."table" (id)
2016
2075
  ON DELETE SET NULL,
2017
2076
  CONSTRAINT schema_fkey
2018
2077
  FOREIGN KEY(schema_id)
@@ -2083,19 +2142,19 @@ CREATE TABLE metaschema_modules_public.plans_module (
2083
2142
  ON DELETE CASCADE,
2084
2143
  CONSTRAINT plans_table_fkey
2085
2144
  FOREIGN KEY(plans_table_id)
2086
- REFERENCES metaschema_public.table (id)
2145
+ REFERENCES metaschema_public."table" (id)
2087
2146
  ON DELETE CASCADE,
2088
2147
  CONSTRAINT plan_limits_table_fkey
2089
2148
  FOREIGN KEY(plan_limits_table_id)
2090
- REFERENCES metaschema_public.table (id)
2149
+ REFERENCES metaschema_public."table" (id)
2091
2150
  ON DELETE CASCADE,
2092
2151
  CONSTRAINT plan_pricing_table_fkey
2093
2152
  FOREIGN KEY(plan_pricing_table_id)
2094
- REFERENCES metaschema_public.table (id)
2153
+ REFERENCES metaschema_public."table" (id)
2095
2154
  ON DELETE CASCADE,
2096
2155
  CONSTRAINT plan_overrides_table_fkey
2097
2156
  FOREIGN KEY(plan_overrides_table_id)
2098
- REFERENCES metaschema_public.table (id)
2157
+ REFERENCES metaschema_public."table" (id)
2099
2158
  ON DELETE CASCADE,
2100
2159
  CONSTRAINT plans_module_database_id_unique
2101
2160
  UNIQUE (database_id)
@@ -2118,6 +2177,8 @@ CREATE TABLE metaschema_modules_public.billing_module (
2118
2177
  balances_table_name text NOT NULL DEFAULT '',
2119
2178
  meter_credits_table_id uuid NOT NULL DEFAULT uuid_nil(),
2120
2179
  meter_credits_table_name text NOT NULL DEFAULT '',
2180
+ meter_sources_table_id uuid NOT NULL DEFAULT uuid_nil(),
2181
+ meter_sources_table_name text NOT NULL DEFAULT '',
2121
2182
  record_usage_function text NOT NULL DEFAULT '',
2122
2183
  prefix text NULL,
2123
2184
  CONSTRAINT db_fkey
@@ -2134,23 +2195,27 @@ CREATE TABLE metaschema_modules_public.billing_module (
2134
2195
  ON DELETE CASCADE,
2135
2196
  CONSTRAINT meters_table_fkey
2136
2197
  FOREIGN KEY(meters_table_id)
2137
- REFERENCES metaschema_public.table (id)
2198
+ REFERENCES metaschema_public."table" (id)
2138
2199
  ON DELETE CASCADE,
2139
2200
  CONSTRAINT plan_subscriptions_table_fkey
2140
2201
  FOREIGN KEY(plan_subscriptions_table_id)
2141
- REFERENCES metaschema_public.table (id)
2202
+ REFERENCES metaschema_public."table" (id)
2142
2203
  ON DELETE CASCADE,
2143
2204
  CONSTRAINT ledger_table_fkey
2144
2205
  FOREIGN KEY(ledger_table_id)
2145
- REFERENCES metaschema_public.table (id)
2206
+ REFERENCES metaschema_public."table" (id)
2146
2207
  ON DELETE CASCADE,
2147
2208
  CONSTRAINT balances_table_fkey
2148
2209
  FOREIGN KEY(balances_table_id)
2149
- REFERENCES metaschema_public.table (id)
2210
+ REFERENCES metaschema_public."table" (id)
2150
2211
  ON DELETE CASCADE,
2151
2212
  CONSTRAINT meter_credits_table_fkey
2152
2213
  FOREIGN KEY(meter_credits_table_id)
2153
- REFERENCES metaschema_public.table (id)
2214
+ REFERENCES metaschema_public."table" (id)
2215
+ ON DELETE CASCADE,
2216
+ CONSTRAINT meter_sources_table_fkey
2217
+ FOREIGN KEY(meter_sources_table_id)
2218
+ REFERENCES metaschema_public."table" (id)
2154
2219
  ON DELETE CASCADE,
2155
2220
  CONSTRAINT billing_module_database_id_unique
2156
2221
  UNIQUE (database_id)
@@ -2193,35 +2258,35 @@ CREATE TABLE metaschema_modules_public.billing_provider_module (
2193
2258
  ON DELETE CASCADE,
2194
2259
  CONSTRAINT billing_customers_table_fkey
2195
2260
  FOREIGN KEY(billing_customers_table_id)
2196
- REFERENCES metaschema_public.table (id)
2261
+ REFERENCES metaschema_public."table" (id)
2197
2262
  ON DELETE CASCADE,
2198
2263
  CONSTRAINT billing_products_table_fkey
2199
2264
  FOREIGN KEY(billing_products_table_id)
2200
- REFERENCES metaschema_public.table (id)
2265
+ REFERENCES metaschema_public."table" (id)
2201
2266
  ON DELETE CASCADE,
2202
2267
  CONSTRAINT billing_prices_table_fkey
2203
2268
  FOREIGN KEY(billing_prices_table_id)
2204
- REFERENCES metaschema_public.table (id)
2269
+ REFERENCES metaschema_public."table" (id)
2205
2270
  ON DELETE CASCADE,
2206
2271
  CONSTRAINT billing_subscriptions_table_fkey
2207
2272
  FOREIGN KEY(billing_subscriptions_table_id)
2208
- REFERENCES metaschema_public.table (id)
2273
+ REFERENCES metaschema_public."table" (id)
2209
2274
  ON DELETE CASCADE,
2210
2275
  CONSTRAINT billing_webhook_events_table_fkey
2211
2276
  FOREIGN KEY(billing_webhook_events_table_id)
2212
- REFERENCES metaschema_public.table (id)
2277
+ REFERENCES metaschema_public."table" (id)
2213
2278
  ON DELETE CASCADE,
2214
2279
  CONSTRAINT products_table_fkey
2215
2280
  FOREIGN KEY(products_table_id)
2216
- REFERENCES metaschema_public.table (id)
2281
+ REFERENCES metaschema_public."table" (id)
2217
2282
  ON DELETE SET NULL,
2218
2283
  CONSTRAINT prices_table_fkey
2219
2284
  FOREIGN KEY(prices_table_id)
2220
- REFERENCES metaschema_public.table (id)
2285
+ REFERENCES metaschema_public."table" (id)
2221
2286
  ON DELETE SET NULL,
2222
2287
  CONSTRAINT subscriptions_table_fkey
2223
2288
  FOREIGN KEY(subscriptions_table_id)
2224
- REFERENCES metaschema_public.table (id)
2289
+ REFERENCES metaschema_public."table" (id)
2225
2290
  ON DELETE SET NULL,
2226
2291
  CONSTRAINT billing_provider_module_database_id_unique
2227
2292
  UNIQUE (database_id)
@@ -2240,7 +2305,7 @@ CREATE TABLE metaschema_modules_public.realtime_module (
2240
2305
  source_registry_table_id uuid NOT NULL DEFAULT uuid_nil(),
2241
2306
  retention_hours int NOT NULL DEFAULT 168,
2242
2307
  premake int NOT NULL DEFAULT 7,
2243
- "interval" text NOT NULL DEFAULT '1 day',
2308
+ interval text NOT NULL DEFAULT '1 day',
2244
2309
  notify_channel text NULL,
2245
2310
  CONSTRAINT db_fkey
2246
2311
  FOREIGN KEY(database_id)
@@ -2260,15 +2325,15 @@ CREATE TABLE metaschema_modules_public.realtime_module (
2260
2325
  ON DELETE CASCADE,
2261
2326
  CONSTRAINT change_log_table_fkey
2262
2327
  FOREIGN KEY(change_log_table_id)
2263
- REFERENCES metaschema_public.table (id)
2328
+ REFERENCES metaschema_public."table" (id)
2264
2329
  ON DELETE CASCADE,
2265
2330
  CONSTRAINT listener_node_table_fkey
2266
2331
  FOREIGN KEY(listener_node_table_id)
2267
- REFERENCES metaschema_public.table (id)
2332
+ REFERENCES metaschema_public."table" (id)
2268
2333
  ON DELETE CASCADE,
2269
2334
  CONSTRAINT source_registry_table_fkey
2270
2335
  FOREIGN KEY(source_registry_table_id)
2271
- REFERENCES metaschema_public.table (id)
2336
+ REFERENCES metaschema_public."table" (id)
2272
2337
  ON DELETE CASCADE
2273
2338
  );
2274
2339
 
@@ -2315,15 +2380,15 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
2315
2380
  ON DELETE CASCADE,
2316
2381
  CONSTRAINT rate_limit_state_table_fkey
2317
2382
  FOREIGN KEY(rate_limit_state_table_id)
2318
- REFERENCES metaschema_public.table (id)
2383
+ REFERENCES metaschema_public."table" (id)
2319
2384
  ON DELETE CASCADE,
2320
2385
  CONSTRAINT rate_limit_overrides_table_fkey
2321
2386
  FOREIGN KEY(rate_limit_overrides_table_id)
2322
- REFERENCES metaschema_public.table (id)
2387
+ REFERENCES metaschema_public."table" (id)
2323
2388
  ON DELETE CASCADE,
2324
2389
  CONSTRAINT rate_window_limits_table_fkey
2325
2390
  FOREIGN KEY(rate_window_limits_table_id)
2326
- REFERENCES metaschema_public.table (id)
2391
+ REFERENCES metaschema_public."table" (id)
2327
2392
  ON DELETE CASCADE,
2328
2393
  CONSTRAINT rate_limit_meters_module_database_id_unique
2329
2394
  UNIQUE (database_id)
@@ -2353,7 +2418,7 @@ CREATE TABLE metaschema_modules_public.config_secrets_org_module (
2353
2418
  ON DELETE CASCADE,
2354
2419
  CONSTRAINT table_fkey
2355
2420
  FOREIGN KEY(table_id)
2356
- REFERENCES metaschema_public.table (id)
2421
+ REFERENCES metaschema_public."table" (id)
2357
2422
  ON DELETE CASCADE
2358
2423
  );
2359
2424
 
@@ -2363,4 +2428,526 @@ CREATE INDEX config_secrets_org_module_schema_id_idx ON metaschema_modules_publi
2363
2428
 
2364
2429
  CREATE INDEX config_secrets_org_module_table_id_idx ON metaschema_modules_public.config_secrets_org_module (table_id);
2365
2430
 
2366
- 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.';
2431
+ 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.';
2432
+
2433
+ CREATE TABLE metaschema_modules_public.inference_log_module (
2434
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2435
+ database_id uuid NOT NULL,
2436
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2437
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2438
+ inference_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2439
+ inference_log_table_name text NOT NULL DEFAULT '',
2440
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2441
+ usage_daily_table_name text NOT NULL DEFAULT '',
2442
+ interval text NOT NULL DEFAULT '1 month',
2443
+ retention text NOT NULL DEFAULT '12 months',
2444
+ premake int NOT NULL DEFAULT 2,
2445
+ scope text NOT NULL DEFAULT 'app',
2446
+ actor_fk_table_id uuid NULL,
2447
+ entity_fk_table_id uuid NULL,
2448
+ prefix text NULL,
2449
+ CONSTRAINT db_fkey
2450
+ FOREIGN KEY(database_id)
2451
+ REFERENCES metaschema_public.database (id)
2452
+ ON DELETE CASCADE,
2453
+ CONSTRAINT schema_fkey
2454
+ FOREIGN KEY(schema_id)
2455
+ REFERENCES metaschema_public.schema (id)
2456
+ ON DELETE CASCADE,
2457
+ CONSTRAINT private_schema_fkey
2458
+ FOREIGN KEY(private_schema_id)
2459
+ REFERENCES metaschema_public.schema (id)
2460
+ ON DELETE CASCADE,
2461
+ CONSTRAINT inference_log_table_fkey
2462
+ FOREIGN KEY(inference_log_table_id)
2463
+ REFERENCES metaschema_public."table" (id)
2464
+ ON DELETE CASCADE,
2465
+ CONSTRAINT usage_daily_table_fkey
2466
+ FOREIGN KEY(usage_daily_table_id)
2467
+ REFERENCES metaschema_public."table" (id)
2468
+ ON DELETE CASCADE,
2469
+ CONSTRAINT inference_log_module_database_id_prefix_unique
2470
+ UNIQUE NULLS NOT DISTINCT (database_id, prefix)
2471
+ );
2472
+
2473
+ CREATE INDEX inference_log_module_database_id_idx ON metaschema_modules_public.inference_log_module (database_id);
2474
+
2475
+ CREATE TABLE metaschema_modules_public.compute_log_module (
2476
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2477
+ database_id uuid NOT NULL,
2478
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2479
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2480
+ compute_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2481
+ compute_log_table_name text NOT NULL DEFAULT '',
2482
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2483
+ usage_daily_table_name text NOT NULL DEFAULT '',
2484
+ interval text NOT NULL DEFAULT '1 month',
2485
+ retention text NOT NULL DEFAULT '12 months',
2486
+ premake int NOT NULL DEFAULT 2,
2487
+ scope text NOT NULL DEFAULT 'app',
2488
+ actor_fk_table_id uuid NULL,
2489
+ entity_fk_table_id uuid NULL,
2490
+ prefix text NULL,
2491
+ CONSTRAINT db_fkey
2492
+ FOREIGN KEY(database_id)
2493
+ REFERENCES metaschema_public.database (id)
2494
+ ON DELETE CASCADE,
2495
+ CONSTRAINT schema_fkey
2496
+ FOREIGN KEY(schema_id)
2497
+ REFERENCES metaschema_public.schema (id)
2498
+ ON DELETE CASCADE,
2499
+ CONSTRAINT private_schema_fkey
2500
+ FOREIGN KEY(private_schema_id)
2501
+ REFERENCES metaschema_public.schema (id)
2502
+ ON DELETE CASCADE,
2503
+ CONSTRAINT compute_log_table_fkey
2504
+ FOREIGN KEY(compute_log_table_id)
2505
+ REFERENCES metaschema_public."table" (id)
2506
+ ON DELETE CASCADE,
2507
+ CONSTRAINT usage_daily_table_fkey
2508
+ FOREIGN KEY(usage_daily_table_id)
2509
+ REFERENCES metaschema_public."table" (id)
2510
+ ON DELETE CASCADE,
2511
+ CONSTRAINT compute_log_module_database_id_prefix_unique
2512
+ UNIQUE NULLS NOT DISTINCT (database_id, prefix)
2513
+ );
2514
+
2515
+ CREATE INDEX compute_log_module_database_id_idx ON metaschema_modules_public.compute_log_module (database_id);
2516
+
2517
+ CREATE TABLE metaschema_modules_public.transfer_log_module (
2518
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2519
+ database_id uuid NOT NULL,
2520
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2521
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2522
+ transfer_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2523
+ transfer_log_table_name text NOT NULL DEFAULT '',
2524
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2525
+ usage_daily_table_name text NOT NULL DEFAULT '',
2526
+ interval text NOT NULL DEFAULT '1 month',
2527
+ retention text NOT NULL DEFAULT '12 months',
2528
+ premake int NOT NULL DEFAULT 2,
2529
+ scope text NOT NULL DEFAULT 'app',
2530
+ actor_fk_table_id uuid NULL,
2531
+ entity_fk_table_id uuid NULL,
2532
+ prefix text NULL,
2533
+ CONSTRAINT db_fkey
2534
+ FOREIGN KEY(database_id)
2535
+ REFERENCES metaschema_public.database (id)
2536
+ ON DELETE CASCADE,
2537
+ CONSTRAINT schema_fkey
2538
+ FOREIGN KEY(schema_id)
2539
+ REFERENCES metaschema_public.schema (id)
2540
+ ON DELETE CASCADE,
2541
+ CONSTRAINT private_schema_fkey
2542
+ FOREIGN KEY(private_schema_id)
2543
+ REFERENCES metaschema_public.schema (id)
2544
+ ON DELETE CASCADE,
2545
+ CONSTRAINT transfer_log_table_fkey
2546
+ FOREIGN KEY(transfer_log_table_id)
2547
+ REFERENCES metaschema_public."table" (id)
2548
+ ON DELETE CASCADE,
2549
+ CONSTRAINT usage_daily_table_fkey
2550
+ FOREIGN KEY(usage_daily_table_id)
2551
+ REFERENCES metaschema_public."table" (id)
2552
+ ON DELETE CASCADE,
2553
+ CONSTRAINT transfer_log_module_database_id_prefix_unique
2554
+ UNIQUE NULLS NOT DISTINCT (database_id, prefix)
2555
+ );
2556
+
2557
+ CREATE INDEX transfer_log_module_database_id_idx ON metaschema_modules_public.transfer_log_module (database_id);
2558
+
2559
+ CREATE TABLE metaschema_modules_public.storage_log_module (
2560
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2561
+ database_id uuid NOT NULL,
2562
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2563
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2564
+ storage_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2565
+ storage_log_table_name text NOT NULL DEFAULT '',
2566
+ usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2567
+ usage_daily_table_name text NOT NULL DEFAULT '',
2568
+ interval text NOT NULL DEFAULT '1 month',
2569
+ retention text NOT NULL DEFAULT '12 months',
2570
+ premake int NOT NULL DEFAULT 2,
2571
+ scope text NOT NULL DEFAULT 'app',
2572
+ actor_fk_table_id uuid NULL,
2573
+ entity_fk_table_id uuid NULL,
2574
+ prefix text NULL,
2575
+ CONSTRAINT db_fkey
2576
+ FOREIGN KEY(database_id)
2577
+ REFERENCES metaschema_public.database (id)
2578
+ ON DELETE CASCADE,
2579
+ CONSTRAINT schema_fkey
2580
+ FOREIGN KEY(schema_id)
2581
+ REFERENCES metaschema_public.schema (id)
2582
+ ON DELETE CASCADE,
2583
+ CONSTRAINT private_schema_fkey
2584
+ FOREIGN KEY(private_schema_id)
2585
+ REFERENCES metaschema_public.schema (id)
2586
+ ON DELETE CASCADE,
2587
+ CONSTRAINT storage_log_table_fkey
2588
+ FOREIGN KEY(storage_log_table_id)
2589
+ REFERENCES metaschema_public."table" (id)
2590
+ ON DELETE CASCADE,
2591
+ CONSTRAINT usage_daily_table_fkey
2592
+ FOREIGN KEY(usage_daily_table_id)
2593
+ REFERENCES metaschema_public."table" (id)
2594
+ ON DELETE CASCADE,
2595
+ CONSTRAINT storage_log_module_database_id_prefix_unique
2596
+ UNIQUE NULLS NOT DISTINCT (database_id, prefix)
2597
+ );
2598
+
2599
+ CREATE INDEX storage_log_module_database_id_idx ON metaschema_modules_public.storage_log_module (database_id);
2600
+
2601
+ CREATE TABLE metaschema_modules_public.db_usage_module (
2602
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2603
+ database_id uuid NOT NULL,
2604
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2605
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2606
+ table_stats_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2607
+ table_stats_log_table_name text NOT NULL DEFAULT '',
2608
+ table_stats_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2609
+ table_stats_daily_table_name text NOT NULL DEFAULT '',
2610
+ query_stats_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
2611
+ query_stats_log_table_name text NOT NULL DEFAULT '',
2612
+ query_stats_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2613
+ query_stats_daily_table_name text NOT NULL DEFAULT '',
2614
+ interval text NOT NULL DEFAULT '1 month',
2615
+ retention text NOT NULL DEFAULT '12 months',
2616
+ premake int NOT NULL DEFAULT 2,
2617
+ scope text NOT NULL DEFAULT 'app',
2618
+ prefix text NULL,
2619
+ CONSTRAINT db_fkey
2620
+ FOREIGN KEY(database_id)
2621
+ REFERENCES metaschema_public.database (id)
2622
+ ON DELETE CASCADE,
2623
+ CONSTRAINT schema_fkey
2624
+ FOREIGN KEY(schema_id)
2625
+ REFERENCES metaschema_public.schema (id)
2626
+ ON DELETE CASCADE,
2627
+ CONSTRAINT private_schema_fkey
2628
+ FOREIGN KEY(private_schema_id)
2629
+ REFERENCES metaschema_public.schema (id)
2630
+ ON DELETE CASCADE,
2631
+ CONSTRAINT table_stats_log_table_fkey
2632
+ FOREIGN KEY(table_stats_log_table_id)
2633
+ REFERENCES metaschema_public."table" (id)
2634
+ ON DELETE CASCADE,
2635
+ CONSTRAINT table_stats_daily_table_fkey
2636
+ FOREIGN KEY(table_stats_daily_table_id)
2637
+ REFERENCES metaschema_public."table" (id)
2638
+ ON DELETE CASCADE,
2639
+ CONSTRAINT query_stats_log_table_fkey
2640
+ FOREIGN KEY(query_stats_log_table_id)
2641
+ REFERENCES metaschema_public."table" (id)
2642
+ ON DELETE CASCADE,
2643
+ CONSTRAINT query_stats_daily_table_fkey
2644
+ FOREIGN KEY(query_stats_daily_table_id)
2645
+ REFERENCES metaschema_public."table" (id)
2646
+ ON DELETE CASCADE,
2647
+ CONSTRAINT db_usage_module_database_id_prefix_unique
2648
+ UNIQUE NULLS NOT DISTINCT (database_id, prefix)
2649
+ );
2650
+
2651
+ CREATE INDEX db_usage_module_database_id_idx ON metaschema_modules_public.db_usage_module (database_id);
2652
+
2653
+ CREATE TABLE metaschema_modules_public.agent_module (
2654
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2655
+ database_id uuid NOT NULL,
2656
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2657
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2658
+ thread_table_id uuid NOT NULL DEFAULT uuid_nil(),
2659
+ message_table_id uuid NOT NULL DEFAULT uuid_nil(),
2660
+ task_table_id uuid NOT NULL DEFAULT uuid_nil(),
2661
+ prompts_table_id uuid NOT NULL DEFAULT uuid_nil(),
2662
+ knowledge_table_id uuid DEFAULT NULL,
2663
+ thread_table_name text NOT NULL DEFAULT 'agent_thread',
2664
+ message_table_name text NOT NULL DEFAULT 'agent_message',
2665
+ task_table_name text NOT NULL DEFAULT 'agent_task',
2666
+ prompts_table_name text NOT NULL DEFAULT 'agent_prompt',
2667
+ knowledge_table_name text NOT NULL DEFAULT 'agent_knowledge',
2668
+ has_knowledge boolean NOT NULL DEFAULT false,
2669
+ api_name text DEFAULT 'agent',
2670
+ membership_type int DEFAULT NULL,
2671
+ key text NOT NULL DEFAULT 'default',
2672
+ entity_table_id uuid NULL,
2673
+ policies jsonb NULL,
2674
+ knowledge_config jsonb NULL,
2675
+ knowledge_policies jsonb NULL,
2676
+ provisions jsonb NULL,
2677
+ CONSTRAINT agent_module_db_fkey
2678
+ FOREIGN KEY(database_id)
2679
+ REFERENCES metaschema_public.database (id)
2680
+ ON DELETE CASCADE,
2681
+ CONSTRAINT agent_module_schema_fkey
2682
+ FOREIGN KEY(schema_id)
2683
+ REFERENCES metaschema_public.schema (id)
2684
+ ON DELETE CASCADE,
2685
+ CONSTRAINT agent_module_private_schema_fkey
2686
+ FOREIGN KEY(private_schema_id)
2687
+ REFERENCES metaschema_public.schema (id)
2688
+ ON DELETE CASCADE,
2689
+ CONSTRAINT agent_module_thread_table_fkey
2690
+ FOREIGN KEY(thread_table_id)
2691
+ REFERENCES metaschema_public."table" (id)
2692
+ ON DELETE CASCADE,
2693
+ CONSTRAINT agent_module_message_table_fkey
2694
+ FOREIGN KEY(message_table_id)
2695
+ REFERENCES metaschema_public."table" (id)
2696
+ ON DELETE CASCADE,
2697
+ CONSTRAINT agent_module_task_table_fkey
2698
+ FOREIGN KEY(task_table_id)
2699
+ REFERENCES metaschema_public."table" (id)
2700
+ ON DELETE CASCADE,
2701
+ CONSTRAINT agent_module_prompts_table_fkey
2702
+ FOREIGN KEY(prompts_table_id)
2703
+ REFERENCES metaschema_public."table" (id)
2704
+ ON DELETE CASCADE,
2705
+ CONSTRAINT agent_module_knowledge_table_fkey
2706
+ FOREIGN KEY(knowledge_table_id)
2707
+ REFERENCES metaschema_public."table" (id)
2708
+ ON DELETE CASCADE,
2709
+ CONSTRAINT agent_module_entity_table_fkey
2710
+ FOREIGN KEY(entity_table_id)
2711
+ REFERENCES metaschema_public."table" (id)
2712
+ ON DELETE CASCADE
2713
+ );
2714
+
2715
+ CREATE INDEX agent_module_database_id_idx ON metaschema_modules_public.agent_module (database_id);
2716
+
2717
+ CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module (database_id, (COALESCE(membership_type, -1)), key);
2718
+
2719
+ CREATE TABLE metaschema_modules_public.merkle_store_module (
2720
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2721
+ database_id uuid NOT NULL,
2722
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2723
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2724
+ public_schema_name text,
2725
+ private_schema_name text,
2726
+ object_table_id uuid NOT NULL DEFAULT uuid_nil(),
2727
+ store_table_id uuid NOT NULL DEFAULT uuid_nil(),
2728
+ commit_table_id uuid NOT NULL DEFAULT uuid_nil(),
2729
+ ref_table_id uuid NOT NULL DEFAULT uuid_nil(),
2730
+ prefix text NOT NULL DEFAULT '',
2731
+ api_name text,
2732
+ private_api_name text,
2733
+ scope_field text NOT NULL DEFAULT 'scope_id',
2734
+ created_at timestamptz NOT NULL DEFAULT now(),
2735
+ CONSTRAINT db_fkey
2736
+ FOREIGN KEY(database_id)
2737
+ REFERENCES metaschema_public.database (id)
2738
+ ON DELETE CASCADE,
2739
+ CONSTRAINT schema_fkey
2740
+ FOREIGN KEY(schema_id)
2741
+ REFERENCES metaschema_public.schema (id)
2742
+ ON DELETE CASCADE,
2743
+ CONSTRAINT private_schema_fkey
2744
+ FOREIGN KEY(private_schema_id)
2745
+ REFERENCES metaschema_public.schema (id)
2746
+ ON DELETE CASCADE,
2747
+ CONSTRAINT object_table_fkey
2748
+ FOREIGN KEY(object_table_id)
2749
+ REFERENCES metaschema_public."table" (id)
2750
+ ON DELETE CASCADE,
2751
+ CONSTRAINT store_table_fkey
2752
+ FOREIGN KEY(store_table_id)
2753
+ REFERENCES metaschema_public."table" (id)
2754
+ ON DELETE CASCADE,
2755
+ CONSTRAINT commit_table_fkey
2756
+ FOREIGN KEY(commit_table_id)
2757
+ REFERENCES metaschema_public."table" (id)
2758
+ ON DELETE CASCADE,
2759
+ CONSTRAINT ref_table_fkey
2760
+ FOREIGN KEY(ref_table_id)
2761
+ REFERENCES metaschema_public."table" (id)
2762
+ ON DELETE CASCADE,
2763
+ CONSTRAINT merkle_store_module_database_prefix_unique
2764
+ UNIQUE (database_id, prefix)
2765
+ );
2766
+
2767
+ CREATE INDEX merkle_store_module_database_id_idx ON metaschema_modules_public.merkle_store_module (database_id);
2768
+
2769
+ CREATE INDEX merkle_store_module_private_schema_id_idx ON metaschema_modules_public.merkle_store_module (private_schema_id);
2770
+
2771
+ CREATE TABLE metaschema_modules_public.graph_module (
2772
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2773
+ database_id uuid NOT NULL,
2774
+ public_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2775
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2776
+ public_schema_name text,
2777
+ private_schema_name text,
2778
+ prefix text NOT NULL DEFAULT '',
2779
+ merkle_store_module_id uuid NOT NULL,
2780
+ graphs_table_id uuid NOT NULL DEFAULT uuid_nil(),
2781
+ executions_table_id uuid NOT NULL DEFAULT uuid_nil(),
2782
+ outputs_table_id uuid NOT NULL DEFAULT uuid_nil(),
2783
+ api_name text,
2784
+ private_api_name text,
2785
+ scope_field text NOT NULL DEFAULT 'scope_id',
2786
+ membership_type int DEFAULT NULL,
2787
+ entity_table_id uuid NULL,
2788
+ policies jsonb NULL,
2789
+ provisions jsonb NULL,
2790
+ created_at timestamptz NOT NULL DEFAULT now(),
2791
+ CONSTRAINT db_fkey
2792
+ FOREIGN KEY(database_id)
2793
+ REFERENCES metaschema_public.database (id)
2794
+ ON DELETE CASCADE,
2795
+ CONSTRAINT public_schema_fkey
2796
+ FOREIGN KEY(public_schema_id)
2797
+ REFERENCES metaschema_public.schema (id)
2798
+ ON DELETE CASCADE,
2799
+ CONSTRAINT private_schema_fkey
2800
+ FOREIGN KEY(private_schema_id)
2801
+ REFERENCES metaschema_public.schema (id)
2802
+ ON DELETE CASCADE,
2803
+ CONSTRAINT merkle_store_fkey
2804
+ FOREIGN KEY(merkle_store_module_id)
2805
+ REFERENCES metaschema_modules_public.merkle_store_module (id)
2806
+ ON DELETE CASCADE,
2807
+ CONSTRAINT graphs_table_fkey
2808
+ FOREIGN KEY(graphs_table_id)
2809
+ REFERENCES metaschema_public."table" (id)
2810
+ ON DELETE CASCADE,
2811
+ CONSTRAINT executions_table_fkey
2812
+ FOREIGN KEY(executions_table_id)
2813
+ REFERENCES metaschema_public."table" (id)
2814
+ ON DELETE CASCADE,
2815
+ CONSTRAINT outputs_table_fkey
2816
+ FOREIGN KEY(outputs_table_id)
2817
+ REFERENCES metaschema_public."table" (id)
2818
+ ON DELETE CASCADE,
2819
+ CONSTRAINT graph_module_entity_table_fkey
2820
+ FOREIGN KEY(entity_table_id)
2821
+ REFERENCES metaschema_public."table" (id)
2822
+ ON DELETE CASCADE,
2823
+ CONSTRAINT graph_module_database_merkle_unique
2824
+ UNIQUE (database_id, merkle_store_module_id)
2825
+ );
2826
+
2827
+ CREATE INDEX graph_module_database_id_idx ON metaschema_modules_public.graph_module (database_id);
2828
+
2829
+ CREATE TABLE metaschema_modules_public.namespace_module (
2830
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2831
+ database_id uuid NOT NULL,
2832
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2833
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2834
+ public_schema_name text,
2835
+ private_schema_name text,
2836
+ namespaces_table_id uuid NOT NULL DEFAULT uuid_nil(),
2837
+ namespace_events_table_id uuid NOT NULL DEFAULT uuid_nil(),
2838
+ namespaces_table_name text NOT NULL DEFAULT 'namespaces',
2839
+ namespace_events_table_name text NOT NULL DEFAULT 'namespace_events',
2840
+ api_name text,
2841
+ private_api_name text,
2842
+ membership_type int DEFAULT NULL,
2843
+ key text NOT NULL DEFAULT 'default',
2844
+ entity_table_id uuid NULL,
2845
+ policies jsonb NULL,
2846
+ provisions jsonb NULL,
2847
+ CONSTRAINT namespace_module_db_fkey
2848
+ FOREIGN KEY(database_id)
2849
+ REFERENCES metaschema_public.database (id)
2850
+ ON DELETE CASCADE,
2851
+ CONSTRAINT namespace_module_schema_fkey
2852
+ FOREIGN KEY(schema_id)
2853
+ REFERENCES metaschema_public.schema (id)
2854
+ ON DELETE CASCADE,
2855
+ CONSTRAINT namespace_module_private_schema_fkey
2856
+ FOREIGN KEY(private_schema_id)
2857
+ REFERENCES metaschema_public.schema (id)
2858
+ ON DELETE CASCADE,
2859
+ CONSTRAINT namespace_module_namespaces_table_fkey
2860
+ FOREIGN KEY(namespaces_table_id)
2861
+ REFERENCES metaschema_public."table" (id)
2862
+ ON DELETE CASCADE,
2863
+ CONSTRAINT namespace_module_events_table_fkey
2864
+ FOREIGN KEY(namespace_events_table_id)
2865
+ REFERENCES metaschema_public."table" (id)
2866
+ ON DELETE CASCADE,
2867
+ CONSTRAINT namespace_module_entity_table_fkey
2868
+ FOREIGN KEY(entity_table_id)
2869
+ REFERENCES metaschema_public."table" (id)
2870
+ ON DELETE CASCADE
2871
+ );
2872
+
2873
+ CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module (database_id);
2874
+
2875
+ CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module (database_id, (COALESCE(membership_type, -1)), key);
2876
+
2877
+ CREATE TABLE metaschema_modules_public.function_module (
2878
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
2879
+ database_id uuid NOT NULL,
2880
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
2881
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2882
+ public_schema_name text,
2883
+ private_schema_name text,
2884
+ definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
2885
+ invocations_table_id uuid NOT NULL DEFAULT uuid_nil(),
2886
+ execution_logs_table_id uuid NOT NULL DEFAULT uuid_nil(),
2887
+ secret_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
2888
+ requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
2889
+ config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
2890
+ config_requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
2891
+ definitions_table_name text NOT NULL DEFAULT 'function_definitions',
2892
+ invocations_table_name text NOT NULL DEFAULT 'function_invocations',
2893
+ execution_logs_table_name text NOT NULL DEFAULT 'function_execution_logs',
2894
+ secret_definitions_table_name text NOT NULL DEFAULT 'secret_definitions',
2895
+ requirements_table_name text NOT NULL DEFAULT 'function_secret_requirements',
2896
+ config_requirements_table_name text NOT NULL DEFAULT 'function_config_requirements',
2897
+ api_name text,
2898
+ private_api_name text,
2899
+ membership_type int DEFAULT NULL,
2900
+ prefix text NULL,
2901
+ key text NOT NULL DEFAULT 'default',
2902
+ entity_table_id uuid NULL,
2903
+ policies jsonb NULL,
2904
+ provisions jsonb NULL,
2905
+ CONSTRAINT function_module_db_fkey
2906
+ FOREIGN KEY(database_id)
2907
+ REFERENCES metaschema_public.database (id)
2908
+ ON DELETE CASCADE,
2909
+ CONSTRAINT function_module_schema_fkey
2910
+ FOREIGN KEY(schema_id)
2911
+ REFERENCES metaschema_public.schema (id)
2912
+ ON DELETE CASCADE,
2913
+ CONSTRAINT function_module_private_schema_fkey
2914
+ FOREIGN KEY(private_schema_id)
2915
+ REFERENCES metaschema_public.schema (id)
2916
+ ON DELETE CASCADE,
2917
+ CONSTRAINT function_module_definitions_table_fkey
2918
+ FOREIGN KEY(definitions_table_id)
2919
+ REFERENCES metaschema_public."table" (id)
2920
+ ON DELETE CASCADE,
2921
+ CONSTRAINT function_module_invocations_table_fkey
2922
+ FOREIGN KEY(invocations_table_id)
2923
+ REFERENCES metaschema_public."table" (id)
2924
+ ON DELETE CASCADE,
2925
+ CONSTRAINT function_module_execution_logs_table_fkey
2926
+ FOREIGN KEY(execution_logs_table_id)
2927
+ REFERENCES metaschema_public."table" (id)
2928
+ ON DELETE CASCADE,
2929
+ CONSTRAINT function_module_secret_defs_table_fkey
2930
+ FOREIGN KEY(secret_definitions_table_id)
2931
+ REFERENCES metaschema_public."table" (id)
2932
+ ON DELETE CASCADE,
2933
+ CONSTRAINT function_module_requirements_table_fkey
2934
+ FOREIGN KEY(requirements_table_id)
2935
+ REFERENCES metaschema_public."table" (id)
2936
+ ON DELETE CASCADE,
2937
+ CONSTRAINT function_module_config_defs_table_fkey
2938
+ FOREIGN KEY(config_definitions_table_id)
2939
+ REFERENCES metaschema_public."table" (id)
2940
+ ON DELETE CASCADE,
2941
+ CONSTRAINT function_module_config_reqs_table_fkey
2942
+ FOREIGN KEY(config_requirements_table_id)
2943
+ REFERENCES metaschema_public."table" (id)
2944
+ ON DELETE CASCADE,
2945
+ CONSTRAINT function_module_entity_table_fkey
2946
+ FOREIGN KEY(entity_table_id)
2947
+ REFERENCES metaschema_public."table" (id)
2948
+ ON DELETE CASCADE
2949
+ );
2950
+
2951
+ CREATE INDEX function_module_database_id_idx ON metaschema_modules_public.function_module (database_id);
2952
+
2953
+ CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module (database_id, (COALESCE(membership_type, -1)), key);