@prisma-next/target-postgres 0.14.0-dev.5 → 0.14.0-dev.50

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 (238) hide show
  1. package/dist/authoring-DzHOdWTl.mjs +364 -0
  2. package/dist/authoring-DzHOdWTl.mjs.map +1 -0
  3. package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
  4. package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
  5. package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
  6. package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
  7. package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
  8. package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
  9. package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
  10. package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
  11. package/dist/codec-ids.d.mts +2 -2
  12. package/dist/codec-ids.mjs +2 -2
  13. package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BDVmvKAW.d.mts} +3 -2
  14. package/dist/codec-types-BDVmvKAW.d.mts.map +1 -0
  15. package/dist/codec-types.d.mts +1 -1
  16. package/dist/{codecs--0A5_4Bq.d.mts → codecs-Dk2sxGLv.d.mts} +77 -4
  17. package/dist/codecs-Dk2sxGLv.d.mts.map +1 -0
  18. package/dist/codecs.d.mts +1 -1
  19. package/dist/codecs.mjs +117 -2
  20. package/dist/codecs.mjs.map +1 -1
  21. package/dist/contract-free.d.mts +8 -3
  22. package/dist/contract-free.d.mts.map +1 -1
  23. package/dist/contract-free.mjs +4 -4
  24. package/dist/control-policy-DUFgy9jO.mjs +1103 -0
  25. package/dist/control-policy-DUFgy9jO.mjs.map +1 -0
  26. package/dist/control.d.mts +2 -2
  27. package/dist/control.d.mts.map +1 -1
  28. package/dist/control.mjs +757 -35
  29. package/dist/control.mjs.map +1 -1
  30. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  31. package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
  32. package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
  33. package/dist/data-transform.d.mts +1 -1
  34. package/dist/{ddl-QDyOSeLc.mjs → ddl-ujxH2A7r.mjs} +63 -6
  35. package/dist/ddl-ujxH2A7r.mjs.map +1 -0
  36. package/dist/ddl.d.mts +3 -2
  37. package/dist/ddl.mjs +2 -2
  38. package/dist/default-normalizer.d.mts +1 -1
  39. package/dist/default-normalizer.d.mts.map +1 -1
  40. package/dist/default-normalizer.mjs +247 -1
  41. package/dist/default-normalizer.mjs.map +1 -0
  42. package/dist/descriptor-meta-CuGDsrG4.mjs +19 -0
  43. package/dist/descriptor-meta-CuGDsrG4.mjs.map +1 -0
  44. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
  45. package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
  46. package/dist/diff-database-schema-BmSmWcaY.mjs +313 -0
  47. package/dist/diff-database-schema-BmSmWcaY.mjs.map +1 -0
  48. package/dist/diff-database-schema.d.mts +46 -0
  49. package/dist/diff-database-schema.d.mts.map +1 -0
  50. package/dist/diff-database-schema.mjs +2 -0
  51. package/dist/issue-planner.d.mts +35 -11
  52. package/dist/issue-planner.d.mts.map +1 -1
  53. package/dist/issue-planner.mjs +2 -2
  54. package/dist/migration.d.mts +5 -5
  55. package/dist/migration.d.mts.map +1 -1
  56. package/dist/migration.mjs +4 -4
  57. package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
  58. package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
  59. package/dist/native-type-normalizer.mjs +37 -1
  60. package/dist/native-type-normalizer.mjs.map +1 -0
  61. package/dist/nodes-CSkPX3rI.d.mts +120 -0
  62. package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
  63. package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
  64. package/dist/nodes-Dh__NS58.mjs.map +1 -0
  65. package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-BKRnMgrB.mjs} +205 -31
  66. package/dist/op-factory-call-BKRnMgrB.mjs.map +1 -0
  67. package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-Dt-Jx5JS.d.mts} +46 -15
  68. package/dist/op-factory-call-Dt-Jx5JS.d.mts.map +1 -0
  69. package/dist/op-factory-call.d.mts +2 -2
  70. package/dist/op-factory-call.mjs +2 -2
  71. package/dist/pack.d.mts +115 -3
  72. package/dist/pack.d.mts.map +1 -1
  73. package/dist/pack.mjs +1 -1
  74. package/dist/planner-BMBRPzsv.mjs +367 -0
  75. package/dist/planner-BMBRPzsv.mjs.map +1 -0
  76. package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
  77. package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
  78. package/dist/planner-ddl-builders.d.mts +4 -6
  79. package/dist/planner-ddl-builders.d.mts.map +1 -1
  80. package/dist/planner-ddl-builders.mjs +2 -2
  81. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
  82. package/dist/planner-identity-values.d.mts +8 -2
  83. package/dist/planner-identity-values.d.mts.map +1 -1
  84. package/dist/planner-identity-values.mjs +2 -2
  85. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-C0a7I1-e.d.mts} +4 -4
  86. package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-C0a7I1-e.d.mts.map} +1 -1
  87. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-Dp6IO_gj.mjs} +3 -3
  88. package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-Dp6IO_gj.mjs.map} +1 -1
  89. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  90. package/dist/planner-produced-postgres-migration.mjs +1 -1
  91. package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-Cze3vMfe.mjs} +2 -2
  92. package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-Cze3vMfe.mjs.map} +1 -1
  93. package/dist/planner-sql-checks.d.mts +2 -2
  94. package/dist/planner-sql-checks.d.mts.map +1 -1
  95. package/dist/planner-sql-checks.mjs +1 -1
  96. package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
  97. package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
  98. package/dist/planner-target-details.d.mts +1 -1
  99. package/dist/planner.d.mts +55 -17
  100. package/dist/planner.d.mts.map +1 -1
  101. package/dist/planner.mjs +3 -2
  102. package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-3xfUgjnC.mjs} +44 -41
  103. package/dist/postgres-contract-view-3xfUgjnC.mjs.map +1 -0
  104. package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
  105. package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
  106. package/dist/postgres-database-schema-node-C9bTuMrd.d.mts +190 -0
  107. package/dist/postgres-database-schema-node-C9bTuMrd.d.mts.map +1 -0
  108. package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-D0jwzYDT.mjs} +21 -2
  109. package/dist/postgres-migration-D0jwzYDT.mjs.map +1 -0
  110. package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DFaxuRyI.d.mts} +20 -7
  111. package/dist/postgres-migration-DFaxuRyI.d.mts.map +1 -0
  112. package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
  113. package/dist/postgres-native-enum-xdiqmBf_.mjs.map +1 -0
  114. package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
  115. package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
  116. package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-CajYAwny.mjs} +135 -7
  117. package/dist/postgres-schema-CajYAwny.mjs.map +1 -0
  118. package/dist/postgres-schema-DqnhQRvR.d.mts +226 -0
  119. package/dist/postgres-schema-DqnhQRvR.d.mts.map +1 -0
  120. package/dist/postgres-table-schema-node-BgaSrxYN.mjs +249 -0
  121. package/dist/postgres-table-schema-node-BgaSrxYN.mjs.map +1 -0
  122. package/dist/render-ops.d.mts +1 -1
  123. package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
  124. package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
  125. package/dist/render-typescript.mjs +1 -1
  126. package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs +22 -0
  127. package/dist/resolve-ddl-schema-Bv1ZvjX8.mjs.map +1 -0
  128. package/dist/rls-canonicalize.d.mts +2 -0
  129. package/dist/rls-canonicalize.mjs +2 -0
  130. package/dist/runtime.d.mts +6 -8
  131. package/dist/runtime.d.mts.map +1 -1
  132. package/dist/runtime.mjs +3 -3
  133. package/dist/runtime.mjs.map +1 -1
  134. package/dist/schema-ir-annotations.d.mts +15 -0
  135. package/dist/schema-ir-annotations.d.mts.map +1 -0
  136. package/dist/schema-ir-annotations.mjs +2 -0
  137. package/dist/schema-node-kinds-ClScchhi.mjs +76 -0
  138. package/dist/schema-node-kinds-ClScchhi.mjs.map +1 -0
  139. package/dist/types.d.mts +4 -140
  140. package/dist/types.mjs +3 -2
  141. package/package.json +23 -17
  142. package/src/contract-free/checks.ts +73 -0
  143. package/src/contract-free/ddl.ts +45 -1
  144. package/src/core/authoring.ts +287 -2
  145. package/src/core/codec-ids.ts +1 -0
  146. package/src/core/codec-type-map.ts +2 -0
  147. package/src/core/codecs.ts +141 -1
  148. package/src/core/ddl/nodes.ts +94 -2
  149. package/src/core/default-normalizer.ts +122 -2
  150. package/src/core/descriptor-meta.ts +6 -1
  151. package/src/core/entity-kinds.ts +30 -0
  152. package/src/core/migrations/bound-schema.ts +10 -0
  153. package/src/core/migrations/column-ddl-rendering.ts +117 -0
  154. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +149 -0
  155. package/src/core/migrations/control-policy.ts +70 -47
  156. package/src/core/migrations/diff-database-schema.ts +280 -0
  157. package/src/core/migrations/issue-planner.ts +647 -652
  158. package/src/core/migrations/op-factory-call.ts +109 -21
  159. package/src/core/migrations/operations/columns.ts +24 -12
  160. package/src/core/migrations/operations/constraints.ts +1 -1
  161. package/src/core/migrations/operations/data-transform.ts +6 -0
  162. package/src/core/migrations/operations/dependencies.ts +2 -1
  163. package/src/core/migrations/operations/rls.ts +106 -0
  164. package/src/core/migrations/operations/shared.ts +0 -30
  165. package/src/core/migrations/planner-ddl-builders.ts +20 -58
  166. package/src/core/migrations/planner-identity-values.ts +1 -1
  167. package/src/core/migrations/planner-recipes.ts +31 -13
  168. package/src/core/migrations/planner-sql-checks.ts +1 -1
  169. package/src/core/migrations/planner-strategies.ts +248 -216
  170. package/src/core/migrations/planner-target-details.ts +3 -1
  171. package/src/core/migrations/planner.ts +297 -59
  172. package/src/core/migrations/postgres-migration.ts +34 -4
  173. package/src/core/migrations/render-typescript.ts +42 -15
  174. package/src/core/migrations/resolve-ddl-schema.ts +26 -0
  175. package/src/core/migrations/runner.ts +10 -16
  176. package/src/core/migrations/verify-postgres-namespaces.ts +47 -30
  177. package/src/core/namespace-ids.ts +3 -0
  178. package/src/core/postgres-contract-serializer.ts +41 -71
  179. package/src/core/postgres-contract-view.ts +48 -0
  180. package/src/core/postgres-native-enum.ts +51 -0
  181. package/src/core/postgres-rls-policy.ts +64 -0
  182. package/src/core/postgres-role.ts +37 -0
  183. package/src/core/postgres-schema-verifier.ts +10 -7
  184. package/src/core/postgres-schema.ts +62 -14
  185. package/src/core/postgres-validators.ts +27 -0
  186. package/src/core/psl-infer/infer-psl-contract.ts +1068 -0
  187. package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
  188. package/src/core/psl-infer/postgres-type-map.ts +157 -0
  189. package/src/core/rls/canonicalize.ts +48 -0
  190. package/src/core/schema-ir/postgres-database-schema-node.ts +60 -0
  191. package/src/core/schema-ir/postgres-namespace-schema-node.ts +60 -0
  192. package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
  193. package/src/core/schema-ir/postgres-role-schema-node.ts +63 -0
  194. package/src/core/schema-ir/postgres-table-schema-node.ts +118 -0
  195. package/src/core/schema-ir/schema-node-kinds.ts +106 -0
  196. package/src/exports/contract-free.ts +7 -1
  197. package/src/exports/control.ts +27 -33
  198. package/src/exports/ddl.ts +4 -0
  199. package/src/exports/diff-database-schema.ts +7 -0
  200. package/src/exports/issue-planner.ts +1 -1
  201. package/src/exports/migration.ts +1 -0
  202. package/src/exports/op-factory-call.ts +1 -0
  203. package/src/exports/planner-ddl-builders.ts +0 -2
  204. package/src/exports/planner-identity-values.ts +4 -1
  205. package/src/exports/planner.ts +1 -0
  206. package/src/exports/rls-canonicalize.ts +6 -0
  207. package/src/exports/runtime.ts +1 -0
  208. package/src/exports/schema-ir-annotations.ts +1 -0
  209. package/src/exports/types.ts +28 -0
  210. package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
  211. package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
  212. package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
  213. package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
  214. package/dist/ddl-QDyOSeLc.mjs.map +0 -1
  215. package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
  216. package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
  217. package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
  218. package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
  219. package/dist/issue-planner-DL6g3CmE.mjs +0 -824
  220. package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
  221. package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
  222. package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
  223. package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
  224. package/dist/nodes-pLeLgdis.d.mts +0 -67
  225. package/dist/nodes-pLeLgdis.d.mts.map +0 -1
  226. package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
  227. package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
  228. package/dist/planner-Bs_baQax.mjs +0 -324
  229. package/dist/planner-Bs_baQax.mjs.map +0 -1
  230. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
  231. package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
  232. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
  233. package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
  234. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
  235. package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
  236. package/dist/render-typescript-KMgosran.mjs.map +0 -1
  237. package/dist/types.d.mts.map +0 -1
  238. package/src/core/postgres-enum-type-schema.ts +0 -17
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-database-schema-BmSmWcaY.mjs","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/diff-database-schema.ts"],"sourcesContent":["import type { ContractToSchemaIROptions } from '@prisma-next/family-sql/control';\nimport { contractNamespaceToSchemaIR } from '@prisma-next/family-sql/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { SqlForeignKeyIR } from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresRlsPolicy } from '../postgres-rls-policy';\nimport type { PostgresContract } from '../postgres-schema';\nimport { isPostgresSchema } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport { PostgresPolicySchemaNode } from '../schema-ir/postgres-policy-schema-node';\nimport { PostgresRoleSchemaNode } from '../schema-ir/postgres-role-schema-node';\nimport { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';\nimport { resolveDdlSchemaForNamespaceStorage } from './resolve-ddl-schema';\n\nfunction toPolicyNode(policy: PostgresRlsPolicy, namespaceId: string): PostgresPolicySchemaNode {\n return new PostgresPolicySchemaNode({\n name: policy.name,\n prefix: policy.prefix,\n tableName: policy.tableName,\n namespaceId,\n operation: policy.operation,\n roles: [...policy.roles],\n ...ifDefined('using', policy.using),\n ...ifDefined('withCheck', policy.withCheck),\n permissive: policy.permissive,\n });\n}\n\n/**\n * Projects a Postgres contract into the expected schema-diff tree: a\n * `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n * per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n * their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n *\n * Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n * single `{ tables }` map (and throws on cross-namespace name collisions, with\n * no RLS/role concept) for SQLite's single-schema world. This is the\n * Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n * It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n * for column/FK/index building and only adds the Postgres tree/policy/role shape.\n *\n * Tables are grouped by their owning namespace (resolved DDL schema name) so\n * the tree mirrors Postgres's object hierarchy. The DDL schema name is\n * resolved once per namespace.\n *\n * A policy that references a table absent from its namespace is a malformed\n * contract — the loop throws rather than fabricating a stub table.\n */\nexport function contractToPostgresDatabaseSchemaNode(\n contract: PostgresContract | null,\n options: ContractToSchemaIROptions,\n): PostgresDatabaseSchemaNode {\n if (contract === null) {\n return new PostgresDatabaseSchemaNode({\n namespaces: {},\n roles: [],\n existingSchemas: [],\n pgVersion: '',\n });\n }\n\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = {};\n const roles: PostgresRoleSchemaNode[] = [];\n const ownedSchemas: string[] = [];\n\n for (const ns of Object.values(contract.storage.namespaces)) {\n if (!isPostgresSchema(ns)) continue;\n const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n ownedSchemas.push(ddlSchema);\n\n // Convert only THIS namespace's tables (passing the full storage for\n // type/value-set/enum resolution that spans namespaces), so the same table\n // name can exist in two schemas without colliding in a bare-keyed record.\n const sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\n const policiesByTable = new Map<string, PostgresPolicySchemaNode[]>();\n for (const policy of Object.values(ns.policy)) {\n const list = policiesByTable.get(policy.tableName) ?? [];\n list.push(toPolicyNode(policy, ddlSchema));\n policiesByTable.set(policy.tableName, list);\n }\n\n const tables: Record<string, PostgresTableSchemaNode> = {};\n for (const tableName of Object.keys(ns.table)) {\n const sqlTable = sqlTables[tableName];\n if (sqlTable === undefined) continue;\n // The family conversion stamps `referencedSchema` with the FK target's\n // namespace id verbatim, which can be the unbound sentinel. Resolve it\n // to the real live DDL schema here — introspected FKs already carry the\n // live schema, so this is what lets an expected FK pair (by diff-node\n // id) with its introspected counterpart.\n const foreignKeys = sqlTable.foreignKeys.map(\n (fk) =>\n new SqlForeignKeyIR({\n columns: fk.columns,\n referencedTable: fk.referencedTable,\n referencedColumns: fk.referencedColumns,\n ...ifDefined('referencedSchema', fk.referencedSchema),\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n ...ifDefined('annotations', fk.annotations),\n resolvedReferencedNamespace: resolveDdlSchemaForNamespaceStorage(\n contract.storage,\n fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n ),\n }),\n );\n tables[tableName] = new PostgresTableSchemaNode({\n name: sqlTable.name,\n columns: sqlTable.columns,\n foreignKeys,\n uniques: sqlTable.uniques,\n indexes: sqlTable.indexes,\n ...ifDefined('primaryKey', sqlTable.primaryKey),\n ...ifDefined('annotations', sqlTable.annotations),\n ...ifDefined('checks', sqlTable.checks),\n policies: policiesByTable.get(tableName) ?? [],\n });\n }\n\n for (const [tableName, tablePolicies] of policiesByTable) {\n if (!(tableName in tables)) {\n const policyName = tablePolicies[0]?.name ?? '(unknown)';\n throw new Error(\n `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`,\n );\n }\n }\n\n namespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n schemaName: ddlSchema,\n tables,\n nativeEnumTypeNames: [],\n });\n\n for (const role of Object.values(ns.role)) {\n roles.push(new PostgresRoleSchemaNode({ name: role.name, namespaceId: role.namespaceId }));\n }\n }\n\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles,\n existingSchemas: ownedSchemas,\n pgVersion: '',\n });\n}\n","import type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { SqlSchemaDiffResult } from '@prisma-next/family-sql/control';\nimport { buildNativeTypeExpander } from '@prisma-next/family-sql/control';\nimport {\n classifyDiffSubjectGranularity,\n resolveSemanticSatisfaction,\n} from '@prisma-next/family-sql/diff';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { diffSchemas } from '@prisma-next/framework-components/control';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresContract } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';\nimport {\n postgresDiffSubjectGranularity,\n type SqlSchemaDiffNode,\n} from '../schema-ir/schema-node-kinds';\nimport { contractToPostgresDatabaseSchemaNode } from './contract-to-postgres-database-schema-node';\nimport { resolvePostgresNodeIssueControlPolicySubject } from './control-policy';\n\nfunction ownedSchemaNames(expected: PostgresDatabaseSchemaNode): ReadonlySet<string> {\n const policyNamespaces = Object.values(expected.namespaces).flatMap((ns) =>\n Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)),\n );\n return new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n\n/**\n * Applies the family's semantic-satisfaction normalization across a Postgres\n * tree pair: every actual table with an expected counterpart (paired by\n * namespace id, then table id) gets its unique/index child lists adjusted;\n * everything else passes through untouched.\n */\nexport function normalizePostgresActualForDiff(\n expected: PostgresDatabaseSchemaNode,\n actual: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = {};\n for (const [nsId, actualNs] of Object.entries(actual.namespaces)) {\n const expectedNs = expected.namespaces[nsId];\n if (expectedNs === undefined) {\n namespaces[nsId] = actualNs;\n continue;\n }\n const tables: Record<string, PostgresTableSchemaNode> = {};\n for (const [tableName, actualTable] of Object.entries(actualNs.tables)) {\n const expectedTable = expectedNs.tables[tableName];\n if (expectedTable === undefined) {\n tables[tableName] = actualTable;\n continue;\n }\n const adjusted = resolveSemanticSatisfaction({\n expectedUniques: expectedTable.uniques,\n expectedIndexes: expectedTable.indexes,\n actualUniques: actualTable.uniques,\n actualIndexes: actualTable.indexes,\n });\n tables[tableName] = new PostgresTableSchemaNode({\n name: actualTable.name,\n columns: actualTable.columns,\n foreignKeys: actualTable.foreignKeys,\n uniques: adjusted.actualUniques,\n indexes: adjusted.actualIndexes,\n ...ifDefined('primaryKey', actualTable.primaryKey),\n ...ifDefined('annotations', actualTable.annotations),\n ...ifDefined('checks', actualTable.checks),\n policies: [...actualTable.policies],\n });\n }\n namespaces[nsId] = new PostgresNamespaceSchemaNode({\n schemaName: actualNs.schemaName,\n tables,\n nativeEnumTypeNames: actualNs.nativeEnumTypeNames,\n });\n }\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...actual.roles],\n existingSchemas: [...actual.existingSchemas],\n pgVersion: actual.pgVersion,\n });\n}\n\n/**\n * Drops contract namespaces that declare no tables from the verdict-diff\n * expected tree and the relational owned-schema set. The legacy relational\n * walk skipped a table-less namespace (e.g. an enums-only schema) before\n * pairing, so neither its DDL schema's absence nor that schema's live\n * relational contents ever reached the verdict — the pruned tree\n * reproduces that. The prune loses no expected policies: policies attach\n * to tables, so a table-less namespace carries none (the projection\n * throws on a policy referencing an absent table). Live policies in a\n * pruned schema remain governed via the full owned set (see\n * {@link diffPostgresSchema}).\n */\nfunction pruneTableLessNamespaces(\n expected: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces = Object.fromEntries(\n Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0),\n );\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...expected.roles],\n existingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== undefined),\n pgVersion: expected.pgVersion,\n });\n}\n\n/**\n * Resolves a verdict-diff issue's subject table's declared control policy\n * directly from the contract, by delegating to the same node-typed resolver\n * ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n * gate DDL calls. `undefined` when the issue resolves to no contract table.\n */\nfunction resolveControlPolicy(\n issue: SchemaDiffIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicy | undefined {\n const nodeIssue = blindCast<\n SchemaDiffIssue<SqlSchemaDiffNode>,\n 'every node in a Postgres schema diff tree is a SqlSchemaDiffNode'\n >(issue);\n return resolvePostgresNodeIssueControlPolicySubject(nodeIssue, contract)\n ?.explicitNodeControlPolicy;\n}\n\n/**\n * The Postgres full-tree node diff for the family verify verdict: derive\n * the expected tree (resolved leaf values, expander threaded, FK schemas\n * resolved, table-less namespaces pruned), normalize the actual tree for\n * semantic satisfaction, run the generic\n * differ, and scope out `not-expected` findings under namespaces the\n * contract does not own. Ownership is role-aware, mirroring the legacy\n * decomposition: relational extras check the PRUNED owned set (the legacy\n * per-namespace walk never visited a table-less namespace, so its live\n * relational contents are invisible), while `structural` extras (RLS\n * policies) check the FULL owned set (the legacy policy diff governed\n * every contract schema regardless of tables — RLS governance does not\n * shrink because a namespace declares no tables). The codec `verifyType`\n * hooks run once per contract namespace with tables against that\n * namespace's paired actual node (the hooks read namespace-scoped state\n * such as `nativeEnumTypeNames`).\n */\nexport function diffPostgresSchema(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): SqlSchemaDiffResult {\n const postgresContract = blindCast<\n PostgresContract,\n 'diffPostgresSchema is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.schema);\n const actual = input.schema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n });\n const expected = pruneTableLessNamespaces(fullExpected);\n const normalizedActual = normalizePostgresActualForDiff(expected, actual);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = diffSchemas(expected, normalizedActual).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n const namespacePairs = Object.values(expected.namespaces).map((ns) => ({\n actual: actual.namespaces[ns.schemaName],\n }));\n return {\n issues,\n resolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n namespacePairs,\n };\n}\n\n/**\n * Adds an empty namespace node to the actual tree for every expected namespace\n * absent from it. The relational plan diff pairs on namespace: a contract\n * namespace whose live schema does not exist yet must surface each of its\n * tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n * `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n * with no tables). Padding makes the namespaces pair, so only table/column/\n * policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n * namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n * tree diff — matching the retired per-namespace-paired relational walk, which\n * paired a missing schema against an empty namespace node.\n */\nfunction padActualNamespaces(\n expected: PostgresDatabaseSchemaNode,\n actual: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = { ...actual.namespaces };\n let padded = false;\n for (const schemaName of Object.keys(expected.namespaces)) {\n if (namespaces[schemaName] === undefined) {\n namespaces[schemaName] = new PostgresNamespaceSchemaNode({\n schemaName,\n tables: {},\n nativeEnumTypeNames: [],\n });\n padded = true;\n }\n }\n if (!padded) return actual;\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...actual.roles],\n existingSchemas: [...actual.existingSchemas],\n pgVersion: actual.pgVersion,\n });\n}\n\nexport interface PostgresPlanDiff {\n /** The desired (\"end\") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */\n readonly expected: PostgresDatabaseSchemaNode;\n /** The live (\"start\") tree, padded with empty namespaces and normalized for semantic satisfaction against `expected`. */\n readonly actual: PostgresDatabaseSchemaNode;\n /** The one node diff over the two trees: relational + policy drift, role-aware ownership filtered. */\n readonly issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[];\n}\n\n/**\n * The Postgres planner's diff input: the SAME tree-building\n * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n * table-less namespaces pruned, actual normalized for semantic satisfaction,\n * role-aware ownership filter) plus actual namespace padding (so a missing\n * schema's tables surface as `not-found` instead of a swallowed namespace\n * `not-found`). One differ drives both verify and plan; this is the\n * plan-side derivation. The single issue list covers tables / columns /\n * constraints / indexes / defaults AND policies — the caller splits it\n * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n * `CREATE SCHEMA` separately.\n */\nexport function buildPostgresPlanDiff(input: {\n readonly contract: Contract<SqlStorage>;\n readonly actualSchema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): PostgresPlanDiff {\n const postgresContract = blindCast<\n PostgresContract,\n 'buildPostgresPlanDiff is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.actualSchema);\n const actual = input.actualSchema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const projectionOptions = {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n };\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, projectionOptions);\n const expected = pruneTableLessNamespaces(fullExpected);\n const paddedActual = padActualNamespaces(expected, actual);\n const normalizedActual = normalizePostgresActualForDiff(expected, paddedActual);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = blindCast<\n readonly SchemaDiffIssue<SqlSchemaDiffNode>[],\n 'both trees are PostgresDatabaseSchemaNodes, so every diff-issue node is a SqlSchemaDiffNode'\n >(diffSchemas(expected, normalizedActual)).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n return { expected, actual: normalizedActual, issues };\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAS,aAAa,QAA2B,aAA+C;CAC9F,OAAO,IAAI,yBAAyB;EAClC,MAAM,OAAO;EACb,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,GAAG,UAAU,SAAS,OAAO,KAAK;EAClC,GAAG,UAAU,aAAa,OAAO,SAAS;EAC1C,YAAY,OAAO;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qCACd,UACA,SAC4B;CAC5B,IAAI,aAAa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ACpC;EACA,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,iBAAiB,CAAC,GAAG,OAAO,eAAe;EAC3C,WAAW,OAAO;CACpB,CAAC;AACH;;;;;;;;;;;;;AAuBA,SAAgB,sBAAsB,OAIjB;CACnB,MAAM,mBAAmB,UAGvB,MAAM,QAAQ;CAChB,2BAA2B,OAAO,MAAM,YAAY;CACpD,MAAM,SAAS,MAAM;CAMrB,MAAM,eAAe,qCAAqC,kBAAkB;EAH1E,qBAAqB;EACrB,GAAG,UAAU,oBAHU,wBAAwB,MAAM,mBAGL,CAAC;CAEyC,CAAC;CAC7F,MAAM,WAAW,yBAAyB,YAAY;CAEtD,MAAM,mBAAmB,+BAA+B,UADnC,oBAAoB,UAAU,MAC0B,CAAC;CAC9E,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CAYrD,OAAO;EAAE;EAAU,QAAQ;EAAkB,QAX9B,UAGb,YAAY,UAAU,gBAAgB,CAAC,CAAC,CAAC,QAAQ,UAAU;GAC3D,IAAI,MAAM,WAAW,gBAAgB,OAAO;GAC5C,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAA,GAAW,OAAO;GAG3C,QAFoB,+BAA+B,OAAO,8BAClC,MAAM,eAAe,kBAAkB,gBAAA,CAClD,IAAI,gBAAgB;EACnC,CACkD;CAAE;AACtD"}
@@ -0,0 +1,46 @@
1
+ import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-C9bTuMrd.mjs";
2
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
3
+ import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
4
+ import { DiffableNode, SchemaDiffIssue } from "@prisma-next/framework-components/control";
5
+ import { Contract } from "@prisma-next/contract/types";
6
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
7
+
8
+ //#region src/core/schema-ir/schema-node-kinds.d.ts
9
+ /**
10
+ * A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements
11
+ * `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`
12
+ * alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)
13
+ * carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node
14
+ * type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).
15
+ */
16
+ type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;
17
+ //#endregion
18
+ //#region src/core/migrations/diff-database-schema.d.ts
19
+ interface PostgresPlanDiff {
20
+ /** The desired ("end") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */
21
+ readonly expected: PostgresDatabaseSchemaNode;
22
+ /** The live ("start") tree, padded with empty namespaces and normalized for semantic satisfaction against `expected`. */
23
+ readonly actual: PostgresDatabaseSchemaNode;
24
+ /** The one node diff over the two trees: relational + policy drift, role-aware ownership filtered. */
25
+ readonly issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[];
26
+ }
27
+ /**
28
+ * The Postgres planner's diff input: the SAME tree-building
29
+ * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,
30
+ * table-less namespaces pruned, actual normalized for semantic satisfaction,
31
+ * role-aware ownership filter) plus actual namespace padding (so a missing
32
+ * schema's tables surface as `not-found` instead of a swallowed namespace
33
+ * `not-found`). One differ drives both verify and plan; this is the
34
+ * plan-side derivation. The single issue list covers tables / columns /
35
+ * constraints / indexes / defaults AND policies — the caller splits it
36
+ * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in
37
+ * `CREATE SCHEMA` separately.
38
+ */
39
+ declare function buildPostgresPlanDiff(input: {
40
+ readonly contract: Contract<SqlStorage>;
41
+ readonly actualSchema: SqlSchemaIRNode;
42
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
43
+ }): PostgresPlanDiff;
44
+ //#endregion
45
+ export { buildPostgresPlanDiff };
46
+ //# sourceMappingURL=diff-database-schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-database-schema.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/migrations/diff-database-schema.ts"],"mappings":";;;;;;;;;;;;;;;KAiBY,iBAAA,GAAoB,eAAA,GAAkB,YAAY;;;UC+M7C,gBAAA;EAsBa;EAAA,SApBnB,QAAA,EAAU,0BAAA;EAqBI;EAAA,SAnBd,MAAA,EAAQ,0BAAA;EAoBa;EAAA,SAlBrB,MAAA,WAAiB,eAAA,CAAgB,iBAAA;AAAA;;;;;;;;;;;;;iBAe5B,qBAAA,CAAsB,KAAA;EAAA,SAC3B,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,YAAA,EAAc,eAAA;EAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA,IAC1C,gBAAA"}
@@ -0,0 +1,2 @@
1
+ import { t as buildPostgresPlanDiff } from "./diff-database-schema-BmSmWcaY.mjs";
2
+ export { buildPostgresPlanDiff };
@@ -1,11 +1,11 @@
1
- import { b as PostgresOpFactoryCall } from "./op-factory-call-DmQEc3XV.mjs";
1
+ import { x as PostgresOpFactoryCall } from "./op-factory-call-Dt-Jx5JS.mjs";
2
+ import { SqlStorage, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
2
3
  import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma-next/family-sql/control";
4
+ import { SqlColumnIR, SqlSchemaIR, SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
5
+ import { DiffableNode, SchemaDiffIssue } from "@prisma-next/framework-components/control";
3
6
  import { Result } from "@prisma-next/utils/result";
4
- import { SqlStorage, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
5
- import { SchemaIssue } from "@prisma-next/framework-components/control";
6
7
  import { Contract } from "@prisma-next/contract/types";
7
8
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
8
- import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
9
9
 
10
10
  //#region src/core/migrations/planner-strategies.d.ts
11
11
  /**
@@ -27,9 +27,16 @@ interface StrategyContext {
27
27
  readonly policy: MigrationOperationPolicy;
28
28
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
29
29
  }
30
- type CallMigrationStrategy = (issues: readonly SchemaIssue[], context: StrategyContext) => {
30
+ /**
31
+ * Consumes node-typed diff issues (`SchemaDiffIssue`, from the one differ —
32
+ * `buildPostgresPlanDiff`), reading the issue's node pair for structural
33
+ * decisions and resolving column DDL from the node's `codecRef`. The
34
+ * retained subsystems (codec type-operations, the NOT-NULL temp-default
35
+ * backfill) keep reading the contract via `StrategyContext`.
36
+ */
37
+ type CallMigrationStrategy = (issues: readonly SchemaDiffIssue[], context: StrategyContext) => {
31
38
  kind: 'match';
32
- issues: readonly SchemaIssue[];
39
+ issues: readonly SchemaDiffIssue[];
33
40
  calls: readonly PostgresOpFactoryCall[];
34
41
  /**
35
42
  * `true` for strategies that emit cohesive sequential recipes whose
@@ -44,8 +51,21 @@ type CallMigrationStrategy = (issues: readonly SchemaIssue[], context: StrategyC
44
51
  };
45
52
  //#endregion
46
53
  //#region src/core/migrations/issue-planner.d.ts
54
+ interface IssuePlannerValue {
55
+ readonly calls: readonly PostgresOpFactoryCall[];
56
+ }
57
+ /**
58
+ * The generic differ is total: a missing/extra table (or column) emits an
59
+ * issue for itself AND for every node in its subtree. `CreateTable`/`DropTable`
60
+ * and `AddColumn`/`DropColumn` already account for the whole subtree, so the
61
+ * nested issues are redundant — coalescing drops any issue whose path is a
62
+ * strict descendant of a `not-found`/`not-expected` issue's path. Run over the
63
+ * relational subset ONLY (policy issues and synthesized namespace issues are
64
+ * handled on their own paths, never coalesced against tables).
65
+ */
66
+ declare function coalesceSubtreeIssues<TNode extends DiffableNode = DiffableNode>(issues: readonly SchemaDiffIssue<TNode>[]): readonly SchemaDiffIssue<TNode>[];
47
67
  interface IssuePlannerOptions {
48
- readonly issues: readonly SchemaIssue[];
68
+ readonly issues: readonly SchemaDiffIssue[];
49
69
  readonly toContract: Contract<SqlStorage>;
50
70
  readonly fromContract: Contract<SqlStorage> | null;
51
71
  readonly schemaName: string;
@@ -72,10 +92,14 @@ interface IssuePlannerOptions {
72
92
  readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
73
93
  readonly strategies?: readonly CallMigrationStrategy[];
74
94
  }
75
- interface IssuePlannerValue {
76
- readonly calls: readonly PostgresOpFactoryCall[];
77
- }
95
+ /**
96
+ * Runs the ordered strategy list over the node-typed diff issues, maps
97
+ * leftover issues via {@link mapNodeIssueToCall}, applies operation-class
98
+ * policy gating, and buckets calls into the fixed DDL emission order (dep →
99
+ * drop → table → column → recipe → alter → primaryKey → unique → index →
100
+ * foreignKey).
101
+ */
78
102
  declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
79
103
  //#endregion
80
- export { planIssues };
104
+ export { coalesceSubtreeIssues, planIssues };
81
105
  //# sourceMappingURL=issue-planner.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UA8HiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;AAAA,KAOlC,qBAAA,IACV,MAAA,WAAiB,WAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,WAAA;EACjB,KAAA,WAAgB,qBAAA;ECEG;;;;;;;EDMnB,MAAA;AAAA;EAEA,IAAA;AAAA;;;UCXW,mBAAA;EAAA,SACN,MAAA,WAAiB,WAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EDnBJ;;;;;;;EAAA,SC2BlC,MAAA,GAAS,WAAA;EDhCT;;;;;EAAA,SCsCA,MAAA,GAAS,wBAAA;EDpCc;;;;EAAA,SCyCvB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;AAAA,UAGhB,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;AAAA,iBA2pBhC,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
1
+ {"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UAwIiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;;ACtB9C;;;;AACgD;AAoShD;KDjQY,qBAAA,IACV,MAAA,WAAiB,eAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,eAAA;EACjB,KAAA,WAAgB,qBAAA;EC2Pa;;;;;;;EDnP7B,MAAA;AAAA;EAEA,IAAA;AAAA;;;UCrDW,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;;;;;;;;;;iBAoShC,qBAAA,eAAoC,YAAA,GAAe,YAAA,EACjE,MAAA,WAAiB,eAAA,CAAgB,KAAA,eACvB,eAAA,CAAgB,KAAA;AAAA,UAkZX,mBAAA;EAAA,SACN,MAAA,WAAiB,eAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAzZd;;;;;;;EAAA,SAiaxB,MAAA,GAAS,WAAA;EAla+C;;;;;EAAA,SAwaxD,MAAA,GAAS,wBAAA;EAtaa;AAAA;AAkZjC;;EAlZiC,SA2atB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;;;;;;;;iBAUjB,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
@@ -1,2 +1,2 @@
1
- import { t as planIssues } from "./issue-planner-DL6g3CmE.mjs";
2
- export { planIssues };
1
+ import { o as coalesceSubtreeIssues, u as planIssues } from "./control-policy-DUFgy9jO.mjs";
2
+ export { coalesceSubtreeIssues, planIssues };
@@ -1,7 +1,7 @@
1
- import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-DDgWdB5o.mjs";
2
- import { T as Op } from "./op-factory-call-DmQEc3XV.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-Y4YBJqkS.mjs";
4
- import { col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
1
+ import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-DPzwBMhW.mjs";
2
+ import { E as Op } from "./op-factory-call-Dt-Jx5JS.mjs";
3
+ import { t as PostgresMigration } from "./postgres-migration-DFaxuRyI.mjs";
4
+ import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
5
5
  import { placeholder } from "@prisma-next/errors/migration";
6
6
  import { MigrationCLI } from "@prisma-next/cli/migration-cli";
7
7
  import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
@@ -22,5 +22,5 @@ declare function createExtension(extensionName: string): Op;
22
22
  */
23
23
  declare function rawSql(op: Op): Op;
24
24
  //#endregion
25
- export { type DataTransformClosure, type DataTransformOptions, PostgresMigration as Migration, MigrationCLI, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
25
+ export { type DataTransformClosure, type DataTransformOptions, PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
26
26
  //# sourceMappingURL=migration.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/migrations/operations/dependencies.ts","../src/core/migrations/operations/raw.ts"],"mappings":";;;;;;;;;iBAKgB,eAAA,CAAgB,aAAA,WAAwB,EAAE;;;;;;;;;;;AAA1D;;iBCOgB,MAAA,CAAO,EAAA,EAAI,EAAA,GAAK,EAAE"}
1
+ {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/migrations/operations/dependencies.ts","../src/core/migrations/operations/raw.ts"],"mappings":";;;;;;;;;iBAMgB,eAAA,CAAgB,aAAA,WAAwB,EAAE;;;;;;;;;;;AAA1D;;iBCMgB,MAAA,CAAO,EAAA,EAAI,EAAA,GAAK,EAAE"}
@@ -1,7 +1,7 @@
1
- import { E as createExtension } from "./op-factory-call-D_p5vxwt.mjs";
1
+ import { k as createExtension } from "./op-factory-call-BKRnMgrB.mjs";
2
2
  import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-B5jKrXv3.mjs";
4
- import { col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
3
+ import { t as PostgresMigration } from "./postgres-migration-D0jwzYDT.mjs";
4
+ import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
5
5
  import { placeholder } from "@prisma-next/errors/migration";
6
6
  import { MigrationCLI } from "@prisma-next/cli/migration-cli";
7
7
  //#region src/core/migrations/operations/raw.ts
@@ -19,6 +19,6 @@ function rawSql(op) {
19
19
  return op;
20
20
  }
21
21
  //#endregion
22
- export { PostgresMigration as Migration, MigrationCLI, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
22
+ export { PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
23
23
 
24
24
  //# sourceMappingURL=migration.mjs.map
@@ -0,0 +1,7 @@
1
+ //#region src/core/namespace-ids.ts
2
+ /** Postgres's default schema; `postgresTargetDescriptorMeta.defaultNamespaceId` is this value. */
3
+ const DEFAULT_NAMESPACE_ID = "public";
4
+ //#endregion
5
+ export { DEFAULT_NAMESPACE_ID as t };
6
+
7
+ //# sourceMappingURL=namespace-ids-xtp_ZY86.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace-ids-xtp_ZY86.mjs","names":[],"sources":["../src/core/namespace-ids.ts"],"sourcesContent":["// Leaf module: authoring.ts and descriptor-meta.ts both need this and import each other.\n/** Postgres's default schema; `postgresTargetDescriptorMeta.defaultNamespaceId` is this value. */\nexport const DEFAULT_NAMESPACE_ID = 'public' as const;\n"],"mappings":";;AAEA,MAAa,uBAAuB"}
@@ -1,2 +1,38 @@
1
- import { t as normalizeSchemaNativeType } from "./native-type-normalizer-Bc9XJzWC.mjs";
1
+ //#region src/core/native-type-normalizer.ts
2
+ /**
3
+ * Postgres native-type normalization.
4
+ *
5
+ * Lives in `target-postgres` because both the migration planner/runner (control
6
+ * plane) and the introspection adapter (control plane) need to normalize raw
7
+ * native-type strings to the same canonical form for comparison.
8
+ */
9
+ /**
10
+ * Lookup map for simple prefix-based type normalization.
11
+ *
12
+ * Using a Map for O(1) lookup instead of multiple startsWith checks.
13
+ */
14
+ const TYPE_PREFIX_MAP = new Map([
15
+ ["varchar", "character varying"],
16
+ ["bpchar", "character"],
17
+ ["varbit", "bit varying"]
18
+ ]);
19
+ /**
20
+ * Normalizes a Postgres schema native type to its canonical form for comparison.
21
+ *
22
+ * Uses a pre-computed lookup map for simple prefix replacements (O(1))
23
+ * and handles complex temporal type normalization separately.
24
+ */
25
+ function normalizeSchemaNativeType(nativeType) {
26
+ const trimmed = nativeType.trim();
27
+ for (const [prefix, replacement] of TYPE_PREFIX_MAP) if (trimmed.startsWith(prefix)) return replacement + trimmed.slice(prefix.length);
28
+ if (trimmed.includes(" with time zone")) {
29
+ if (trimmed.startsWith("timestamp")) return `timestamptz${trimmed.slice(9).replace(" with time zone", "")}`;
30
+ if (trimmed.startsWith("time")) return `timetz${trimmed.slice(4).replace(" with time zone", "")}`;
31
+ }
32
+ if (trimmed.includes(" without time zone")) return trimmed.replace(" without time zone", "");
33
+ return trimmed;
34
+ }
35
+ //#endregion
2
36
  export { normalizeSchemaNativeType };
37
+
38
+ //# sourceMappingURL=native-type-normalizer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-type-normalizer.mjs","names":[],"sources":["../src/core/native-type-normalizer.ts"],"sourcesContent":["/**\n * Postgres native-type normalization.\n *\n * Lives in `target-postgres` because both the migration planner/runner (control\n * plane) and the introspection adapter (control plane) need to normalize raw\n * native-type strings to the same canonical form for comparison.\n */\n\n/**\n * Lookup map for simple prefix-based type normalization.\n *\n * Using a Map for O(1) lookup instead of multiple startsWith checks.\n */\nconst TYPE_PREFIX_MAP: ReadonlyMap<string, string> = new Map([\n ['varchar', 'character varying'],\n ['bpchar', 'character'],\n ['varbit', 'bit varying'],\n]);\n\n/**\n * Normalizes a Postgres schema native type to its canonical form for comparison.\n *\n * Uses a pre-computed lookup map for simple prefix replacements (O(1))\n * and handles complex temporal type normalization separately.\n */\nexport function normalizeSchemaNativeType(nativeType: string): string {\n const trimmed = nativeType.trim();\n\n for (const [prefix, replacement] of TYPE_PREFIX_MAP) {\n if (trimmed.startsWith(prefix)) {\n return replacement + trimmed.slice(prefix.length);\n }\n }\n\n if (trimmed.includes(' with time zone')) {\n if (trimmed.startsWith('timestamp')) {\n return `timestamptz${trimmed.slice(9).replace(' with time zone', '')}`;\n }\n if (trimmed.startsWith('time')) {\n return `timetz${trimmed.slice(4).replace(' with time zone', '')}`;\n }\n }\n\n if (trimmed.includes(' without time zone')) {\n return trimmed.replace(' without time zone', '');\n }\n\n return trimmed;\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,kBAA+C,IAAI,IAAI;CAC3D,CAAC,WAAW,mBAAmB;CAC/B,CAAC,UAAU,WAAW;CACtB,CAAC,UAAU,aAAa;AAC1B,CAAC;;;;;;;AAQD,SAAgB,0BAA0B,YAA4B;CACpE,MAAM,UAAU,WAAW,KAAK;CAEhC,KAAK,MAAM,CAAC,QAAQ,gBAAgB,iBAClC,IAAI,QAAQ,WAAW,MAAM,GAC3B,OAAO,cAAc,QAAQ,MAAM,OAAO,MAAM;CAIpD,IAAI,QAAQ,SAAS,iBAAiB,GAAG;EACvC,IAAI,QAAQ,WAAW,WAAW,GAChC,OAAO,cAAc,QAAQ,MAAM,CAAC,CAAC,CAAC,QAAQ,mBAAmB,EAAE;EAErE,IAAI,QAAQ,WAAW,MAAM,GAC3B,OAAO,SAAS,QAAQ,MAAM,CAAC,CAAC,CAAC,QAAQ,mBAAmB,EAAE;CAElE;CAEA,IAAI,QAAQ,SAAS,oBAAoB,GACvC,OAAO,QAAQ,QAAQ,sBAAsB,EAAE;CAGjD,OAAO;AACT"}
@@ -0,0 +1,120 @@
1
+ import { n as RlsPolicyOperation } from "./canonicalize-CAbXtVtB.mjs";
2
+ import { DdlColumn, DdlNode, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
3
+
4
+ //#region src/core/ddl/nodes.d.ts
5
+ interface AlterTableActionVisitor<R> {
6
+ addColumn(action: AddColumnAction): R;
7
+ dropDefault(action: DropDefaultAction): R;
8
+ }
9
+ declare abstract class AlterTableAction {
10
+ abstract readonly kind: string;
11
+ abstract accept<R>(visitor: AlterTableActionVisitor<R>): R;
12
+ }
13
+ declare class AddColumnAction extends AlterTableAction {
14
+ readonly kind: "add-column";
15
+ readonly column: DdlColumn;
16
+ constructor(column: DdlColumn);
17
+ accept<R>(visitor: AlterTableActionVisitor<R>): R;
18
+ }
19
+ declare class DropDefaultAction extends AlterTableAction {
20
+ readonly kind: "drop-default";
21
+ readonly columnName: string;
22
+ constructor(columnName: string);
23
+ accept<R>(visitor: AlterTableActionVisitor<R>): R;
24
+ }
25
+ /**
26
+ * The set of ALTER TABLE subactions currently expressible as typed DDL.
27
+ *
28
+ * The remaining actions — SetDefault, SetNotNull, DropNotNull,
29
+ * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`
30
+ * and join this union as they are converted to typed DDL. Until then it is
31
+ * intentionally partial: only the ALTER subactions used by the
32
+ * already-converted ops (AddColumn, DropDefault) appear here.
33
+ */
34
+ type AnyAlterTableAction = AddColumnAction | DropDefaultAction;
35
+ interface PostgresDdlVisitor<R> {
36
+ createTable(node: PostgresCreateTable): R;
37
+ createSchema(node: PostgresCreateSchema): R;
38
+ alterTable(node: PostgresAlterTable): R;
39
+ createPolicy(node: PostgresCreatePolicy): R;
40
+ dropPolicy(node: PostgresDropPolicy): R;
41
+ }
42
+ declare abstract class PostgresDdlNode extends DdlNode {
43
+ abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;
44
+ }
45
+ declare class PostgresCreateTable extends PostgresDdlNode {
46
+ readonly kind: "create-table";
47
+ readonly table: string;
48
+ readonly schema: string | undefined;
49
+ readonly ifNotExists: boolean | undefined;
50
+ readonly columns: ReadonlyArray<DdlColumn>;
51
+ readonly constraints: ReadonlyArray<DdlTableConstraint> | undefined;
52
+ constructor(options: {
53
+ readonly table: string;
54
+ readonly schema?: string;
55
+ readonly ifNotExists?: boolean;
56
+ readonly columns: readonly DdlColumn[];
57
+ readonly constraints?: readonly DdlTableConstraint[];
58
+ });
59
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
60
+ }
61
+ declare class PostgresCreateSchema extends PostgresDdlNode {
62
+ readonly kind: "create-schema";
63
+ readonly schema: string;
64
+ readonly ifNotExists: boolean | undefined;
65
+ constructor(options: {
66
+ readonly schema: string;
67
+ readonly ifNotExists?: boolean;
68
+ });
69
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
70
+ }
71
+ declare class PostgresAlterTable extends PostgresDdlNode {
72
+ readonly kind: "alter-table";
73
+ readonly table: string;
74
+ readonly schema: string | undefined;
75
+ readonly actions: ReadonlyArray<AnyAlterTableAction>;
76
+ constructor(options: {
77
+ readonly table: string;
78
+ readonly schema?: string;
79
+ readonly actions: readonly AnyAlterTableAction[];
80
+ });
81
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
82
+ }
83
+ declare class PostgresCreatePolicy extends PostgresDdlNode {
84
+ readonly kind: "create-policy";
85
+ readonly schema: string;
86
+ readonly table: string;
87
+ readonly name: string;
88
+ readonly permissive: boolean;
89
+ readonly operation: RlsPolicyOperation;
90
+ readonly roles: ReadonlyArray<string>;
91
+ readonly using: string | undefined;
92
+ readonly withCheck: string | undefined;
93
+ constructor(options: {
94
+ readonly schema: string;
95
+ readonly table: string;
96
+ readonly name: string;
97
+ readonly permissive: boolean;
98
+ readonly operation: RlsPolicyOperation;
99
+ readonly roles: readonly string[];
100
+ readonly using?: string;
101
+ readonly withCheck?: string;
102
+ });
103
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
104
+ }
105
+ declare class PostgresDropPolicy extends PostgresDdlNode {
106
+ readonly kind: "drop-policy";
107
+ readonly schema: string;
108
+ readonly table: string;
109
+ readonly name: string;
110
+ constructor(options: {
111
+ readonly schema: string;
112
+ readonly table: string;
113
+ readonly name: string;
114
+ });
115
+ accept<R>(visitor: PostgresDdlVisitor<R>): R;
116
+ }
117
+ type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema | PostgresAlterTable | PostgresCreatePolicy | PostgresDropPolicy;
118
+ //#endregion
119
+ export { DropDefaultAction as a, PostgresCreateSchema as c, PostgresDdlVisitor as d, PostgresDropPolicy as f, AnyPostgresDdlNode as i, PostgresCreateTable as l, AlterTableActionVisitor as n, PostgresAlterTable as o, AnyAlterTableAction as r, PostgresCreatePolicy as s, AddColumnAction as t, PostgresDdlNode as u };
120
+ //# sourceMappingURL=nodes-CSkPX3rI.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes-CSkPX3rI.d.mts","names":[],"sources":["../src/core/ddl/nodes.ts"],"mappings":";;;;UAWiB,uBAAA;EACf,SAAA,CAAU,MAAA,EAAQ,eAAA,GAAkB,CAAA;EACpC,WAAA,CAAY,MAAA,EAAQ,iBAAA,GAAoB,CAAA;AAAA;AAAA,uBAGpB,gBAAA;EAAA,kBACF,IAAA;EAAA,SACT,MAAA,IAAU,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,CAAA;AAAA;AAAA,cAG9C,eAAA,SAAwB,gBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,MAAA,EAAQ,SAAA;cAEL,MAAA,EAAQ,SAAA;EAMX,MAAA,IAAU,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,CAAA;AAAA;AAAA,cAK9C,iBAAA,SAA0B,gBAAA;EAAA,SAC5B,IAAA;EAAA,SACA,UAAA;cAEG,UAAA;EAMH,MAAA,IAAU,OAAA,EAAS,uBAAA,CAAwB,CAAA,IAAK,CAAA;AAAA;;AAjChB;AAG3C;;;;;;;KA4CY,mBAAA,GAAsB,eAAA,GAAkB,iBAAiB;A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BAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,cAOzC,oBAAA,SAA6B,eAAA;EAAA,SAC/B,IAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA;EAAA,SACA,SAAA,EAAW,kBAAA;EAAA,SACX,KAAA,EAAO,aAAA;EAAA,SACP,KAAA;EAAA,SACA,SAAA;cAEG,OAAA;IAAA,SACD,MAAA;IAAA,SACA,KAAA;IAAA,SACA,IAAA;IAAA,SACA,UAAA;IAAA,SACA,SAAA,EAAW,kBAAA;IAAA,SACX,KAAA;IAAA,SACA,KAAA;IAAA,SACA,SAAA;EAAA;EAcF,MAAA,IAAU,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,cAKzC,kBAAA,SAA2B,eAAA;EAAA,SAC7B,IAAA;EAAA,SACA,MAAA;EAAA,SACA,KAAA;EAAA,SACA,IAAA;cAEG,OAAA;IAAA,SAAoB,MAAA;IAAA,SAAyB,KAAA;IAAA,SAAwB,IAAA;EAAA;EAQxE,MAAA,IAAU,OAAA,EAAS,kBAAA,CAAmB,CAAA,IAAK,CAAA;AAAA;AAAA,KAK1C,kBAAA,GACR,mBAAA,GACA,oBAAA,GACA,kBAAA,GACA,oBAAA,GACA,kBAAA"}
@@ -13,6 +13,18 @@ var AddColumnAction = class extends AlterTableAction {
13
13
  return visitor.addColumn(this);
14
14
  }
15
15
  };
16
+ var DropDefaultAction = class extends AlterTableAction {
17
+ kind = "drop-default";
18
+ columnName;
19
+ constructor(columnName) {
20
+ super();
21
+ this.columnName = columnName;
22
+ Object.freeze(this);
23
+ }
24
+ accept(visitor) {
25
+ return visitor.dropDefault(this);
26
+ }
27
+ };
16
28
  var PostgresDdlNode = class extends DdlNode {};
17
29
  function freezeDdlColumns(columns) {
18
30
  return Object.freeze([...columns]);
@@ -70,7 +82,49 @@ var PostgresAlterTable = class extends PostgresDdlNode {
70
82
  return visitor.alterTable(this);
71
83
  }
72
84
  };
85
+ var PostgresCreatePolicy = class extends PostgresDdlNode {
86
+ kind = "create-policy";
87
+ schema;
88
+ table;
89
+ name;
90
+ permissive;
91
+ operation;
92
+ roles;
93
+ using;
94
+ withCheck;
95
+ constructor(options) {
96
+ super();
97
+ this.schema = options.schema;
98
+ this.table = options.table;
99
+ this.name = options.name;
100
+ this.permissive = options.permissive;
101
+ this.operation = options.operation;
102
+ this.roles = Object.freeze([...options.roles]);
103
+ this.using = options.using;
104
+ this.withCheck = options.withCheck;
105
+ this.freeze();
106
+ }
107
+ accept(visitor) {
108
+ return visitor.createPolicy(this);
109
+ }
110
+ };
111
+ var PostgresDropPolicy = class extends PostgresDdlNode {
112
+ kind = "drop-policy";
113
+ schema;
114
+ table;
115
+ name;
116
+ constructor(options) {
117
+ super();
118
+ this.schema = options.schema;
119
+ this.table = options.table;
120
+ this.name = options.name;
121
+ this.freeze();
122
+ }
123
+ accept(visitor) {
124
+ return visitor.dropPolicy(this);
125
+ }
126
+ };
73
127
  //#endregion
74
- export { PostgresDdlNode as a, PostgresCreateTable as i, PostgresAlterTable as n, PostgresCreateSchema as r, AddColumnAction as t };
128
+ export { PostgresCreateSchema as a, PostgresDropPolicy as c, PostgresCreatePolicy as i, DropDefaultAction as n, PostgresCreateTable as o, PostgresAlterTable as r, PostgresDdlNode as s, AddColumnAction as t };
75
129
 
76
- //# sourceMappingURL=nodes-Bbhs2rwj.mjs.map
130
+ //# sourceMappingURL=nodes-Dh__NS58.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes-Dh__NS58.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import {\n type DdlColumn,\n DdlNode,\n type DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { RlsPolicyOperation } from '../rls/canonicalize';\n\n// ---------------------------------------------------------------------------\n// AlterTableAction — nested polymorphic hierarchy\n// ---------------------------------------------------------------------------\n\nexport interface AlterTableActionVisitor<R> {\n addColumn(action: AddColumnAction): R;\n dropDefault(action: DropDefaultAction): R;\n}\n\nexport abstract class AlterTableAction {\n abstract readonly kind: string;\n abstract accept<R>(visitor: AlterTableActionVisitor<R>): R;\n}\n\nexport class AddColumnAction extends AlterTableAction {\n readonly kind = 'add-column' as const;\n readonly column: DdlColumn;\n\n constructor(column: DdlColumn) {\n super();\n this.column = column;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.addColumn(this);\n }\n}\n\nexport class DropDefaultAction extends AlterTableAction {\n readonly kind = 'drop-default' as const;\n readonly columnName: string;\n\n constructor(columnName: string) {\n super();\n this.columnName = columnName;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.dropDefault(this);\n }\n}\n\n/**\n * The set of ALTER TABLE subactions currently expressible as typed DDL.\n *\n * The remaining actions — SetDefault, SetNotNull, DropNotNull,\n * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`\n * and join this union as they are converted to typed DDL. Until then it is\n * intentionally partial: only the ALTER subactions used by the\n * already-converted ops (AddColumn, DropDefault) appear here.\n */\nexport type AnyAlterTableAction = AddColumnAction | DropDefaultAction;\n\n// ---------------------------------------------------------------------------\n// Top-level DDL visitor\n// ---------------------------------------------------------------------------\n\nexport interface PostgresDdlVisitor<R> {\n createTable(node: PostgresCreateTable): R;\n createSchema(node: PostgresCreateSchema): R;\n alterTable(node: PostgresAlterTable): R;\n createPolicy(node: PostgresCreatePolicy): R;\n dropPolicy(node: PostgresDropPolicy): R;\n}\n\nexport abstract class PostgresDdlNode extends DdlNode {\n abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nfunction freezeConstraints(\n constraints: readonly DdlTableConstraint[] | undefined,\n): ReadonlyArray<DdlTableConstraint> | undefined {\n return constraints ? Object.freeze([...constraints]) : undefined;\n}\n\nexport class PostgresCreateTable extends PostgresDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n readonly constraints: ReadonlyArray<DdlTableConstraint> | undefined;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.constraints = freezeConstraints(options.constraints);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport class PostgresCreateSchema extends PostgresDdlNode {\n readonly kind = 'create-schema' as const;\n readonly schema: string;\n readonly ifNotExists: boolean | undefined;\n\n constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {\n super();\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createSchema(this);\n }\n}\n\nexport class PostgresAlterTable extends PostgresDdlNode {\n readonly kind = 'alter-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly actions: ReadonlyArray<AnyAlterTableAction>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.actions = Object.freeze([...options.actions]);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterTable(this);\n }\n}\n\nexport type { RlsPolicyOperation };\n\nexport class PostgresCreatePolicy extends PostgresDdlNode {\n readonly kind = 'create-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: ReadonlyArray<string>;\n readonly using: string | undefined;\n readonly withCheck: string | undefined;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.permissive = options.permissive;\n this.operation = options.operation;\n this.roles = Object.freeze([...options.roles]);\n this.using = options.using;\n this.withCheck = options.withCheck;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createPolicy(this);\n }\n}\n\nexport class PostgresDropPolicy extends PostgresDdlNode {\n readonly kind = 'drop-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n\n constructor(options: { readonly schema: string; readonly table: string; readonly name: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.dropPolicy(this);\n }\n}\n\nexport type AnyPostgresDdlNode =\n | PostgresCreateTable\n | PostgresCreateSchema\n | PostgresAlterTable\n | PostgresCreatePolicy\n | PostgresDropPolicy;\n"],"mappings":";;AAgBA,IAAsB,mBAAtB,MAAuC,CAGvC;AAEA,IAAa,kBAAb,cAAqC,iBAAiB;CACpD,OAAgB;CAChB;CAEA,YAAY,QAAmB;EAC7B,MAAM;EACN,KAAK,SAAS;EACd,OAAO,OAAO,IAAI;CACpB;CAEA,OAAmB,SAAwC;EACzD,OAAO,QAAQ,UAAU,IAAI;CAC/B;AACF;AAEA,IAAa,oBAAb,cAAuC,iBAAiB;CACtD,OAAgB;CAChB;CAEA,YAAY,YAAoB;EAC9B,MAAM;EACN,KAAK,aAAa;EAClB,OAAO,OAAO,IAAI;CACpB;CAEA,OAAmB,SAAwC;EACzD,OAAO,QAAQ,YAAY,IAAI;CACjC;AACF;AAyBA,IAAsB,kBAAtB,cAA8C,QAAQ,CAEtD;AAEA,SAAS,i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