@marinoscar/platform-db 0.1.0-next.3 → 0.1.0-next.30

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 (132) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/README.md +158 -13
  3. package/dist/baseline/deps.d.ts.map +1 -1
  4. package/dist/baseline/deps.js +2 -0
  5. package/dist/baseline/deps.js.map +1 -1
  6. package/dist/baseline/errors.d.ts +3 -1
  7. package/dist/baseline/errors.d.ts.map +1 -1
  8. package/dist/baseline/errors.js.map +1 -1
  9. package/dist/baseline/report.d.ts +3 -1
  10. package/dist/baseline/report.d.ts.map +1 -1
  11. package/dist/baseline/report.js +4 -0
  12. package/dist/baseline/report.js.map +1 -1
  13. package/dist/baseline/run.d.ts +12 -1
  14. package/dist/baseline/run.d.ts.map +1 -1
  15. package/dist/baseline/run.js +19 -0
  16. package/dist/baseline/run.js.map +1 -1
  17. package/dist/bin/db-commands.d.ts +1 -1
  18. package/dist/bin/db-commands.d.ts.map +1 -1
  19. package/dist/bin/db-commands.js +40 -5
  20. package/dist/bin/db-commands.js.map +1 -1
  21. package/dist/drift/app-objects.d.ts +107 -0
  22. package/dist/drift/app-objects.d.ts.map +1 -0
  23. package/dist/drift/app-objects.js +193 -0
  24. package/dist/drift/app-objects.js.map +1 -0
  25. package/dist/drift/db-conformance.d.ts +3 -0
  26. package/dist/drift/db-conformance.d.ts.map +1 -1
  27. package/dist/drift/db-conformance.js +24 -0
  28. package/dist/drift/db-conformance.js.map +1 -1
  29. package/dist/drift/index.d.ts +5 -2
  30. package/dist/drift/index.d.ts.map +1 -1
  31. package/dist/drift/index.js +18 -1
  32. package/dist/drift/index.js.map +1 -1
  33. package/dist/drift/raw-sql-tripwire.d.ts +44 -3
  34. package/dist/drift/raw-sql-tripwire.d.ts.map +1 -1
  35. package/dist/drift/raw-sql-tripwire.js +39 -11
  36. package/dist/drift/raw-sql-tripwire.js.map +1 -1
  37. package/dist/drift/rls-policies.d.ts +226 -0
  38. package/dist/drift/rls-policies.d.ts.map +1 -0
  39. package/dist/drift/rls-policies.js +317 -0
  40. package/dist/drift/rls-policies.js.map +1 -0
  41. package/dist/drift/run.d.ts +24 -0
  42. package/dist/drift/run.d.ts.map +1 -1
  43. package/dist/drift/run.js +52 -1
  44. package/dist/drift/run.js.map +1 -1
  45. package/dist/drift/sql-expression.d.ts +27 -0
  46. package/dist/drift/sql-expression.d.ts.map +1 -0
  47. package/dist/drift/sql-expression.js +64 -0
  48. package/dist/drift/sql-expression.js.map +1 -0
  49. package/dist/lock/index.d.ts +1 -1
  50. package/dist/lock/index.d.ts.map +1 -1
  51. package/dist/lock/index.js.map +1 -1
  52. package/dist/lock/lock.d.ts +37 -0
  53. package/dist/lock/lock.d.ts.map +1 -1
  54. package/dist/lock/lock.js +11 -0
  55. package/dist/lock/lock.js.map +1 -1
  56. package/dist/lock/manifest.d.ts +8 -0
  57. package/dist/lock/manifest.d.ts.map +1 -1
  58. package/dist/lock/manifest.js +1 -0
  59. package/dist/lock/manifest.js.map +1 -1
  60. package/dist/seed/index.d.ts +1 -0
  61. package/dist/seed/index.d.ts.map +1 -1
  62. package/dist/seed/index.js +7 -1
  63. package/dist/seed/index.js.map +1 -1
  64. package/dist/seed/seed-platform.d.ts +16 -3
  65. package/dist/seed/seed-platform.d.ts.map +1 -1
  66. package/dist/seed/seed-platform.js +37 -5
  67. package/dist/seed/seed-platform.js.map +1 -1
  68. package/dist/seed/steps.d.ts +172 -0
  69. package/dist/seed/steps.d.ts.map +1 -0
  70. package/dist/seed/steps.js +136 -0
  71. package/dist/seed/steps.js.map +1 -0
  72. package/dist/seed/types.d.ts +12 -2
  73. package/dist/seed/types.d.ts.map +1 -1
  74. package/dist/sync/app-migrations.d.ts +52 -0
  75. package/dist/sync/app-migrations.d.ts.map +1 -0
  76. package/dist/sync/app-migrations.js +62 -0
  77. package/dist/sync/app-migrations.js.map +1 -0
  78. package/dist/sync/apply.d.ts.map +1 -1
  79. package/dist/sync/apply.js +1 -0
  80. package/dist/sync/apply.js.map +1 -1
  81. package/dist/sync/check.d.ts +5 -2
  82. package/dist/sync/check.d.ts.map +1 -1
  83. package/dist/sync/check.js +8 -1
  84. package/dist/sync/check.js.map +1 -1
  85. package/dist/sync/errors.d.ts +2 -1
  86. package/dist/sync/errors.d.ts.map +1 -1
  87. package/dist/sync/errors.js.map +1 -1
  88. package/dist/sync/index.d.ts +1 -0
  89. package/dist/sync/index.d.ts.map +1 -1
  90. package/dist/sync/index.js +3 -1
  91. package/dist/sync/index.js.map +1 -1
  92. package/dist/sync/plan.d.ts +3 -1
  93. package/dist/sync/plan.d.ts.map +1 -1
  94. package/dist/sync/plan.js +9 -2
  95. package/dist/sync/plan.js.map +1 -1
  96. package/dist/sync/promote.d.ts +4 -0
  97. package/dist/sync/promote.d.ts.map +1 -1
  98. package/dist/sync/promote.js +2 -0
  99. package/dist/sync/promote.js.map +1 -1
  100. package/migrations/0025_org_scoped_rls/migration.sql +215 -0
  101. package/migrations/0026_add_groups/migration.sql +165 -0
  102. package/migrations/0027_add_grants/migration.sql +117 -0
  103. package/migrations/0028_add_org_settings/migration.sql +49 -0
  104. package/migrations/0029_add_org_credentials/migration.sql +54 -0
  105. package/migrations/0030_add_jobs_org_id/migration.sql +18 -0
  106. package/migrations/0031_add_jobs_org_id_status_index/migration.sql +6 -0
  107. package/migrations/0032_add_broadcast_target_org/migration.sql +21 -0
  108. package/migrations/0033_add_android_app/migration.sql +60 -0
  109. package/migrations/0034_open_job_reason/migration.sql +16 -0
  110. package/migrations/0035_ai_usage_feature/migration.sql +37 -0
  111. package/migrations/0036_add_app_metadata/migration.sql +49 -0
  112. package/migrations/0037_open_sharing_vocabularies/migration.sql +97 -0
  113. package/migrations/0038_add_worker_node_events/migration.sql +21 -0
  114. package/migrations/0039_add_webhooks/migration.sql +125 -0
  115. package/migrations/0040_add_alerts/migration.sql +66 -0
  116. package/migrations/0041_notifications_state_counted/migration.sql +19 -0
  117. package/migrations/0042_add_storage_migrations/migration.sql +130 -0
  118. package/migrations/manifest.json +185 -0
  119. package/package.json +5 -2
  120. package/raw-sql-indexes.json +72 -0
  121. package/rls-policies.json +102 -0
  122. package/schema/ai.prisma +59 -2
  123. package/schema/alerts.prisma +75 -0
  124. package/schema/android-app.prisma +47 -0
  125. package/schema/credentials.prisma +62 -0
  126. package/schema/identity.prisma +34 -1
  127. package/schema/jobs.prisma +69 -7
  128. package/schema/notifications.prisma +84 -5
  129. package/schema/settings.prisma +25 -0
  130. package/schema/sharing.prisma +223 -0
  131. package/schema/storage.prisma +143 -4
  132. package/schema/webhooks.prisma +108 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,112 @@
1
1
  # @marinoscar/platform-db
2
2
 
3
+ ## 0.1.0-next.30
4
+
5
+ ## 0.1.0-next.29
6
+
7
+ ## 0.1.0-next.28
8
+
9
+ ## 0.1.0-next.27
10
+
11
+ ### Minor Changes
12
+
13
+ - 3c48c78: Add copy-only storage provider migration (#1093). An administrator starts a run from one storage driver to another (`POST /api/admin/storage/migrations`, `storage_config:write`; list, get and cancel need `storage_config:read` / `storage_config:write`); every `ready` object recorded on the source is copied by streaming, verified (byte count and sha256 of the bytes read back from the target), and only then repointed, while the source object is left in place as a fallback. Platform migration `0042_add_storage_migrations` adds `storage_migration_runs` and `storage_migration_items` (both under forced row-level security on `org_id`; an item links to its object by the composite `(object_id, org_id)` key) and the raw-SQL partial unique index `storage_migration_runs_active_uniq_idx`, so at most one run is pending or running (a second start is a 409 naming `details.activeRunId`). Two server-only job types do the work: `storage.migrate_plan` (one per run, lists the objects and queues them, resumable) and `storage.migrate_object` (one per object, `skipDedup`, background priority). A cancelled run stops before its next unclaimed object, and a re-run skips objects already on the target. The contract gains the run wire shapes, and `StorageConfigPage` gains a migration panel with live progress and run history.
14
+
15
+ ## 0.1.0-next.26
16
+
17
+ ### Minor Changes
18
+
19
+ - 5c815ac: Identity: `PersonalAccessToken` is now marked `// @extensible`, so an app fragment can declare the back-relation of a foreign key to `personal_access_tokens` (for example a device row that records the token it paired with) with `extend model PersonalAccessToken { ... }`. Marker only: no column, key or index changes, no migration.
20
+
21
+ ## 0.1.0-next.25
22
+
23
+ ## 0.1.0-next.24
24
+
25
+ ## 0.1.0-next.23
26
+
27
+ ### Minor Changes
28
+
29
+ - d8777d8: Add STATE and COUNTED inbox notifications (#1077). `NotificationsService.notifyState` keeps ONE live inbox row per user, event and scope, refreshed in place and dismissed when its count drains to zero; `notifyCounted` folds repeated occurrences into one row whose `data.count` grows, optionally inside a rolling window and partitioned by a match object. Both serialize on a transaction-scoped advisory lock, and the database backs them with the partial unique index `notifications_live_dedup_uniq_idx`. Platform migration `0041_notifications_state_counted` adds `data`, `scope_id`, `dismissed_at`, `updated_at` and `dedup_key` to `notifications` (all additive). The inbox gains a Dismiss action (`POST /api/notifications/:id/dismiss`), list and unread count exclude dismissed rows, the wire shape gains `count`, `scopeId`, `dismissedAt` and `updatedAt`, and the retention sweep removes read and dismissed rows by age while STATE and COUNTED rows that are unread are never purged by age. Plain `notify()` is unchanged.
30
+
31
+ ## 0.1.0-next.22
32
+
33
+ ## 0.1.0-next.21
34
+
35
+ ## 0.1.0-next.20
36
+
37
+ ### Minor Changes
38
+
39
+ - 7b5796f: Add the `alerts` slice (#1047). `@marinoscar/platform-contract/alerts` carries the wire shapes (rules, the configs of the built-in kinds, incidents, the dry-run response, the kind catalog, the summary). `@marinoscar/platform-api/alerts` adds `AlertsModule.forRoot`, the open rule-kind registry (`registerAlertRuleKind`) with the `metric_threshold`, `node_event`, `verdict`, `node_offline` and `telemetry_unavailable` kinds, the pending/firing/resolved state machine, the `alerts.evaluate`, `alerts.evaluate_event` and `alerts.incidents_purge` server-only jobs, notifications on a transition with an optional webhook port (`ALERTS_WEBHOOK_EMITTER`), eight disabled starter rules, the `/api/admin/alerts` routes behind the new `alerts:read` and `alerts:write` permissions, and the `alerts` conformance suite (`@marinoscar/platform-api/alerts/testing`). The telemetry slice now exports `TelemetryDashboardService` and `createQueryFacade`, accepts a `null` (system) user and an `alert` query source, and the nodes slice exports `deriveNodeHealth`. `@marinoscar/platform-db` adds migration `0040_add_alerts` (`alert_rules`, `alert_incidents` and the raw-SQL partial unique index `alert_incidents_open_uniq_idx`).
40
+ - ad3f525: Add the `webhooks` slice schema (#1046): `WebhookEndpoint` (`webhook_endpoints`) and `WebhookDelivery` (`webhook_deliveries`), with the `WebhookScope` and `WebhookDeliveryStatus` enums and back-relations on `User` and `Organization`. Both tables are org-owned with a nullable `org_id` (NULL only for a system-scope endpoint) under FORCEd `webhook_endpoints_org_isolation` and `webhook_deliveries_org_isolation` policies (listed in `RLS_POLICIES`). Endpoints cascade with their owning user and organization, deliveries with their endpoint. Migration `0039_add_webhooks`.
41
+
42
+ ### Patch Changes
43
+
44
+ - f4ce36e: Add the `worker_node_events` table (`WorkerNodeEvent`, jobs/nodes slice, #1045): events a worker node reports about itself, with an open `type`, a `severity`, optional JSON `attrs`, the node's `occurred_at` and the server's `received_at`. Cascades with `worker_nodes`; no row-level security. Migration `0038_add_worker_node_events`; apply it with `npm run db:sync`, then `prisma:migrate`.
45
+
46
+ ## 0.1.0-next.19
47
+
48
+ ## 0.1.0-next.18
49
+
50
+ ## 0.1.0-next.17
51
+
52
+ ## 0.1.0-next.16
53
+
54
+ ## 0.1.0-next.15
55
+
56
+ ## 0.1.0-next.14
57
+
58
+ ## 0.1.0-next.13
59
+
60
+ ## 0.1.0-next.12
61
+
62
+ ## 0.1.0-next.11
63
+
64
+ ## 0.1.0-next.10
65
+
66
+ ## 0.1.0-next.9
67
+
68
+ ## 0.1.0-next.8
69
+
70
+ ## 0.1.0-next.7
71
+
72
+ ## 0.1.0-next.6
73
+
74
+ ## 0.1.0-next.5
75
+
76
+ ## 0.1.0-next.4
77
+
78
+ ### Minor Changes
79
+
80
+ - a426fd8: Open the AI capability and operation vocabularies, add a custom-operation port, richer transcription results and per-feature usage (PP-14.17). API: `registerAiCapability` and `registerAiOperation` (the 14 built-in capabilities and the usage operations register through them; `AiCapability` and `AiUsageOperation` become `Builtin | (string & {})`; `AI_CAPABILITIES` stays as a deprecated alias of `BUILTIN_AI_CAPABILITIES`); `AiProviderAdapter.operations` and `AiService.forUser(...).run(operationId, input)` run an app's operation through the same gate pipeline as a built-in port (kill switch, schema-validated input and output, model and capability gates, key policy, rate limits, one usage row, one span), never logging or recording its input or output and refusing an output or an error that carries the key; `AiTranscriptionResult.extras` (speaker-labelled segments, language and any JSON, at most 64 KiB, dropped when malformed) reaches the run output, and a transcription's `providerOptions` is bounded to 4 KiB and never logged; `GET /api/admin/ai/capabilities` (`ai_config:read`) lists the vocabularies; the usage reports take a `feature` filter and group by `feature` and `operation`; `AiModule.forRoot({ pricing })` binds the `AI_PRICING` port and the admin and organization reports then carry `priced` and a `cost` per bucket. The provider conformance kit gains `operations.*` scenarios, `FakeAiProvider` gains `operations` and `transcriptionExtras`, and `ai-secret-egress` covers the new route and fields. Contract: `AI_CAPABILITY_ID_PATTERN`, `AI_OPERATION_ID_PATTERN`, `AI_FEATURE_ID_PATTERN` and the capability, operation and cost schemas. Web: `registerAiPlaygroundMode` (subpath `/ai/ui/playground-modes`; the six built-in modes register through it, DOM unchanged; the fixed `AI_PLAYGROUND_MODES` tuple and `AiModePlaceholder` are removed), `useAiCapabilities` and `registerAiCapabilityLabel` (the Models page filter and the override dialog list an app's capabilities), Feature and Operation breakdowns, a Cost tile and column on a priced usage report, and speaker-labelled transcripts. DB: migration `0035_ai_usage_feature` adds the nullable `feature` column to `ai_usage_events` and `ai_runs` and the `(org_id, feature, created_at)` index on usage (both tables are row-level-security tables, so the migration runs in the `app.rls_bypass` transaction form); apply it with `npm run db:sync`, then `prisma:migrate`. Back-compat: every existing route, shape and id is unchanged; rows written before the column have no feature. The OpenAPI document shows a pattern where the models list's `capability` query and a provider's `supportedCapabilities` showed an enum.
81
+ - deeb8b5: Add the notifications slice: `@marinoscar/platform-api/notifications` (`NotificationsModule.forRoot`, the event, channel and template registries with open channel ids and `registerNotificationChannel`, `NotificationsService` with org-aware policy, the `notifications` system namespace with an org layer that only tightens, runtime Web Push (VAPID) configuration on `SystemSettingsRowStore`, broadcasts with `targetOrgId` and the org-scoped `org_broadcasts:*` pair, the SSE stream on `NOTIFICATIONS_EVENT_BUS`, the email channel forwarding template attachments, the `notifications` conformance suite at `/notifications/testing`), `@Auth({ anyPermissions })` in the identity slice, a `SystemSettingsRowStore` row key that admits camelCase (`webPush`), `@marinoscar/platform-contract/notifications` (the wire shapes, `BROADCAST_CHUNK_SIZE`), `@marinoscar/platform-web/notifications/{headless,ui}` (`configureNotificationsWeb`, `NotificationProvider`, `usePushSubscriptionSync`, `NotificationBell` with slots, the banner and the four pages, the service-worker helpers `registerNotificationServiceWorkerHandlers`, `handlePushEvent`, `handleNotificationClick`, `handlePushSubscriptionChange`), any-of card permissions in the settings hub (`SettingsCardDef.permission: string | readonly string[]`, `cardPermissionGranted`), and the platform migration `0032_add_broadcast_target_org` (`notification_broadcasts.target_org_id`).
82
+ - da8a6f2: Add the `android-app` fragment (`AndroidAppRelease`, `sizeBytes` BigInt), `push_subscriptions.platform` and platform migration `0033_add_android_app` with the raw-SQL partial unique index `android_app_releases_one_current_uniq_idx` (listed in `raw-sql-indexes.json`) (#746).
83
+ - 1822636: App metadata on users and organizations, more extensible models, offline checks for app indexes and policies, and a seed hook (PP-14.27). DB: migration `0036_add_app_metadata` adds `metadata JSONB NOT NULL DEFAULT '{}'` to `users` and `organizations` (each with a CHECK that the document is an object of at most 32 KiB of `jsonb` text, a backstop to the writer's 16 KiB) and a unique `(id, org_id)` key on `ai_runs` and `grants`, the target of a composite foreign key from an org-owned app table (the migration runs in the `app.rls_bypass` transaction form because both are row-level-security tables); apply it with `npm run db:sync`, then `prisma:migrate`. `Role`, `Notification`, `NotificationDelivery`, `Credential` (non-secret relations only), `AiRun` and `Grant` become `// @extensible` (a back-relation changes no SQL); `Permission` stays closed, with the reason documented. `runDbConformance({ appRoot })` gains `app-schema-objects` (every `rawSqlIndexes` and `rlsPolicies` entry of `platform.lock` is created by an app migration and dropped by none, an index definition agrees with the SQL, an unlisted partial or expression index or policy fails; the package's own entries are read, not judged) and `app-migrations`; a `rlsPolicies` lock entry gains optional `usingSha256` and `checkSha256` (`normaliseSqlExpression`, `sqlExpressionSha256`, `platform db policies` prints them), so a weakened policy is caught without a database; `platform db sync` and `platform db check` refuse an app migration named like a package migration (`APP_MIGRATION_ID_COLLISION`) or added after the last sync with a timestamp before an installed platform migration (`APP_MIGRATION_OUT_OF_ORDER`; the lock records the app directories seen at the last sync in `appMigrations`). New exports: `checkAppSchemaObjects`, `assertAppSchemaObjects`, `readAppMigrations`, `scanAllIndexes`, `checkAppMigrations`, `LockRlsPolicy`. Seed: `seedPlatform(prisma, input, { log?, extras? })` runs `SeedStep { id, run(tx, ctx) }` steps after the platform's own, each in a transaction when the client has one, under the same log, validated before any write; `assertSeedIdempotent` proves a second run creates 0; a bare `SeedLogger` third argument still works and the five fixed seed tables are unchanged. API: `registerUserMetadataSchema` and `registerOrganizationMetadataSchema` (a closed zod object per namespace; secret-named fields and open shapes are refused at registration, secret-named keys and a document over 16 KiB at write) and the injectable `IdentityMetadataService` (`get`, `set`, `update` under a row lock, `delete`; users and organizations); no platform route returns the document. Back-compat: no existing table, column, route or response changes; the OpenAPI document is unchanged. A lock written before `appMigrations` skips the ordering rule until its next sync; an app with an unlisted partial index or policy now fails `app-schema-objects` until it lists them in `platform.lock`.
84
+ - f9737d4: Jobs carry their organization (#734): `Job.orgId` (`jobs.org_id`, nullable, FK `organizations(id)` `ON DELETE SET NULL`; NULL is a deployment-wide system job) and `Organization.jobs` in the `jobs` fragment. Migration `0030_add_jobs_org_id` adds the column (metadata-only) and the foreign key (`NOT VALID`, then `VALIDATE`); `0031_add_jobs_org_id_status_index` builds `jobs_org_id_status_idx` `(org_id, status)` `CONCURRENTLY`, alone in its migration. No row-level security on `jobs`, and `jobs_active_dedup_uniq_idx` is unchanged.
85
+ - 10ac7be: Add `OrgCredential` (`org_credentials`) to the `credentials` fragment (#735): an organization's own encrypted credentials, addressed by `(org_id, purpose, name)`, cascading with the organization, the last editor kept as provenance (SetNull). Migration `0029_add_org_credentials` creates the table with the FORCEd `org_credentials_org_isolation` row-level-security policy (listed in `RLS_POLICIES`).
86
+ - 42151ac: Put `org_id` on the tenant-scoped tables and turn row-level security on (#725, platform migration `0025_org_scoped_rls`). `storage_objects`, `storage_object_chunks` and `ai_runs` get a NOT NULL `org_id` (foreign key `RESTRICT`), `ai_usage_events` a nullable one (`SET NULL`), `audit_events` a nullable one (`SET NULL`, no policy). The four `org` tables get `ENABLE` and `FORCE ROW LEVEL SECURITY` and a `<table>_org_isolation` policy keyed on the transaction-local `app.org_id` or `app.rls_bypass`; a chunk references its object through the composite key `(object_id, org_id)`. Existing rows are backfilled to the default organization (system audit actions and catalogue usage events keep NULL). The application role must be NOSUPERUSER NOBYPASSRLS or every policy is inert.
87
+
88
+ `Organization` is now `// @extensible`. New: `RLS_POLICIES` (from the shipped `rls-policies.json`), `assertRlsPolicies`, `checkRlsPolicySources`, `scanRlsPolicies` and `checkRlsPolicies`; `platform db drift` asserts the policies against `pg_policies` and the forced flag against `pg_class` (the `rlsPolicies` list in `platform.lock` carries an app's own); `runDbConformance()` gains the policy tripwire. The manifest gains an optional `rls` flag (`platform db promote --rls --touches`), and `platform db baseline` stops with `RLS_OPT_IN_REQUIRED` before a migration flagged `rls` that sits above `--through` until the app passes `--allow-rls`; it also asserts the live policies up to `--through`.
89
+
90
+ - fc11b22: Add `OrgSettings` to the `settings` fragment and migration `0028_add_org_settings` (#733): one row per organization holding its settings overrides, with its own version, FORCEd row-level security and the `org_settings_org_isolation` policy (listed in `RLS_POLICIES`).
91
+ - b618459: Add `Organization`, `Membership` and `Invite` to the identity fragment (#721) and the nullable `org_id` columns on `refresh_tokens`, `personal_access_tokens` and `device_codes`, as platform migration `0023_add_organizations`. The migration backfills the default organization (slug `default`), one active membership per existing user and the default `org_id` on every existing credential row, and creates the raw-SQL partial unique index `organizations_default_uniq_idx` (exactly one default organization), now listed in `raw-sql-indexes.json`.
92
+
93
+ `seedPlatform` (`@marinoscar/platform-db/seed`) gains an idempotent default-organization step: it creates the organization only when none is flagged default, found by `isDefault` rather than by slug. `PlatformSeedInput.defaultOrganization` is optional; `SeedPrisma` gains an `organization` delegate and `SeedSummary` a `defaultOrganizationCreated` field.
94
+
95
+ - 52eab37: Add the `Grant` model and platform migration `0027_add_grants` to the `sharing` fragment (#729): the `GrantGranteeKind` enum (`user`, `group`, `link`) and the `grants` table, a polymorphic `(resource_type, resource_id)` share with a role, an optional expiry and a soft revocation, the link columns #730 needs, a NOT NULL `org_id` under a forced `grants_org_isolation` policy, and a composite `(grantee_group_id, org_id)` key so a grant can never name another organization's group. The raw-SQL partial unique indexes `grants_active_user_uniq_idx` and `grants_active_group_uniq_idx` allow one active grant per resource and grantee, and `grants_grantee_consistency_check` keeps the grantee columns consistent with the kind; `RAW_SQL_INDEXES` and `RLS_POLICIES` list them.
96
+ - 1404a97: Add the `sharing` fragment and platform migration `0026_add_groups` (#728): the `GroupRole` enum and the `Group` (`// @extensible`), `GroupMember` and `GroupInvite` models (tables `groups`, `group_members`, `group_invites`), each with a NOT NULL `org_id`, `ENABLE` and `FORCE ROW LEVEL SECURITY` and a `<table>_org_isolation` policy. Members and invites reach their group through the composite key `(group_id, org_id)` -> `groups (id, org_id)`, so a row can never name another organization's group. The raw-SQL partial unique index `group_invites_pending_uniq_idx` allows one pending invite per group and address; `RAW_SQL_INDEXES` and `RLS_POLICIES` list the new index and the three policies.
97
+ - 7f175f0: Split RBAC into system roles and org roles (#723), as platform migration `0024_split_system_org_roles`. The identity fragment gains the `RoleScope` enum (`system`, `org`), `Role.scope` and `Permission.scope` (default `system`), `Membership.roleId` (required, `onDelete: Restrict`) and `Invite.roleId` (nullable: NULL means the default org role). The migration creates the `org_admin` role, scopes `contributor`, `viewer` and the org permissions to `org`, moves the `admin` role's org-permission grants to `org_admin`, sets every membership's role from the user's global roles (`admin` to `org_admin`, else the highest of `contributor` and `viewer`, else `viewer`) and deletes the `user_roles` rows of org-scoped roles.
98
+
99
+ `seedPlatform` writes and refreshes the `scope` of a role or permission entry that declares one; `SeedNamedEntry` gains an optional `scope` and the package exports `SeedScope`.
100
+
101
+ - 8a0f3b9: Open the jobs and nodes vocabularies to an app (PP-14.19). Jobs: `registerRetentionPolicy` puts an app table on the nightly retention (the `retention` settings namespace is composed from the registry: schemas, defaults, merge and policy-by-policy read-compat; the platform's four keep their order and defaults, and the enqueue-only `RetentionPurgeTask` enqueues one purge per enabled policy whose handler is mounted); `registerJobReason` opens `jobs.reason`, with `reasonLabel` on the admin job row. Migration `0034_open_job_reason` turns `jobs.reason` from the `JobReason` enum into `TEXT`, keeping every stored value (apply it with `npm run db:sync`, then `prisma:migrate`; the table is rewritten under a short lock); `JobReason` becomes `BuiltinJobReason | (string & {})` and the contract's `reason` a pattern (`jobReasonSchema`), so the OpenAPI document shows a pattern where it showed an enum. Nodes: a heartbeat may carry `vitals.extra` (at most 16 numeric keys), `registerNodeVital` words them in the vitals dialog, which also lists the node's reported capabilities; relayed spans may be named `job.app.<name>` with attributes registered through `registerNodeSpanAttribute` (emitted as `job.app.<key>`), and a span that fails validation is now dropped and counted instead of failing its whole batch with a 400. CLI: `registerJobRequirement` and `registerProbedBinary` (with `versionArgs`) are exported from `@marinoscar/platform-cli/node` and used by the startup self-test and `node doctor`; `JobExecutor.vitals()` feeds `vitals.extra`. Back-compat: with only the built-ins nothing served changes; `JOB_REASONS` and `RETENTION_POLICY_KEYS` remain as deprecated aliases of `BUILTIN_JOB_REASONS` and `BUILTIN_RETENTION_POLICY_KEYS`. Upgrade the API before the nodes: an API that predates `vitals.extra` answers a heartbeat that carries it with a 400, and the CLI then stops sending vitals for the process.
102
+ - d35900e: Sharing: open group roles and persisted app grantee kinds. Migration `0037_open_sharing_vocabularies` turns `group_members.role`, `group_invites.role` and `grants.grantee_kind` from Prisma enums into text, adds the nullable `grants.grantee_ref` and relaxes `grants_grantee_consistency_check`; an app registers a group role with `registerGroupRole` and a persisted grantee kind with `registerGranteeKind({ persisted: true })`, and the share dialog and member role pickers read the registries.
103
+ - 74c4aff: Declare peer dependencies per slice (`packages/platform-slice-peers.json`, checked by `npm run check:slice-peers`) and make every peer that the universal slice does not need optional. `platform-api` now requires only what `core` needs (`@nestjs/common`, `@nestjs/core`, `@nestjs/swagger`, `@opentelemetry/api`, `@prisma/client`, `nestjs-zod`, `reflect-metadata`, `rxjs`, `zod`); `@nestjs/config`, `@nestjs/schedule`, `@nestjs/event-emitter`, `@nestjs/jwt`, `@nestjs/passport`, `passport`, `@nestjs/terminus` and `@prisma/client-runtime-utils` become optional peers an app installs for the slices that use them. `platform-web` requires only `@mui/material`, Emotion, `react` and `react-dom`; `@mui/icons-material`, `react-router-dom` and `zod` become optional. `platform-db` no longer lists `@prisma/client` (its seed takes the app's client structurally) and `prisma` becomes optional; `platform-cli`'s `react` becomes optional. An app that installed every peer needs no change; an app that imports only some slices can now install only their peers. The datatable no longer imports the undeclared transitive `@mui/utils`.
104
+
105
+ ### Patch Changes
106
+
107
+ - f6e319b: Documentation only: every slice README's Extension-point catalog links the new extension author guide (`docs/EXTENDING.md`); the email README no longer promises that a provider of `SmtpEmailProvider` in the app module replaces the transport (it does not reach the package's consumers; a transport registry is not supported yet); the AI READMEs say that a provider cannot be enabled from an app yet; the platform-db README documents `rlsPolicies` in `platform.lock` with the migration SQL for an app table protected by row-level security.
108
+ - fe73d7a: Documentation only: the overview READMEs list every shipped slice and subpath, and the stale "version 0.0.0" status lines are replaced.
109
+
3
110
  ## 0.1.0-next.3
4
111
 
5
112
  ## 0.1.0-next.2
package/README.md CHANGED
@@ -6,9 +6,9 @@ The data layer of the platform: Prisma schema fragments (`schema/`), SQL migrati
6
6
 
7
7
  Schema fragments, migrations and seeds of the platform's data slices, and the **composer** that turns the fragments into the Prisma schema an app generates its client from.
8
8
 
9
- What ships today: the schema fragments (`schema/`, 34 models and 12 enums in eight slices), `platform db compose`, and the migration tooling (`platform db sync|check|promote|drift`, the `platform.lock` and `manifest.json` formats, the raw-SQL index list). The package also ships platform history v1: the base's 22 migrations as `migrations/0001_initial` to `0022_add_retention_created_at_indexes`, with a filled manifest, the raw-SQL index list `RAW_SQL_INDEXES` and its tripwire, and the offline `runDbConformance()` suite. The platform seed is shipped too: `seedPlatform` (the [`seed` slice](src/seed/README.md), `@marinoscar/platform-db/seed`). The package does not run migrations against a database itself; the app's `prisma:*` scripts do.
9
+ What ships today: the schema fragments (`schema/`, 41 models and 12 enums in nine slices), `platform db compose`, and the migration tooling (`platform db sync|check|promote|drift|policies`, the `platform.lock` and `manifest.json` formats, the raw-SQL index list). The package also ships platform history v1: the base's 22 migrations as `migrations/0001_initial` to `0022_add_retention_created_at_indexes`, with a filled manifest, the raw-SQL index list `RAW_SQL_INDEXES` and its tripwire, and the offline `runDbConformance()` suite. The platform seed is shipped too: `seedPlatform` (the [`seed` slice](src/seed/README.md), `@marinoscar/platform-db/seed`). The package does not run migrations against a database itself; the app's `prisma:*` scripts do.
10
10
 
11
- Status: pre-release (version `0.0.0`). The `extend model` seam is `experimental` until the extension contract is frozen.
11
+ Status: pre-release (the current channel and how to install it: the [release runbook](../../docs/runbooks/release-platform-packages.md)). The `extend model` seam is `experimental` until the extension contract is frozen.
12
12
 
13
13
  ## Install and peer dependencies
14
14
 
@@ -18,10 +18,13 @@ npm install @marinoscar/platform-db
18
18
 
19
19
  Install these in the app; the package never bundles its own copy (a second copy breaks dependency injection, hooks or theme context).
20
20
 
21
- | Package | Range |
22
- |---|---|
23
- | `@prisma/client` | `^7.8.0` |
24
- | `prisma` | `^7.8.0` |
21
+ | Package | Range | Required |
22
+ |---|---|---|
23
+ | `zod` | `^4.4.3` | yes (`lock`, and so `sync`, `drift`, `baseline` and the `platform db` CLI) |
24
+ | `prisma` | `^7.8.0` | optional: the `drift` slice and the CLI resolve its `build/index.js` at run time |
25
+ | `pg` | `^8.23.0` | optional: the `drift` slice loads it by name |
26
+
27
+ `@prisma/client` is not a peer of this package: the seed takes the app's client as a structural type ([the rule](../../docs/PACKAGES.md#peer-dependencies-per-slice)). The app has it anyway.
25
28
 
26
29
  ## Quick start
27
30
 
@@ -94,6 +97,7 @@ The programmatic API takes the same three folders as `ComposeOptions` (`platform
94
97
  | `platform db check` | `--database` (also compare `_prisma_migrations`; needs `DATABASE_URL`), `--root`, `--package-dir` |
95
98
  | `platform db promote <localDir>` | `--id <slug>` (required), `--since <version>`, `--slice <slice>`, `--requires <slices>`, `--root`, `--package-dir` |
96
99
  | `platform db drift` | `--schema <path>` (default `prisma/schema`, else `prisma/schema.prisma`), `--shadow-database-url <url>`, `--root` |
100
+ | `platform db policies` | `--root`, `--package-dir`: prints the row-level-security policies the app's migrations leave, as `platform.lock` `rlsPolicies` entries with their expression hashes |
97
101
 
98
102
  `--root` is the directory holding `prisma/` (default: the current directory). `--package-dir` is the package that holds `migrations/` (default: the installed one). Exit codes: `0` success, `1` a failed check or a refusal, `2` a usage error or a missing `DATABASE_URL`.
99
103
 
@@ -101,11 +105,13 @@ The programmatic API takes the same three folders as `ComposeOptions` (`platform
101
105
 
102
106
  ## Extension-point catalog
103
107
 
108
+ The extension ladder and a recipe per extension: [docs/EXTENDING.md](../../docs/EXTENDING.md).
109
+
104
110
  The one seam of the data layer is the `extend model` block, written in the app's fragment folder (`ComposeOptions.appFragmentsDir`). The row below names the option that locates it.
105
111
 
106
112
  | Name | Kind | Signature | When to use | Stability | Example |
107
113
  |---|---|---|---|---|---|
108
- | `ComposeOptions.appFragmentsDir` | option | `extend model <Model> { <back-relation field> }` in a `*.prisma` file of the folder | An app model points at a platform model (`User`, `Job`, `StorageObject`) and Prisma needs the back-relation field on the platform side | experimental | [example](../../apps/api/prisma/fragments/README.md) |
114
+ | `ComposeOptions.appFragmentsDir` | option | `extend model <Model> { <back-relation field> }` in a `*.prisma` file of the folder | An app model points at a platform model (`User`, `Organization`, `Role`, `Notification`, `Grant`, ... see the table below) and Prisma needs the back-relation field on the platform side | experimental | [example](../../apps/api/test/examples/db/coach-notes.prisma) |
109
115
 
110
116
  Stability stays `experimental` until the extension contract is frozen (issue #727).
111
117
 
@@ -130,16 +136,37 @@ Run `npm run db:compose`, then `include: { workouts: true }` type-checks on the
130
136
 
131
137
  Rules:
132
138
 
133
- - Only a model its owner marked `// @extensible` can be extended: `User`, `Job` and `StorageObject` today. Everything else is closed; opening one more is a minor-version change reached through a seam request, never an app edit.
139
+ - Only a model its owner marked `// @extensible` can be extended (the table below). Everything else is closed; opening one more is a minor-version change reached through a seam request, never an app edit. Marking a model adds no column, key or index: the generated SQL of every existing table is unchanged and no migration is needed for a back-relation.
134
140
  - An `extend` block holds back-relation fields only: no scalar field (it would add a column), no relation with `fields: [...]` (it would add a foreign key column), no `@@` attribute.
135
141
  - The slice or app that owns the foreign key writes the back-relation; the composer merges what is written and generates nothing.
136
142
  - Fragments are `prisma format` shaped: a block header is `<kind> <Name> {` on one line at column 0, and the block ends with `}` alone at column 0.
137
143
  - An app fragment named `base.prisma` replaces the package's `base.prisma` (the generator and datasource), which is how an app sets the generator `output` or `previewFeatures`. The composer warns when it does.
138
144
 
145
+ **Which models are extensible, and what an app may hang on each**
146
+
147
+ | Model | Table | Ownership | An app may relate | Never |
148
+ |---|---|---|---|---|
149
+ | `User` | `users` | system | its own per-user rows (a plain key on `id`); app fields that fit a document go in [`metadata`](#app-metadata-on-users-and-organizations) with no table at all | a column; the credential and token tables |
150
+ | `Organization` | `organizations` | system | its own per-organization rows; org-owned app tables point here with a `Cascade` key on `org_id` | |
151
+ | `PersonalAccessToken` | `personal_access_tokens` | system | a link from an app row to the token it was paired with (a nullable key on `id`, `onDelete: SetNull`, so revoking or purging a token never deletes the app row) | the `token_hash` column: an app reads token state through `PatService`, never copies the hash |
152
+ | `Role` | `roles` | system | per-role app data (a plain key on `id`) | `role_permissions`: `seedPlatform` owns the grants |
153
+ | `Group` | `groups` | org (row-level security) | app rows of a group: a composite key `(group_id, org_id)` -> `groups (id, org_id)` | a plain key on `id` alone |
154
+ | `Grant` | `grants` | org (row-level security) | an annotation of a grant: a composite key `(grant_id, org_id)` -> `grants (id, org_id)` | a plain key on `id` alone; an `@@unique` over the two partial unique indexes' columns |
155
+ | `AiRun` | `ai_runs` | org (row-level security) | an annotation of a run: a composite key `(ai_run_id, org_id)` -> `ai_runs (id, org_id)` | a copy of `request` (it holds the full prompt) |
156
+ | `StorageObject` | `storage_objects` | org (row-level security) | app rows about a file: a composite key `(object_id, org_id)` | |
157
+ | `Notification` | `notifications` | user | follow-up rows keyed by a notification (a plain key on `id`, `onDelete: Cascade` so the inbox purge keeps working) | |
158
+ | `NotificationDelivery` | `notification_deliveries` | user, optional | app annotations of a delivery receipt | |
159
+ | `Credential` | `credentials` | system | **non-secret bookkeeping only** (which feature uses it, when it was rotated) | the `secret` column: read plaintext through `CredentialsService`, never copy ciphertext or plaintext into an app table |
160
+ | `Job` | `jobs` | system, no row-level security | app rows tied to a job | `subject_type` / `subject_id` stay polymorphic, not keys |
161
+ | `Permission` | `permissions` | closed | nothing | **Deliberately closed.** A permission is a string the registry owns: `seedPlatform` upserts the rows by `name`, never deletes one, and a retired permission leaves through an expand/contract migration. A key from an app table would block that and tie app data to a row id no registry declares. An app refers to a permission by name in code |
162
+
163
+ `ai_runs` and `grants` carry an `(id, org_id)` unique key (migration `0036_add_app_metadata`) so an org-owned app table can link with a composite key, as `groups` and `storage_objects` already allowed: a plain foreign key on `id` would let a row of one organization point at another's, because a foreign-key check runs without row-level security. The worked example is [`coach-notes.prisma`](../../apps/api/test/examples/db/coach-notes.prisma) and its [migration](../../apps/api/test/examples/db/coach-notes.migration.sql): a table with keys to `notifications` and `grants`, a partial unique index and a policy, with `extend model` blocks on `Notification`, `Grant` and `Organization`, composed against the real platform fragments by [`app-schema-objects.spec.ts`](../../apps/api/test/examples/db/app-schema-objects.spec.ts) and run against Postgres by [`app-extension.db.spec.ts`](../../apps/api/test/examples/db/app-extension.db.spec.ts).
164
+
139
165
  The migration tooling adds no row to the catalog. How an app extends the migration history, which is a convention rather than a code seam:
140
166
 
141
- - **The app's own migrations live after the installed ones.** `platform db sync` names every installed directory after the newest directory already in `prisma/migrations`, so an app-authored migration and an installed one never reorder. The app keeps authoring with `prisma migrate dev`; those directories are not in `platform.lock`.
142
- - **App-owned raw-SQL indexes** go in `platform.lock` under `rawSqlIndexes` (`name` and `pg_indexes.indexdef`); `platform db drift` asserts them next to the package's own.
167
+ - **The app's own migrations live after the installed ones.** `platform db sync` names every installed directory after the newest directory already in `prisma/migrations`, so an app-authored migration and an installed one never reorder. The app keeps authoring with `prisma migrate dev`; those directories are not in `platform.lock`. [App migrations and the installed history](#app-migrations-and-the-installed-history) says what `sync` and `check` refuse.
168
+ - **App-owned raw-SQL indexes** go in `platform.lock` under `rawSqlIndexes` (`name` and `pg_indexes.indexdef`); `platform db drift` asserts them against the database next to the package's own, and `runDbConformance` asserts them offline against the migration SQL ([App schema objects, offline](#app-schema-objects-offline)).
169
+ - **App-owned row-level-security policies** go in `platform.lock` under `rlsPolicies` (`name`, `table` and, optionally, the hashes of the `USING` and `WITH CHECK` expressions that `platform db policies` prints); `platform db drift` asserts them against the database next to the package's own, and `runDbConformance` offline ([App tables with row-level security](#app-tables-with-row-level-security)).
143
170
  - **A comment-only difference** between an installed file and its package origin is recorded in the lock entry as `localSha256` plus `note`; any further edit is still caught.
144
171
  - **`platform db promote` is platform-internal.** It is how a maintainer turns a migration generated in the base app into a package migration; an app that only consumes the package never runs it.
145
172
 
@@ -151,13 +178,16 @@ The migration tooling adds no row to the catalog. How an app extends the migrati
151
178
  |---|---|
152
179
  | `base.prisma` | `generator client`, `datasource db` |
153
180
  | `identity.prisma` | `User` (`@extensible`), `UserIdentity`, `Role`, `Permission`, `RolePermission`, `UserRole`, `RefreshToken`, `PersonalAccessToken`, `DeviceCode`, `AllowedEmail`, `AuditEvent`, `Organization`, `Membership`, `Invite` |
154
- | `settings.prisma` | `SystemSettings`, `UserSettings` |
181
+ | `settings.prisma` | `SystemSettings`, `UserSettings`, `OrgSettings` |
155
182
  | `storage.prisma` | `StorageObject` (`@extensible`), `StorageObjectChunk` |
156
183
  | `credentials.prisma` | `Credential`, `UserCredential` |
157
184
  | `notifications.prisma` | `Notification`, `NotificationDelivery`, `PushSubscription`, `NotificationBroadcast` |
158
185
  | `jobs.prisma` | `Job` (`@extensible`), `JobStatsRollup`, `WorkerNode`, `NodeCredential`, `JobNodeSecret` |
159
186
  | `db-backup.prisma` | `DatabaseBackupRun` |
160
187
  | `ai.prisma` | `AiModel`, `UserAiKey`, `AiRun`, `AiUsageEvent` |
188
+ | `sharing.prisma` | `Group` (`@extensible`), `GroupMember`, `GroupInvite` |
189
+ | `webhooks.prisma` | `WebhookEndpoint`, `WebhookDelivery` (#1046: outbound webhook destinations and delivery attempts; nullable `org_id` under forced row-level security, NULL only for system scope; no secret column, the signing secret is in `credentials`) |
190
+ | `android-app.prisma` | `AndroidAppRelease` (#746: the hosted Android APKs; `sizeBytes` BigInt; at most one current release through the raw-SQL index `android_app_releases_one_current_uniq_idx`) |
161
191
 
162
192
  A slice declares the back-relations that point **into** another slice as `extend model` blocks in its own fragment (the 17 `User` fields that leave identity, and `Job.backupRun` in `db-backup.prisma`). Every block comment of the original schema is kept verbatim: they are the design documentation.
163
193
 
@@ -169,6 +199,18 @@ A slice declares the back-relations that point **into** another slice as `extend
169
199
 
170
200
  **Organizations.** The identity fragment owns `Organization`, `Membership` and `Invite` (tables `organizations`, `memberships`, `org_invites`) and the nullable `org_id` on `refresh_tokens`, `personal_access_tokens` and `device_codes` (migration `0023_add_organizations`). The migration backfills the default organization (slug `default`), one active membership per existing user and the default `org_id` on every existing credential row. The columns stay nullable (the expand step). Exactly one organization is the default, enforced by the raw-SQL index `organizations_default_uniq_idx`. These are identity tables read across organizations at login: no RLS on them.
171
201
 
202
+ **Tenant tables (`0025_org_scoped_rls`).** `org_id` (with a foreign key to `organizations`) is on `storage_objects`, `storage_object_chunks`, `ai_runs` (NOT NULL, `Restrict`), `ai_usage_events` (nullable, `SetNull`: a deployment-wide event and the history of a deleted organization keep no organization) and `audit_events` (nullable, `SetNull`, no policy). The four tables other than `audit_events` `ENABLE` and `FORCE ROW LEVEL SECURITY` with one policy each ([below](#row-level-security-policies)); `storage_object_chunks` links to its object with the composite `(object_id, org_id)`, because a foreign-key check bypasses row-level security. The migration backfills every existing row to the default organization (system audit actions and catalogue-sync usage keep NULL) inside a transaction that raises `app.rls_bypass`.
203
+
204
+ **Groups (`0026_add_groups`, #728).** The `sharing` fragment owns `Group`, `GroupMember` and `GroupInvite` (tables `groups`, `group_members`, `group_invites`) and, from `0026_add_groups` to `0037_open_sharing_vocabularies`, the enum `GroupRole` (`admin`, `editor`, `viewer`; since `0037` the `role` columns are text, see below). A group is a set of users inside one organization, never a tenant. All three carry a NOT NULL `org_id` (foreign key `Cascade`), `ENABLE` and `FORCE ROW LEVEL SECURITY` and a `<table>_org_isolation` policy; a member and an invite reach their group through the composite `(group_id, org_id)` -> `groups (id, org_id)` (the target of `@@unique([id, orgId])`). `group_invites_pending_uniq_idx` is the one raw-SQL index. `Group` is `// @extensible`, so an app table owned by a group adds its back-relation with `extend model Group`. New tables, so no backfill.
205
+
206
+ **Grants (`0027_add_grants`, #729).** The `sharing` fragment also owns `Grant` (table `grants`) and, until `0037_open_sharing_vocabularies`, the enum `GrantGranteeKind` (`user`, `group`, `link`; since `0037` `grantee_kind` is text). A grant shares one record of an app's registered resource type, named polymorphically by `(resource_type, resource_id)` with no foreign key (the platform cannot know app tables; apps delete a record's grants in the same transaction and the `sharing.grants.prune` job catches the rest), with a role, an optional `expires_at` and a soft `revoked_at`. `org_id` is NOT NULL under a forced `grants_org_isolation` policy, and a group grantee reaches its group through the composite key `(grantee_group_id, org_id)`, so a grant cannot name another organization's group. The raw-SQL partial unique indexes `grants_active_user_uniq_idx` and `grants_active_group_uniq_idx` allow one active grant per resource and grantee, and the `CHECK` constraint `grants_grantee_consistency_check` keeps the grantee columns consistent with `grantee_kind` (a link grant has neither grantee and a `link_token_hash`). The link columns (`link_token_hash`, unique; `link_token_ciphertext`; `link_label`) are created now for #730.
207
+
208
+ **Open sharing vocabularies (`0037_open_sharing_vocabularies`, #967).** `group_members.role`, `group_invites.role` and `grants.grantee_kind` become `TEXT` (every stored value kept, both enums dropped, no CHECK on the roles: a row outlives the registry that wrote it), so an app adds a group role (`registerGroupRole`) or a persisted grantee kind (`registerGranteeKind({ persisted: true })`) with no migration. `grants` gains the nullable `grantee_ref` (the reference of an app kind, as the kind normalised it). `grants_grantee_consistency_check` is relaxed to the three built-in row shapes (each now also with `grantee_ref` NULL) OR a row of any other kind with a `grantee_ref` and none of `grantee_user_id`, `grantee_group_id`, `link_token_hash`; the new partial unique index `grants_active_ref_uniq_idx` allows one ACTIVE grant per `(resource_type, resource_id, grantee_kind, grantee_ref)` for those kinds (`RAW_SQL_INDEXES`). The two older partial indexes are rebuilt with a text predicate (`'user'::text`), which is why their `definition` in `raw-sql-indexes.json` changed. The migration runs in the `app.rls_bypass` transaction (RLS org tables).
209
+
210
+ **Organization settings (`0028_add_org_settings`, #733).** The `settings` fragment owns `OrgSettings` (table `org_settings`): one row per organization (`org_id` unique, foreign key to `organizations`, `Cascade`; `updated_by_user_id` `SetNull`) holding that organization's overrides of the org-overridable system settings namespaces, with a `version` of its own. NOT NULL `org_id`, `ENABLE` and `FORCE ROW LEVEL SECURITY` and the `org_settings_org_isolation` policy. A new table, so no backfill; `system_settings` and `user_settings` are unchanged.
211
+
212
+ **Jobs carry their organization (`0030_add_jobs_org_id`, `0031_add_jobs_org_id_status_index`, #734).** The `jobs` fragment's `Job` gains `orgId` (`jobs.org_id`): nullable, no default (a metadata-only `ADD COLUMN`), foreign key to `organizations` `ON DELETE SET NULL` (added `NOT VALID`, then validated), so deleting an organization keeps its job history. `NULL` is a deployment-wide (system) job, and every earlier row is one. The `(org_id, status)` index `jobs_org_id_status_idx` is built `CONCURRENTLY` in `0031`, the only statement of that migration (`jobs` is a big table). Deliberately no row-level security on `jobs` (the claim is one cross-organization statement), and `jobs_active_dedup_uniq_idx` is unchanged.
213
+
172
214
  **System and org roles.** Migration `0024_split_system_org_roles` (#723) adds the `RoleScope` enum (`system`, `org`), `roles.scope` and `permissions.scope` (default `system`), the required `memberships.role_id` (the member's org role, `onDelete: Restrict`) and the nullable `org_invites.role_id` (NULL means the default org role). Its data step creates `org_admin`, scopes `contributor`, `viewer` and the org permissions to `org`, moves `admin`'s org-permission grants to `org_admin`, sets each membership's role from the user's global roles (`admin` to `org_admin`, otherwise `contributor` over `viewer`, otherwise `viewer`) and deletes the `user_roles` rows of org roles; `user_roles` keeps its shape. `seedPlatform` writes the scope of every role and permission entry that carries one.
173
215
 
174
216
  **Seeds** (`@marinoscar/platform-db/seed`, stability `experimental`; details in the [slice README](src/seed/README.md)). `seedPlatform(prisma, input, log?)` upserts the platform's roles, permissions, default role grants, the `global` `system_settings` row and the initial administrator's `allowed_emails` row, then creates the default organization when none is flagged default, in that order, and returns a summary. Idempotent: every write is an upsert on a natural unique, so a second run changes nothing, which is what `appctl deploy update` and the CI `smoke` job rely on. **Never deletes and never overwrites an admin-edited value:** a permission removed from the registry stays as a row until a migration removes it (expand/contract), and the settings row and the allowlist row are created with `update: {}`. `prisma` is the structural type `SeedPrisma` (the delegates `role`, `permission`, `rolePermission`, `systemSettings`, `allowedEmail`, `organization`), so the package never imports or bundles a generated client.
@@ -240,6 +282,9 @@ Prisma's schema language cannot express a partial index or an expression index,
240
282
  | `jobs_succeeded_duration_idx` | `jobs` | no | `0008_add_jobs` | finished succeeded jobs, for the duration percentiles | [job-queue](../../docs/specs/job-queue.md) |
241
283
  | `database_backup_runs_active_uniq_idx` | `database_backup_runs` | yes | `0010_add_database_backup_runs`, re-created in `0012_add_backup_run_job_link` | at most one pending or running backup (a constant-expression key) | [database-backup](../../docs/specs/database-backup.md) |
242
284
  | `organizations_default_uniq_idx` | `organizations` | yes | `0023_add_organizations` | exactly one default organization (a constant-expression key over `is_default`) | [platform-packages](../../docs/specs/platform-packages.md#tenancy-and-access-model) |
285
+ | `group_invites_pending_uniq_idx` | `group_invites` | yes | `0026_add_groups` | at most one PENDING invite per group and address; a declined, revoked or accepted one does not block a re-invite | [platform-packages](../../docs/specs/platform-packages.md#tenancy-and-access-model) |
286
+ | `grants_active_user_uniq_idx` | `grants` | yes | `0027_add_grants` | at most one ACTIVE (unrevoked) grant per resource and user; the grants API upserts on it | [platform-packages](../../docs/specs/platform-packages.md#tenancy-and-access-model) |
287
+ | `grants_active_group_uniq_idx` | `grants` | yes | `0027_add_grants` | at most one ACTIVE grant per resource and group | [platform-packages](../../docs/specs/platform-packages.md#tenancy-and-access-model) |
243
288
 
244
289
  `raw-sql-indexes.json` is the one list (`name`, `table`, `unique`, `definition`, `reason`, `doc`, `createdIn`), exported as `RAW_SQL_INDEXES`. `platform db drift` asserts each against `pg_indexes` by name and definition, and `assertRawSqlIndexes` is the tripwire that travels with the package. It scans every manifest migration (ignoring comments, following `DROP INDEX` and `ALTER INDEX ... RENAME`) for a `CREATE [UNIQUE] INDEX` with a `WHERE` clause or an expression key, and fails when
245
290
 
@@ -247,10 +292,107 @@ Prisma's schema language cannot express a partial index or an expression index,
247
292
  - a listed one is not created, or its table, uniqueness or `createdIn` disagrees,
248
293
  - a schema fragment declares `@@unique`, `@@index` or `@unique` under a listed index's name or on its table and key columns.
249
294
 
250
- An app's own raw-SQL indexes go in its `platform.lock` under `rawSqlIndexes`; the drift test asserts them too.
295
+ An app's own raw-SQL indexes go in its `platform.lock` under `rawSqlIndexes`, as `{ "name", "definition" }` with the definition exactly as `pg_indexes.indexdef` prints it; the drift test asserts them too ([example lock entry](#app-tables-with-row-level-security)).
296
+
297
+ ### Row-level security policies
298
+
299
+ Prisma's schema language cannot express a policy either, and `prisma migrate diff` does not see one, so the tenant-isolation policies of `0025_org_scoped_rls`, `0026_add_groups`, `0027_add_grants` and `0028_add_org_settings` exist only in migration SQL, like the raw-SQL indexes. They are intentional drift too: never remove one to "fix" a diff.
300
+
301
+ | Policy | Table | Created in |
302
+ |---|---|---|
303
+ | `storage_objects_org_isolation` | `storage_objects` | `0025_org_scoped_rls` |
304
+ | `storage_object_chunks_org_isolation` | `storage_object_chunks` | `0025_org_scoped_rls` |
305
+ | `ai_runs_org_isolation` | `ai_runs` | `0025_org_scoped_rls` |
306
+ | `ai_usage_events_org_isolation` | `ai_usage_events` | `0025_org_scoped_rls` |
307
+ | `groups_org_isolation` | `groups` | `0026_add_groups` |
308
+ | `group_members_org_isolation` | `group_members` | `0026_add_groups` |
309
+ | `group_invites_org_isolation` | `group_invites` | `0026_add_groups` |
310
+ | `grants_org_isolation` | `grants` | `0027_add_grants` |
311
+ | `org_settings_org_isolation` | `org_settings` | `0028_add_org_settings` |
312
+
313
+ `rls-policies.json` is the one list (`name`, `table`, `reason`, `doc`, `createdIn`), exported as `RLS_POLICIES` beside `RAW_SQL_INDEXES`. `platform db drift` reads `pg_policies` and `pg_class` and reports `POLICY_MISSING` (a listed policy is not in the database), `POLICY_UNLISTED` (the database has one nobody listed), `RLS_NOT_ENABLED`, `RLS_NOT_FORCED` (the table does not `FORCE` it, so the owner, which is the application role, bypasses the policy) and `RLS_FORCED_WITHOUT_POLICY` (everything would be denied). `assertRlsPolicies` is the offline tripwire (`runDbConformance` runs it as `rls-policies`): it scans the manifest migrations and fails on `UNLISTED_POLICY`, `LISTED_POLICY_NOT_FOUND`, `LISTED_POLICY_MISMATCH` (`createdIn` disagrees) and a policy whose table the migrations never `ENABLE` / `FORCE`. The policy text and the settings it reads (`app.org_id`, `app.user_id`, `app.rls_bypass`, always `set_config(..., true)`) are specified in [SECURITY-ARCHITECTURE.md §18](../../docs/SECURITY-ARCHITECTURE.md#18-tenant-isolation-rls); the clients that set them are `PrismaService.forOrg` / `runInOrg` and `PrismaSystemService` in the reference app, built on the row-level-security helpers of `@marinoscar/platform-api/core` ([core README](../platform-api/src/core/README.md)).
314
+
315
+ A migration that enables row-level security carries `"rls": true` in the manifest (`platform db promote --rls`), and, because it changes what a connection can see, a partial `platform db baseline` that stops before it does so deliberately: a baseline through or past it needs `--allow-rls`, which is the operator's statement that the application role is already `NOSUPERUSER NOBYPASSRLS` (error `RLS_OPT_IN_REQUIRED` otherwise). `--touches <slices>` on promote records the other slices' tables a migration changes (`0025` touches `ai` and `identity` from the `storage` slice), so a baseline of a subset of slices can tell.
316
+
317
+ ### App schema objects, offline
318
+
319
+ `platform db drift` asserts an app's own `rawSqlIndexes` and `rlsPolicies` (from `platform.lock`) against a live database. The same lists are also checked **offline**, against the migration SQL, by `runDbConformance` (test `app-schema-objects`, function `checkAppSchemaObjects` / `assertAppSchemaObjects`), so a typo or a forgotten migration fails the app's unit tests instead of the `smoke` job. It scans the app's whole `prisma/migrations` history in directory order (installed platform migrations included, so a later app migration that drops or rewrites something is seen) and fails when
320
+
321
+ - a listed index or policy is created by no migration, or dropped by a later one (`APP_INDEX_NOT_FOUND`, `APP_POLICY_NOT_FOUND`),
322
+ - a listed index's `definition` states another table, uniqueness or key columns than the migrations leave (`APP_INDEX_MISMATCH`),
323
+ - a listed policy carries `usingSha256` or `checkSha256` and the migrations leave a different expression (`APP_POLICY_EXPRESSION_MISMATCH`): a policy weakened by a later `ALTER POLICY` or re-created with another body is caught without a database. The hash is the SHA-256 of the expression after `normaliseSqlExpression` (whitespace collapsed, case folded outside quotes, spaces inside parentheses and around commas dropped); `platform db policies` prints it. Both hashes are optional, so an existing lock entry keeps working,
324
+ - a listed policy's table does not both `ENABLE` and `FORCE ROW LEVEL SECURITY` (`APP_POLICY_TABLE_NOT_ENABLED`, `APP_POLICY_TABLE_NOT_FORCED`),
325
+ - the migrations leave a partial or expression index, or a policy, that neither the package's lists nor the lock lists (`UNLISTED_APP_RAW_INDEX`, `UNLISTED_APP_POLICY`): the lock is the app's allow-list, as `raw-sql-indexes.json` and `rls-policies.json` are the package's.
326
+
327
+ The package's own entries are never judged here (the package tripwires do that) and need nothing in the lock. An app upgrading to this check lists any index or policy it already has in its lock first; `platform db policies` prints the policy entries.
328
+
329
+ ### App migrations and the installed history
330
+
331
+ `platform db sync` and `platform db check` (and the `app-migrations` conformance test) compare the app-authored directories of `prisma/migrations` (those no `platform.lock` entry names) with the installed platform history, and refuse:
332
+
333
+ - **`APP_MIGRATION_ID_COLLISION`**: an app directory named exactly like a package migration (`0036_add_app_metadata`). The history could not tell the two apart.
334
+ - **`APP_MIGRATION_OUT_OF_ORDER`**: an app directory that sorts before the last installed platform migration but was not there at the last `sync`. `sync` installs a platform migration under a timestamp later than everything in the history, so an app migration that existed then sorts before it by design (an app's `add_notes` between two platform migrations is normal). One that appears afterwards with an older timestamp (a branch started before the sync, merged after) would run, on a fresh database, before platform migrations other databases applied first. The lock remembers the app directories present at the last sync in `appMigrations` (`sync` and `promote` write it); a lock without the field skips this rule until its next sync.
335
+
336
+ `sync` throws `APP_MIGRATION_COLLISION` and installs nothing while either exists. The fix is a rename of a migration that was never applied (a timestamp after the last installed one), or, for one that was applied, `platform db sync` once it is the only reason the check fails.
337
+
338
+ ### App tables with row-level security
339
+
340
+ An app table that carries `org_id` is isolated the way the platform's `org` tables are, and the app declares it in two places that `platform db drift` reads: the migration that creates the policy, and `rlsPolicies` in `platform.lock`. Prisma cannot express the policy, so it is intentional drift in the app too: never "fix" it with a schema change.
341
+
342
+ 1. **The model.** In the app's fragment, a NOT NULL `orgId` with a `Cascade` relation to `Organization`, and the back-relation as `extend model Organization { workouts Workout[] }` (`Organization` is `// @extensible`). A link to another org-owned table is a composite foreign key that includes `org_id` (`@relation(fields: [parentId, orgId], references: [id, orgId])`, with `@@unique([id, orgId])` on the parent), because a foreign-key check runs without row-level security.
343
+ 2. **The migration.** `prisma migrate dev --create-only`, then append the three statements to the generated SQL. The policy is the platform's own (copy it unchanged, only the names differ):
344
+
345
+ ```sql
346
+ ALTER TABLE "workouts" ENABLE ROW LEVEL SECURITY;
347
+ ALTER TABLE "workouts" FORCE ROW LEVEL SECURITY;
348
+ CREATE POLICY "workouts_org_isolation" ON "workouts"
349
+ USING ("org_id" = NULLIF(current_setting('app.org_id', true), '')::uuid
350
+ OR current_setting('app.rls_bypass', true) = 'on')
351
+ WITH CHECK ("org_id" = NULLIF(current_setting('app.org_id', true), '')::uuid
352
+ OR current_setting('app.rls_bypass', true) = 'on');
353
+ ```
354
+
355
+ A migration that reads or writes rows of an org table (a backfill, a data fix) wraps its statements, because under `FORCE` an unscoped statement silently affects zero rows:
356
+
357
+ ```sql
358
+ BEGIN;
359
+ SELECT set_config('app.rls_bypass', 'on', true);
360
+ -- the backfill, the policy statements above
361
+ COMMIT;
362
+ ```
363
+
364
+ The setting is always `set_config(..., true)` (transaction-local), never a session-level `SET`. Creating a new, empty table needs no bypass; the wrapper is harmless there.
365
+ 3. **The lock.** List the policy in the app's `prisma/platform.lock` (the file is JSON; `rlsPolicies` and `rawSqlIndexes` are optional keys, and `platform db sync` and `baseline` carry them through unchanged):
366
+
367
+ ```json
368
+ {
369
+ "lockVersion": 1,
370
+ "platformVersion": "0.1.0",
371
+ "migrations": [],
372
+ "rawSqlIndexes": [
373
+ { "name": "workouts_active_uniq_idx", "definition": "CREATE UNIQUE INDEX workouts_active_uniq_idx ON public.workouts USING btree (org_id, slug) WHERE (archived_at IS NULL)" }
374
+ ],
375
+ "rlsPolicies": [
376
+ { "name": "workouts_org_isolation", "table": "workouts" }
377
+ ]
378
+ }
379
+ ```
380
+
381
+ An entry is exactly `name` and `table` (the lock refuses another key). It is the app's statement that the policy is intentional.
382
+ 4. **Check it.** `platform db drift` diffs the replayed migrations against the schema in a shadow database, then asserts in the migrated database it is given (`DATABASE_URL`) each listed policy in `pg_policies` and that its table has row-level security enabled **and** forced. It reports `POLICY_MISSING`, `RLS_NOT_ENABLED` and `RLS_NOT_FORCED` for a listed policy that is not (fully) in place, `POLICY_UNLISTED` for a policy in the database that neither list names, and `RLS_FORCED_WITHOUT_POLICY` for a forced table no listed policy protects. Today the check is against a live database only; `runDbConformance` and `assertRlsPolicies` still read the package's list, not the lock's.
383
+
384
+ The application role must be an ordinary role that owns the tables (`NOSUPERUSER NOBYPASSRLS`); a superuser ignores every policy. The runtime clients (`PrismaService.forOrg` / `runInOrg`) and the model-ownership registration an `org` model needs are in the reference app's [ownership README](../../apps/api/src/prisma/ownership/README.md); the step-by-step recipe is [EXTENDING.md](../../docs/EXTENDING.md#add-an-rls-protected-app-table).
251
385
 
252
386
  The exported functions (`planSync`, `applySync`, `checkLock`, `checkLedger`, `promote`, `readLock`, `readManifest`, `serializeLock`, `RAW_SQL_INDEXES`, `assertRawSqlIndexes`, `runDbConformance`) are `experimental` and documented in the API reference (`npm run docs:packages`).
253
387
 
388
+ ### App metadata on users and organizations
389
+
390
+ `users.metadata` and `organizations.metadata` (migration `0036_add_app_metadata`) are `JSONB NOT NULL DEFAULT '{}'` documents the **app** fills, one top-level key per namespace it registers (`registerUserMetadataSchema`, `registerOrganizationMetadataSchema` of `@marinoscar/platform-api/identity`). They are the sanctioned place for a per-user or per-organization app field, so an app does not add a column to a package-owned table or a side table for a handful of settings. Neither table has row-level security.
391
+
392
+ - Not a secret store: the API refuses secret-named fields and keys, and nothing encrypts the document (it travels in backups and exports).
393
+ - 16 KiB per row, enforced by the writer; a CHECK (`users_metadata_size_check`, `organizations_metadata_size_check`: a JSON object, at most 32 KiB of `jsonb` text) backs it whoever writes.
394
+ - Never returned by a platform route. Details and the recipe: the [identity README](../platform-api/src/identity/README.md#app-metadata-on-users-and-organizations).
395
+
254
396
  ## Permissions and settings
255
397
 
256
398
  The data layer declares no permission or setting of its own; the API slices do. It **seeds** them: `seedPlatform` writes the roles, the permissions and the default grants an app's permission registry rendered into `prisma/catalog/permissions.json`, and the `global` system settings row from the settings namespaces' defaults in `prisma/catalog/system-settings-defaults.json` (stability `experimental`). A permission or a settings key is added in the registry plus a catalog regeneration (`npm run catalog:permissions`, `npm run catalog:settings` in the reference app), never in this package. Defaults are written once: the row is never overwritten, so a changed default reaches an existing deployment only through its own migration or the settings API.
@@ -271,7 +413,7 @@ None. The package emits nothing at run time.
271
413
 
272
414
  The composer reads and writes schema text only: it opens no database connection and reads no environment variable. A fragment cannot add a column to a platform table (the `EXTEND_SCALAR_FIELD` and `EXTEND_OWNING_RELATION` rejections), so an app cannot weaken a platform constraint through composition. No secret belongs in a fragment: secrets are stored encrypted in the `credentials`, `user_credentials` and `user_ai_keys` tables, never as a column that holds plaintext. Raw-SQL partial unique indexes stay in migration SQL, never as `@@unique` (see the repository's invariants).
273
415
 
274
- Raw-SQL partial unique indexes stay in migration SQL, never as `@@unique` (see the repository's invariants), and `platform db drift` asserts them against `pg_indexes` rather than filtering Prisma's diff. The tooling reads and writes only migration files, the lock and the manifest. It holds no credential: `db drift` and `check --database` use the `DATABASE_URL` the caller supplies, and `drift` creates and drops only its own throwaway shadow database. An installed migration is never edited: `platform.lock` proves it, and Prisma does not (`migrate deploy` and `migrate status` stay silent about an applied file that changed afterwards).
416
+ **Row-level security is only as strong as the role.** A superuser or `BYPASSRLS` role ignores every policy (`FORCE` included), so the policies protect nothing for an app that connects as one; the reference app's Doctor check `db.rls_role` fails in that case. A migration that backfills an RLS table runs as system work in an explicit transaction that sets `app.rls_bypass` (`BEGIN; SELECT set_config('app.rls_bypass', 'on', true); ... COMMIT;`), or the statement silently changes zero rows. Raw-SQL partial unique indexes stay in migration SQL, never as `@@unique` (see the repository's invariants), and `platform db drift` asserts them against `pg_indexes` rather than filtering Prisma's diff. The tooling reads and writes only migration files, the lock and the manifest. It holds no credential: `db drift` and `check --database` use the `DATABASE_URL` the caller supplies, and `drift` creates and drops only its own throwaway shadow database. An installed migration is never edited: `platform.lock` proves it, and Prisma does not (`migrate deploy` and `migrate status` stay silent about an applied file that changed afterwards).
275
417
 
276
418
  ## Conformance suite
277
419
 
@@ -281,6 +423,9 @@ Raw-SQL partial unique indexes stay in migration SQL, never as `@@unique` (see t
281
423
  |---|---|
282
424
  | `raw-sql-indexes` | the raw-SQL index tripwire above is tripped |
283
425
  | `platform.lock` | an installed migration differs from the lock or the package, a package migration is not installed, or a locked directory is missing (the same check as `platform db check`) |
426
+ | `rls-policies` | the policy tripwire above is tripped |
427
+ | `app-schema-objects` | a raw-SQL index or policy listed in the lock is created by no migration (or dropped later), a listed policy's expression hash differs from the SQL, or an unlisted partial or expression index or policy exists ([App schema objects, offline](#app-schema-objects-offline)) |
428
+ | `app-migrations` | an app-authored migration directory is named like a package migration or would reorder the installed history ([App migrations and the installed history](#app-migrations-and-the-installed-history)) |
284
429
 
285
430
  ```ts
286
431
  // apps/api/test/prisma/platform-db-conformance.spec.ts
@@ -1 +1 @@
1
- {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/baseline/deps.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,gHAAgH;IAChH,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,oIAAoI;IACpI,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,6IAA6I;IAC7I,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,kCAAkC;IAClC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,iBAAiB;IACjB,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAuD7E"}
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/baseline/deps.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,gHAAgH;IAChH,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,oIAAoI;IACpI,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,6IAA6I;IAC7I,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,kCAAkC;IAClC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,iBAAiB;IACjB,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAyD7E"}
@@ -51,6 +51,8 @@ function createBaselineDeps(options) {
51
51
  }
52
52
  },
53
53
  readIndexes: () => (0, index_js_1.readIndexRows)(options.databaseUrl, options.root),
54
+ readPolicies: () => (0, index_js_1.readPolicyRows)(options.databaseUrl, options.root),
55
+ readTableRls: () => (0, index_js_1.readTableRlsRows)(options.databaseUrl, options.root),
54
56
  diffReplayToLive: (replayMigrationsDir) => (0, index_js_1.withShadowDatabase)({ cwd: options.root, databaseUrl: options.databaseUrl, shadowDatabaseUrl: options.shadowDatabaseUrl }, async (shadowUrl) => {
55
57
  const result = runPrisma(['migrate', 'diff', '--from-migrations', replayMigrationsDir, '--to-config-datasource', '--script'], { SHADOW_DATABASE_URL: shadowUrl });
56
58
  if (result.status !== 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"deps.js","sourceRoot":"","sources":["../../src/baseline/deps.ts"],"names":[],"mappings":";;AAqCA,gDAuDC;AA5FD,2DAA+C;AAC/C,qCAAqC;AACrC,yCAAiC;AACjC,gDAAsG;AA0BtG;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,OAA4B;IAC7D,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,IAAI,IAAA,gBAAI,EAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAEtF,SAAS,SAAS,CAAC,IAA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AC;AACJ,CAAC"}
@@ -8,6 +8,8 @@
8
8
  * - `LEDGER_CHECKSUM_MISMATCH`: a mapped directory's file differs from the checksum the database recorded.
9
9
  * - `DIFF_BLOCKING`: the live database differs from the package history in a statement no deviation declares.
10
10
  * - `INDEX_MISSING`, `INDEX_DEFINITION_DIFFERS`: a raw-SQL index is missing or changed in the live database.
11
+ * - `RLS_OPT_IN_REQUIRED`: a migration above `--through` is flagged `rls` in the manifest and the app has not opted in with `--allow-rls`.
12
+ * - `POLICY_MISSING`, `POLICY_UNLISTED`, `RLS_NOT_ENABLED`, `RLS_NOT_FORCED`, `RLS_FORCED_WITHOUT_POLICY`: the live row-level security does not match the policies the history up to `--through` creates.
11
13
  * - `LOCK_NOT_EMPTY`: `platform.lock` already has entries and `--force-remap` was not given.
12
14
  * - `PLACEMENT_IMPOSSIBLE`: a migration to resolve cannot be named so that the history keeps package order.
13
15
  * - `PACKAGE_FILE_MISMATCH`: a package file does not match its manifest hash.
@@ -16,7 +18,7 @@
16
18
  *
17
19
  * @stability experimental
18
20
  */
19
- export type BaselineErrorCode = 'THROUGH_UNKNOWN' | 'MAP_INVALID' | 'LEDGER_FAILED_ROW' | 'LEDGER_ROW_MISSING' | 'LEDGER_CHECKSUM_MISMATCH' | 'DIFF_BLOCKING' | 'INDEX_MISSING' | 'INDEX_DEFINITION_DIFFERS' | 'LOCK_NOT_EMPTY' | 'PLACEMENT_IMPOSSIBLE' | 'PACKAGE_FILE_MISMATCH' | 'RESOLVE_FAILED' | 'VERIFY_FAILED';
21
+ export type BaselineErrorCode = 'THROUGH_UNKNOWN' | 'MAP_INVALID' | 'LEDGER_FAILED_ROW' | 'LEDGER_ROW_MISSING' | 'LEDGER_CHECKSUM_MISMATCH' | 'DIFF_BLOCKING' | 'INDEX_MISSING' | 'INDEX_DEFINITION_DIFFERS' | 'RLS_OPT_IN_REQUIRED' | 'POLICY_MISSING' | 'POLICY_UNLISTED' | 'RLS_NOT_ENABLED' | 'RLS_NOT_FORCED' | 'RLS_FORCED_WITHOUT_POLICY' | 'LOCK_NOT_EMPTY' | 'PLACEMENT_IMPOSSIBLE' | 'PACKAGE_FILE_MISMATCH' | 'RESOLVE_FAILED' | 'VERIFY_FAILED';
20
22
  /**
21
23
  * A refusal of `platform db baseline`, with a stable code.
22
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/baseline/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,iBAAiB,GACzB,iBAAiB,GACjB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,0BAA0B,GAC1B,eAAe,GACf,eAAe,GACf,0BAA0B,GAC1B,gBAAgB,GAChB,sBAAsB,GACtB,uBAAuB,GACvB,gBAAgB,GAChB,eAAe,CAAC;AAEpB;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC;;;OAGG;gBACS,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM;CAKrD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/baseline/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,iBAAiB,GACzB,iBAAiB,GACjB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,0BAA0B,GAC1B,eAAe,GACf,eAAe,GACf,0BAA0B,GAC1B,qBAAqB,GACrB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,gBAAgB,GAChB,2BAA2B,GAC3B,gBAAgB,GAChB,sBAAsB,GACtB,uBAAuB,GACvB,gBAAgB,GAChB,eAAe,CAAC;AAEpB;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC;;;OAGG;gBACS,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM;CAKrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/baseline/errors.ts"],"names":[],"mappings":";;;AAiCA;;;;GAIG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,4BAA4B;IACnB,IAAI,CAAoB;IAEjC;;;OAGG;IACH,YAAY,IAAuB,EAAE,OAAe;QAClD,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAbD,sCAaC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/baseline/errors.ts"],"names":[],"mappings":";;;AAyCA;;;;GAIG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,4BAA4B;IACnB,IAAI,CAAoB;IAEjC;;;OAGG;IACH,YAAY,IAAuB,EAAE,OAAe;QAClD,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAbD,sCAaC"}
@@ -1,4 +1,4 @@
1
- import type { RawIndexProblem } from '../drift/index.js';
1
+ import type { RawIndexProblem, RlsProblem } from '../drift/index.js';
2
2
  import type { BaselineErrorCode } from './errors.js';
3
3
  import type { MatchedMigration } from './mapping.js';
4
4
  /**
@@ -91,6 +91,8 @@ export interface BaselineReport {
91
91
  diff: BaselineDiff;
92
92
  /** Raw-SQL indexes that are missing or whose definition differs (step B4). */
93
93
  indexProblems: RawIndexProblem[];
94
+ /** Row-level-security policies that are missing, unlisted or not forced (step B4). */
95
+ policyProblems: RlsProblem[];
94
96
  /** The `_prisma_migrations` ledger: whether Prisma manages the database, and the problems found. */
95
97
  ledger: BaselineLedgerState;
96
98
  /** Everything that blocks `--apply`; empty when the baseline can proceed. */
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/baseline/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,iIAAiI;IACjI,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,uGAAuG;IACvG,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,gFAAgF;IAChF,EAAE,EAAE,OAAO,CAAC;IACZ,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,W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YAAY,CAAC;IACnB,8EAA8E;IAC9E,aAAa,EAAE,eAAe,EAAE,CAAC;IACjC,sFAAsF;IACtF,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,oGAAoG;IACpG,MAAM,EAAE,mBAAmB,CAAC;IAC5B,6EAA6E;IAC7E,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,kCAAkC;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,yDAAyD;IACzD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oDAAoD;IACpD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,iFAAiF;IACjF,YAAY,EAAE,OAAO,CAAC;IACtB,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CAmD7D"}
@@ -47,6 +47,10 @@ function renderReport(report) {
47
47
  for (const p of report.indexProblems)
48
48
  lines.push(` ${p.code} ${p.message}`);
49
49
  lines.push('');
50
+ lines.push(`B4 row-level security: ${report.policyProblems.length} problem(s)`);
51
+ for (const p of report.policyProblems)
52
+ lines.push(` ${p.code} ${p.message}`);
53
+ lines.push('');
50
54
  lines.push(`B5 act: ${report.toResolve.length} to resolve, ${report.toInstall.length} to install only`);
51
55
  for (const r of report.toResolve)
52
56
  lines.push(` ${report.applied ? 'resolved' : 'would resolve'} --applied ${r.localDir}${r.install ? ' (installed first)' : ''} <- ${r.originId}`);
@@ -1 +1 @@
1
- {"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/baseline/report.ts"],"names":[],"mappings":";;AA2HA,0CAEC;AASD,oCAgDC;AAlED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,MAAsB;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC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