@pgpm/metaschema-modules 0.26.3 → 0.26.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/Makefile +1 -1
  2. package/README.md +19 -4
  3. package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +35 -24
  4. package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +13 -0
  5. package/deploy/schemas/metaschema_modules_public/tables/billing_provider_module/table.sql +4 -0
  6. package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +7 -2
  7. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +82 -0
  8. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +4 -0
  9. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +4 -0
  10. package/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +4 -0
  11. package/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +4 -0
  12. package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +11 -2
  13. package/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +4 -0
  14. package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +0 -4
  15. package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +14 -4
  16. package/deploy/schemas/metaschema_modules_public/tables/function_invocation_module/table.sql +67 -0
  17. package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +14 -33
  18. package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +10 -8
  19. package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +10 -3
  20. package/deploy/schemas/metaschema_modules_public/tables/i18n_module/table.sql +31 -0
  21. package/deploy/schemas/metaschema_modules_public/tables/identity_providers_module/table.sql +35 -3
  22. package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +7 -2
  23. package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +12 -10
  24. package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +10 -4
  25. package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +17 -8
  26. package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +8 -2
  27. package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +13 -12
  28. package/deploy/schemas/metaschema_modules_public/tables/notifications_module/table.sql +11 -0
  29. package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +12 -5
  30. package/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +4 -0
  31. package/deploy/schemas/metaschema_modules_public/tables/plans_module/table.sql +16 -0
  32. package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +10 -4
  33. package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +8 -0
  34. package/deploy/schemas/metaschema_modules_public/tables/realtime_module/table.sql +4 -0
  35. package/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +4 -0
  36. package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +7 -2
  37. package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +19 -14
  38. package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +7 -2
  39. package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +4 -0
  40. package/deploy/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +42 -0
  41. package/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +34 -0
  42. package/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +4 -0
  43. package/deploy/schemas/metaschema_modules_public/tables/webauthn_credentials_module/table.sql +4 -0
  44. package/metaschema-modules.control +1 -1
  45. package/package.json +4 -4
  46. package/pgpm.plan +5 -0
  47. package/revert/schemas/metaschema_modules_public/tables/agent_chat_module/table.sql +3 -0
  48. package/revert/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
  49. package/revert/schemas/metaschema_modules_public/tables/function_invocation_module/table.sql +7 -0
  50. package/revert/schemas/metaschema_modules_public/tables/i18n_module/table.sql +7 -0
  51. package/revert/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
  52. package/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
  53. package/sql/{metaschema-modules--0.26.1.sql → metaschema-modules--0.26.5.sql} +565 -262
  54. package/verify/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
  55. package/verify/schemas/metaschema_modules_public/tables/function_invocation_module/table.sql +7 -0
  56. package/verify/schemas/metaschema_modules_public/tables/i18n_module/table.sql +9 -0
  57. package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +3 -1
  58. package/verify/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
  59. package/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
@@ -31,17 +31,19 @@ CREATE TABLE metaschema_modules_public.connected_accounts_module (
31
31
  table_id uuid NOT NULL DEFAULT uuid_nil(),
32
32
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
33
33
  table_name text NOT NULL,
34
+ api_name text DEFAULT 'auth',
35
+ private_api_name text DEFAULT NULL,
34
36
  CONSTRAINT db_fkey
35
37
  FOREIGN KEY(database_id)
36
38
  REFERENCES metaschema_public.database (id)
37
39
  ON DELETE CASCADE,
38
40
  CONSTRAINT table_fkey
39
41
  FOREIGN KEY(table_id)
40
- REFERENCES metaschema_public."table" (id)
42
+ REFERENCES metaschema_public.table (id)
41
43
  ON DELETE CASCADE,
42
44
  CONSTRAINT owner_table_fkey
43
45
  FOREIGN KEY(owner_table_id)
44
- REFERENCES metaschema_public."table" (id)
46
+ REFERENCES metaschema_public.table (id)
45
47
  ON DELETE CASCADE,
46
48
  CONSTRAINT schema_fkey
47
49
  FOREIGN KEY(schema_id)
@@ -64,17 +66,19 @@ CREATE TABLE metaschema_modules_public.crypto_addresses_module (
64
66
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
65
67
  table_name text NOT NULL,
66
68
  crypto_network text NOT NULL DEFAULT 'BTC',
69
+ api_name text DEFAULT 'auth',
70
+ private_api_name text DEFAULT NULL,
67
71
  CONSTRAINT db_fkey
68
72
  FOREIGN KEY(database_id)
69
73
  REFERENCES metaschema_public.database (id)
70
74
  ON DELETE CASCADE,
71
75
  CONSTRAINT table_fkey
72
76
  FOREIGN KEY(table_id)
73
- REFERENCES metaschema_public."table" (id)
77
+ REFERENCES metaschema_public.table (id)
74
78
  ON DELETE CASCADE,
75
79
  CONSTRAINT owner_table_fkey
76
80
  FOREIGN KEY(owner_table_id)
77
- REFERENCES metaschema_public."table" (id)
81
+ REFERENCES metaschema_public.table (id)
78
82
  ON DELETE CASCADE,
79
83
  CONSTRAINT schema_fkey
80
84
  FOREIGN KEY(schema_id)
@@ -109,19 +113,19 @@ CREATE TABLE metaschema_modules_public.crypto_auth_module (
109
113
  ON DELETE CASCADE,
110
114
  CONSTRAINT secrets_table_fkey
111
115
  FOREIGN KEY(secrets_table_id)
112
- REFERENCES metaschema_public."table" (id)
116
+ REFERENCES metaschema_public.table (id)
113
117
  ON DELETE CASCADE,
114
118
  CONSTRAINT users_table_fkey
115
119
  FOREIGN KEY(users_table_id)
116
- REFERENCES metaschema_public."table" (id)
120
+ REFERENCES metaschema_public.table (id)
117
121
  ON DELETE CASCADE,
118
122
  CONSTRAINT sessions_table_fkey
119
123
  FOREIGN KEY(sessions_table_id)
120
- REFERENCES metaschema_public."table" (id)
124
+ REFERENCES metaschema_public.table (id)
121
125
  ON DELETE CASCADE,
122
126
  CONSTRAINT session_credentials_table_fkey
123
127
  FOREIGN KEY(session_credentials_table_id)
124
- REFERENCES metaschema_public."table" (id)
128
+ REFERENCES metaschema_public.table (id)
125
129
  ON DELETE CASCADE,
126
130
  CONSTRAINT schema_fkey
127
131
  FOREIGN KEY(schema_id)
@@ -161,11 +165,11 @@ CREATE TABLE metaschema_modules_public.denormalized_table_field (
161
165
  ON DELETE CASCADE,
162
166
  CONSTRAINT table_fkey
163
167
  FOREIGN KEY(table_id)
164
- REFERENCES metaschema_public."table" (id)
168
+ REFERENCES metaschema_public.table (id)
165
169
  ON DELETE CASCADE,
166
170
  CONSTRAINT ref_table_fkey
167
171
  FOREIGN KEY(ref_table_id)
168
- REFERENCES metaschema_public."table" (id)
172
+ REFERENCES metaschema_public.table (id)
169
173
  ON DELETE CASCADE,
170
174
  CONSTRAINT field_fkey
171
175
  FOREIGN KEY(field_id)
@@ -187,17 +191,19 @@ CREATE TABLE metaschema_modules_public.emails_module (
187
191
  table_id uuid NOT NULL DEFAULT uuid_nil(),
188
192
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
189
193
  table_name text NOT NULL,
194
+ api_name text DEFAULT 'auth',
195
+ private_api_name text DEFAULT NULL,
190
196
  CONSTRAINT db_fkey
191
197
  FOREIGN KEY(database_id)
192
198
  REFERENCES metaschema_public.database (id)
193
199
  ON DELETE CASCADE,
194
200
  CONSTRAINT table_fkey
195
201
  FOREIGN KEY(table_id)
196
- REFERENCES metaschema_public."table" (id)
202
+ REFERENCES metaschema_public.table (id)
197
203
  ON DELETE CASCADE,
198
204
  CONSTRAINT owner_table_fkey
199
205
  FOREIGN KEY(owner_table_id)
200
- REFERENCES metaschema_public."table" (id)
206
+ REFERENCES metaschema_public.table (id)
201
207
  ON DELETE CASCADE,
202
208
  CONSTRAINT schema_fkey
203
209
  FOREIGN KEY(schema_id)
@@ -218,6 +224,8 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
218
224
  table_id uuid NOT NULL DEFAULT uuid_nil(),
219
225
  table_name text NOT NULL DEFAULT 'user_secrets',
220
226
  config_definitions_table_id uuid NOT NULL DEFAULT uuid_nil(),
227
+ api_name text DEFAULT 'config',
228
+ private_api_name text DEFAULT NULL,
221
229
  CONSTRAINT db_fkey
222
230
  FOREIGN KEY(database_id)
223
231
  REFERENCES metaschema_public.database (id)
@@ -228,11 +236,11 @@ CREATE TABLE metaschema_modules_public.config_secrets_user_module (
228
236
  ON DELETE CASCADE,
229
237
  CONSTRAINT table_fkey
230
238
  FOREIGN KEY(table_id)
231
- REFERENCES metaschema_public."table" (id)
239
+ REFERENCES metaschema_public.table (id)
232
240
  ON DELETE CASCADE,
233
241
  CONSTRAINT config_defs_table_fkey
234
242
  FOREIGN KEY(config_definitions_table_id)
235
- REFERENCES metaschema_public."table" (id)
243
+ REFERENCES metaschema_public.table (id)
236
244
  ON DELETE CASCADE
237
245
  );
238
246
 
@@ -250,32 +258,34 @@ CREATE TABLE metaschema_modules_public.invites_module (
250
258
  invites_table_name text NOT NULL DEFAULT '',
251
259
  claimed_invites_table_name text NOT NULL DEFAULT '',
252
260
  submit_invite_code_function text NOT NULL DEFAULT '',
253
- prefix text NULL,
254
- membership_type int NOT NULL,
261
+ scope text NOT NULL DEFAULT 'app',
262
+ prefix text NOT NULL DEFAULT '',
255
263
  entity_table_id uuid NULL,
264
+ api_name text DEFAULT 'admin',
265
+ private_api_name text DEFAULT NULL,
256
266
  CONSTRAINT db_fkey
257
267
  FOREIGN KEY(database_id)
258
268
  REFERENCES metaschema_public.database (id)
259
269
  ON DELETE CASCADE,
260
270
  CONSTRAINT invites_table_fkey
261
271
  FOREIGN KEY(invites_table_id)
262
- REFERENCES metaschema_public."table" (id)
272
+ REFERENCES metaschema_public.table (id)
263
273
  ON DELETE CASCADE,
264
274
  CONSTRAINT emails_table_fkey
265
275
  FOREIGN KEY(emails_table_id)
266
- REFERENCES metaschema_public."table" (id)
276
+ REFERENCES metaschema_public.table (id)
267
277
  ON DELETE CASCADE,
268
278
  CONSTRAINT users_table_fkey
269
279
  FOREIGN KEY(users_table_id)
270
- REFERENCES metaschema_public."table" (id)
280
+ REFERENCES metaschema_public.table (id)
271
281
  ON DELETE CASCADE,
272
282
  CONSTRAINT entity_table_fkey
273
283
  FOREIGN KEY(entity_table_id)
274
- REFERENCES metaschema_public."table" (id)
284
+ REFERENCES metaschema_public.table (id)
275
285
  ON DELETE CASCADE,
276
286
  CONSTRAINT claimed_invites_table_fkey
277
287
  FOREIGN KEY(claimed_invites_table_id)
278
- REFERENCES metaschema_public."table" (id)
288
+ REFERENCES metaschema_public.table (id)
279
289
  ON DELETE CASCADE,
280
290
  CONSTRAINT schema_fkey
281
291
  FOREIGN KEY(schema_id)
@@ -289,7 +299,7 @@ CREATE TABLE metaschema_modules_public.invites_module (
289
299
 
290
300
  CREATE INDEX invites_module_database_id_idx ON metaschema_modules_public.invites_module (database_id);
291
301
 
292
- CREATE UNIQUE INDEX invites_module_unique_scope ON metaschema_modules_public.invites_module (database_id, membership_type);
302
+ CREATE UNIQUE INDEX invites_module_unique_scope ON metaschema_modules_public.invites_module (database_id, scope, prefix);
293
303
 
294
304
  CREATE TABLE metaschema_modules_public.events_module (
295
305
  id uuid PRIMARY KEY DEFAULT uuidv7(),
@@ -324,13 +334,16 @@ CREATE TABLE metaschema_modules_public.events_module (
324
334
  tg_check_achievements text NOT NULL DEFAULT '',
325
335
  grant_achievement text NOT NULL DEFAULT '',
326
336
  tg_achievement_reward text NOT NULL DEFAULT '',
327
- interval text NOT NULL DEFAULT '1 month',
337
+ "interval" text NOT NULL DEFAULT '1 month',
328
338
  retention text DEFAULT '12 months',
329
339
  premake int NOT NULL DEFAULT 2,
330
- prefix text NULL,
331
- membership_type int NOT NULL,
340
+ scope text NOT NULL DEFAULT 'app',
341
+ prefix text NOT NULL DEFAULT '',
332
342
  entity_table_id uuid NULL,
333
343
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
344
+ default_permissions text[] DEFAULT NULL,
345
+ api_name text DEFAULT 'usage',
346
+ private_api_name text DEFAULT NULL,
334
347
  CONSTRAINT db_fkey
335
348
  FOREIGN KEY(database_id)
336
349
  REFERENCES metaschema_public.database (id)
@@ -345,39 +358,39 @@ CREATE TABLE metaschema_modules_public.events_module (
345
358
  ON DELETE CASCADE,
346
359
  CONSTRAINT events_table_fkey
347
360
  FOREIGN KEY(events_table_id)
348
- REFERENCES metaschema_public."table" (id)
361
+ REFERENCES metaschema_public.table (id)
349
362
  ON DELETE CASCADE,
350
363
  CONSTRAINT event_aggregates_table_fkey
351
364
  FOREIGN KEY(event_aggregates_table_id)
352
- REFERENCES metaschema_public."table" (id)
365
+ REFERENCES metaschema_public.table (id)
353
366
  ON DELETE CASCADE,
354
367
  CONSTRAINT event_types_table_fkey
355
368
  FOREIGN KEY(event_types_table_id)
356
- REFERENCES metaschema_public."table" (id)
369
+ REFERENCES metaschema_public.table (id)
357
370
  ON DELETE CASCADE,
358
371
  CONSTRAINT levels_table_fkey
359
372
  FOREIGN KEY(levels_table_id)
360
- REFERENCES metaschema_public."table" (id)
373
+ REFERENCES metaschema_public.table (id)
361
374
  ON DELETE CASCADE,
362
375
  CONSTRAINT level_requirements_table_fkey
363
376
  FOREIGN KEY(level_requirements_table_id)
364
- REFERENCES metaschema_public."table" (id)
377
+ REFERENCES metaschema_public.table (id)
365
378
  ON DELETE CASCADE,
366
379
  CONSTRAINT level_grants_table_fkey
367
380
  FOREIGN KEY(level_grants_table_id)
368
- REFERENCES metaschema_public."table" (id)
381
+ REFERENCES metaschema_public.table (id)
369
382
  ON DELETE CASCADE,
370
383
  CONSTRAINT achievement_rewards_table_fkey
371
384
  FOREIGN KEY(achievement_rewards_table_id)
372
- REFERENCES metaschema_public."table" (id)
385
+ REFERENCES metaschema_public.table (id)
373
386
  ON DELETE CASCADE,
374
387
  CONSTRAINT entity_table_fkey
375
388
  FOREIGN KEY(entity_table_id)
376
- REFERENCES metaschema_public."table" (id)
389
+ REFERENCES metaschema_public.table (id)
377
390
  ON DELETE CASCADE,
378
391
  CONSTRAINT actor_table_fkey
379
392
  FOREIGN KEY(actor_table_id)
380
- REFERENCES metaschema_public."table" (id)
393
+ REFERENCES metaschema_public.table (id)
381
394
  ON DELETE CASCADE
382
395
  );
383
396
 
@@ -412,10 +425,12 @@ CREATE TABLE metaschema_modules_public.limits_module (
412
425
  limit_warning_state_table_id uuid NULL,
413
426
  limit_check_soft_function text NOT NULL DEFAULT '',
414
427
  limit_aggregate_check_soft_function text NOT NULL DEFAULT '',
415
- prefix text NULL,
416
- membership_type int NOT NULL,
428
+ scope text NOT NULL DEFAULT 'app',
429
+ prefix text NOT NULL DEFAULT '',
417
430
  entity_table_id uuid NULL,
418
431
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
432
+ api_name text DEFAULT 'usage',
433
+ private_api_name text DEFAULT NULL,
419
434
  CONSTRAINT db_fkey
420
435
  FOREIGN KEY(database_id)
421
436
  REFERENCES metaschema_public.database (id)
@@ -430,59 +445,59 @@ CREATE TABLE metaschema_modules_public.limits_module (
430
445
  ON DELETE CASCADE,
431
446
  CONSTRAINT table_fkey
432
447
  FOREIGN KEY(table_id)
433
- REFERENCES metaschema_public."table" (id)
448
+ REFERENCES metaschema_public.table (id)
434
449
  ON DELETE CASCADE,
435
450
  CONSTRAINT default_table_fkey
436
451
  FOREIGN KEY(default_table_id)
437
- REFERENCES metaschema_public."table" (id)
452
+ REFERENCES metaschema_public.table (id)
438
453
  ON DELETE CASCADE,
439
454
  CONSTRAINT entity_table_fkey
440
455
  FOREIGN KEY(entity_table_id)
441
- REFERENCES metaschema_public."table" (id)
456
+ REFERENCES metaschema_public.table (id)
442
457
  ON DELETE CASCADE,
443
458
  CONSTRAINT actor_table_fkey
444
459
  FOREIGN KEY(actor_table_id)
445
- REFERENCES metaschema_public."table" (id)
460
+ REFERENCES metaschema_public.table (id)
446
461
  ON DELETE CASCADE,
447
462
  CONSTRAINT aggregate_table_fkey
448
463
  FOREIGN KEY(aggregate_table_id)
449
- REFERENCES metaschema_public."table" (id)
464
+ REFERENCES metaschema_public.table (id)
450
465
  ON DELETE CASCADE,
451
466
  CONSTRAINT limit_credits_table_fkey
452
467
  FOREIGN KEY(limit_credits_table_id)
453
- REFERENCES metaschema_public."table" (id)
468
+ REFERENCES metaschema_public.table (id)
454
469
  ON DELETE CASCADE,
455
470
  CONSTRAINT events_table_fkey
456
471
  FOREIGN KEY(events_table_id)
457
- REFERENCES metaschema_public."table" (id)
472
+ REFERENCES metaschema_public.table (id)
458
473
  ON DELETE CASCADE,
459
474
  CONSTRAINT credit_codes_table_fkey
460
475
  FOREIGN KEY(credit_codes_table_id)
461
- REFERENCES metaschema_public."table" (id)
476
+ REFERENCES metaschema_public.table (id)
462
477
  ON DELETE CASCADE,
463
478
  CONSTRAINT credit_code_items_table_fkey
464
479
  FOREIGN KEY(credit_code_items_table_id)
465
- REFERENCES metaschema_public."table" (id)
480
+ REFERENCES metaschema_public.table (id)
466
481
  ON DELETE CASCADE,
467
482
  CONSTRAINT credit_redemptions_table_fkey
468
483
  FOREIGN KEY(credit_redemptions_table_id)
469
- REFERENCES metaschema_public."table" (id)
484
+ REFERENCES metaschema_public.table (id)
470
485
  ON DELETE CASCADE,
471
486
  CONSTRAINT limit_caps_table_fkey
472
487
  FOREIGN KEY(limit_caps_table_id)
473
- REFERENCES metaschema_public."table" (id)
488
+ REFERENCES metaschema_public.table (id)
474
489
  ON DELETE CASCADE,
475
490
  CONSTRAINT limit_caps_defaults_table_fkey
476
491
  FOREIGN KEY(limit_caps_defaults_table_id)
477
- REFERENCES metaschema_public."table" (id)
492
+ REFERENCES metaschema_public.table (id)
478
493
  ON DELETE CASCADE,
479
494
  CONSTRAINT limit_warnings_table_fkey
480
495
  FOREIGN KEY(limit_warnings_table_id)
481
- REFERENCES metaschema_public."table" (id)
496
+ REFERENCES metaschema_public.table (id)
482
497
  ON DELETE CASCADE,
483
498
  CONSTRAINT limit_warning_state_table_fkey
484
499
  FOREIGN KEY(limit_warning_state_table_id)
485
- REFERENCES metaschema_public."table" (id)
500
+ REFERENCES metaschema_public.table (id)
486
501
  ON DELETE CASCADE
487
502
  );
488
503
 
@@ -504,7 +519,7 @@ CREATE TABLE metaschema_modules_public.membership_types_module (
504
519
  ON DELETE CASCADE,
505
520
  CONSTRAINT table_fkey
506
521
  FOREIGN KEY(table_id)
507
- REFERENCES metaschema_public."table" (id)
522
+ REFERENCES metaschema_public.table (id)
508
523
  ON DELETE CASCADE
509
524
  );
510
525
 
@@ -535,10 +550,10 @@ CREATE TABLE metaschema_modules_public.memberships_module (
535
550
  admin_grants_table_name text NOT NULL DEFAULT '',
536
551
  owner_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
537
552
  owner_grants_table_name text NOT NULL DEFAULT '',
538
- membership_type int NOT NULL,
553
+ scope text NOT NULL DEFAULT 'app',
554
+ prefix text NOT NULL DEFAULT '',
539
555
  entity_table_id uuid NULL,
540
556
  entity_table_owner_id uuid NULL,
541
- prefix text NULL,
542
557
  get_org_fn text NULL,
543
558
  actor_mask_check text NOT NULL DEFAULT '',
544
559
  actor_perm_check text NOT NULL DEFAULT '',
@@ -546,6 +561,10 @@ CREATE TABLE metaschema_modules_public.memberships_module (
546
561
  entity_ids_by_perm text NULL,
547
562
  entity_ids_function text NULL,
548
563
  member_profiles_table_id uuid NULL,
564
+ permission_default_permissions_table_id uuid NULL,
565
+ permission_default_grants_table_id uuid NULL,
566
+ api_name text DEFAULT 'admin',
567
+ private_api_name text DEFAULT NULL,
549
568
  CONSTRAINT db_fkey
550
569
  FOREIGN KEY(database_id)
551
570
  REFERENCES metaschema_public.database (id)
@@ -560,31 +579,31 @@ CREATE TABLE metaschema_modules_public.memberships_module (
560
579
  ON DELETE CASCADE,
561
580
  CONSTRAINT memberships_table_fkey
562
581
  FOREIGN KEY(memberships_table_id)
563
- REFERENCES metaschema_public."table" (id)
582
+ REFERENCES metaschema_public.table (id)
564
583
  ON DELETE CASCADE,
565
584
  CONSTRAINT membership_defaults_table_fkey
566
585
  FOREIGN KEY(membership_defaults_table_id)
567
- REFERENCES metaschema_public."table" (id)
586
+ REFERENCES metaschema_public.table (id)
568
587
  ON DELETE CASCADE,
569
588
  CONSTRAINT membership_settings_table_fkey
570
589
  FOREIGN KEY(membership_settings_table_id)
571
- REFERENCES metaschema_public."table" (id)
590
+ REFERENCES metaschema_public.table (id)
572
591
  ON DELETE CASCADE,
573
592
  CONSTRAINT members_table_fkey
574
593
  FOREIGN KEY(members_table_id)
575
- REFERENCES metaschema_public."table" (id)
594
+ REFERENCES metaschema_public.table (id)
576
595
  ON DELETE CASCADE,
577
596
  CONSTRAINT grants_table_fkey
578
597
  FOREIGN KEY(grants_table_id)
579
- REFERENCES metaschema_public."table" (id)
598
+ REFERENCES metaschema_public.table (id)
580
599
  ON DELETE CASCADE,
581
600
  CONSTRAINT sprt_table_fkey
582
601
  FOREIGN KEY(sprt_table_id)
583
- REFERENCES metaschema_public."table" (id)
602
+ REFERENCES metaschema_public.table (id)
584
603
  ON DELETE CASCADE,
585
604
  CONSTRAINT entity_table_fkey
586
605
  FOREIGN KEY(entity_table_id)
587
- REFERENCES metaschema_public."table" (id)
606
+ REFERENCES metaschema_public.table (id)
588
607
  ON DELETE CASCADE,
589
608
  CONSTRAINT entity_table_owner_fkey
590
609
  FOREIGN KEY(entity_table_owner_id)
@@ -592,24 +611,26 @@ CREATE TABLE metaschema_modules_public.memberships_module (
592
611
  ON DELETE CASCADE,
593
612
  CONSTRAINT actor_table_fkey
594
613
  FOREIGN KEY(actor_table_id)
595
- REFERENCES metaschema_public."table" (id)
614
+ REFERENCES metaschema_public.table (id)
596
615
  ON DELETE CASCADE,
597
616
  CONSTRAINT limits_table_fkey
598
617
  FOREIGN KEY(limits_table_id)
599
- REFERENCES metaschema_public."table" (id)
618
+ REFERENCES metaschema_public.table (id)
600
619
  ON DELETE CASCADE,
601
620
  CONSTRAINT default_limits_table_fkey
602
621
  FOREIGN KEY(default_limits_table_id)
603
- REFERENCES metaschema_public."table" (id)
622
+ REFERENCES metaschema_public.table (id)
604
623
  ON DELETE CASCADE,
605
624
  CONSTRAINT permissions_table_fkey
606
625
  FOREIGN KEY(permissions_table_id)
607
- REFERENCES metaschema_public."table" (id)
626
+ REFERENCES metaschema_public.table (id)
608
627
  ON DELETE CASCADE,
609
628
  CONSTRAINT default_permissions_table_fkey
610
629
  FOREIGN KEY(default_permissions_table_id)
611
- REFERENCES metaschema_public."table" (id)
612
- ON DELETE CASCADE
630
+ REFERENCES metaschema_public.table (id)
631
+ ON DELETE CASCADE,
632
+ CONSTRAINT memberships_module_unique
633
+ UNIQUE (database_id, scope, prefix)
613
634
  );
614
635
 
615
636
  CREATE INDEX memberships_module_database_id_idx ON metaschema_modules_public.memberships_module (database_id);
@@ -624,14 +645,16 @@ CREATE TABLE metaschema_modules_public.permissions_module (
624
645
  default_table_id uuid NOT NULL DEFAULT uuid_nil(),
625
646
  default_table_name text NOT NULL DEFAULT '',
626
647
  bitlen int NOT NULL DEFAULT 64,
627
- membership_type int NOT NULL,
648
+ scope text NOT NULL DEFAULT 'app',
649
+ prefix text NOT NULL DEFAULT '',
628
650
  entity_table_id uuid NULL,
629
651
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
630
- prefix text NULL,
631
652
  get_padded_mask text NOT NULL DEFAULT '',
632
653
  get_mask text NOT NULL DEFAULT '',
633
654
  get_by_mask text NOT NULL DEFAULT '',
634
655
  get_mask_by_name text NOT NULL DEFAULT '',
656
+ api_name text DEFAULT 'admin',
657
+ private_api_name text DEFAULT NULL,
635
658
  CONSTRAINT db_fkey
636
659
  FOREIGN KEY(database_id)
637
660
  REFERENCES metaschema_public.database (id)
@@ -646,19 +669,19 @@ CREATE TABLE metaschema_modules_public.permissions_module (
646
669
  ON DELETE CASCADE,
647
670
  CONSTRAINT table_fkey
648
671
  FOREIGN KEY(table_id)
649
- REFERENCES metaschema_public."table" (id)
672
+ REFERENCES metaschema_public.table (id)
650
673
  ON DELETE CASCADE,
651
674
  CONSTRAINT default_table_fkey
652
675
  FOREIGN KEY(default_table_id)
653
- REFERENCES metaschema_public."table" (id)
676
+ REFERENCES metaschema_public.table (id)
654
677
  ON DELETE CASCADE,
655
678
  CONSTRAINT entity_table_fkey
656
679
  FOREIGN KEY(entity_table_id)
657
- REFERENCES metaschema_public."table" (id)
680
+ REFERENCES metaschema_public.table (id)
658
681
  ON DELETE CASCADE,
659
682
  CONSTRAINT actor_table_fkey
660
683
  FOREIGN KEY(actor_table_id)
661
- REFERENCES metaschema_public."table" (id)
684
+ REFERENCES metaschema_public.table (id)
662
685
  ON DELETE CASCADE
663
686
  );
664
687
 
@@ -672,17 +695,19 @@ CREATE TABLE metaschema_modules_public.phone_numbers_module (
672
695
  table_id uuid NOT NULL DEFAULT uuid_nil(),
673
696
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
674
697
  table_name text NOT NULL,
698
+ api_name text DEFAULT 'auth',
699
+ private_api_name text DEFAULT NULL,
675
700
  CONSTRAINT db_fkey
676
701
  FOREIGN KEY(database_id)
677
702
  REFERENCES metaschema_public.database (id)
678
703
  ON DELETE CASCADE,
679
704
  CONSTRAINT table_fkey
680
705
  FOREIGN KEY(table_id)
681
- REFERENCES metaschema_public."table" (id)
706
+ REFERENCES metaschema_public.table (id)
682
707
  ON DELETE CASCADE,
683
708
  CONSTRAINT owner_table_fkey
684
709
  FOREIGN KEY(owner_table_id)
685
- REFERENCES metaschema_public."table" (id)
710
+ REFERENCES metaschema_public.table (id)
686
711
  ON DELETE CASCADE,
687
712
  CONSTRAINT schema_fkey
688
713
  FOREIGN KEY(schema_id)
@@ -711,12 +736,14 @@ CREATE TABLE metaschema_modules_public.profiles_module (
711
736
  profile_definition_grants_table_name text NOT NULL DEFAULT '',
712
737
  profile_templates_table_id uuid NOT NULL DEFAULT uuid_nil(),
713
738
  profile_templates_table_name text NOT NULL DEFAULT '',
714
- membership_type int NOT NULL,
739
+ scope text NOT NULL DEFAULT 'app',
740
+ prefix text NOT NULL DEFAULT '',
715
741
  entity_table_id uuid NULL,
716
742
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
717
743
  permissions_table_id uuid NOT NULL DEFAULT uuid_nil(),
718
744
  memberships_table_id uuid NOT NULL DEFAULT uuid_nil(),
719
- prefix text NULL,
745
+ api_name text DEFAULT 'admin',
746
+ private_api_name text DEFAULT NULL,
720
747
  CONSTRAINT db_fkey
721
748
  FOREIGN KEY(database_id)
722
749
  REFERENCES metaschema_public.database (id)
@@ -731,42 +758,42 @@ CREATE TABLE metaschema_modules_public.profiles_module (
731
758
  ON DELETE CASCADE,
732
759
  CONSTRAINT table_fkey
733
760
  FOREIGN KEY(table_id)
734
- REFERENCES metaschema_public."table" (id)
761
+ REFERENCES metaschema_public.table (id)
735
762
  ON DELETE CASCADE,
736
763
  CONSTRAINT profile_permissions_table_fkey
737
764
  FOREIGN KEY(profile_permissions_table_id)
738
- REFERENCES metaschema_public."table" (id)
765
+ REFERENCES metaschema_public.table (id)
739
766
  ON DELETE CASCADE,
740
767
  CONSTRAINT profile_grants_table_fkey
741
768
  FOREIGN KEY(profile_grants_table_id)
742
- REFERENCES metaschema_public."table" (id)
769
+ REFERENCES metaschema_public.table (id)
743
770
  ON DELETE CASCADE,
744
771
  CONSTRAINT profile_definition_grants_table_fkey
745
772
  FOREIGN KEY(profile_definition_grants_table_id)
746
- REFERENCES metaschema_public."table" (id)
773
+ REFERENCES metaschema_public.table (id)
747
774
  ON DELETE CASCADE,
748
775
  CONSTRAINT profile_templates_table_fkey
749
776
  FOREIGN KEY(profile_templates_table_id)
750
- REFERENCES metaschema_public."table" (id)
777
+ REFERENCES metaschema_public.table (id)
751
778
  ON DELETE CASCADE,
752
779
  CONSTRAINT entity_table_fkey
753
780
  FOREIGN KEY(entity_table_id)
754
- REFERENCES metaschema_public."table" (id)
781
+ REFERENCES metaschema_public.table (id)
755
782
  ON DELETE CASCADE,
756
783
  CONSTRAINT actor_table_fkey
757
784
  FOREIGN KEY(actor_table_id)
758
- REFERENCES metaschema_public."table" (id)
785
+ REFERENCES metaschema_public.table (id)
759
786
  ON DELETE CASCADE,
760
787
  CONSTRAINT permissions_table_fkey
761
788
  FOREIGN KEY(permissions_table_id)
762
- REFERENCES metaschema_public."table" (id)
789
+ REFERENCES metaschema_public.table (id)
763
790
  ON DELETE CASCADE,
764
791
  CONSTRAINT memberships_table_fkey
765
792
  FOREIGN KEY(memberships_table_id)
766
- REFERENCES metaschema_public."table" (id)
793
+ REFERENCES metaschema_public.table (id)
767
794
  ON DELETE CASCADE,
768
795
  CONSTRAINT profiles_module_unique
769
- UNIQUE (database_id, membership_type)
796
+ UNIQUE (database_id, scope, prefix)
770
797
  );
771
798
 
772
799
  CREATE INDEX profiles_module_database_id_idx ON metaschema_modules_public.profiles_module (database_id);
@@ -783,21 +810,23 @@ CREATE TABLE metaschema_modules_public.rls_module (
783
810
  authenticate_strict text NOT NULL DEFAULT 'authenticate_strict',
784
811
  "current_role" text NOT NULL DEFAULT 'current_user',
785
812
  current_role_id text NOT NULL DEFAULT 'current_user_id',
813
+ api_name text DEFAULT 'auth',
814
+ private_api_name text DEFAULT NULL,
786
815
  CONSTRAINT db_fkey
787
816
  FOREIGN KEY(database_id)
788
817
  REFERENCES metaschema_public.database (id)
789
818
  ON DELETE CASCADE,
790
819
  CONSTRAINT session_credentials_table_fkey
791
820
  FOREIGN KEY(session_credentials_table_id)
792
- REFERENCES metaschema_public."table" (id)
821
+ REFERENCES metaschema_public.table (id)
793
822
  ON DELETE CASCADE,
794
823
  CONSTRAINT sessions_table_fkey
795
824
  FOREIGN KEY(sessions_table_id)
796
- REFERENCES metaschema_public."table" (id)
825
+ REFERENCES metaschema_public.table (id)
797
826
  ON DELETE CASCADE,
798
827
  CONSTRAINT users_table_fkey
799
828
  FOREIGN KEY(users_table_id)
800
- REFERENCES metaschema_public."table" (id)
829
+ REFERENCES metaschema_public.table (id)
801
830
  ON DELETE CASCADE,
802
831
  CONSTRAINT schema_fkey
803
832
  FOREIGN KEY(schema_id)
@@ -837,7 +866,7 @@ CREATE TABLE metaschema_modules_public.user_state_module (
837
866
  ON DELETE CASCADE,
838
867
  CONSTRAINT table_fkey
839
868
  FOREIGN KEY(table_id)
840
- REFERENCES metaschema_public."table" (id)
869
+ REFERENCES metaschema_public.table (id)
841
870
  ON DELETE CASCADE
842
871
  );
843
872
 
@@ -865,19 +894,19 @@ CREATE TABLE metaschema_modules_public.sessions_module (
865
894
  ON DELETE CASCADE,
866
895
  CONSTRAINT sessions_table_fkey
867
896
  FOREIGN KEY(sessions_table_id)
868
- REFERENCES metaschema_public."table" (id)
897
+ REFERENCES metaschema_public.table (id)
869
898
  ON DELETE CASCADE,
870
899
  CONSTRAINT session_credentials_table_fkey
871
900
  FOREIGN KEY(session_credentials_table_id)
872
- REFERENCES metaschema_public."table" (id)
901
+ REFERENCES metaschema_public.table (id)
873
902
  ON DELETE CASCADE,
874
903
  CONSTRAINT auth_settings_table_fkey
875
904
  FOREIGN KEY(auth_settings_table_id)
876
- REFERENCES metaschema_public."table" (id)
905
+ REFERENCES metaschema_public.table (id)
877
906
  ON DELETE CASCADE,
878
907
  CONSTRAINT users_table_fkey
879
908
  FOREIGN KEY(users_table_id)
880
- REFERENCES metaschema_public."table" (id)
909
+ REFERENCES metaschema_public.table (id)
881
910
  ON DELETE CASCADE
882
911
  );
883
912
 
@@ -916,6 +945,8 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
916
945
  sign_in_cross_origin_function text NOT NULL DEFAULT 'sign_in_cross_origin',
917
946
  request_cross_origin_token_function text NOT NULL DEFAULT 'request_cross_origin_token',
918
947
  extend_token_expires text NOT NULL DEFAULT 'extend_token_expires',
948
+ api_name text DEFAULT 'auth',
949
+ private_api_name text DEFAULT NULL,
919
950
  CONSTRAINT db_fkey
920
951
  FOREIGN KEY(database_id)
921
952
  REFERENCES metaschema_public.database (id)
@@ -926,27 +957,27 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
926
957
  ON DELETE CASCADE,
927
958
  CONSTRAINT email_table_fkey
928
959
  FOREIGN KEY(emails_table_id)
929
- REFERENCES metaschema_public."table" (id)
960
+ REFERENCES metaschema_public.table (id)
930
961
  ON DELETE CASCADE,
931
962
  CONSTRAINT users_table_fkey
932
963
  FOREIGN KEY(users_table_id)
933
- REFERENCES metaschema_public."table" (id)
964
+ REFERENCES metaschema_public.table (id)
934
965
  ON DELETE CASCADE,
935
966
  CONSTRAINT secrets_table_fkey
936
967
  FOREIGN KEY(secrets_table_id)
937
- REFERENCES metaschema_public."table" (id)
968
+ REFERENCES metaschema_public.table (id)
938
969
  ON DELETE CASCADE,
939
970
  CONSTRAINT encrypted_table_fkey
940
971
  FOREIGN KEY(encrypted_table_id)
941
- REFERENCES metaschema_public."table" (id)
972
+ REFERENCES metaschema_public.table (id)
942
973
  ON DELETE CASCADE,
943
974
  CONSTRAINT sessions_table_fkey
944
975
  FOREIGN KEY(sessions_table_id)
945
- REFERENCES metaschema_public."table" (id)
976
+ REFERENCES metaschema_public.table (id)
946
977
  ON DELETE CASCADE,
947
978
  CONSTRAINT session_credentials_table_fkey
948
979
  FOREIGN KEY(session_credentials_table_id)
949
- REFERENCES metaschema_public."table" (id)
980
+ REFERENCES metaschema_public.table (id)
950
981
  ON DELETE CASCADE
951
982
  );
952
983
 
@@ -972,6 +1003,8 @@ CREATE TABLE metaschema_modules_public.users_module (
972
1003
  table_name text NOT NULL DEFAULT 'users',
973
1004
  type_table_id uuid NOT NULL DEFAULT uuid_nil(),
974
1005
  type_table_name text NOT NULL DEFAULT 'role_types',
1006
+ api_name text DEFAULT 'auth',
1007
+ private_api_name text DEFAULT NULL,
975
1008
  CONSTRAINT db_fkey
976
1009
  FOREIGN KEY(database_id)
977
1010
  REFERENCES metaschema_public.database (id)
@@ -982,11 +1015,11 @@ CREATE TABLE metaschema_modules_public.users_module (
982
1015
  ON DELETE CASCADE,
983
1016
  CONSTRAINT table_fkey
984
1017
  FOREIGN KEY(table_id)
985
- REFERENCES metaschema_public."table" (id)
1018
+ REFERENCES metaschema_public.table (id)
986
1019
  ON DELETE CASCADE,
987
1020
  CONSTRAINT type_table_fkey
988
1021
  FOREIGN KEY(type_table_id)
989
- REFERENCES metaschema_public."table" (id)
1022
+ REFERENCES metaschema_public.table (id)
990
1023
  ON DELETE CASCADE
991
1024
  );
992
1025
 
@@ -1005,13 +1038,15 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
1005
1038
  chart_edge_grants_table_name text NOT NULL DEFAULT '',
1006
1039
  entity_table_id uuid NOT NULL,
1007
1040
  users_table_id uuid NOT NULL,
1008
- prefix text NOT NULL DEFAULT 'org',
1041
+ scope text NOT NULL DEFAULT 'org',
1042
+ prefix text NOT NULL DEFAULT '',
1009
1043
  private_schema_name text NOT NULL DEFAULT '',
1010
1044
  sprt_table_name text NOT NULL DEFAULT '',
1011
1045
  rebuild_hierarchy_function text NOT NULL DEFAULT '',
1012
1046
  get_subordinates_function text NOT NULL DEFAULT '',
1013
1047
  get_managers_function text NOT NULL DEFAULT '',
1014
1048
  is_manager_of_function text NOT NULL DEFAULT '',
1049
+ default_permissions text[] DEFAULT NULL,
1015
1050
  created_at timestamptz NOT NULL DEFAULT now(),
1016
1051
  CONSTRAINT db_fkey
1017
1052
  FOREIGN KEY(database_id)
@@ -1027,23 +1062,23 @@ CREATE TABLE metaschema_modules_public.hierarchy_module (
1027
1062
  ON DELETE CASCADE,
1028
1063
  CONSTRAINT chart_edges_table_fkey
1029
1064
  FOREIGN KEY(chart_edges_table_id)
1030
- REFERENCES metaschema_public."table" (id)
1065
+ REFERENCES metaschema_public.table (id)
1031
1066
  ON DELETE CASCADE,
1032
1067
  CONSTRAINT hierarchy_sprt_table_fkey
1033
1068
  FOREIGN KEY(hierarchy_sprt_table_id)
1034
- REFERENCES metaschema_public."table" (id)
1069
+ REFERENCES metaschema_public.table (id)
1035
1070
  ON DELETE CASCADE,
1036
1071
  CONSTRAINT chart_edge_grants_table_fkey
1037
1072
  FOREIGN KEY(chart_edge_grants_table_id)
1038
- REFERENCES metaschema_public."table" (id)
1073
+ REFERENCES metaschema_public.table (id)
1039
1074
  ON DELETE CASCADE,
1040
1075
  CONSTRAINT entity_table_fkey
1041
1076
  FOREIGN KEY(entity_table_id)
1042
- REFERENCES metaschema_public."table" (id)
1077
+ REFERENCES metaschema_public.table (id)
1043
1078
  ON DELETE CASCADE,
1044
1079
  CONSTRAINT users_table_fkey
1045
1080
  FOREIGN KEY(users_table_id)
1046
- REFERENCES metaschema_public."table" (id)
1081
+ REFERENCES metaschema_public.table (id)
1047
1082
  ON DELETE CASCADE,
1048
1083
  CONSTRAINT hierarchy_module_database_unique
1049
1084
  UNIQUE (database_id)
@@ -1069,7 +1104,7 @@ CREATE TABLE metaschema_modules_public.secure_table_provision (
1069
1104
  ON DELETE CASCADE,
1070
1105
  CONSTRAINT table_fkey
1071
1106
  FOREIGN KEY(table_id)
1072
- REFERENCES metaschema_public."table" (id)
1107
+ REFERENCES metaschema_public.table (id)
1073
1108
  ON DELETE CASCADE,
1074
1109
  CONSTRAINT schema_fkey
1075
1110
  FOREIGN KEY(schema_id)
@@ -1136,11 +1171,11 @@ CREATE TABLE metaschema_modules_public.relation_provision (
1136
1171
  ON DELETE CASCADE,
1137
1172
  CONSTRAINT source_table_fkey
1138
1173
  FOREIGN KEY(source_table_id)
1139
- REFERENCES metaschema_public."table" (id)
1174
+ REFERENCES metaschema_public.table (id)
1140
1175
  ON DELETE CASCADE,
1141
1176
  CONSTRAINT target_table_fkey
1142
1177
  FOREIGN KEY(target_table_id)
1143
- REFERENCES metaschema_public."table" (id)
1178
+ REFERENCES metaschema_public.table (id)
1144
1179
  ON DELETE CASCADE
1145
1180
  );
1146
1181
 
@@ -1460,10 +1495,10 @@ CREATE TABLE metaschema_modules_public.storage_module (
1460
1495
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
1461
1496
  buckets_table_id uuid NOT NULL DEFAULT uuid_nil(),
1462
1497
  files_table_id uuid NOT NULL DEFAULT uuid_nil(),
1463
- buckets_table_name text NOT NULL DEFAULT 'app_buckets',
1464
- files_table_name text NOT NULL DEFAULT 'app_files',
1465
- membership_type int DEFAULT NULL,
1466
- key text NOT NULL DEFAULT 'default',
1498
+ buckets_table_name text NOT NULL DEFAULT 'buckets',
1499
+ files_table_name text NOT NULL DEFAULT 'files',
1500
+ scope text NOT NULL DEFAULT 'app',
1501
+ prefix text NOT NULL DEFAULT '',
1467
1502
  policies jsonb NULL,
1468
1503
  provisions jsonb NULL,
1469
1504
  entity_table_id uuid NULL,
@@ -1488,6 +1523,9 @@ CREATE TABLE metaschema_modules_public.storage_module (
1488
1523
  has_confirm_upload boolean NOT NULL DEFAULT false,
1489
1524
  confirm_upload_delay interval NOT NULL DEFAULT '30 seconds',
1490
1525
  file_events_table_id uuid NULL DEFAULT NULL,
1526
+ default_permissions text[] DEFAULT NULL,
1527
+ api_name text DEFAULT 'admin',
1528
+ private_api_name text DEFAULT NULL,
1491
1529
  CONSTRAINT db_fkey
1492
1530
  FOREIGN KEY(database_id)
1493
1531
  REFERENCES metaschema_public.database (id)
@@ -1502,29 +1540,29 @@ CREATE TABLE metaschema_modules_public.storage_module (
1502
1540
  ON DELETE CASCADE,
1503
1541
  CONSTRAINT buckets_table_fkey
1504
1542
  FOREIGN KEY(buckets_table_id)
1505
- REFERENCES metaschema_public."table" (id)
1543
+ REFERENCES metaschema_public.table (id)
1506
1544
  ON DELETE CASCADE,
1507
1545
  CONSTRAINT files_table_fkey
1508
1546
  FOREIGN KEY(files_table_id)
1509
- REFERENCES metaschema_public."table" (id)
1547
+ REFERENCES metaschema_public.table (id)
1510
1548
  ON DELETE CASCADE,
1511
1549
  CONSTRAINT entity_table_fkey
1512
1550
  FOREIGN KEY(entity_table_id)
1513
- REFERENCES metaschema_public."table" (id)
1551
+ REFERENCES metaschema_public.table (id)
1514
1552
  ON DELETE CASCADE,
1515
1553
  CONSTRAINT path_shares_table_fkey
1516
1554
  FOREIGN KEY(path_shares_table_id)
1517
- REFERENCES metaschema_public."table" (id)
1555
+ REFERENCES metaschema_public.table (id)
1518
1556
  ON DELETE CASCADE,
1519
1557
  CONSTRAINT file_events_table_fkey
1520
1558
  FOREIGN KEY(file_events_table_id)
1521
- REFERENCES metaschema_public."table" (id)
1559
+ REFERENCES metaschema_public.table (id)
1522
1560
  ON DELETE CASCADE
1523
1561
  );
1524
1562
 
1525
1563
  CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module (database_id);
1526
1564
 
1527
- CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module (database_id, (COALESCE(membership_type, -1)), key);
1565
+ CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module (database_id, scope, prefix);
1528
1566
 
1529
1567
  CREATE TABLE metaschema_modules_public.entity_type_provision (
1530
1568
  id uuid PRIMARY KEY DEFAULT uuidv7(),
@@ -1564,8 +1602,6 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
1564
1602
  out_invocations_table_id uuid DEFAULT NULL,
1565
1603
  out_execution_logs_table_id uuid DEFAULT NULL,
1566
1604
  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
1605
  out_graph_module_id uuid DEFAULT NULL,
1570
1606
  out_graphs_table_id uuid DEFAULT NULL,
1571
1607
  out_agent_module_id uuid DEFAULT NULL,
@@ -1800,15 +1836,15 @@ CREATE TABLE metaschema_modules_public.rate_limits_module (
1800
1836
  ON DELETE CASCADE,
1801
1837
  CONSTRAINT rate_limit_settings_table_fkey
1802
1838
  FOREIGN KEY(rate_limit_settings_table_id)
1803
- REFERENCES metaschema_public."table" (id)
1839
+ REFERENCES metaschema_public.table (id)
1804
1840
  ON DELETE CASCADE,
1805
1841
  CONSTRAINT ip_rate_limits_table_fkey
1806
1842
  FOREIGN KEY(ip_rate_limits_table_id)
1807
- REFERENCES metaschema_public."table" (id)
1843
+ REFERENCES metaschema_public.table (id)
1808
1844
  ON DELETE CASCADE,
1809
1845
  CONSTRAINT rate_limits_table_fkey
1810
1846
  FOREIGN KEY(rate_limits_table_id)
1811
- REFERENCES metaschema_public."table" (id)
1847
+ REFERENCES metaschema_public.table (id)
1812
1848
  ON DELETE CASCADE,
1813
1849
  CONSTRAINT rate_limits_module_database_id_uniq
1814
1850
  UNIQUE (database_id)
@@ -1840,11 +1876,11 @@ CREATE TABLE metaschema_modules_public.devices_module (
1840
1876
  ON DELETE CASCADE,
1841
1877
  CONSTRAINT user_devices_table_fkey
1842
1878
  FOREIGN KEY(user_devices_table_id)
1843
- REFERENCES metaschema_public."table" (id)
1879
+ REFERENCES metaschema_public.table (id)
1844
1880
  ON DELETE CASCADE,
1845
1881
  CONSTRAINT device_settings_table_fkey
1846
1882
  FOREIGN KEY(device_settings_table_id)
1847
- REFERENCES metaschema_public."table" (id)
1883
+ REFERENCES metaschema_public.table (id)
1848
1884
  ON DELETE CASCADE,
1849
1885
  CONSTRAINT devices_module_database_id_uniq
1850
1886
  UNIQUE (database_id)
@@ -1873,11 +1909,11 @@ CREATE TABLE metaschema_modules_public.session_secrets_module (
1873
1909
  ON DELETE CASCADE,
1874
1910
  CONSTRAINT table_fkey
1875
1911
  FOREIGN KEY(table_id)
1876
- REFERENCES metaschema_public."table" (id)
1912
+ REFERENCES metaschema_public.table (id)
1877
1913
  ON DELETE CASCADE,
1878
1914
  CONSTRAINT sessions_table_fkey
1879
1915
  FOREIGN KEY(sessions_table_id)
1880
- REFERENCES metaschema_public."table" (id)
1916
+ REFERENCES metaschema_public.table (id)
1881
1917
  ON DELETE CASCADE
1882
1918
  );
1883
1919
 
@@ -1901,17 +1937,19 @@ CREATE TABLE metaschema_modules_public.webauthn_credentials_module (
1901
1937
  table_id uuid NOT NULL DEFAULT uuid_nil(),
1902
1938
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
1903
1939
  table_name text NOT NULL DEFAULT 'webauthn_credentials',
1940
+ api_name text DEFAULT 'auth',
1941
+ private_api_name text DEFAULT NULL,
1904
1942
  CONSTRAINT db_fkey
1905
1943
  FOREIGN KEY(database_id)
1906
1944
  REFERENCES metaschema_public.database (id)
1907
1945
  ON DELETE CASCADE,
1908
1946
  CONSTRAINT table_fkey
1909
1947
  FOREIGN KEY(table_id)
1910
- REFERENCES metaschema_public."table" (id)
1948
+ REFERENCES metaschema_public.table (id)
1911
1949
  ON DELETE CASCADE,
1912
1950
  CONSTRAINT owner_table_fkey
1913
1951
  FOREIGN KEY(owner_table_id)
1914
- REFERENCES metaschema_public."table" (id)
1952
+ REFERENCES metaschema_public.table (id)
1915
1953
  ON DELETE CASCADE,
1916
1954
  CONSTRAINT schema_fkey
1917
1955
  FOREIGN KEY(schema_id)
@@ -1956,27 +1994,27 @@ CREATE TABLE metaschema_modules_public.webauthn_auth_module (
1956
1994
  ON DELETE CASCADE,
1957
1995
  CONSTRAINT users_table_fkey
1958
1996
  FOREIGN KEY(users_table_id)
1959
- REFERENCES metaschema_public."table" (id)
1997
+ REFERENCES metaschema_public.table (id)
1960
1998
  ON DELETE CASCADE,
1961
1999
  CONSTRAINT credentials_table_fkey
1962
2000
  FOREIGN KEY(credentials_table_id)
1963
- REFERENCES metaschema_public."table" (id)
2001
+ REFERENCES metaschema_public.table (id)
1964
2002
  ON DELETE CASCADE,
1965
2003
  CONSTRAINT sessions_table_fkey
1966
2004
  FOREIGN KEY(sessions_table_id)
1967
- REFERENCES metaschema_public."table" (id)
2005
+ REFERENCES metaschema_public.table (id)
1968
2006
  ON DELETE CASCADE,
1969
2007
  CONSTRAINT session_credentials_table_fkey
1970
2008
  FOREIGN KEY(session_credentials_table_id)
1971
- REFERENCES metaschema_public."table" (id)
2009
+ REFERENCES metaschema_public.table (id)
1972
2010
  ON DELETE CASCADE,
1973
2011
  CONSTRAINT session_secrets_table_fkey
1974
2012
  FOREIGN KEY(session_secrets_table_id)
1975
- REFERENCES metaschema_public."table" (id)
2013
+ REFERENCES metaschema_public.table (id)
1976
2014
  ON DELETE CASCADE,
1977
2015
  CONSTRAINT auth_settings_table_fkey
1978
2016
  FOREIGN KEY(auth_settings_table_id)
1979
- REFERENCES metaschema_public."table" (id)
2017
+ REFERENCES metaschema_public.table (id)
1980
2018
  ON DELETE CASCADE
1981
2019
  );
1982
2020
 
@@ -1989,13 +2027,18 @@ CREATE TABLE metaschema_modules_public.identity_providers_module (
1989
2027
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
1990
2028
  table_id uuid NOT NULL DEFAULT uuid_nil(),
1991
2029
  table_name text NOT NULL DEFAULT 'identity_providers',
2030
+ api_name text DEFAULT 'auth',
2031
+ private_api_name text DEFAULT NULL,
2032
+ scope text NOT NULL DEFAULT 'app',
2033
+ prefix text NOT NULL DEFAULT '',
2034
+ entity_table_id uuid NULL,
1992
2035
  CONSTRAINT db_fkey
1993
2036
  FOREIGN KEY(database_id)
1994
2037
  REFERENCES metaschema_public.database (id)
1995
2038
  ON DELETE CASCADE,
1996
2039
  CONSTRAINT table_fkey
1997
2040
  FOREIGN KEY(table_id)
1998
- REFERENCES metaschema_public."table" (id)
2041
+ REFERENCES metaschema_public.table (id)
1999
2042
  ON DELETE CASCADE,
2000
2043
  CONSTRAINT schema_fkey
2001
2044
  FOREIGN KEY(schema_id)
@@ -2004,6 +2047,10 @@ CREATE TABLE metaschema_modules_public.identity_providers_module (
2004
2047
  CONSTRAINT private_schema_fkey
2005
2048
  FOREIGN KEY(private_schema_id)
2006
2049
  REFERENCES metaschema_public.schema (id)
2050
+ ON DELETE CASCADE,
2051
+ CONSTRAINT entity_table_fkey
2052
+ FOREIGN KEY(entity_table_id)
2053
+ REFERENCES metaschema_public.table (id)
2007
2054
  ON DELETE CASCADE
2008
2055
  );
2009
2056
 
@@ -2015,7 +2062,18 @@ CREATE INDEX identity_providers_module_private_schema_id_idx ON metaschema_modul
2015
2062
 
2016
2063
  CREATE INDEX identity_providers_module_table_id_idx ON metaschema_modules_public.identity_providers_module (table_id);
2017
2064
 
2018
- COMMENT ON TABLE metaschema_modules_public.identity_providers_module IS 'Config row for the identity_providers_module, which provisions a per-database identity_providers config table holding OAuth2 / OIDC (and future SAML) provider definitions: protocol kind, endpoint URLs, encrypted client secret, scopes, audience validation, PKCE, and email-handling flags. Built-in providers (google, github, apple, ...) are seeded as is_built_in=true rows; custom providers use slugs of the form custom:<slug>.';
2065
+ CREATE UNIQUE INDEX identity_providers_module_unique_scope ON metaschema_modules_public.identity_providers_module (database_id, scope);
2066
+
2067
+ COMMENT ON TABLE metaschema_modules_public.identity_providers_module IS 'Entity-aware config row for the identity_providers_module, which provisions a per-database
2068
+ identity_providers table holding OAuth2 / OIDC (and future SAML) provider definitions.
2069
+ The scope column determines which config_secrets_module table the rotate proc targets
2070
+ (app_secrets for app scope, org_secrets for org scope). When scope = platform,
2071
+ the secrets table gets a database_id column and platform-level RLS via
2072
+ AuthzRelatedEntityMembership through database.owner_id.
2073
+ Scoping matrix:
2074
+ scope=app → per-database flat, in-app admin manages
2075
+ scope=platform → per-database, platform admin manages (generate:constructive)
2076
+ scope=org → per-org tenant, org admin manages';
2019
2077
 
2020
2078
  COMMENT ON COLUMN metaschema_modules_public.identity_providers_module.private_schema_id IS 'Private schema that hosts SECURITY DEFINER admin helpers which write to identity_providers (create / update / enable / disable / rotate-secret / delete) and the per-app quota check.';
2021
2079
 
@@ -2029,6 +2087,7 @@ CREATE TABLE metaschema_modules_public.notifications_module (
2029
2087
  preferences_table_id uuid,
2030
2088
  channels_table_id uuid,
2031
2089
  delivery_log_table_id uuid,
2090
+ suppressions_table_id uuid,
2032
2091
  owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
2033
2092
  user_settings_table_id uuid,
2034
2093
  organization_settings_table_id uuid,
@@ -2037,41 +2096,48 @@ CREATE TABLE metaschema_modules_public.notifications_module (
2037
2096
  has_settings_extension boolean NOT NULL DEFAULT false,
2038
2097
  has_digest_metadata boolean NOT NULL DEFAULT false,
2039
2098
  has_subscriptions boolean NOT NULL DEFAULT false,
2099
+ default_permissions text[] DEFAULT NULL,
2100
+ api_name text DEFAULT 'notifications',
2101
+ private_api_name text DEFAULT NULL,
2040
2102
  CONSTRAINT db_fkey
2041
2103
  FOREIGN KEY(database_id)
2042
2104
  REFERENCES metaschema_public.database (id)
2043
2105
  ON DELETE CASCADE,
2044
2106
  CONSTRAINT notifications_table_fkey
2045
2107
  FOREIGN KEY(notifications_table_id)
2046
- REFERENCES metaschema_public."table" (id)
2108
+ REFERENCES metaschema_public.table (id)
2047
2109
  ON DELETE CASCADE,
2048
2110
  CONSTRAINT read_state_table_fkey
2049
2111
  FOREIGN KEY(read_state_table_id)
2050
- REFERENCES metaschema_public."table" (id)
2112
+ REFERENCES metaschema_public.table (id)
2051
2113
  ON DELETE CASCADE,
2052
2114
  CONSTRAINT preferences_table_fkey
2053
2115
  FOREIGN KEY(preferences_table_id)
2054
- REFERENCES metaschema_public."table" (id)
2116
+ REFERENCES metaschema_public.table (id)
2055
2117
  ON DELETE SET NULL,
2056
2118
  CONSTRAINT channels_table_fkey
2057
2119
  FOREIGN KEY(channels_table_id)
2058
- REFERENCES metaschema_public."table" (id)
2120
+ REFERENCES metaschema_public.table (id)
2059
2121
  ON DELETE SET NULL,
2060
2122
  CONSTRAINT delivery_log_table_fkey
2061
2123
  FOREIGN KEY(delivery_log_table_id)
2062
- REFERENCES metaschema_public."table" (id)
2124
+ REFERENCES metaschema_public.table (id)
2125
+ ON DELETE SET NULL,
2126
+ CONSTRAINT suppressions_table_fkey
2127
+ FOREIGN KEY(suppressions_table_id)
2128
+ REFERENCES metaschema_public.table (id)
2063
2129
  ON DELETE SET NULL,
2064
2130
  CONSTRAINT owner_table_fkey
2065
2131
  FOREIGN KEY(owner_table_id)
2066
- REFERENCES metaschema_public."table" (id)
2132
+ REFERENCES metaschema_public.table (id)
2067
2133
  ON DELETE CASCADE,
2068
2134
  CONSTRAINT user_settings_table_fkey
2069
2135
  FOREIGN KEY(user_settings_table_id)
2070
- REFERENCES metaschema_public."table" (id)
2136
+ REFERENCES metaschema_public.table (id)
2071
2137
  ON DELETE SET NULL,
2072
2138
  CONSTRAINT organization_settings_table_fkey
2073
2139
  FOREIGN KEY(organization_settings_table_id)
2074
- REFERENCES metaschema_public."table" (id)
2140
+ REFERENCES metaschema_public.table (id)
2075
2141
  ON DELETE SET NULL,
2076
2142
  CONSTRAINT schema_fkey
2077
2143
  FOREIGN KEY(schema_id)
@@ -2102,6 +2168,8 @@ COMMENT ON CONSTRAINT channels_table_fkey ON metaschema_modules_public.notificat
2102
2168
  COMMENT ON CONSTRAINT delivery_log_table_fkey ON metaschema_modules_public.notifications_module IS '@fieldName deliveryLogTableByDeliveryLogTableId
2103
2169
  @omit manyToMany';
2104
2170
 
2171
+ COMMENT ON CONSTRAINT suppressions_table_fkey ON metaschema_modules_public.notifications_module IS '@fieldName suppressionsTableBySuppressionsTableId';
2172
+
2105
2173
  COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.notifications_module IS '@omit manyToMany';
2106
2174
 
2107
2175
  COMMENT ON CONSTRAINT user_settings_table_fkey ON metaschema_modules_public.notifications_module IS '@fieldName userSettingsTableByUserSettingsTableId
@@ -2125,9 +2193,15 @@ CREATE TABLE metaschema_modules_public.plans_module (
2125
2193
  plan_limits_table_name text NOT NULL DEFAULT '',
2126
2194
  plan_pricing_table_id uuid NULL,
2127
2195
  plan_overrides_table_id uuid NULL,
2196
+ plan_meter_limits_table_id uuid NULL,
2197
+ plan_caps_table_id uuid NULL,
2128
2198
  apply_plan_function text NOT NULL DEFAULT '',
2129
2199
  apply_plan_aggregate_function text NOT NULL DEFAULT '',
2200
+ apply_billing_plan_function text NULL,
2201
+ apply_plan_caps_function text NULL,
2130
2202
  prefix text NULL,
2203
+ api_name text DEFAULT 'usage',
2204
+ private_api_name text DEFAULT NULL,
2131
2205
  CONSTRAINT db_fkey
2132
2206
  FOREIGN KEY(database_id)
2133
2207
  REFERENCES metaschema_public.database (id)
@@ -2142,19 +2216,27 @@ CREATE TABLE metaschema_modules_public.plans_module (
2142
2216
  ON DELETE CASCADE,
2143
2217
  CONSTRAINT plans_table_fkey
2144
2218
  FOREIGN KEY(plans_table_id)
2145
- REFERENCES metaschema_public."table" (id)
2219
+ REFERENCES metaschema_public.table (id)
2146
2220
  ON DELETE CASCADE,
2147
2221
  CONSTRAINT plan_limits_table_fkey
2148
2222
  FOREIGN KEY(plan_limits_table_id)
2149
- REFERENCES metaschema_public."table" (id)
2223
+ REFERENCES metaschema_public.table (id)
2150
2224
  ON DELETE CASCADE,
2151
2225
  CONSTRAINT plan_pricing_table_fkey
2152
2226
  FOREIGN KEY(plan_pricing_table_id)
2153
- REFERENCES metaschema_public."table" (id)
2227
+ REFERENCES metaschema_public.table (id)
2154
2228
  ON DELETE CASCADE,
2155
2229
  CONSTRAINT plan_overrides_table_fkey
2156
2230
  FOREIGN KEY(plan_overrides_table_id)
2157
- REFERENCES metaschema_public."table" (id)
2231
+ REFERENCES metaschema_public.table (id)
2232
+ ON DELETE CASCADE,
2233
+ CONSTRAINT plan_meter_limits_table_fkey
2234
+ FOREIGN KEY(plan_meter_limits_table_id)
2235
+ REFERENCES metaschema_public.table (id)
2236
+ ON DELETE CASCADE,
2237
+ CONSTRAINT plan_caps_table_fkey
2238
+ FOREIGN KEY(plan_caps_table_id)
2239
+ REFERENCES metaschema_public.table (id)
2158
2240
  ON DELETE CASCADE,
2159
2241
  CONSTRAINT plans_module_database_id_unique
2160
2242
  UNIQUE (database_id)
@@ -2179,8 +2261,13 @@ CREATE TABLE metaschema_modules_public.billing_module (
2179
2261
  meter_credits_table_name text NOT NULL DEFAULT '',
2180
2262
  meter_sources_table_id uuid NOT NULL DEFAULT uuid_nil(),
2181
2263
  meter_sources_table_name text NOT NULL DEFAULT '',
2264
+ meter_defaults_table_id uuid NOT NULL DEFAULT uuid_nil(),
2265
+ meter_defaults_table_name text NOT NULL DEFAULT '',
2182
2266
  record_usage_function text NOT NULL DEFAULT '',
2183
2267
  prefix text NULL,
2268
+ default_permissions text[] DEFAULT NULL,
2269
+ api_name text DEFAULT 'usage',
2270
+ private_api_name text DEFAULT NULL,
2184
2271
  CONSTRAINT db_fkey
2185
2272
  FOREIGN KEY(database_id)
2186
2273
  REFERENCES metaschema_public.database (id)
@@ -2195,27 +2282,31 @@ CREATE TABLE metaschema_modules_public.billing_module (
2195
2282
  ON DELETE CASCADE,
2196
2283
  CONSTRAINT meters_table_fkey
2197
2284
  FOREIGN KEY(meters_table_id)
2198
- REFERENCES metaschema_public."table" (id)
2285
+ REFERENCES metaschema_public.table (id)
2199
2286
  ON DELETE CASCADE,
2200
2287
  CONSTRAINT plan_subscriptions_table_fkey
2201
2288
  FOREIGN KEY(plan_subscriptions_table_id)
2202
- REFERENCES metaschema_public."table" (id)
2289
+ REFERENCES metaschema_public.table (id)
2203
2290
  ON DELETE CASCADE,
2204
2291
  CONSTRAINT ledger_table_fkey
2205
2292
  FOREIGN KEY(ledger_table_id)
2206
- REFERENCES metaschema_public."table" (id)
2293
+ REFERENCES metaschema_public.table (id)
2207
2294
  ON DELETE CASCADE,
2208
2295
  CONSTRAINT balances_table_fkey
2209
2296
  FOREIGN KEY(balances_table_id)
2210
- REFERENCES metaschema_public."table" (id)
2297
+ REFERENCES metaschema_public.table (id)
2211
2298
  ON DELETE CASCADE,
2212
2299
  CONSTRAINT meter_credits_table_fkey
2213
2300
  FOREIGN KEY(meter_credits_table_id)
2214
- REFERENCES metaschema_public."table" (id)
2301
+ REFERENCES metaschema_public.table (id)
2215
2302
  ON DELETE CASCADE,
2216
2303
  CONSTRAINT meter_sources_table_fkey
2217
2304
  FOREIGN KEY(meter_sources_table_id)
2218
- REFERENCES metaschema_public."table" (id)
2305
+ REFERENCES metaschema_public.table (id)
2306
+ ON DELETE CASCADE,
2307
+ CONSTRAINT meter_defaults_table_fkey
2308
+ FOREIGN KEY(meter_defaults_table_id)
2309
+ REFERENCES metaschema_public.table (id)
2219
2310
  ON DELETE CASCADE,
2220
2311
  CONSTRAINT billing_module_database_id_unique
2221
2312
  UNIQUE (database_id)
@@ -2244,6 +2335,8 @@ CREATE TABLE metaschema_modules_public.billing_provider_module (
2244
2335
  billing_webhook_events_table_name text NOT NULL DEFAULT '',
2245
2336
  process_billing_event_function text NOT NULL DEFAULT '',
2246
2337
  prefix text NULL,
2338
+ api_name text DEFAULT NULL,
2339
+ private_api_name text DEFAULT NULL,
2247
2340
  CONSTRAINT db_fkey
2248
2341
  FOREIGN KEY(database_id)
2249
2342
  REFERENCES metaschema_public.database (id)
@@ -2258,35 +2351,35 @@ CREATE TABLE metaschema_modules_public.billing_provider_module (
2258
2351
  ON DELETE CASCADE,
2259
2352
  CONSTRAINT billing_customers_table_fkey
2260
2353
  FOREIGN KEY(billing_customers_table_id)
2261
- REFERENCES metaschema_public."table" (id)
2354
+ REFERENCES metaschema_public.table (id)
2262
2355
  ON DELETE CASCADE,
2263
2356
  CONSTRAINT billing_products_table_fkey
2264
2357
  FOREIGN KEY(billing_products_table_id)
2265
- REFERENCES metaschema_public."table" (id)
2358
+ REFERENCES metaschema_public.table (id)
2266
2359
  ON DELETE CASCADE,
2267
2360
  CONSTRAINT billing_prices_table_fkey
2268
2361
  FOREIGN KEY(billing_prices_table_id)
2269
- REFERENCES metaschema_public."table" (id)
2362
+ REFERENCES metaschema_public.table (id)
2270
2363
  ON DELETE CASCADE,
2271
2364
  CONSTRAINT billing_subscriptions_table_fkey
2272
2365
  FOREIGN KEY(billing_subscriptions_table_id)
2273
- REFERENCES metaschema_public."table" (id)
2366
+ REFERENCES metaschema_public.table (id)
2274
2367
  ON DELETE CASCADE,
2275
2368
  CONSTRAINT billing_webhook_events_table_fkey
2276
2369
  FOREIGN KEY(billing_webhook_events_table_id)
2277
- REFERENCES metaschema_public."table" (id)
2370
+ REFERENCES metaschema_public.table (id)
2278
2371
  ON DELETE CASCADE,
2279
2372
  CONSTRAINT products_table_fkey
2280
2373
  FOREIGN KEY(products_table_id)
2281
- REFERENCES metaschema_public."table" (id)
2374
+ REFERENCES metaschema_public.table (id)
2282
2375
  ON DELETE SET NULL,
2283
2376
  CONSTRAINT prices_table_fkey
2284
2377
  FOREIGN KEY(prices_table_id)
2285
- REFERENCES metaschema_public."table" (id)
2378
+ REFERENCES metaschema_public.table (id)
2286
2379
  ON DELETE SET NULL,
2287
2380
  CONSTRAINT subscriptions_table_fkey
2288
2381
  FOREIGN KEY(subscriptions_table_id)
2289
- REFERENCES metaschema_public."table" (id)
2382
+ REFERENCES metaschema_public.table (id)
2290
2383
  ON DELETE SET NULL,
2291
2384
  CONSTRAINT billing_provider_module_database_id_unique
2292
2385
  UNIQUE (database_id)
@@ -2305,8 +2398,10 @@ CREATE TABLE metaschema_modules_public.realtime_module (
2305
2398
  source_registry_table_id uuid NOT NULL DEFAULT uuid_nil(),
2306
2399
  retention_hours int NOT NULL DEFAULT 168,
2307
2400
  premake int NOT NULL DEFAULT 7,
2308
- interval text NOT NULL DEFAULT '1 day',
2401
+ "interval" text NOT NULL DEFAULT '1 day',
2309
2402
  notify_channel text NULL,
2403
+ api_name text DEFAULT 'realtime',
2404
+ private_api_name text DEFAULT NULL,
2310
2405
  CONSTRAINT db_fkey
2311
2406
  FOREIGN KEY(database_id)
2312
2407
  REFERENCES metaschema_public.database (id)
@@ -2325,15 +2420,15 @@ CREATE TABLE metaschema_modules_public.realtime_module (
2325
2420
  ON DELETE CASCADE,
2326
2421
  CONSTRAINT change_log_table_fkey
2327
2422
  FOREIGN KEY(change_log_table_id)
2328
- REFERENCES metaschema_public."table" (id)
2423
+ REFERENCES metaschema_public.table (id)
2329
2424
  ON DELETE CASCADE,
2330
2425
  CONSTRAINT listener_node_table_fkey
2331
2426
  FOREIGN KEY(listener_node_table_id)
2332
- REFERENCES metaschema_public."table" (id)
2427
+ REFERENCES metaschema_public.table (id)
2333
2428
  ON DELETE CASCADE,
2334
2429
  CONSTRAINT source_registry_table_fkey
2335
2430
  FOREIGN KEY(source_registry_table_id)
2336
- REFERENCES metaschema_public."table" (id)
2431
+ REFERENCES metaschema_public.table (id)
2337
2432
  ON DELETE CASCADE
2338
2433
  );
2339
2434
 
@@ -2366,6 +2461,9 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
2366
2461
  rate_window_limits_table_name text NOT NULL DEFAULT '',
2367
2462
  check_rate_limit_function text NOT NULL DEFAULT '',
2368
2463
  prefix text NULL,
2464
+ default_permissions text[] DEFAULT NULL,
2465
+ api_name text DEFAULT 'usage',
2466
+ private_api_name text DEFAULT NULL,
2369
2467
  CONSTRAINT db_fkey
2370
2468
  FOREIGN KEY(database_id)
2371
2469
  REFERENCES metaschema_public.database (id)
@@ -2380,15 +2478,15 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
2380
2478
  ON DELETE CASCADE,
2381
2479
  CONSTRAINT rate_limit_state_table_fkey
2382
2480
  FOREIGN KEY(rate_limit_state_table_id)
2383
- REFERENCES metaschema_public."table" (id)
2481
+ REFERENCES metaschema_public.table (id)
2384
2482
  ON DELETE CASCADE,
2385
2483
  CONSTRAINT rate_limit_overrides_table_fkey
2386
2484
  FOREIGN KEY(rate_limit_overrides_table_id)
2387
- REFERENCES metaschema_public."table" (id)
2485
+ REFERENCES metaschema_public.table (id)
2388
2486
  ON DELETE CASCADE,
2389
2487
  CONSTRAINT rate_window_limits_table_fkey
2390
2488
  FOREIGN KEY(rate_window_limits_table_id)
2391
- REFERENCES metaschema_public."table" (id)
2489
+ REFERENCES metaschema_public.table (id)
2392
2490
  ON DELETE CASCADE,
2393
2491
  CONSTRAINT rate_limit_meters_module_database_id_unique
2394
2492
  UNIQUE (database_id)
@@ -2408,6 +2506,8 @@ CREATE TABLE metaschema_modules_public.config_secrets_org_module (
2408
2506
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
2409
2507
  table_id uuid NOT NULL DEFAULT uuid_nil(),
2410
2508
  table_name text NOT NULL DEFAULT 'org_secrets',
2509
+ api_name text DEFAULT 'config',
2510
+ private_api_name text DEFAULT NULL,
2411
2511
  CONSTRAINT db_fkey
2412
2512
  FOREIGN KEY(database_id)
2413
2513
  REFERENCES metaschema_public.database (id)
@@ -2418,7 +2518,7 @@ CREATE TABLE metaschema_modules_public.config_secrets_org_module (
2418
2518
  ON DELETE CASCADE,
2419
2519
  CONSTRAINT table_fkey
2420
2520
  FOREIGN KEY(table_id)
2421
- REFERENCES metaschema_public."table" (id)
2521
+ REFERENCES metaschema_public.table (id)
2422
2522
  ON DELETE CASCADE
2423
2523
  );
2424
2524
 
@@ -2439,13 +2539,15 @@ CREATE TABLE metaschema_modules_public.inference_log_module (
2439
2539
  inference_log_table_name text NOT NULL DEFAULT '',
2440
2540
  usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2441
2541
  usage_daily_table_name text NOT NULL DEFAULT '',
2442
- interval text NOT NULL DEFAULT '1 month',
2542
+ "interval" text NOT NULL DEFAULT '1 month',
2443
2543
  retention text NOT NULL DEFAULT '12 months',
2444
2544
  premake int NOT NULL DEFAULT 2,
2445
2545
  scope text NOT NULL DEFAULT 'app',
2446
2546
  actor_fk_table_id uuid NULL,
2447
2547
  entity_fk_table_id uuid NULL,
2448
- prefix text NULL,
2548
+ prefix text NOT NULL DEFAULT '',
2549
+ api_name text DEFAULT 'usage',
2550
+ private_api_name text DEFAULT NULL,
2449
2551
  CONSTRAINT db_fkey
2450
2552
  FOREIGN KEY(database_id)
2451
2553
  REFERENCES metaschema_public.database (id)
@@ -2460,11 +2562,11 @@ CREATE TABLE metaschema_modules_public.inference_log_module (
2460
2562
  ON DELETE CASCADE,
2461
2563
  CONSTRAINT inference_log_table_fkey
2462
2564
  FOREIGN KEY(inference_log_table_id)
2463
- REFERENCES metaschema_public."table" (id)
2565
+ REFERENCES metaschema_public.table (id)
2464
2566
  ON DELETE CASCADE,
2465
2567
  CONSTRAINT usage_daily_table_fkey
2466
2568
  FOREIGN KEY(usage_daily_table_id)
2467
- REFERENCES metaschema_public."table" (id)
2569
+ REFERENCES metaschema_public.table (id)
2468
2570
  ON DELETE CASCADE,
2469
2571
  CONSTRAINT inference_log_module_database_id_prefix_unique
2470
2572
  UNIQUE NULLS NOT DISTINCT (database_id, prefix)
@@ -2481,13 +2583,15 @@ CREATE TABLE metaschema_modules_public.compute_log_module (
2481
2583
  compute_log_table_name text NOT NULL DEFAULT '',
2482
2584
  usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2483
2585
  usage_daily_table_name text NOT NULL DEFAULT '',
2484
- interval text NOT NULL DEFAULT '1 month',
2586
+ "interval" text NOT NULL DEFAULT '1 month',
2485
2587
  retention text NOT NULL DEFAULT '12 months',
2486
2588
  premake int NOT NULL DEFAULT 2,
2487
2589
  scope text NOT NULL DEFAULT 'app',
2488
2590
  actor_fk_table_id uuid NULL,
2489
2591
  entity_fk_table_id uuid NULL,
2490
- prefix text NULL,
2592
+ prefix text NOT NULL DEFAULT '',
2593
+ api_name text DEFAULT 'usage',
2594
+ private_api_name text DEFAULT NULL,
2491
2595
  CONSTRAINT db_fkey
2492
2596
  FOREIGN KEY(database_id)
2493
2597
  REFERENCES metaschema_public.database (id)
@@ -2502,11 +2606,11 @@ CREATE TABLE metaschema_modules_public.compute_log_module (
2502
2606
  ON DELETE CASCADE,
2503
2607
  CONSTRAINT compute_log_table_fkey
2504
2608
  FOREIGN KEY(compute_log_table_id)
2505
- REFERENCES metaschema_public."table" (id)
2609
+ REFERENCES metaschema_public.table (id)
2506
2610
  ON DELETE CASCADE,
2507
2611
  CONSTRAINT usage_daily_table_fkey
2508
2612
  FOREIGN KEY(usage_daily_table_id)
2509
- REFERENCES metaschema_public."table" (id)
2613
+ REFERENCES metaschema_public.table (id)
2510
2614
  ON DELETE CASCADE,
2511
2615
  CONSTRAINT compute_log_module_database_id_prefix_unique
2512
2616
  UNIQUE NULLS NOT DISTINCT (database_id, prefix)
@@ -2523,13 +2627,15 @@ CREATE TABLE metaschema_modules_public.transfer_log_module (
2523
2627
  transfer_log_table_name text NOT NULL DEFAULT '',
2524
2628
  usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2525
2629
  usage_daily_table_name text NOT NULL DEFAULT '',
2526
- interval text NOT NULL DEFAULT '1 month',
2630
+ "interval" text NOT NULL DEFAULT '1 month',
2527
2631
  retention text NOT NULL DEFAULT '12 months',
2528
2632
  premake int NOT NULL DEFAULT 2,
2529
2633
  scope text NOT NULL DEFAULT 'app',
2530
2634
  actor_fk_table_id uuid NULL,
2531
2635
  entity_fk_table_id uuid NULL,
2532
- prefix text NULL,
2636
+ prefix text NOT NULL DEFAULT '',
2637
+ api_name text DEFAULT 'usage',
2638
+ private_api_name text DEFAULT NULL,
2533
2639
  CONSTRAINT db_fkey
2534
2640
  FOREIGN KEY(database_id)
2535
2641
  REFERENCES metaschema_public.database (id)
@@ -2544,11 +2650,11 @@ CREATE TABLE metaschema_modules_public.transfer_log_module (
2544
2650
  ON DELETE CASCADE,
2545
2651
  CONSTRAINT transfer_log_table_fkey
2546
2652
  FOREIGN KEY(transfer_log_table_id)
2547
- REFERENCES metaschema_public."table" (id)
2653
+ REFERENCES metaschema_public.table (id)
2548
2654
  ON DELETE CASCADE,
2549
2655
  CONSTRAINT usage_daily_table_fkey
2550
2656
  FOREIGN KEY(usage_daily_table_id)
2551
- REFERENCES metaschema_public."table" (id)
2657
+ REFERENCES metaschema_public.table (id)
2552
2658
  ON DELETE CASCADE,
2553
2659
  CONSTRAINT transfer_log_module_database_id_prefix_unique
2554
2660
  UNIQUE NULLS NOT DISTINCT (database_id, prefix)
@@ -2565,13 +2671,15 @@ CREATE TABLE metaschema_modules_public.storage_log_module (
2565
2671
  storage_log_table_name text NOT NULL DEFAULT '',
2566
2672
  usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2567
2673
  usage_daily_table_name text NOT NULL DEFAULT '',
2568
- interval text NOT NULL DEFAULT '1 month',
2674
+ "interval" text NOT NULL DEFAULT '1 month',
2569
2675
  retention text NOT NULL DEFAULT '12 months',
2570
2676
  premake int NOT NULL DEFAULT 2,
2571
2677
  scope text NOT NULL DEFAULT 'app',
2572
2678
  actor_fk_table_id uuid NULL,
2573
2679
  entity_fk_table_id uuid NULL,
2574
- prefix text NULL,
2680
+ prefix text NOT NULL DEFAULT '',
2681
+ api_name text DEFAULT 'usage',
2682
+ private_api_name text DEFAULT NULL,
2575
2683
  CONSTRAINT db_fkey
2576
2684
  FOREIGN KEY(database_id)
2577
2685
  REFERENCES metaschema_public.database (id)
@@ -2586,11 +2694,11 @@ CREATE TABLE metaschema_modules_public.storage_log_module (
2586
2694
  ON DELETE CASCADE,
2587
2695
  CONSTRAINT storage_log_table_fkey
2588
2696
  FOREIGN KEY(storage_log_table_id)
2589
- REFERENCES metaschema_public."table" (id)
2697
+ REFERENCES metaschema_public.table (id)
2590
2698
  ON DELETE CASCADE,
2591
2699
  CONSTRAINT usage_daily_table_fkey
2592
2700
  FOREIGN KEY(usage_daily_table_id)
2593
- REFERENCES metaschema_public."table" (id)
2701
+ REFERENCES metaschema_public.table (id)
2594
2702
  ON DELETE CASCADE,
2595
2703
  CONSTRAINT storage_log_module_database_id_prefix_unique
2596
2704
  UNIQUE NULLS NOT DISTINCT (database_id, prefix)
@@ -2611,11 +2719,14 @@ CREATE TABLE metaschema_modules_public.db_usage_module (
2611
2719
  query_stats_log_table_name text NOT NULL DEFAULT '',
2612
2720
  query_stats_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
2613
2721
  query_stats_daily_table_name text NOT NULL DEFAULT '',
2614
- interval text NOT NULL DEFAULT '1 month',
2722
+ "interval" text NOT NULL DEFAULT '1 month',
2615
2723
  retention text NOT NULL DEFAULT '12 months',
2616
2724
  premake int NOT NULL DEFAULT 2,
2617
2725
  scope text NOT NULL DEFAULT 'app',
2618
- prefix text NULL,
2726
+ prefix text NOT NULL DEFAULT '',
2727
+ default_permissions text[] DEFAULT NULL,
2728
+ api_name text DEFAULT 'usage',
2729
+ private_api_name text DEFAULT NULL,
2619
2730
  CONSTRAINT db_fkey
2620
2731
  FOREIGN KEY(database_id)
2621
2732
  REFERENCES metaschema_public.database (id)
@@ -2630,19 +2741,19 @@ CREATE TABLE metaschema_modules_public.db_usage_module (
2630
2741
  ON DELETE CASCADE,
2631
2742
  CONSTRAINT table_stats_log_table_fkey
2632
2743
  FOREIGN KEY(table_stats_log_table_id)
2633
- REFERENCES metaschema_public."table" (id)
2744
+ REFERENCES metaschema_public.table (id)
2634
2745
  ON DELETE CASCADE,
2635
2746
  CONSTRAINT table_stats_daily_table_fkey
2636
2747
  FOREIGN KEY(table_stats_daily_table_id)
2637
- REFERENCES metaschema_public."table" (id)
2748
+ REFERENCES metaschema_public.table (id)
2638
2749
  ON DELETE CASCADE,
2639
2750
  CONSTRAINT query_stats_log_table_fkey
2640
2751
  FOREIGN KEY(query_stats_log_table_id)
2641
- REFERENCES metaschema_public."table" (id)
2752
+ REFERENCES metaschema_public.table (id)
2642
2753
  ON DELETE CASCADE,
2643
2754
  CONSTRAINT query_stats_daily_table_fkey
2644
2755
  FOREIGN KEY(query_stats_daily_table_id)
2645
- REFERENCES metaschema_public."table" (id)
2756
+ REFERENCES metaschema_public.table (id)
2646
2757
  ON DELETE CASCADE,
2647
2758
  CONSTRAINT db_usage_module_database_id_prefix_unique
2648
2759
  UNIQUE NULLS NOT DISTINCT (database_id, prefix)
@@ -2659,21 +2770,31 @@ CREATE TABLE metaschema_modules_public.agent_module (
2659
2770
  message_table_id uuid NOT NULL DEFAULT uuid_nil(),
2660
2771
  task_table_id uuid NOT NULL DEFAULT uuid_nil(),
2661
2772
  prompts_table_id uuid NOT NULL DEFAULT uuid_nil(),
2662
- knowledge_table_id uuid DEFAULT NULL,
2773
+ plan_table_id uuid DEFAULT NULL,
2774
+ agent_table_id uuid DEFAULT NULL,
2775
+ persona_table_id uuid DEFAULT NULL,
2776
+ resource_table_id uuid DEFAULT NULL,
2663
2777
  thread_table_name text NOT NULL DEFAULT 'agent_thread',
2664
2778
  message_table_name text NOT NULL DEFAULT 'agent_message',
2665
2779
  task_table_name text NOT NULL DEFAULT 'agent_task',
2666
2780
  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,
2781
+ plan_table_name text NOT NULL DEFAULT 'agent_plan',
2782
+ agent_table_name text NOT NULL DEFAULT 'agent',
2783
+ persona_table_name text NOT NULL DEFAULT 'agent_persona',
2784
+ resource_table_name text NOT NULL DEFAULT 'agent_resource',
2785
+ has_plans boolean NOT NULL DEFAULT false,
2786
+ has_resources boolean NOT NULL DEFAULT false,
2787
+ has_agents boolean NOT NULL DEFAULT false,
2788
+ shared boolean NOT NULL DEFAULT false,
2669
2789
  api_name text DEFAULT 'agent',
2670
- membership_type int DEFAULT NULL,
2671
- key text NOT NULL DEFAULT 'default',
2790
+ private_api_name text DEFAULT NULL,
2791
+ scope text NOT NULL DEFAULT 'app',
2792
+ prefix text NOT NULL DEFAULT '',
2672
2793
  entity_table_id uuid NULL,
2673
2794
  policies jsonb NULL,
2674
- knowledge_config jsonb NULL,
2675
- knowledge_policies jsonb NULL,
2795
+ resources jsonb NULL,
2676
2796
  provisions jsonb NULL,
2797
+ default_permissions text[] DEFAULT NULL,
2677
2798
  CONSTRAINT agent_module_db_fkey
2678
2799
  FOREIGN KEY(database_id)
2679
2800
  REFERENCES metaschema_public.database (id)
@@ -2688,33 +2809,45 @@ CREATE TABLE metaschema_modules_public.agent_module (
2688
2809
  ON DELETE CASCADE,
2689
2810
  CONSTRAINT agent_module_thread_table_fkey
2690
2811
  FOREIGN KEY(thread_table_id)
2691
- REFERENCES metaschema_public."table" (id)
2812
+ REFERENCES metaschema_public.table (id)
2692
2813
  ON DELETE CASCADE,
2693
2814
  CONSTRAINT agent_module_message_table_fkey
2694
2815
  FOREIGN KEY(message_table_id)
2695
- REFERENCES metaschema_public."table" (id)
2816
+ REFERENCES metaschema_public.table (id)
2696
2817
  ON DELETE CASCADE,
2697
2818
  CONSTRAINT agent_module_task_table_fkey
2698
2819
  FOREIGN KEY(task_table_id)
2699
- REFERENCES metaschema_public."table" (id)
2820
+ REFERENCES metaschema_public.table (id)
2700
2821
  ON DELETE CASCADE,
2701
2822
  CONSTRAINT agent_module_prompts_table_fkey
2702
2823
  FOREIGN KEY(prompts_table_id)
2703
- REFERENCES metaschema_public."table" (id)
2824
+ REFERENCES metaschema_public.table (id)
2825
+ ON DELETE CASCADE,
2826
+ CONSTRAINT agent_module_plan_table_fkey
2827
+ FOREIGN KEY(plan_table_id)
2828
+ REFERENCES metaschema_public.table (id)
2829
+ ON DELETE CASCADE,
2830
+ CONSTRAINT agent_module_agent_table_fkey
2831
+ FOREIGN KEY(agent_table_id)
2832
+ REFERENCES metaschema_public.table (id)
2704
2833
  ON DELETE CASCADE,
2705
- CONSTRAINT agent_module_knowledge_table_fkey
2706
- FOREIGN KEY(knowledge_table_id)
2707
- REFERENCES metaschema_public."table" (id)
2834
+ CONSTRAINT agent_module_persona_table_fkey
2835
+ FOREIGN KEY(persona_table_id)
2836
+ REFERENCES metaschema_public.table (id)
2837
+ ON DELETE CASCADE,
2838
+ CONSTRAINT agent_module_resource_table_fkey
2839
+ FOREIGN KEY(resource_table_id)
2840
+ REFERENCES metaschema_public.table (id)
2708
2841
  ON DELETE CASCADE,
2709
2842
  CONSTRAINT agent_module_entity_table_fkey
2710
2843
  FOREIGN KEY(entity_table_id)
2711
- REFERENCES metaschema_public."table" (id)
2844
+ REFERENCES metaschema_public.table (id)
2712
2845
  ON DELETE CASCADE
2713
2846
  );
2714
2847
 
2715
2848
  CREATE INDEX agent_module_database_id_idx ON metaschema_modules_public.agent_module (database_id);
2716
2849
 
2717
- CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module (database_id, (COALESCE(membership_type, -1)), key);
2850
+ CREATE UNIQUE INDEX agent_module_unique_scope ON metaschema_modules_public.agent_module (database_id, scope, prefix);
2718
2851
 
2719
2852
  CREATE TABLE metaschema_modules_public.merkle_store_module (
2720
2853
  id uuid PRIMARY KEY DEFAULT uuidv7(),
@@ -2730,7 +2863,8 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
2730
2863
  prefix text NOT NULL DEFAULT '',
2731
2864
  api_name text,
2732
2865
  private_api_name text,
2733
- scope_field text NOT NULL DEFAULT 'scope_id',
2866
+ scope text NOT NULL DEFAULT 'app',
2867
+ function_prefix text DEFAULT NULL,
2734
2868
  created_at timestamptz NOT NULL DEFAULT now(),
2735
2869
  CONSTRAINT db_fkey
2736
2870
  FOREIGN KEY(database_id)
@@ -2746,19 +2880,19 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
2746
2880
  ON DELETE CASCADE,
2747
2881
  CONSTRAINT object_table_fkey
2748
2882
  FOREIGN KEY(object_table_id)
2749
- REFERENCES metaschema_public."table" (id)
2883
+ REFERENCES metaschema_public.table (id)
2750
2884
  ON DELETE CASCADE,
2751
2885
  CONSTRAINT store_table_fkey
2752
2886
  FOREIGN KEY(store_table_id)
2753
- REFERENCES metaschema_public."table" (id)
2887
+ REFERENCES metaschema_public.table (id)
2754
2888
  ON DELETE CASCADE,
2755
2889
  CONSTRAINT commit_table_fkey
2756
2890
  FOREIGN KEY(commit_table_id)
2757
- REFERENCES metaschema_public."table" (id)
2891
+ REFERENCES metaschema_public.table (id)
2758
2892
  ON DELETE CASCADE,
2759
2893
  CONSTRAINT ref_table_fkey
2760
2894
  FOREIGN KEY(ref_table_id)
2761
- REFERENCES metaschema_public."table" (id)
2895
+ REFERENCES metaschema_public.table (id)
2762
2896
  ON DELETE CASCADE,
2763
2897
  CONSTRAINT merkle_store_module_database_prefix_unique
2764
2898
  UNIQUE (database_id, prefix)
@@ -2775,6 +2909,7 @@ CREATE TABLE metaschema_modules_public.graph_module (
2775
2909
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
2776
2910
  public_schema_name text,
2777
2911
  private_schema_name text,
2912
+ scope text NOT NULL DEFAULT 'app',
2778
2913
  prefix text NOT NULL DEFAULT '',
2779
2914
  merkle_store_module_id uuid NOT NULL,
2780
2915
  graphs_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -2782,11 +2917,10 @@ CREATE TABLE metaschema_modules_public.graph_module (
2782
2917
  outputs_table_id uuid NOT NULL DEFAULT uuid_nil(),
2783
2918
  api_name text,
2784
2919
  private_api_name text,
2785
- scope_field text NOT NULL DEFAULT 'scope_id',
2786
- membership_type int DEFAULT NULL,
2787
2920
  entity_table_id uuid NULL,
2788
2921
  policies jsonb NULL,
2789
2922
  provisions jsonb NULL,
2923
+ default_permissions text[] DEFAULT NULL,
2790
2924
  created_at timestamptz NOT NULL DEFAULT now(),
2791
2925
  CONSTRAINT db_fkey
2792
2926
  FOREIGN KEY(database_id)
@@ -2806,19 +2940,19 @@ CREATE TABLE metaschema_modules_public.graph_module (
2806
2940
  ON DELETE CASCADE,
2807
2941
  CONSTRAINT graphs_table_fkey
2808
2942
  FOREIGN KEY(graphs_table_id)
2809
- REFERENCES metaschema_public."table" (id)
2943
+ REFERENCES metaschema_public.table (id)
2810
2944
  ON DELETE CASCADE,
2811
2945
  CONSTRAINT executions_table_fkey
2812
2946
  FOREIGN KEY(executions_table_id)
2813
- REFERENCES metaschema_public."table" (id)
2947
+ REFERENCES metaschema_public.table (id)
2814
2948
  ON DELETE CASCADE,
2815
2949
  CONSTRAINT outputs_table_fkey
2816
2950
  FOREIGN KEY(outputs_table_id)
2817
- REFERENCES metaschema_public."table" (id)
2951
+ REFERENCES metaschema_public.table (id)
2818
2952
  ON DELETE CASCADE,
2819
2953
  CONSTRAINT graph_module_entity_table_fkey
2820
2954
  FOREIGN KEY(entity_table_id)
2821
- REFERENCES metaschema_public."table" (id)
2955
+ REFERENCES metaschema_public.table (id)
2822
2956
  ON DELETE CASCADE,
2823
2957
  CONSTRAINT graph_module_database_merkle_unique
2824
2958
  UNIQUE (database_id, merkle_store_module_id)
@@ -2839,11 +2973,12 @@ CREATE TABLE metaschema_modules_public.namespace_module (
2839
2973
  namespace_events_table_name text NOT NULL DEFAULT 'namespace_events',
2840
2974
  api_name text,
2841
2975
  private_api_name text,
2842
- membership_type int DEFAULT NULL,
2843
- key text NOT NULL DEFAULT 'default',
2976
+ scope text NOT NULL DEFAULT 'app',
2977
+ prefix text NOT NULL DEFAULT '',
2844
2978
  entity_table_id uuid NULL,
2845
2979
  policies jsonb NULL,
2846
2980
  provisions jsonb NULL,
2981
+ default_permissions text[] DEFAULT NULL,
2847
2982
  CONSTRAINT namespace_module_db_fkey
2848
2983
  FOREIGN KEY(database_id)
2849
2984
  REFERENCES metaschema_public.database (id)
@@ -2858,21 +2993,21 @@ CREATE TABLE metaschema_modules_public.namespace_module (
2858
2993
  ON DELETE CASCADE,
2859
2994
  CONSTRAINT namespace_module_namespaces_table_fkey
2860
2995
  FOREIGN KEY(namespaces_table_id)
2861
- REFERENCES metaschema_public."table" (id)
2996
+ REFERENCES metaschema_public.table (id)
2862
2997
  ON DELETE CASCADE,
2863
2998
  CONSTRAINT namespace_module_events_table_fkey
2864
2999
  FOREIGN KEY(namespace_events_table_id)
2865
- REFERENCES metaschema_public."table" (id)
3000
+ REFERENCES metaschema_public.table (id)
2866
3001
  ON DELETE CASCADE,
2867
3002
  CONSTRAINT namespace_module_entity_table_fkey
2868
3003
  FOREIGN KEY(entity_table_id)
2869
- REFERENCES metaschema_public."table" (id)
3004
+ REFERENCES metaschema_public.table (id)
2870
3005
  ON DELETE CASCADE
2871
3006
  );
2872
3007
 
2873
3008
  CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module (database_id);
2874
3009
 
2875
- CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module (database_id, (COALESCE(membership_type, -1)), key);
3010
+ CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module (database_id, scope, prefix);
2876
3011
 
2877
3012
  CREATE TABLE metaschema_modules_public.function_module (
2878
3013
  id uuid PRIMARY KEY DEFAULT uuidv7(),
@@ -2882,26 +3017,17 @@ CREATE TABLE metaschema_modules_public.function_module (
2882
3017
  public_schema_name text,
2883
3018
  private_schema_name text,
2884
3019
  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
3020
  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
3021
  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
3022
  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
3023
  api_name text,
2898
3024
  private_api_name text,
2899
- membership_type int DEFAULT NULL,
2900
- prefix text NULL,
2901
- key text NOT NULL DEFAULT 'default',
3025
+ scope text NOT NULL DEFAULT 'app',
3026
+ prefix text NOT NULL DEFAULT '',
2902
3027
  entity_table_id uuid NULL,
2903
3028
  policies jsonb NULL,
2904
3029
  provisions jsonb NULL,
3030
+ default_permissions text[] DEFAULT NULL,
2905
3031
  CONSTRAINT function_module_db_fkey
2906
3032
  FOREIGN KEY(database_id)
2907
3033
  REFERENCES metaschema_public.database (id)
@@ -2916,38 +3042,215 @@ CREATE TABLE metaschema_modules_public.function_module (
2916
3042
  ON DELETE CASCADE,
2917
3043
  CONSTRAINT function_module_definitions_table_fkey
2918
3044
  FOREIGN KEY(definitions_table_id)
2919
- REFERENCES metaschema_public."table" (id)
3045
+ REFERENCES metaschema_public.table (id)
3046
+ ON DELETE CASCADE,
3047
+ CONSTRAINT function_module_secret_defs_table_fkey
3048
+ FOREIGN KEY(secret_definitions_table_id)
3049
+ REFERENCES metaschema_public.table (id)
3050
+ ON DELETE CASCADE,
3051
+ CONSTRAINT function_module_entity_table_fkey
3052
+ FOREIGN KEY(entity_table_id)
3053
+ REFERENCES metaschema_public.table (id)
3054
+ ON DELETE CASCADE
3055
+ );
3056
+
3057
+ CREATE INDEX function_module_database_id_idx ON metaschema_modules_public.function_module (database_id);
3058
+
3059
+ CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module (database_id, scope, prefix);
3060
+
3061
+ CREATE TABLE metaschema_modules_public.function_invocation_module (
3062
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
3063
+ database_id uuid NOT NULL,
3064
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
3065
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
3066
+ public_schema_name text,
3067
+ private_schema_name text,
3068
+ invocations_table_id uuid NOT NULL DEFAULT uuid_nil(),
3069
+ execution_logs_table_id uuid NOT NULL DEFAULT uuid_nil(),
3070
+ invocations_table_name text NOT NULL DEFAULT 'function_invocations',
3071
+ execution_logs_table_name text NOT NULL DEFAULT 'function_execution_logs',
3072
+ api_name text,
3073
+ private_api_name text,
3074
+ scope text NOT NULL DEFAULT 'app',
3075
+ prefix text NOT NULL DEFAULT '',
3076
+ entity_table_id uuid NULL,
3077
+ policies jsonb NULL,
3078
+ provisions jsonb NULL,
3079
+ default_permissions text[] DEFAULT NULL,
3080
+ CONSTRAINT function_invocation_module_db_fkey
3081
+ FOREIGN KEY(database_id)
3082
+ REFERENCES metaschema_public.database (id)
3083
+ ON DELETE CASCADE,
3084
+ CONSTRAINT function_invocation_module_schema_fkey
3085
+ FOREIGN KEY(schema_id)
3086
+ REFERENCES metaschema_public.schema (id)
3087
+ ON DELETE CASCADE,
3088
+ CONSTRAINT function_invocation_module_private_schema_fkey
3089
+ FOREIGN KEY(private_schema_id)
3090
+ REFERENCES metaschema_public.schema (id)
2920
3091
  ON DELETE CASCADE,
2921
- CONSTRAINT function_module_invocations_table_fkey
3092
+ CONSTRAINT function_invocation_module_invocations_table_fkey
2922
3093
  FOREIGN KEY(invocations_table_id)
2923
- REFERENCES metaschema_public."table" (id)
3094
+ REFERENCES metaschema_public.table (id)
2924
3095
  ON DELETE CASCADE,
2925
- CONSTRAINT function_module_execution_logs_table_fkey
3096
+ CONSTRAINT function_invocation_module_logs_table_fkey
2926
3097
  FOREIGN KEY(execution_logs_table_id)
2927
- REFERENCES metaschema_public."table" (id)
3098
+ REFERENCES metaschema_public.table (id)
2928
3099
  ON DELETE CASCADE,
2929
- CONSTRAINT function_module_secret_defs_table_fkey
2930
- FOREIGN KEY(secret_definitions_table_id)
2931
- REFERENCES metaschema_public."table" (id)
3100
+ CONSTRAINT function_invocation_module_entity_table_fkey
3101
+ FOREIGN KEY(entity_table_id)
3102
+ REFERENCES metaschema_public.table (id)
3103
+ ON DELETE CASCADE
3104
+ );
3105
+
3106
+ CREATE INDEX function_invocation_module_database_id_idx ON metaschema_modules_public.function_invocation_module (database_id);
3107
+
3108
+ CREATE UNIQUE INDEX function_invocation_module_unique_scope ON metaschema_modules_public.function_invocation_module (database_id, scope, prefix);
3109
+
3110
+ CREATE TABLE metaschema_modules_public.config_secrets_module (
3111
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
3112
+ database_id uuid NOT NULL,
3113
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
3114
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
3115
+ table_id uuid NOT NULL DEFAULT uuid_nil(),
3116
+ config_definitions_table_id uuid NULL DEFAULT NULL,
3117
+ table_name text NOT NULL DEFAULT 'secrets',
3118
+ api_name text DEFAULT 'config',
3119
+ private_api_name text DEFAULT NULL,
3120
+ scope text NOT NULL DEFAULT 'app',
3121
+ prefix text NOT NULL DEFAULT '',
3122
+ entity_table_id uuid NULL,
3123
+ policies jsonb NULL,
3124
+ provisions jsonb NULL,
3125
+ has_config boolean NOT NULL DEFAULT false,
3126
+ CONSTRAINT config_secrets_module_db_fkey
3127
+ FOREIGN KEY(database_id)
3128
+ REFERENCES metaschema_public.database (id)
2932
3129
  ON DELETE CASCADE,
2933
- CONSTRAINT function_module_requirements_table_fkey
2934
- FOREIGN KEY(requirements_table_id)
2935
- REFERENCES metaschema_public."table" (id)
3130
+ CONSTRAINT config_secrets_module_schema_fkey
3131
+ FOREIGN KEY(schema_id)
3132
+ REFERENCES metaschema_public.schema (id)
2936
3133
  ON DELETE CASCADE,
2937
- CONSTRAINT function_module_config_defs_table_fkey
2938
- FOREIGN KEY(config_definitions_table_id)
2939
- REFERENCES metaschema_public."table" (id)
3134
+ CONSTRAINT config_secrets_module_private_schema_fkey
3135
+ FOREIGN KEY(private_schema_id)
3136
+ REFERENCES metaschema_public.schema (id)
2940
3137
  ON DELETE CASCADE,
2941
- CONSTRAINT function_module_config_reqs_table_fkey
2942
- FOREIGN KEY(config_requirements_table_id)
2943
- REFERENCES metaschema_public."table" (id)
3138
+ CONSTRAINT config_secrets_module_table_fkey
3139
+ FOREIGN KEY(table_id)
3140
+ REFERENCES metaschema_public.table (id)
2944
3141
  ON DELETE CASCADE,
2945
- CONSTRAINT function_module_entity_table_fkey
3142
+ CONSTRAINT config_secrets_module_config_defs_table_fkey
3143
+ FOREIGN KEY(config_definitions_table_id)
3144
+ REFERENCES metaschema_public.table (id)
3145
+ ON DELETE CASCADE,
3146
+ CONSTRAINT config_secrets_module_entity_table_fkey
2946
3147
  FOREIGN KEY(entity_table_id)
2947
- REFERENCES metaschema_public."table" (id)
3148
+ REFERENCES metaschema_public.table (id)
2948
3149
  ON DELETE CASCADE
2949
3150
  );
2950
3151
 
2951
- CREATE INDEX function_module_database_id_idx ON metaschema_modules_public.function_module (database_id);
3152
+ CREATE INDEX config_secrets_module_database_id_idx ON metaschema_modules_public.config_secrets_module (database_id);
3153
+
3154
+ CREATE INDEX config_secrets_module_schema_id_idx ON metaschema_modules_public.config_secrets_module (schema_id);
3155
+
3156
+ CREATE INDEX config_secrets_module_table_id_idx ON metaschema_modules_public.config_secrets_module (table_id);
3157
+
3158
+ CREATE UNIQUE INDEX config_secrets_module_unique_scope ON metaschema_modules_public.config_secrets_module (database_id, scope, prefix);
3159
+
3160
+ COMMENT ON TABLE metaschema_modules_public.config_secrets_module IS 'Entity-aware PGP-encrypted key-value config/secrets module. Supports app-level (admin-only)
3161
+ and org-scoped (per-org secrets with manage_secrets permission) via the scope column.
3162
+ User-scoped bcrypt credentials are handled by user_credentials_module.';
3163
+
3164
+ CREATE TABLE metaschema_modules_public.user_credentials_module (
3165
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
3166
+ database_id uuid NOT NULL,
3167
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
3168
+ table_id uuid NOT NULL DEFAULT uuid_nil(),
3169
+ table_name text NOT NULL DEFAULT 'user_secrets',
3170
+ api_name text DEFAULT 'config',
3171
+ private_api_name text DEFAULT NULL,
3172
+ CONSTRAINT user_credentials_module_db_fkey
3173
+ FOREIGN KEY(database_id)
3174
+ REFERENCES metaschema_public.database (id)
3175
+ ON DELETE CASCADE,
3176
+ CONSTRAINT user_credentials_module_schema_fkey
3177
+ FOREIGN KEY(schema_id)
3178
+ REFERENCES metaschema_public.schema (id)
3179
+ ON DELETE CASCADE,
3180
+ CONSTRAINT user_credentials_module_table_fkey
3181
+ FOREIGN KEY(table_id)
3182
+ REFERENCES metaschema_public.table (id)
3183
+ ON DELETE CASCADE
3184
+ );
3185
+
3186
+ CREATE INDEX user_credentials_module_database_id_idx ON metaschema_modules_public.user_credentials_module (database_id);
3187
+
3188
+ CREATE INDEX user_credentials_module_schema_id_idx ON metaschema_modules_public.user_credentials_module (schema_id);
3189
+
3190
+ CREATE INDEX user_credentials_module_table_id_idx ON metaschema_modules_public.user_credentials_module (table_id);
3191
+
3192
+ CREATE UNIQUE INDEX user_credentials_module_unique ON metaschema_modules_public.user_credentials_module (database_id);
3193
+
3194
+ COMMENT ON TABLE metaschema_modules_public.user_credentials_module IS 'Per-user bcrypt credential store (password hashes, API key hashes).
3195
+ Always user-scoped with AuthzDirectOwner RLS. Consumed by user_auth_module,
3196
+ identity_providers_module, and bootstrap procedures.';
3197
+
3198
+ CREATE TABLE metaschema_modules_public.user_settings_module (
3199
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
3200
+ database_id uuid NOT NULL,
3201
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
3202
+ table_id uuid NOT NULL DEFAULT uuid_nil(),
3203
+ owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
3204
+ table_name text NOT NULL DEFAULT 'user_settings',
3205
+ api_name text DEFAULT NULL,
3206
+ CONSTRAINT db_fkey
3207
+ FOREIGN KEY(database_id)
3208
+ REFERENCES metaschema_public.database (id)
3209
+ ON DELETE CASCADE,
3210
+ CONSTRAINT schema_fkey
3211
+ FOREIGN KEY(schema_id)
3212
+ REFERENCES metaschema_public.schema (id)
3213
+ ON DELETE CASCADE,
3214
+ CONSTRAINT table_fkey
3215
+ FOREIGN KEY(table_id)
3216
+ REFERENCES metaschema_public.table (id)
3217
+ ON DELETE CASCADE,
3218
+ CONSTRAINT owner_table_fkey
3219
+ FOREIGN KEY(owner_table_id)
3220
+ REFERENCES metaschema_public.table (id)
3221
+ ON DELETE CASCADE
3222
+ );
3223
+
3224
+ CREATE INDEX user_settings_module_database_id_idx ON metaschema_modules_public.user_settings_module (database_id);
3225
+
3226
+ CREATE UNIQUE INDEX user_settings_module_unique_per_db ON metaschema_modules_public.user_settings_module (database_id);
3227
+
3228
+ CREATE TABLE metaschema_modules_public.i18n_module (
3229
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
3230
+ database_id uuid NOT NULL,
3231
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
3232
+ private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
3233
+ settings_table_id uuid NOT NULL DEFAULT uuid_nil(),
3234
+ api_name text DEFAULT NULL,
3235
+ private_api_name text DEFAULT NULL,
3236
+ CONSTRAINT db_fkey
3237
+ FOREIGN KEY(database_id)
3238
+ REFERENCES metaschema_public.database (id)
3239
+ ON DELETE CASCADE,
3240
+ CONSTRAINT schema_fkey
3241
+ FOREIGN KEY(schema_id)
3242
+ REFERENCES metaschema_public.schema (id)
3243
+ ON DELETE CASCADE,
3244
+ CONSTRAINT private_schema_fkey
3245
+ FOREIGN KEY(private_schema_id)
3246
+ REFERENCES metaschema_public.schema (id)
3247
+ ON DELETE CASCADE,
3248
+ CONSTRAINT settings_table_fkey
3249
+ FOREIGN KEY(settings_table_id)
3250
+ REFERENCES metaschema_public.table (id)
3251
+ ON DELETE CASCADE
3252
+ );
3253
+
3254
+ CREATE INDEX i18n_module_database_id_idx ON metaschema_modules_public.i18n_module (database_id);
2952
3255
 
2953
- CREATE UNIQUE INDEX function_module_unique_scope ON metaschema_modules_public.function_module (database_id, (COALESCE(membership_type, -1)), key);
3256
+ CREATE UNIQUE INDEX i18n_module_unique_per_db ON metaschema_modules_public.i18n_module (database_id);