@prisma/orm-target-postgres 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/README.md +4 -6
  2. package/dist/adapter-5qylEP__.d.mts +403 -0
  3. package/dist/adapter-5qylEP__.d.mts.map +1 -0
  4. package/dist/{adapter-B0xsc80z-sYcF0RVF.mjs → adapter-svGTIjA2-1p-Iw8D2.mjs} +24 -30
  5. package/dist/adapter-svGTIjA2-1p-Iw8D2.mjs.map +1 -0
  6. package/dist/adapter.d.mts +11 -13
  7. package/dist/adapter.mjs +7 -8
  8. package/dist/adapter__adapter.d.mts +2 -2
  9. package/dist/adapter__adapter.mjs +3 -2
  10. package/dist/adapter__column-types.d.mts +2 -2
  11. package/dist/adapter__column-types.mjs +2 -2
  12. package/dist/adapter__control.d.mts +4 -5
  13. package/dist/adapter__control.mjs +11 -423
  14. package/dist/adapter__control.mjs.map +1 -1
  15. package/dist/adapter__runtime.d.mts +1 -1
  16. package/dist/adapter__runtime.mjs +29 -19
  17. package/dist/adapter__runtime.mjs.map +1 -1
  18. package/dist/adapter__sql-renderer.d.mts +1 -1
  19. package/dist/adapter__sql-renderer.mjs +1 -1
  20. package/dist/adapter__types.d.mts +4 -3
  21. package/dist/aggregates-CEqqEg8k.d.mts +318 -0
  22. package/dist/aggregates-CEqqEg8k.d.mts.map +1 -0
  23. package/dist/{aggregates-Dh6HPdvC.mjs → aggregates-Dw-lAutX.mjs} +105 -40
  24. package/dist/aggregates-Dw-lAutX.mjs.map +1 -0
  25. package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts +52 -0
  26. package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts.map +1 -0
  27. package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs +1342 -0
  28. package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs.map +1 -0
  29. package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs +58 -0
  30. package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs.map +1 -0
  31. package/dist/{canonicalize-CQlxSR4D-MnrT5gtW.d.mts → canonicalize-B-xvDOdd-G3yUeKj4.d.mts} +7 -3
  32. package/dist/canonicalize-B-xvDOdd-G3yUeKj4.d.mts.map +1 -0
  33. package/dist/{canonicalize-CrN3u_xM-D4MrOqcB.mjs → canonicalize-RdxoUHao-FTTkizfe.mjs} +15 -3
  34. package/dist/canonicalize-RdxoUHao-FTTkizfe.mjs.map +1 -0
  35. package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs +48 -0
  36. package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs.map +1 -0
  37. package/dist/{check-expressions-DRgG8RN5-DiA-22aC.d.mts → check-expressions-CtTzM58x-LloO-5Vf.d.mts} +14 -13
  38. package/dist/check-expressions-CtTzM58x-LloO-5Vf.d.mts.map +1 -0
  39. package/dist/{codec-descriptor-LT7BpQta-BaDM8UQQ.mjs → codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs} +12 -21
  40. package/dist/codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs.map +1 -0
  41. package/dist/codec-descriptor-Fb3UoQGb.d.mts +1 -0
  42. package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts +47 -0
  43. package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts.map +1 -0
  44. package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs +41 -0
  45. package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs.map +1 -0
  46. package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts +41 -0
  47. package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts.map +1 -0
  48. package/dist/codec-ids-CcB5uBNf.d.mts +1 -0
  49. package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs +61 -0
  50. package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs.map +1 -0
  51. package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts +53 -0
  52. package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts.map +1 -0
  53. package/dist/codec-types-BBACckHa.d.mts +2 -0
  54. package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts +84 -0
  55. package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts.map +1 -0
  56. package/dist/codecs-CADK7dCR-C8WToYQb.d.mts +724 -0
  57. package/dist/codecs-CADK7dCR-C8WToYQb.d.mts.map +1 -0
  58. package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs +1743 -0
  59. package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs.map +1 -0
  60. package/dist/codecs-CoEpEqjM.d.mts +31 -0
  61. package/dist/codecs-CoEpEqjM.d.mts.map +1 -0
  62. package/dist/column-types-B4zsV-u3.mjs +106 -0
  63. package/dist/column-types-B4zsV-u3.mjs.map +1 -0
  64. package/dist/column-types-Bs2V0j8T.d.mts +164 -0
  65. package/dist/column-types-Bs2V0j8T.d.mts.map +1 -0
  66. package/dist/{control-adapter-DFr4gS-r-DM3KcZdQ.mjs → contract-contributions-Xz2FpyfI-CeQZqHKf.mjs} +489 -292
  67. package/dist/contract-contributions-Xz2FpyfI-CeQZqHKf.mjs.map +1 -0
  68. package/dist/{contract-free-DzpGxLfb.d.mts → contract-free-B6-wuc6M.d.mts} +36 -6
  69. package/dist/contract-free-B6-wuc6M.d.mts.map +1 -0
  70. package/dist/{contract-free-aQ4nT-_R.mjs → contract-free-o7olebm9.mjs} +13 -9
  71. package/dist/contract-free-o7olebm9.mjs.map +1 -0
  72. package/dist/control--HupSPoV.d.mts +847 -0
  73. package/dist/control--HupSPoV.d.mts.map +1 -0
  74. package/dist/{control-BaUpALVp.d.mts → control-CQEjh4P7.d.mts} +2 -2
  75. package/dist/control-CQEjh4P7.d.mts.map +1 -0
  76. package/dist/{control-DLTOAEHj.d.mts → control-D4cTcpcJ.d.mts} +22 -48
  77. package/dist/control-D4cTcpcJ.d.mts.map +1 -0
  78. package/dist/{control-Y6FxMu3o.mjs → control-DZQwENIP.mjs} +21 -9
  79. package/dist/control-DZQwENIP.mjs.map +1 -0
  80. package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs → control-policy-DtU5u9Dm-44r_OF94.mjs} +444 -218
  81. package/dist/control-policy-DtU5u9Dm-44r_OF94.mjs.map +1 -0
  82. package/dist/{data-transform-ChZzy2dP-CxVCat_8.mjs → data-transform-h9agBu_c-RlC5A7aY.mjs} +12 -5
  83. package/dist/data-transform-h9agBu_c-RlC5A7aY.mjs.map +1 -0
  84. package/dist/{data-transform-Ck5FbyNO-BNE7QlAo.d.mts → data-transform-nGy9rz87-CE3DGlgn.d.mts} +15 -4
  85. package/dist/data-transform-nGy9rz87-CE3DGlgn.d.mts.map +1 -0
  86. package/dist/data-transform-nqkqNIb8.d.mts +1 -0
  87. package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs +128 -0
  88. package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs.map +1 -0
  89. package/dist/data-types--7V9yY1G.d.mts +99 -0
  90. package/dist/data-types--7V9yY1G.d.mts.map +1 -0
  91. package/dist/data-types-Chx0mjTP-DczU4S9b.mjs +950 -0
  92. package/dist/data-types-Chx0mjTP-DczU4S9b.mjs.map +1 -0
  93. package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts +45 -0
  94. package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts.map +1 -0
  95. package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs +647 -0
  96. package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs.map +1 -0
  97. package/dist/ddl-B8nQZTWN.d.mts +1 -0
  98. package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs +18 -0
  99. package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs.map +1 -0
  100. package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs +311 -0
  101. package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs.map +1 -0
  102. package/dist/default-normalizer-DO-cH75Q.d.mts +25 -0
  103. package/dist/default-normalizer-DO-cH75Q.d.mts.map +1 -0
  104. package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs +36 -0
  105. package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs.map +1 -0
  106. package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs +64 -0
  107. package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs.map +1 -0
  108. package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs +15 -0
  109. package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs.map +1 -0
  110. package/dist/{diff-database-schema-DsoNznGC.d.mts → diff-database-schema-BxzhZaVN.d.mts} +12 -7
  111. package/dist/diff-database-schema-BxzhZaVN.d.mts.map +1 -0
  112. package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs → diff-database-schema-DAEzWtzU-DoyVgKqh.mjs} +38 -18
  113. package/dist/diff-database-schema-DAEzWtzU-DoyVgKqh.mjs.map +1 -0
  114. package/dist/driver.d.mts +3 -3
  115. package/dist/driver.mjs +3 -2
  116. package/dist/driver__control.d.mts +1 -1
  117. package/dist/driver__control.mjs +1 -1
  118. package/dist/driver__runtime.d.mts +2 -2
  119. package/dist/driver__runtime.mjs +2 -639
  120. package/dist/errors-BrhQYgdL-IvZHPjwL.mjs +103 -0
  121. package/dist/errors-BrhQYgdL-IvZHPjwL.mjs.map +1 -0
  122. package/dist/{errors-CU4xIwwk.d.mts → errors-D3Mj-x0o.d.mts} +3 -3
  123. package/dist/errors-D3Mj-x0o.d.mts.map +1 -0
  124. package/dist/full-text-BYg7EVX2.mjs +39 -0
  125. package/dist/full-text-BYg7EVX2.mjs.map +1 -0
  126. package/dist/full-text-SDbfxrE_.d.mts +26 -0
  127. package/dist/full-text-SDbfxrE_.d.mts.map +1 -0
  128. package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts +27 -0
  129. package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts.map +1 -0
  130. package/dist/full-text-index-authoring-CN1L9C1k.d.mts +7 -0
  131. package/dist/full-text-index-authoring-CN1L9C1k.d.mts.map +1 -0
  132. package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs +195 -0
  133. package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs.map +1 -0
  134. package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts +71 -0
  135. package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts.map +1 -0
  136. package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs +139 -0
  137. package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs.map +1 -0
  138. package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs +54 -0
  139. package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs.map +1 -0
  140. package/dist/index-types-BihjrAAq-C2VnfAyF.mjs +14 -0
  141. package/dist/index-types-BihjrAAq-C2VnfAyF.mjs.map +1 -0
  142. package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts +60 -0
  143. package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts.map +1 -0
  144. package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs +1143 -0
  145. package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs.map +1 -0
  146. package/dist/{issue-planner-Biq9Ls7e.d.mts → issue-planner-D-On52xP.d.mts} +39 -9
  147. package/dist/issue-planner-D-On52xP.d.mts.map +1 -0
  148. package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts +7 -0
  149. package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts.map +1 -0
  150. package/dist/marker-lock-BviIbusV.d.mts +11 -0
  151. package/dist/marker-lock-BviIbusV.d.mts.map +1 -0
  152. package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs +11 -0
  153. package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs.map +1 -0
  154. package/dist/{migration-PTHAY9Cv.mjs → migration-Be_iuIpn.mjs} +5 -4
  155. package/dist/migration-Be_iuIpn.mjs.map +1 -0
  156. package/dist/migration-D4lMmLVj.d.mts +26 -0
  157. package/dist/migration-D4lMmLVj.d.mts.map +1 -0
  158. package/dist/{namespace-ids-xtp_ZY86-Cpp8PTxD.mjs → namespace-ids-xtp_ZY86-Cxc0dBbO.mjs} +2 -2
  159. package/dist/namespace-ids-xtp_ZY86-Cxc0dBbO.mjs.map +1 -0
  160. package/dist/native-type-normalizer-BaGa9eeb.d.mts +30 -0
  161. package/dist/native-type-normalizer-BaGa9eeb.d.mts.map +1 -0
  162. package/dist/native-type-normalizer-Cn-RGt_E.mjs +24 -0
  163. package/dist/native-type-normalizer-Cn-RGt_E.mjs.map +1 -0
  164. package/dist/{nodes-DAvDJLvJ-BBdvFXNa.mjs → nodes-G8VTh4PM-DNvIhHag.mjs} +78 -7
  165. package/dist/nodes-G8VTh4PM-DNvIhHag.mjs.map +1 -0
  166. package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts → nodes-s0Oe37jT-Cw3BU2gL.d.mts} +82 -29
  167. package/dist/nodes-s0Oe37jT-Cw3BU2gL.d.mts.map +1 -0
  168. package/dist/op-factory-call-CRaVUOb_.d.mts +1 -0
  169. package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-gGX-mZu--0QUG5xH4.mjs} +1014 -258
  170. package/dist/op-factory-call-gGX-mZu--0QUG5xH4.mjs.map +1 -0
  171. package/dist/{op-factory-call-BAeyLFYf-BAgG1h1C.d.mts → op-factory-call-nLHvNx0O-BTBhGbOF.d.mts} +169 -111
  172. package/dist/op-factory-call-nLHvNx0O-BTBhGbOF.d.mts.map +1 -0
  173. package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts +192 -0
  174. package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts.map +1 -0
  175. package/dist/operation-types-OXILTAOX.d.mts +1 -0
  176. package/dist/pack-2CYw2w-b.d.mts +1573 -0
  177. package/dist/pack-2CYw2w-b.d.mts.map +1 -0
  178. package/dist/{planner-CT-7zSfk.d.mts → planner-AD3Dt57t.d.mts} +23 -51
  179. package/dist/planner-AD3Dt57t.d.mts.map +1 -0
  180. package/dist/planner-VuR6URu3-CCUT2Osx.mjs +954 -0
  181. package/dist/planner-VuR6URu3-CCUT2Osx.mjs.map +1 -0
  182. package/dist/planner-ddl-builders-CPM3y7cQ.d.mts +16 -0
  183. package/dist/planner-ddl-builders-CPM3y7cQ.d.mts.map +1 -0
  184. package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs +28 -0
  185. package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs.map +1 -0
  186. package/dist/planner-identity-values-Dsq989Lh.d.mts +26 -0
  187. package/dist/planner-identity-values-Dsq989Lh.d.mts.map +1 -0
  188. package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs +70 -0
  189. package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs.map +1 -0
  190. package/dist/planner-produced-postgres-migration-BBUwtjA_.d.mts +1 -0
  191. package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs → planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs} +5 -5
  192. package/dist/planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs.map +1 -0
  193. package/dist/{planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts → planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts} +4 -4
  194. package/dist/planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts.map +1 -0
  195. package/dist/{planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs → planner-schema-lookup-BbUY9oVy.mjs} +2 -2
  196. package/dist/planner-schema-lookup-BbUY9oVy.mjs.map +1 -0
  197. package/dist/{planner-schema-lookup-C4DHAddq.d.mts → planner-schema-lookup-ceCNOGFf.d.mts} +2 -2
  198. package/dist/planner-schema-lookup-ceCNOGFf.d.mts.map +1 -0
  199. package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs +151 -0
  200. package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs.map +1 -0
  201. package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts +37 -0
  202. package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts.map +1 -0
  203. package/dist/planner-sql-checks-rEjFx_Jv.d.mts +1 -0
  204. package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs +14 -0
  205. package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs.map +1 -0
  206. package/dist/{planner-target-details-HkP4RrRO-_xPQVPF0.d.mts → planner-target-details-HkP4RrRO-D6VtK0jY.d.mts} +2 -2
  207. package/dist/planner-target-details-HkP4RrRO-D6VtK0jY.d.mts.map +1 -0
  208. package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs +11 -0
  209. package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs.map +1 -0
  210. package/dist/{postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts → postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts} +2 -2
  211. package/dist/postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts.map +1 -0
  212. package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs → postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs} +27 -14
  213. package/dist/postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs.map +1 -0
  214. package/dist/{postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts → postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts} +4 -4
  215. package/dist/postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map +1 -0
  216. package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs +1312 -0
  217. package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs.map +1 -0
  218. package/dist/{postgres-migration-BNsrwlxh-CwI5BqAu.d.mts → postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts} +135 -15
  219. package/dist/postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts.map +1 -0
  220. package/dist/{postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs → postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs} +2 -2
  221. package/dist/postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs.map +1 -0
  222. package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs +23 -0
  223. package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs.map +1 -0
  224. package/dist/{postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts → postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts} +2 -2
  225. package/dist/postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts.map +1 -0
  226. package/dist/{postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs → postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs} +3 -3
  227. package/dist/postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs.map +1 -0
  228. package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs → postgres-schema-C6w1rzOF-D1fdwqRx.mjs} +14 -12
  229. package/dist/postgres-schema-C6w1rzOF-D1fdwqRx.mjs.map +1 -0
  230. package/dist/{postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts → postgres-schema-Xsjt3RKO-bis-SVSB.d.mts} +4 -4
  231. package/dist/postgres-schema-Xsjt3RKO-bis-SVSB.d.mts.map +1 -0
  232. package/dist/{postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs → postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs} +2 -2
  233. package/dist/postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs.map +1 -0
  234. package/dist/prisma7-binding-BjiLA9F7.mjs +307 -0
  235. package/dist/prisma7-binding-BjiLA9F7.mjs.map +1 -0
  236. package/dist/prisma7-binding-a56klfkc.d.mts +1651 -0
  237. package/dist/prisma7-binding-a56klfkc.d.mts.map +1 -0
  238. package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs → render-ops-BgqtCw9Z-T8BPTX85.mjs} +17 -10
  239. package/dist/render-ops-BgqtCw9Z-T8BPTX85.mjs.map +1 -0
  240. package/dist/{render-ops-DPwhZt2W.d.mts → render-ops-Bl84i7ut.d.mts} +3 -3
  241. package/dist/render-ops-Bl84i7ut.d.mts.map +1 -0
  242. package/dist/{render-typescript-6sCFvMBh.d.mts → render-typescript-BysdXYpH.d.mts} +2 -2
  243. package/dist/render-typescript-BysdXYpH.d.mts.map +1 -0
  244. package/dist/{render-typescript-Dqp1Spgn-B128r1qw.mjs → render-typescript-Dqp1Spgn-B4mJhuVr.mjs} +2 -2
  245. package/dist/render-typescript-Dqp1Spgn-B4mJhuVr.mjs.map +1 -0
  246. package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs +34 -0
  247. package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs.map +1 -0
  248. package/dist/{runtime-lHBKgjB9.d.mts → runtime-C0VXuM0b.d.mts} +4 -3
  249. package/dist/runtime-C0VXuM0b.d.mts.map +1 -0
  250. package/dist/runtime-CXfxy5ED.mjs +660 -0
  251. package/dist/runtime-CXfxy5ED.mjs.map +1 -0
  252. package/dist/{runtime-_TfO66h5.d.mts → runtime-Ci_toEDZ.d.mts} +12 -4
  253. package/dist/runtime-Ci_toEDZ.d.mts.map +1 -0
  254. package/dist/{runtime-DOXznQe0.d.mts → runtime-DtjW0GP_.d.mts} +4 -4
  255. package/dist/runtime-DtjW0GP_.d.mts.map +1 -0
  256. package/dist/{schema-ir-annotations-DuuYh0gl.d.mts → schema-ir-annotations-BygaWBiC.d.mts} +2 -2
  257. package/dist/schema-ir-annotations-BygaWBiC.d.mts.map +1 -0
  258. package/dist/{schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts → schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts} +2 -2
  259. package/dist/schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts.map +1 -0
  260. package/dist/{normalize-error-CNjgVO71-CLlZ3CuJ.mjs → server-text-types-DeNPQpv5-DqX0h8WF.mjs} +45 -3
  261. package/dist/server-text-types-DeNPQpv5-DqX0h8WF.mjs.map +1 -0
  262. package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs → sql-renderer-BdWJPa5F-Ct0CPlXc.mjs} +113 -123
  263. package/dist/sql-renderer-BdWJPa5F-Ct0CPlXc.mjs.map +1 -0
  264. package/dist/{sql-renderer-BgC0ZgLS.d.mts → sql-renderer-BiBhge7D.d.mts} +9 -7
  265. package/dist/sql-renderer-BiBhge7D.d.mts.map +1 -0
  266. package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs → sql-utils-Bnw3JbWf-BN0gcjZB.mjs} +31 -8
  267. package/dist/sql-utils-Bnw3JbWf-BN0gcjZB.mjs.map +1 -0
  268. package/dist/{sql-utils-DW6fkczF.d.mts → sql-utils-CnnGiZBc.d.mts} +12 -4
  269. package/dist/sql-utils-CnnGiZBc.d.mts.map +1 -0
  270. package/dist/{table-source-ikHOZmhD-DriY1Lcr.d.mts → table-source-ikHOZmhD-vYcblBYv.d.mts} +2 -2
  271. package/dist/table-source-ikHOZmhD-vYcblBYv.d.mts.map +1 -0
  272. package/dist/target.d.mts +61 -49
  273. package/dist/target.mjs +45 -36
  274. package/dist/target__aggregates.d.mts +1 -1
  275. package/dist/target__aggregates.mjs +1 -1
  276. package/dist/target__codec-descriptor.d.mts +2 -2
  277. package/dist/target__codec-descriptor.mjs +1 -1
  278. package/dist/target__codec-ids.d.mts +3 -3
  279. package/dist/target__codec-ids.mjs +2 -2
  280. package/dist/target__codec-types.d.mts +4 -4
  281. package/dist/target__codecs.d.mts +4 -3
  282. package/dist/target__codecs.mjs +3 -3
  283. package/dist/target__contract-free.d.mts +3 -3
  284. package/dist/target__contract-free.mjs +4 -4
  285. package/dist/target__control.d.mts +4 -2
  286. package/dist/target__control.mjs +2501 -2
  287. package/dist/target__control.mjs.map +1 -0
  288. package/dist/target__data-transform.d.mts +2 -2
  289. package/dist/target__data-transform.mjs +1 -1
  290. package/dist/target__data-types.d.mts +2 -0
  291. package/dist/target__data-types.mjs +3 -0
  292. package/dist/target__ddl.d.mts +4 -4
  293. package/dist/target__ddl.mjs +2 -2
  294. package/dist/target__default-normalizer.d.mts +2 -2
  295. package/dist/target__default-normalizer.mjs +2 -2
  296. package/dist/target__diff-database-schema.d.mts +1 -1
  297. package/dist/target__diff-database-schema.mjs +1 -1
  298. package/dist/target__errors.d.mts +1 -1
  299. package/dist/target__errors.mjs +1 -1
  300. package/dist/target__full-text-index-authoring.d.mts +3 -0
  301. package/dist/target__full-text-index-authoring.mjs +3 -0
  302. package/dist/target__full-text.d.mts +4 -0
  303. package/dist/target__full-text.mjs +3 -0
  304. package/dist/target__issue-planner.d.mts +1 -1
  305. package/dist/target__issue-planner.mjs +1 -1
  306. package/dist/target__marker-lock.d.mts +2 -0
  307. package/dist/target__marker-lock.mjs +2 -0
  308. package/dist/target__migration.d.mts +4 -4
  309. package/dist/target__migration.mjs +5 -5
  310. package/dist/target__native-type-normalizer.d.mts +2 -2
  311. package/dist/target__native-type-normalizer.mjs +2 -2
  312. package/dist/target__op-factory-call.d.mts +3 -3
  313. package/dist/target__op-factory-call.mjs +2 -2
  314. package/dist/target__operation-types.d.mts +4 -0
  315. package/dist/target__pack.d.mts +3 -2
  316. package/dist/target__pack.mjs +1 -1
  317. package/dist/target__planner-ddl-builders.d.mts +2 -2
  318. package/dist/target__planner-ddl-builders.mjs +2 -2
  319. package/dist/target__planner-identity-values.d.mts +1 -1
  320. package/dist/target__planner-identity-values.mjs +1 -1
  321. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  322. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  323. package/dist/target__planner-schema-lookup.d.mts +1 -1
  324. package/dist/target__planner-schema-lookup.mjs +1 -1
  325. package/dist/target__planner-sql-checks.d.mts +3 -2
  326. package/dist/target__planner-sql-checks.mjs +2 -2
  327. package/dist/target__planner-target-details.d.mts +1 -1
  328. package/dist/target__planner.d.mts +1 -1
  329. package/dist/target__planner.mjs +2 -2
  330. package/dist/target__prisma7-binding.d.mts +2 -0
  331. package/dist/target__prisma7-binding.mjs +2 -0
  332. package/dist/target__render-ops.d.mts +1 -1
  333. package/dist/target__render-ops.mjs +1 -1
  334. package/dist/target__render-typescript.d.mts +1 -1
  335. package/dist/target__render-typescript.mjs +1 -1
  336. package/dist/target__rls-canonicalize.d.mts +2 -2
  337. package/dist/target__rls-canonicalize.mjs +2 -2
  338. package/dist/target__runtime.d.mts +6 -3
  339. package/dist/target__runtime.mjs +193 -4
  340. package/dist/target__runtime.mjs.map +1 -1
  341. package/dist/target__schema-ir-annotations.d.mts +1 -1
  342. package/dist/target__schema-ir-annotations.mjs +1 -1
  343. package/dist/target__sql-utils.d.mts +3 -2
  344. package/dist/target__sql-utils.mjs +4 -2
  345. package/dist/target__types.d.mts +7 -7
  346. package/dist/target__types.mjs +5 -5
  347. package/dist/types-AvjnIUna.d.mts +2 -0
  348. package/dist/types-D6lgKhE5-D1J9YJnd.d.mts +28 -0
  349. package/dist/types-D6lgKhE5-D1J9YJnd.d.mts.map +1 -0
  350. package/dist/{types-CjGjPLr5.d.mts → types-DOmgp_12.d.mts} +8 -8
  351. package/dist/types-DOmgp_12.d.mts.map +1 -0
  352. package/dist/{types-ue6jkJyF-BQJzjx1P.d.mts → types-ue6jkJyF-D79DmBTl.d.mts} +2 -2
  353. package/dist/types-ue6jkJyF-D79DmBTl.d.mts.map +1 -0
  354. package/package.json +22 -14
  355. package/dist/adapter-B0xsc80z-sYcF0RVF.mjs.map +0 -1
  356. package/dist/adapter-CPesdzv0.d.mts +0 -26
  357. package/dist/adapter-CPesdzv0.d.mts.map +0 -1
  358. package/dist/adapter__operation-types.d.mts +0 -2
  359. package/dist/aggregates-CgqNfj2O.d.mts +0 -10
  360. package/dist/aggregates-CgqNfj2O.d.mts.map +0 -1
  361. package/dist/aggregates-Dh6HPdvC.mjs.map +0 -1
  362. package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs +0 -773
  363. package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs.map +0 -1
  364. package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +0 -1
  365. package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +0 -1
  366. package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs +0 -41
  367. package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs.map +0 -1
  368. package/dist/check-expressions-DRgG8RN5-DiA-22aC.d.mts.map +0 -1
  369. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +0 -37
  370. package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +0 -1
  371. package/dist/codec-descriptor-Bg-_412t.d.mts +0 -1
  372. package/dist/codec-descriptor-LT7BpQta-BaDM8UQQ.mjs.map +0 -1
  373. package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts +0 -35
  374. package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +0 -1
  375. package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs +0 -35
  376. package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +0 -1
  377. package/dist/codec-ids-DJ6j6pZc.d.mts +0 -1
  378. package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts +0 -84
  379. package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +0 -1
  380. package/dist/codec-types-bX63JRLf.d.mts +0 -2
  381. package/dist/codecs-B1HgsJZ2.mjs +0 -15
  382. package/dist/codecs-B1HgsJZ2.mjs.map +0 -1
  383. package/dist/codecs-BmPCJWqb-DveZGJvm.mjs +0 -1680
  384. package/dist/codecs-BmPCJWqb-DveZGJvm.mjs.map +0 -1
  385. package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts +0 -638
  386. package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +0 -1
  387. package/dist/codecs-DmCKO7dg.d.mts +0 -15
  388. package/dist/codecs-DmCKO7dg.d.mts.map +0 -1
  389. package/dist/column-types-BH-MU6uU.d.mts +0 -108
  390. package/dist/column-types-BH-MU6uU.d.mts.map +0 -1
  391. package/dist/column-types-Bh92dNjD.mjs +0 -126
  392. package/dist/column-types-Bh92dNjD.mjs.map +0 -1
  393. package/dist/contract-free-DzpGxLfb.d.mts.map +0 -1
  394. package/dist/contract-free-aQ4nT-_R.mjs.map +0 -1
  395. package/dist/control-2F195jJk.d.mts +0 -11
  396. package/dist/control-2F195jJk.d.mts.map +0 -1
  397. package/dist/control-BaUpALVp.d.mts.map +0 -1
  398. package/dist/control-DLTOAEHj.d.mts.map +0 -1
  399. package/dist/control-V7OkAC55.mjs +0 -1459
  400. package/dist/control-V7OkAC55.mjs.map +0 -1
  401. package/dist/control-Y6FxMu3o.mjs.map +0 -1
  402. package/dist/control-adapter-DFr4gS-r-DM3KcZdQ.mjs.map +0 -1
  403. package/dist/control-policy-B53lnBCT-B9K9Cj1x.mjs.map +0 -1
  404. package/dist/data-transform-BSM7TQpE.d.mts +0 -1
  405. package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +0 -1
  406. package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +0 -1
  407. package/dist/ddl-B4Rh8ntj.d.mts +0 -1
  408. package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs +0 -395
  409. package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs.map +0 -1
  410. package/dist/default-normalizer-B36TOul4.d.mts +0 -31
  411. package/dist/default-normalizer-B36TOul4.d.mts.map +0 -1
  412. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +0 -253
  413. package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +0 -1
  414. package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs +0 -354
  415. package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs.map +0 -1
  416. package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs +0 -30
  417. package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs.map +0 -1
  418. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +0 -13
  419. package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +0 -1
  420. package/dist/diff-database-schema-DKq76rCk-uehceHYz.mjs.map +0 -1
  421. package/dist/diff-database-schema-DsoNznGC.d.mts.map +0 -1
  422. package/dist/driver__runtime.mjs.map +0 -1
  423. package/dist/errors-CU4xIwwk.d.mts.map +0 -1
  424. package/dist/errors-DKjQzNaN-DFcF1thx.mjs +0 -39
  425. package/dist/errors-DKjQzNaN-DFcF1thx.mjs.map +0 -1
  426. package/dist/issue-planner-Biq9Ls7e.d.mts.map +0 -1
  427. package/dist/migration-PTHAY9Cv.mjs.map +0 -1
  428. package/dist/migration-aFeTWTOJ.d.mts +0 -25
  429. package/dist/migration-aFeTWTOJ.d.mts.map +0 -1
  430. package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +0 -1
  431. package/dist/native-type-normalizer-DqJlOTeX.d.mts +0 -19
  432. package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +0 -1
  433. package/dist/native-type-normalizer-yvd3tqv-.mjs +0 -38
  434. package/dist/native-type-normalizer-yvd3tqv-.mjs.map +0 -1
  435. package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +0 -1
  436. package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +0 -1
  437. package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +0 -1
  438. package/dist/op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map +0 -1
  439. package/dist/op-factory-call-BTU8I_x0.d.mts +0 -1
  440. package/dist/op-factory-call-H6zeDGLe-_1pAftJk.mjs.map +0 -1
  441. package/dist/operation-types-BfRocNI8.d.mts +0 -22
  442. package/dist/operation-types-BfRocNI8.d.mts.map +0 -1
  443. package/dist/pack-CySS3DQU.d.mts +0 -626
  444. package/dist/pack-CySS3DQU.d.mts.map +0 -1
  445. package/dist/planner-CT-7zSfk.d.mts.map +0 -1
  446. package/dist/planner-D0uogzvT-1WyGIC5p.mjs +0 -671
  447. package/dist/planner-D0uogzvT-1WyGIC5p.mjs.map +0 -1
  448. package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs +0 -102
  449. package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs.map +0 -1
  450. package/dist/planner-ddl-builders-ijp60-JO.d.mts +0 -19
  451. package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +0 -1
  452. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +0 -90
  453. package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +0 -1
  454. package/dist/planner-identity-values-TfEhnoWa.d.mts +0 -25
  455. package/dist/planner-identity-values-TfEhnoWa.d.mts.map +0 -1
  456. package/dist/planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts.map +0 -1
  457. package/dist/planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs.map +0 -1
  458. package/dist/planner-produced-postgres-migration-D6C0T2xV.d.mts +0 -1
  459. package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +0 -1
  460. package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +0 -1
  461. package/dist/planner-sql-checks-CFgbRTJw.d.mts +0 -20
  462. package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +0 -1
  463. package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs +0 -152
  464. package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs.map +0 -1
  465. package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +0 -1
  466. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +0 -15
  467. package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +0 -1
  468. package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +0 -1
  469. package/dist/postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs.map +0 -1
  470. package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +0 -1
  471. package/dist/postgres-migration-BNsrwlxh-CwI5BqAu.d.mts.map +0 -1
  472. package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs +0 -205
  473. package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs.map +0 -1
  474. package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +0 -1
  475. package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +0 -1
  476. package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +0 -1
  477. package/dist/postgres-schema-CF0yHESb-D7n2X21R.mjs.map +0 -1
  478. package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +0 -1
  479. package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +0 -1
  480. package/dist/render-ops-DOsRP0Po-BKn_c_Ia.mjs.map +0 -1
  481. package/dist/render-ops-DPwhZt2W.d.mts.map +0 -1
  482. package/dist/render-typescript-6sCFvMBh.d.mts.map +0 -1
  483. package/dist/render-typescript-Dqp1Spgn-B128r1qw.mjs.map +0 -1
  484. package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs +0 -22
  485. package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs.map +0 -1
  486. package/dist/runtime-DOXznQe0.d.mts.map +0 -1
  487. package/dist/runtime-_TfO66h5.d.mts.map +0 -1
  488. package/dist/runtime-lHBKgjB9.d.mts.map +0 -1
  489. package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +0 -1
  490. package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +0 -1
  491. package/dist/sql-renderer-BgC0ZgLS.d.mts.map +0 -1
  492. package/dist/sql-renderer-ComgusFq-BBlqM1fw.mjs.map +0 -1
  493. package/dist/sql-utils-DW6fkczF.d.mts.map +0 -1
  494. package/dist/sql-utils-DuzN3JZg-DiXy4Vah.mjs.map +0 -1
  495. package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +0 -1
  496. package/dist/types-B-4d5_4a.d.mts +0 -1
  497. package/dist/types-CjGjPLr5.d.mts.map +0 -1
  498. package/dist/types-CkryN1AS-BcQRGsDn.d.mts +0 -27
  499. package/dist/types-CkryN1AS-BcQRGsDn.d.mts.map +0 -1
  500. package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +0 -1
  501. /package/dist/{adapter__operation-types.mjs → target__operation-types.mjs} +0 -0
@@ -1,19 +1,25 @@
1
- import { d as isPostgresSchema } from "./postgres-schema-CF0yHESb-D7n2X21R.mjs";
2
- import { n as PostgresSchemaNodeKind, o as postgresNodeEntityKind, r as PostgresTableSchemaNode, t as PostgresNativeEnumSchemaNode } from "./postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs";
3
- import { t as buildExpectedFormatType } from "./planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs";
4
- import { n as buildColumnTypeSql, t as buildColumnDefaultSql } from "./planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs";
5
- import { C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, L as postgresDefaultToDdlColumnDefault, M as SetDefaultCall, N as SetNotNullCall, O as RawSqlCall, P as buildTargetDetails, S as DropIndexCall, _ as DisableRowLevelSecurityCall, a as AddNotNullColumnDirectCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, g as DataTransformCall, h as CreateTableCall, i as AddNativeEnumValueCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddNotNullColumnWithTempDefaultCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-H6zeDGLe-_1pAftJk.mjs";
6
- import { n as resolveIdentityValue } from "./planner-identity-values-BmHn5C6U-BYBbUAyR.mjs";
7
- import { i as hasUniqueConstraint, n as hasForeignKey, t as buildSchemaLookupMap } from "./planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs";
1
+ import { E as pgInt8, F as pgText, J as pgVarchar, L as pgTime, M as pgNumeric, S as pgFloat8, T as pgInt4, U as pgTimetz, V as pgTimestamptz, q as pgVarbit, w as pgInt2, x as pgFloat4, z as pgTimestamp } from "./data-types-Chx0mjTP-DczU4S9b.mjs";
2
+ import { d as isPostgresSchema } from "./postgres-schema-C6w1rzOF-D1fdwqRx.mjs";
3
+ import { n as PostgresSchemaNodeKind, o as postgresNodeEntityKind, r as PostgresTableSchemaNode, t as PostgresNativeEnumSchemaNode } from "./postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs";
4
+ import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs";
5
+ import { i as hasAutoincrementDefault, n as autoincrementWidthOfDataType } from "./autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs";
6
+ import { a as stackDataTypes } from "./planner-sql-checks-D-K44J19-CzvrqzNB.mjs";
7
+ import { t as buildTargetDetails } from "./planner-target-details-CUEF0s90-6g-mOgTI.mjs";
8
+ import { C as DropNativeEnumTypeCall, D as DropTableCall, G as postgresDefaultToDdlColumnDefault, L as SetDefaultCall, O as EnableRowLevelSecurityCall, R as SetNotNullCall, S as DropIndexCall, V as columnNameOfCall, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, g as DataTransformCall, h as CreateTableCall, i as AddForeignKeyCall, k as RawSqlCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-gGX-mZu--0QUG5xH4.mjs";
9
+ import { t as buildColumnTypeSql } from "./planner-ddl-builders-cYnH52gC-BWifb_M6.mjs";
10
+ import { n as resolveIdentityValue } from "./planner-identity-values-QstrMJ2U-CcpaRVPY.mjs";
11
+ import { dataTypeParams } from "@prisma/orm-framework/components/codec";
8
12
  import { blindCast } from "@prisma/orm-framework/utils/casts";
13
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
14
+ import { isSqlDataType, renderSqlTypeName } from "@prisma/orm-family-sql/contract/data-type";
9
15
  import { UNBOUND_NAMESPACE_ID, entityAt } from "@prisma/orm-framework/components/ir";
16
+ import { issueOutcome, orderIssuesByDependencies } from "@prisma/orm-framework/components/control";
10
17
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
11
18
  import * as contractFree from "@prisma/orm-family-sql/relational-core/contract-free";
12
- import { issueOutcome, orderIssuesByDependencies } from "@prisma/orm-framework/components/control";
13
- import { RelationalSchemaNodeKind, SqlSchemaIR } from "@prisma/orm-family-sql/schema-ir/types";
14
- import { InternalError } from "@prisma/orm-framework/utils/internal-error";
19
+ import { RelationalSchemaNodeKind, SqlSchemaIR, sqlColumnTypesEqual } from "@prisma/orm-family-sql/schema-ir/types";
20
+ import { columnTakesTemporaryValue } from "@prisma/orm-family-sql/family/control";
15
21
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
16
- //#region ../../../3-targets/3-targets/postgres/dist/control-policy-B53lnBCT.mjs
22
+ //#region ../../../3-targets/postgres/1-target/dist/control-policy-DtU5u9Dm.mjs
17
23
  /**
18
24
  * The storage-`entries` coordinate `(entityKind, entityName)` a Postgres diff
19
25
  * node addresses — a table by its name, a native enum by its physical type
@@ -37,40 +43,49 @@ function postgresNodeStorageCoordinate(node) {
37
43
  };
38
44
  }
39
45
  }
46
+ const AUTOINCREMENT = "autoincrement()";
40
47
  /**
41
48
  * Reconstructs the `StorageColumn`-shaped fields the DDL builder functions
42
- * (`buildColumnTypeSql`, `buildExpectedFormatType`, `resolveIdentityValue`)
43
- * expect, from a column node's own stamped codec identity (`codecRef` /
44
- * `codecBaseNativeType` / `codecNamedType`, Decision 5) — never the
45
- * contract. The builders were written against `StorageColumn` and are
46
- * unchanged here; only the shape feeding them moves from the contract to
47
- * the node. An empty `storageTypes` catalog is passed alongside: the
48
- * node's fields are already resolved past any `typeRef` indirection, so no
49
- * live lookup is needed, and passing a non-empty catalog would risk a
50
- * false `typeRef` hit against an unrelated storage type.
49
+ * (`buildColumnTypeSql`, `resolveIdentityValue`)
50
+ * expect, from a column node's own stamped codec identity (`codecRef`,
51
+ * Decision 5) — never the contract.
51
52
  */
52
53
  function columnLike(column) {
53
- if (column.codecRef === void 0 || column.codecBaseNativeType === void 0) throw new InternalError(`columnLike: expected column "${column.name}" carries no codec identity — the expected tree must be derived via contractToSchemaIR for planning`);
54
54
  return {
55
- nativeType: column.codecBaseNativeType,
56
- codecId: column.codecRef.codecId,
55
+ ...columnTypeLike(`column "${column.name}"`, column),
57
56
  nullable: column.nullable,
58
- ...ifDefined("many", column.many ?? column.codecRef.many),
59
- ...ifDefined("typeParams", column.codecRef.typeParams !== void 0 ? blindCast(column.codecRef.typeParams) : void 0),
60
- ...column.codecNamedType ? { typeRef: "<resolved>" } : {},
61
- ...ifDefined("default", column.resolvedDefault)
57
+ ...ifDefined("default", column.authoredDefault ?? column.resolvedDefault)
58
+ };
59
+ }
60
+ function columnTypeLike(owner, identity) {
61
+ if (identity.codecRef === void 0) throw new InternalError(`columnTypeLike: expected ${owner} carries no codec identity — the expected tree must be derived via contractToSchemaIR for planning`);
62
+ return {
63
+ codecId: identity.codecRef.codecId,
64
+ many: identity.many ?? identity.codecRef.many ? { elementNullable: false } : false,
65
+ ...ifDefined("typeParams", identity.codecRef.typeParams !== void 0 ? blindCast(identity.codecRef.typeParams) : void 0)
62
66
  };
63
67
  }
64
68
  /**
69
+ * The type DDL writes for a column node: the name of the type it is stored as, with the parameters as the contract writes them, `[]` for a list, and for an `autoincrement()` column of an integer type the serial pseudo-type when `allowPseudoTypes`.
70
+ */
71
+ function columnTypeSql(column, allowPseudoTypes) {
72
+ const type = column.storedType;
73
+ if (type === void 0 || !isSqlDataType(type)) throw new InternalError(`column "${column.name}" has no data type; the expected tree must be derived via contractToSchemaIR for planning`);
74
+ const columnDefault = column.authoredDefault ?? column.resolvedDefault;
75
+ if (allowPseudoTypes && columnDefault?.kind === "function" && columnDefault.expression === AUTOINCREMENT) {
76
+ const width = autoincrementWidthOfDataType(type.id);
77
+ if (width !== void 0) return width.serialType;
78
+ }
79
+ const typeSql = renderSqlTypeName(type, dataTypeParams(type, column.codecRef?.typeParams));
80
+ return column.many ?? column.codecRef?.many ? `${typeSql}[]` : typeSql;
81
+ }
82
+ /**
65
83
  * Builds the `CREATE TABLE` / `ADD COLUMN` DDL column for an expected column
66
- * node, resolving type rendering from the node's codec identity against the
67
- * codec hooks the caller holds — the same builder the pre-`plan(start, end)`
68
- * op-path called, so the output is byte-identical.
84
+ * node, writing its type from the type the column is stored as.
69
85
  */
70
- function renderColumnDdl(name, column, codecHooks) {
71
- const like = columnLike(column);
72
- const typeSql = buildColumnTypeSql(like, codecHooks, {});
73
- const ddlDefault = postgresDefaultToDdlColumnDefault(like.default);
86
+ function renderColumnDdl(name, column) {
87
+ const typeSql = columnTypeSql(column, true);
88
+ const ddlDefault = postgresDefaultToDdlColumnDefault(column.authoredDefault ?? column.resolvedDefault);
74
89
  return contractFree.col(name, typeSql, {
75
90
  ...!column.nullable ? { notNull: true } : {},
76
91
  ...ifDefined("default", ddlDefault),
@@ -80,12 +95,8 @@ function renderColumnDdl(name, column, codecHooks) {
80
95
  /**
81
96
  * Builds the `ALTER COLUMN … TYPE` operands for an expected column node.
82
97
  */
83
- function renderColumnAlterType(column, codecHooks) {
84
- const like = columnLike(column);
85
- return {
86
- qualifiedTargetType: buildColumnTypeSql(like, codecHooks, {}, false),
87
- formatTypeExpected: buildExpectedFormatType(like, codecHooks, {})
88
- };
98
+ function renderColumnAlterType(column) {
99
+ return columnTypeSql(column, false);
89
100
  }
90
101
  /**
91
102
  * Resolves the identity value (monoid neutral element) SQL literal used as
@@ -94,20 +105,220 @@ function renderColumnAlterType(column, codecHooks) {
94
105
  * `null` when the column's type has no built-in/codec-provided identity
95
106
  * value.
96
107
  */
97
- function resolveColumnTemporaryDefault(column, codecHooks) {
98
- return resolveIdentityValue(columnLike(column), codecHooks, {});
108
+ function resolveColumnTemporaryDefault(column, codecHooks, types) {
109
+ return resolveIdentityValue(columnLike(column), codecHooks, types);
99
110
  }
100
111
  /**
101
- * The column's `SET DEFAULT` clause SQL, resolved from a column-default
102
- * diff node. `''` when the node carries no resolved default.
112
+ * The column whose `SET DEFAULT` a column-default diff node asks for, carrying its authored default, or its resolved one when nothing was authored, and its type and codec, from which the adapter writes the clause. An `autoincrement()` default is carried as itself, for `setDefault` to attach a sequence, or to refuse when the column is not a smallint, integer or bigint. `undefined` when the node carries no default, or one DDL does not write.
103
113
  */
104
- function renderColumnDefaultSql(defaultNode) {
105
- if (defaultNode.resolved === void 0) return "";
106
- return buildColumnDefaultSql(defaultNode.resolved, {
107
- nativeType: defaultNode.nativeTypeContext ?? "",
108
- ...ifDefined("many", defaultNode.many)
114
+ function buildSetDefaultColumn(columnName, defaultNode, types) {
115
+ const authored = defaultNode.authored ?? defaultNode.resolved;
116
+ if (authored === void 0) return void 0;
117
+ const typeLike = columnTypeLike("column default", defaultNode);
118
+ if (authored.kind === "function" && authored.expression === AUTOINCREMENT) return contractFree.col(columnName, buildColumnTypeSql(typeLike, types, false), {
119
+ default: contractFree.fn(AUTOINCREMENT),
120
+ ...ifDefined("codecRef", defaultNode.codecRef)
121
+ });
122
+ const ddlDefault = postgresDefaultToDdlColumnDefault(authored);
123
+ if (ddlDefault === void 0) return void 0;
124
+ return contractFree.col(columnName, buildColumnTypeSql(typeLike, types, false), {
125
+ default: ddlDefault,
126
+ ...ifDefined("codecRef", defaultNode.codecRef)
109
127
  });
110
128
  }
129
+ function keyChangeOf(issue) {
130
+ const ddlSchemaName = issueSchemaName(issue);
131
+ const tableName = issueTableName(issue);
132
+ if (issueNode(issue)?.nodeKind !== RelationalSchemaNodeKind.primaryKey || issueOutcome(issue) === "not-found" || ddlSchemaName === void 0 || tableName === void 0) return;
133
+ return {
134
+ issue,
135
+ ddlSchemaName,
136
+ tableName,
137
+ oldKey: blindCast(issue.actual)
138
+ };
139
+ }
140
+ function sameColumnSet(left, right) {
141
+ return left.length === right.length && left.every((column) => right.includes(column));
142
+ }
143
+ function foreignKeysOf(tree) {
144
+ return Object.values(tree.namespaces).flatMap((namespace) => Object.values(namespace.tables).flatMap((table) => table.foreignKeys.map((foreignKey) => ({
145
+ ddlSchemaName: namespace.schemaName,
146
+ tableName: table.name,
147
+ foreignKey
148
+ }))));
149
+ }
150
+ function referencesKey(at, change) {
151
+ return (at.foreignKey.resolvedReferencedNamespace ?? at.ddlSchemaName) === change.ddlSchemaName && at.foreignKey.referencedTable === change.tableName && sameColumnSet(at.foreignKey.referencedColumns, change.oldKey.columns);
152
+ }
153
+ function isTableIssueOf(issue, at) {
154
+ return issueSchemaName(issue) === at.ddlSchemaName && issueTableName(issue) === at.tableName;
155
+ }
156
+ function hasOwnIssue(at, issues) {
157
+ return issues.some((issue) => issueNode(issue)?.nodeKind === RelationalSchemaNodeKind.foreignKey && isTableIssueOf(issue, at) && issue.actual?.id === at.foreignKey.id);
158
+ }
159
+ function dropsTable(at, issues) {
160
+ return issues.some((issue) => issueNode(issue)?.nodeKind === PostgresSchemaNodeKind.table && issueOutcome(issue) === "not-expected" && isTableIssueOf(issue, at));
161
+ }
162
+ function endForeignKey(endTree, at) {
163
+ return Object.values(endTree.namespaces).find((candidate) => candidate.schemaName === at.ddlSchemaName)?.tables[at.tableName]?.foreignKeys.find((foreignKey) => foreignKey.id === at.foreignKey.id);
164
+ }
165
+ function foreignKeyName(at) {
166
+ return at.foreignKey.name ?? defaultForeignKeyName(at.tableName, at.foreignKey.columns);
167
+ }
168
+ const migrationNewAdvice = "write the change as its own migration with prisma migration new, dropping that foreign key before the key change and adding it back after it.";
169
+ function quotedTable(at) {
170
+ return `"${at.ddlSchemaName}"."${at.tableName}"`;
171
+ }
172
+ function blockedKeyChange(change, at, reason, why) {
173
+ const keyName = change.oldKey.name ?? defaultPrimaryKeyName(change.tableName);
174
+ const name = foreignKeyName(at);
175
+ return {
176
+ kind: "foreignKeyConflict",
177
+ summary: `Primary key "${keyName}" on "${change.ddlSchemaName}"."${change.tableName}" cannot change while foreign key "${name}" on ${quotedTable(at)} references it, and ${reason}.`,
178
+ why,
179
+ location: {
180
+ entityKind: "table",
181
+ entityName: at.tableName,
182
+ constraint: name
183
+ }
184
+ };
185
+ }
186
+ function controlPolicyRefusal(change, at, declared) {
187
+ const table = quotedTable(at);
188
+ const dbUpdateAdvice = declared ? "With db update, drop that foreign key yourself and leave it out of the contract, run db update, then add the foreign key back to both if you still want it and run db update again." : "With db update, drop that foreign key yourself, run db update, then add the foreign key back if you still want it.";
189
+ return blockedKeyChange(change, at, `the control policy does not let this plan change ${table}`, `With migration plan, give ${table} a control policy that lets this plan change it and plan again, or ${migrationNewAdvice} ${dbUpdateAdvice}`);
190
+ }
191
+ function otherSpaceRefusal(change, at) {
192
+ const table = quotedTable(at);
193
+ return blockedKeyChange(change, at, `another contract space owns ${table}`, `Change that foreign key through the contract space that owns ${table}, or ${migrationNewAdvice}`);
194
+ }
195
+ function undeclaredTableRefusal(change, at) {
196
+ const table = quotedTable(at);
197
+ return blockedKeyChange(change, at, `the contract does not declare ${table}`, `This plan allows only additive changes, as db init does, so it cannot change a primary key. Run db update instead, which drops ${table} together with its foreign key; add ${table} to the contract first if you want to keep it.`);
198
+ }
199
+ function removedForeignKeyRefusal(change, at) {
200
+ return blockedKeyChange(change, at, `the contract leaves that foreign key out of ${quotedTable(at)}`, "This plan allows only additive changes, as db init does, so it can neither drop that foreign key nor change a primary key. Run db update instead, which drops that foreign key before the key change.");
201
+ }
202
+ function undeclaredSchemaRefusal(change, at) {
203
+ const table = quotedTable(at);
204
+ return blockedKeyChange(change, at, `the contract does not declare schema "${at.ddlSchemaName}", whose tables a plan never drops`, `With migration plan, declare ${table} in the contract and plan again, or ${migrationNewAdvice} With db update, drop that foreign key yourself, run db update, then add the foreign key back if you still want it.`);
205
+ }
206
+ function allowsOnlyAdditive(ctx) {
207
+ const allowed = ctx.policy.allowedOperationClasses;
208
+ return !allowed.includes("widening") && !allowed.includes("destructive");
209
+ }
210
+ function tableInEndTree(endTree, at) {
211
+ return Object.values(endTree.namespaces).some((namespace) => namespace.schemaName === at.ddlSchemaName && namespace.tables[at.tableName] !== void 0);
212
+ }
213
+ function keyCalls(change, ctx) {
214
+ const schemaName = emissionSchemaName(ctx, change.ddlSchemaName);
215
+ const drop = new DropConstraintCall(schemaName, change.tableName, change.oldKey.name ?? defaultPrimaryKeyName(change.tableName), "primaryKey");
216
+ if (issueOutcome(change.issue) === "not-expected") return [drop];
217
+ const newKey = blindCast(change.issue.expected);
218
+ return [drop, new AddPrimaryKeyCall(schemaName, change.tableName, newKey.name ?? defaultPrimaryKeyName(change.tableName), [...newKey.columns])];
219
+ }
220
+ /**
221
+ * Plans a primary key whose columns change, or that is removed: a drop of the old key, then an add of the new one. Postgres refuses to drop a key while a foreign key depends on its index, so every foreign key of the start tree that references the old key's columns is dropped first, unless its own issue already drops it, and added back from the end tree. The plan refuses the change instead when such a foreign key is on a table the control policy keeps it away from or another contract space owns, or when the end tree leaves the foreign key out and the plan does not drop it or its table: under a policy that allows additive changes alone, as `db init` does, or because the table is in a schema the end contract does not declare.
222
+ */
223
+ function primaryKeyChangeStrategy(issues, ctx) {
224
+ const changes = issues.flatMap((issue) => keyChangeOf(issue) ?? []);
225
+ if (changes.length === 0) return { kind: "no_match" };
226
+ const startForeignKeys = foreignKeysOf(ctx.startTree);
227
+ const calls = [];
228
+ const conflicts = [];
229
+ for (const change of changes) {
230
+ const changeCalls = [];
231
+ const changeConflicts = [];
232
+ for (const at of startForeignKeys) {
233
+ if (!referencesKey(at, change) || hasOwnIssue(at, ctx.allIssues)) continue;
234
+ const drop = new DropConstraintCall(emissionSchemaName(ctx, at.ddlSchemaName), at.tableName, foreignKeyName(at), "foreignKey");
235
+ const kept = endForeignKey(ctx.endTree, at);
236
+ const authority = ctx.foreignKeyDropAuthority(at.ddlSchemaName, at.tableName, at.foreignKey);
237
+ if (authority !== "allowed") {
238
+ changeConflicts.push(authority === "otherSpace" ? otherSpaceRefusal(change, at) : controlPolicyRefusal(change, at, kept !== void 0));
239
+ continue;
240
+ }
241
+ if (kept !== void 0) changeCalls.push(drop, new AddForeignKeyCall(drop.schemaName, at.tableName, fkSpecFromNode(kept, at.tableName)));
242
+ else if (dropsTable(at, ctx.allIssues)) changeCalls.push(drop);
243
+ else changeConflicts.push(tableInEndTree(ctx.endTree, at) ? removedForeignKeyRefusal(change, at) : allowsOnlyAdditive(ctx) ? undeclaredTableRefusal(change, at) : undeclaredSchemaRefusal(change, at));
244
+ }
245
+ if (changeConflicts.length > 0) conflicts.push(...changeConflicts);
246
+ else calls.push(...changeCalls, ...keyCalls(change, ctx));
247
+ }
248
+ const consumed = new Set(changes.map((change) => change.issue));
249
+ return {
250
+ kind: "match",
251
+ issues: issues.filter((issue) => !consumed.has(issue)),
252
+ calls,
253
+ conflicts
254
+ };
255
+ }
256
+ /** The changes between data types that keep every value: each pair is `from→to` by data type id. */
257
+ const SAFE_WIDENINGS = /* @__PURE__ */ new Set([
258
+ `${pgInt2.id}→${pgInt4.id}`,
259
+ `${pgInt2.id}→${pgInt8.id}`,
260
+ `${pgInt4.id}→${pgInt8.id}`,
261
+ `${pgInt2.id}→${pgFloat4.id}`,
262
+ `${pgInt2.id}→${pgFloat8.id}`,
263
+ `${pgInt4.id}→${pgFloat8.id}`,
264
+ `${pgFloat4.id}→${pgFloat8.id}`,
265
+ `${pgVarchar.id}→${pgText.id}`,
266
+ `${pgInt2.id}→${pgText.id}`,
267
+ `${pgInt4.id}→${pgText.id}`,
268
+ `${pgInt8.id}→${pgText.id}`,
269
+ `${pgNumeric.id}→${pgText.id}`,
270
+ `${pgFloat4.id}→${pgText.id}`,
271
+ `${pgFloat8.id}→${pgText.id}`
272
+ ]);
273
+ /** Types whose `length` caps their values; a larger cap, or none, keeps every value. */
274
+ const LENGTH_CAPPED = /* @__PURE__ */ new Set([pgVarchar.id, pgVarbit.id]);
275
+ /** Types whose `precision` rounds their fractional seconds; more, or none, keeps every value. */
276
+ const PRECISION_ROUNDED = /* @__PURE__ */ new Set([
277
+ pgTime.id,
278
+ pgTimetz.id,
279
+ pgTimestamp.id,
280
+ pgTimestamptz.id
281
+ ]);
282
+ function numberParam(params, key) {
283
+ const value = params[key];
284
+ return typeof value === "number" ? value : void 0;
285
+ }
286
+ /** Whether a cap, where `undefined` means none, is at least as large as before. */
287
+ function capGrows(from, to) {
288
+ return to === void 0 || from !== void 0 && to >= from;
289
+ }
290
+ /**
291
+ * A `numeric` keeps every value when it allows at least as many digits before the point and after
292
+ * it; an unconstrained `numeric` holds any value.
293
+ */
294
+ function numericGrows(from, to) {
295
+ const toPrecision = numberParam(to, "precision");
296
+ if (toPrecision === void 0) return true;
297
+ const fromPrecision = numberParam(from, "precision");
298
+ if (fromPrecision === void 0) return false;
299
+ const fromScale = numberParam(from, "scale") ?? 0;
300
+ const toScale = numberParam(to, "scale") ?? 0;
301
+ return toScale >= fromScale && toPrecision - toScale >= fromPrecision - fromScale;
302
+ }
303
+ /** Whether changing a column from one type to another keeps every value: both have a stored type, and the pair is a safe widening by stored type id and parameters in normal form. */
304
+ function isSafeTypeWidening(from, to) {
305
+ if (from.storedType === void 0 || to.storedType === void 0) return false;
306
+ const fromId = from.storedType.id;
307
+ const toId = to.storedType.id;
308
+ const fromParams = from.storedTypeParams ?? {};
309
+ const toParams = to.storedTypeParams ?? {};
310
+ if (SAFE_WIDENINGS.has(`${fromId}→${toId}`)) return true;
311
+ if (fromId !== toId) return false;
312
+ if (LENGTH_CAPPED.has(fromId)) return capGrows(numberParam(fromParams, "length"), numberParam(toParams, "length"));
313
+ if (PRECISION_ROUNDED.has(fromId)) return capGrows(numberParam(fromParams, "precision"), numberParam(toParams, "precision"));
314
+ if (fromId === pgNumeric.id) return numericGrows(fromParams, toParams);
315
+ return false;
316
+ }
317
+ /** Whether changing a live column to the contract's column keeps every value. A list column never widens safely. */
318
+ function liveColumnWidensSafely(expected, actual) {
319
+ if (expected.many === true || actual.many === true) return false;
320
+ return isSafeTypeWidening(actual, expected);
321
+ }
111
322
  /**
112
323
  * Look up a storage table by its explicit namespace coordinate. Returns
113
324
  * `undefined` when the namespace has no table by that name (or no such
@@ -143,6 +354,16 @@ function columnNodePair(issue) {
143
354
  actual: blindCast(issue.actual)
144
355
  };
145
356
  }
357
+ /** The `--backfill` statement's column an issue is about, if a statement names it. */
358
+ function backfilled(ctx, ddlSchemaName, tableName, columnName) {
359
+ const namespaceId = namespaceIdForDdlSchema(ctx, ddlSchemaName);
360
+ return ctx.statementColumns.backfill.find((column) => column.namespaceId === namespaceId && column.table === tableName && column.column === columnName);
361
+ }
362
+ /**
363
+ * Handles a required column with no default added to an existing table, for a field a
364
+ * `--backfill` statement names: a nullable add, a data transform whose slots the user fills, then
365
+ * `SET NOT NULL`. Every other such column is left to `notNullAddColumnCallStrategy`.
366
+ */
146
367
  const notNullBackfillCallStrategy = (issues, ctx) => {
147
368
  if (!ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
148
369
  const matched = [];
@@ -156,11 +377,18 @@ const notNullBackfillCallStrategy = (issues, ctx) => {
156
377
  const ddlSchemaName = issueSchemaName(issue);
157
378
  const tableName = issueTableName(issue);
158
379
  if (ddlSchemaName === void 0 || tableName === void 0) continue;
380
+ const named = backfilled(ctx, ddlSchemaName, tableName, expected.name);
381
+ if (named === void 0) continue;
159
382
  const schemaName = emissionSchemaName(ctx, ddlSchemaName);
383
+ const slot = named.text;
160
384
  matched.push(issue);
161
- const ddl = renderColumnDdl(expected.name, expected, ctx.codecHooks);
385
+ const ddl = renderColumnDdl(expected.name, expected);
162
386
  const nullableSpec = contractFree.col(ddl.name, ddl.type, { ...ddl.codecRef !== void 0 ? { codecRef: ddl.codecRef } : {} });
163
- calls.push(new AddColumnCall(schemaName, tableName, nullableSpec), new DataTransformCall(`backfill-${tableName}-${expected.name}`, `backfill-${tableName}-${expected.name}:check`, `backfill-${tableName}-${expected.name}:run`), new SetNotNullCall(schemaName, tableName, expected.name));
387
+ calls.push(new AddColumnCall(schemaName, tableName, nullableSpec, ctx.dataTypes), new DataTransformCall(`backfill-${tableName}-${expected.name}`, `${slot}:check`, `${slot}:run`, "data", {
388
+ schema: schemaName,
389
+ table: tableName,
390
+ column: expected.name
391
+ }), new SetNotNullCall(schemaName, tableName, expected.name));
164
392
  }
165
393
  if (matched.length === 0) return { kind: "no_match" };
166
394
  return {
@@ -170,31 +398,19 @@ const notNullBackfillCallStrategy = (issues, ctx) => {
170
398
  recipe: true
171
399
  };
172
400
  };
173
- const SAFE_WIDENINGS = /* @__PURE__ */ new Set([
174
- "int2→int4",
175
- "int2→int8",
176
- "int4→int8",
177
- "float4→float8"
178
- ]);
179
401
  /**
180
- * Handles `not-equal` column issues whose TYPE differs. `fromContract` is
181
- * only supplied by `migration plan` — for reconciliation (`db update` /
182
- * `db init`, `fromContract === null`) this strategy never fires, mirroring
183
- * the legacy `typeChangeCallStrategy`'s requirement of a prior contract:
184
- * `mapNodeIssueToCall`'s in-place ALTER covers reconciliation directly.
402
+ * Handles a `not-equal` column issue whose type differs, for a field a `--convert` statement names,
403
+ * in a plan that may include `data` operations: `migration plan`. The alter is classed `data` and
404
+ * its USING clause is a slot the user fills with the conversion. A known-safe widening needs no
405
+ * conversion and is left to `mapNodeIssueToCall`, as is every type change no statement names: a
406
+ * direct alter, `widening` or `destructive`, which the plan asks about.
185
407
  *
186
- * A single node issue can carry BOTH type and nullability drift (Postgres
187
- * alters in place, so the differ emits one `not-equal` column issue where
188
- * the legacy coordinate walk emitted two: `type_mismatch` +
189
- * `nullability_mismatch`). When this strategy consumes the issue for its
190
- * type portion, it also emits whatever nullability delta the same node pair
191
- * carries — using the same construction `nullableTighteningCallStrategy` /
192
- * the mapper's direct dispatch would have used — so the issue is never
193
- * partially handled.
408
+ * One node issue can carry both type and nullability drift, so the strategy also emits the
409
+ * nullability change: `SET NOT NULL` after the alter, whose conversion can map NULL to a value.
194
410
  */
411
+ /** A field as a statement names it: with its namespace only when the contract has several. */
195
412
  const typeChangeCallStrategy = (issues, ctx) => {
196
- if (ctx.fromContract === null) return { kind: "no_match" };
197
- const dataAllowed = ctx.policy.allowedOperationClasses.includes("data");
413
+ if (ctx.fromContract === null || !ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
198
414
  const matched = [];
199
415
  const calls = [];
200
416
  for (const issue of issues) {
@@ -202,27 +418,30 @@ const typeChangeCallStrategy = (issues, ctx) => {
202
418
  const pair = columnNodePair(issue);
203
419
  if (pair === void 0) continue;
204
420
  const { expected, actual } = pair;
205
- if (!columnTypeChangedNativeOnly(expected, actual)) continue;
206
- const fromType = actual.nativeType;
207
- const toType = expected.nativeType;
208
- const isSafeWidening = SAFE_WIDENINGS.has(`${fromType}→${toType}`);
209
- if (!isSafeWidening && !dataAllowed) continue;
421
+ if (sqlColumnTypesEqual(expected, actual)) continue;
210
422
  const ddlSchemaName = issueSchemaName(issue);
211
423
  const tableName = issueTableName(issue);
212
424
  if (ddlSchemaName === void 0 || tableName === void 0) continue;
425
+ const namespaceId = namespaceIdForDdlSchema(ctx, ddlSchemaName);
426
+ const converted = ctx.statementColumns.convert.find((column) => column.namespaceId === namespaceId && column.table === tableName && column.column === expected.name);
427
+ if (converted === void 0) continue;
428
+ if (isSafeTypeWidening(actual, expected)) continue;
213
429
  const schemaName = emissionSchemaName(ctx, ddlSchemaName);
214
430
  matched.push(issue);
215
- const { qualifiedTargetType, formatTypeExpected } = renderColumnAlterType(expected, ctx.codecHooks);
216
- const alterOpts = {
217
- qualifiedTargetType,
218
- formatTypeExpected,
219
- rawTargetTypeForLabel: qualifiedTargetType
220
- };
221
- if (isSafeWidening) calls.push(new AlterColumnTypeCall(schemaName, tableName, expected.name, alterOpts));
222
- else calls.push(new DataTransformCall(`typechange-${tableName}-${expected.name}`, `typechange-${tableName}-${expected.name}:check`, `typechange-${tableName}-${expected.name}:run`), new AlterColumnTypeCall(schemaName, tableName, expected.name, alterOpts));
223
- if (expected.nullable !== actual.nullable) if (expected.nullable) calls.push(new DropNotNullCall(schemaName, tableName, expected.name));
224
- else if (dataAllowed) calls.push(new DataTransformCall(`handle-nulls-${tableName}-${expected.name}`, `handle-nulls-${tableName}-${expected.name}:check`, `handle-nulls-${tableName}-${expected.name}:run`), new SetNotNullCall(schemaName, tableName, expected.name));
225
- else calls.push(new SetNotNullCall(schemaName, tableName, expected.name));
431
+ calls.push(new AlterColumnTypeCall({
432
+ schemaName,
433
+ tableName,
434
+ columnName: expected.name,
435
+ type: renderColumnAlterType(expected),
436
+ using: {
437
+ kind: "placeholder",
438
+ slot: `${converted.text}:convert`
439
+ },
440
+ ...expected.catalogText !== void 0 ? { raw: true } : {},
441
+ dataTypes: ctx.dataTypes,
442
+ ownsAutoincrementSequence: hasAutoincrementDefault(actual)
443
+ }));
444
+ if (expected.nullable !== actual.nullable) calls.push(expected.nullable ? new DropNotNullCall(schemaName, tableName, expected.name) : new SetNotNullCall(schemaName, tableName, expected.name));
226
445
  }
227
446
  if (matched.length === 0) return { kind: "no_match" };
228
447
  return {
@@ -233,21 +452,11 @@ const typeChangeCallStrategy = (issues, ctx) => {
233
452
  };
234
453
  };
235
454
  /**
236
- * Whether the raw (unresolved) native type differs — the SAME comparison
237
- * `typeChangeCallStrategy` always used (`fromColumn.nativeType !==
238
- * toColumn.nativeType`), which for the widenable numeric/float types
239
- * `SAFE_WIDENINGS` lists is identical to the resolved comparison
240
- * `columnTypeChanged` (in `issue-planner.ts`) performs.
241
- */
242
- function columnTypeChangedNativeOnly(expected, actual) {
243
- return expected.nativeType !== actual.nativeType;
244
- }
245
- /**
246
- * Handles `not-equal` column issues whose type did NOT change but
247
- * nullability tightened (contract requires NOT NULL, live column is
248
- * nullable). A type-changed issue's nullability delta (if any) is already
249
- * handled by `typeChangeCallStrategy`, which runs first — this strategy
250
- * only ever sees issues that strategy left behind.
455
+ * Handles a `not-equal` column issue whose type did not change but which becomes required, for a
456
+ * field a `--backfill` statement names: a data transform whose slots the user fills with values for
457
+ * the NULLs, then `SET NOT NULL`. Every other such column gets the direct `SET NOT NULL` of
458
+ * `mapNodeIssueToCall`. A type-changed issue's nullability is handled by `typeChangeCallStrategy`
459
+ * or the direct alter.
251
460
  */
252
461
  const nullableTighteningCallStrategy = (issues, ctx) => {
253
462
  if (!ctx.policy.allowedOperationClasses.includes("data")) return { kind: "no_match" };
@@ -258,14 +467,21 @@ const nullableTighteningCallStrategy = (issues, ctx) => {
258
467
  const pair = columnNodePair(issue);
259
468
  if (pair === void 0) continue;
260
469
  const { expected, actual } = pair;
261
- if (columnTypeChangedNativeOnly(expected, actual)) continue;
470
+ if (!sqlColumnTypesEqual(expected, actual)) continue;
262
471
  if (expected.nullable !== false || actual.nullable !== true) continue;
263
472
  const ddlSchemaName = issueSchemaName(issue);
264
473
  const tableName = issueTableName(issue);
265
474
  if (ddlSchemaName === void 0 || tableName === void 0) continue;
475
+ const named = backfilled(ctx, ddlSchemaName, tableName, expected.name);
476
+ if (named === void 0) continue;
266
477
  const schemaName = emissionSchemaName(ctx, ddlSchemaName);
478
+ const slot = named.text;
267
479
  matched.push(issue);
268
- calls.push(new DataTransformCall(`handle-nulls-${tableName}-${expected.name}`, `handle-nulls-${tableName}-${expected.name}:check`, `handle-nulls-${tableName}-${expected.name}:run`), new SetNotNullCall(schemaName, tableName, expected.name));
480
+ calls.push(new DataTransformCall(`handle-nulls-${tableName}-${expected.name}`, `${slot}:check`, `${slot}:run`, "data", {
481
+ schema: schemaName,
482
+ table: tableName,
483
+ column: expected.name
484
+ }), new SetNotNullCall(schemaName, tableName, expected.name));
269
485
  }
270
486
  if (matched.length === 0) return { kind: "no_match" };
271
487
  return {
@@ -288,7 +504,7 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
288
504
  if (Object.keys(storageTypes).length === 0) return { kind: "no_match" };
289
505
  const calls = [];
290
506
  for (const [typeName, typeInstance] of Object.entries(storageTypes).sort(([a], [b]) => a.localeCompare(b))) {
291
- const codecInstance = typeInstance;
507
+ const codecInstance = blindCast(typeInstance);
292
508
  const hook = ctx.codecHooks.get(codecInstance.codecId);
293
509
  if (!hook?.planTypeOperations) continue;
294
510
  const planResult = hook.planTypeOperations({
@@ -300,13 +516,13 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
300
516
  policy: ctx.policy
301
517
  });
302
518
  if (!planResult) continue;
303
- for (const op of planResult.operations) calls.push(new RawSqlCall({
519
+ for (const op of planResult.operations) calls.push(new RawSqlCall(blindCast({
304
520
  ...op,
305
521
  target: {
306
522
  id: op.target.id,
307
523
  details: buildTargetDetails("type", typeName, ctx.schemaName)
308
524
  }
309
- }));
525
+ })));
310
526
  }
311
527
  if (calls.length === 0) return { kind: "no_match" };
312
528
  return {
@@ -324,7 +540,8 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
324
540
  * nullable → backfill identity value → `SET NOT NULL` → `DROP DEFAULT`).
325
541
  * The temp-default value is resolved from the column node's `codecRef`
326
542
  * (`resolveColumnTemporaryDefault`, wrapping `resolveIdentityValue`).
327
- * - Empty-table guarded: emit a hand-built op with a `tableIsEmptyCheck`
543
+ * - Empty-table guarded, for a column in a key, or whose values come from a value set, which
544
+ * no one value stands in for: emit a hand-built op with a `tableIsEmptyCheck`
328
545
  * precheck so the failure message is "table is not empty" rather than the
329
546
  * raw PG NOT NULL violation.
330
547
  *
@@ -334,9 +551,6 @@ const storageTypePlanCallStrategy = (issues, ctx) => {
334
551
  const notNullAddColumnCallStrategy = (issues, ctx) => {
335
552
  const matched = [];
336
553
  const calls = [];
337
- const schemaLookups = buildSchemaLookupMap(ctx.schema);
338
- const mutableCodecHooks = ctx.codecHooks;
339
- const mutableStorageTypes = ctx.storageTypes;
340
554
  for (const issue of issues) {
341
555
  if (issueOutcome(issue) !== "not-found") continue;
342
556
  const node = issueNode(issue);
@@ -351,30 +565,12 @@ const notNullAddColumnCallStrategy = (issues, ctx) => {
351
565
  const contractTable = tableAt(ctx.toContract.storage, namespaceId, tableName);
352
566
  const column = contractTable?.columns[expected.name];
353
567
  if (!contractTable || !column) continue;
354
- const schemaTable = ctx.schema.tables[tableName];
355
- if (!schemaTable) continue;
356
- const temporaryDefault = resolveColumnTemporaryDefault(expected, ctx.codecHooks);
357
- const schemaLookup = schemaLookups.get(tableName);
358
- const canUseSharedTempDefault = temporaryDefault !== null && canUseSharedTemporaryDefaultStrategy({
359
- table: contractTable,
360
- schemaTable,
361
- schemaLookup,
362
- columnName: expected.name
363
- });
568
+ if (ctx.schema.tables[tableName] === void 0) continue;
569
+ const temporaryDefault = resolveColumnTemporaryDefault(expected, ctx.codecHooks, ctx.types);
570
+ const canUseSharedTempDefault = temporaryDefault !== null && columnTakesTemporaryValue(contractTable, expected.name);
364
571
  matched.push(issue);
365
- if (canUseSharedTempDefault && temporaryDefault !== null) {
366
- calls.push(new AddNotNullColumnWithTempDefaultCall({
367
- schemaName,
368
- tableName,
369
- columnName: expected.name,
370
- column,
371
- codecHooks: mutableCodecHooks,
372
- storageTypes: mutableStorageTypes,
373
- temporaryDefault
374
- }));
375
- continue;
376
- }
377
- calls.push(new AddNotNullColumnDirectCall(schemaName, tableName, expected.name, renderColumnDdl(expected.name, expected, ctx.codecHooks)));
572
+ const ddl = renderColumnDdl(expected.name, expected);
573
+ calls.push(canUseSharedTempDefault && temporaryDefault !== null ? new AddColumnWithTemporaryDefaultCall(schemaName, tableName, ddl.name, ddl.type, temporaryDefault, ctx.dataTypes) : new AddRequiredColumnToEmptyTableCall(schemaName, tableName, ddl.name, ddl.type, ctx.dataTypes));
378
574
  }
379
575
  if (matched.length === 0) return { kind: "no_match" };
380
576
  return {
@@ -383,36 +579,19 @@ const notNullAddColumnCallStrategy = (issues, ctx) => {
383
579
  calls
384
580
  };
385
581
  };
386
- function canUseSharedTemporaryDefaultStrategy(options) {
387
- const { table, schemaTable, schemaLookup, columnName } = options;
388
- if (table.primaryKey?.columns.includes(columnName) && !schemaTable.primaryKey) return false;
389
- for (const unique of table.uniques) {
390
- if (!unique.columns.includes(columnName)) continue;
391
- if (!schemaLookup || !hasUniqueConstraint(schemaLookup, unique.columns)) return false;
392
- }
393
- for (const foreignKey of table.foreignKeys) {
394
- if (!foreignKey.source.columns.includes(columnName)) continue;
395
- if (!schemaLookup || !hasForeignKey(schemaLookup, foreignKey)) return false;
396
- }
397
- return true;
398
- }
399
582
  /**
400
583
  * Ordered list of Postgres planner strategies, shared by `migration plan`
401
584
  * and `db update` / `db init`. The issue planner runs each strategy in
402
585
  * order, letting it consume any issues it handles, and routes whatever's
403
- * left through `mapNodeIssueToCall`. Behavior diverges purely on
404
- * `policy.allowedOperationClasses`:
405
- *
406
- * - When `'data'` is allowed (`migration plan`), the data-safe strategies
407
- * (`notNullBackfillCallStrategy`, `typeChangeCallStrategy`,
408
- * `nullableTighteningCallStrategy`) consume their matching issues and emit
409
- * `DataTransformCall` placeholders or recipe ops.
586
+ * left through `mapNodeIssueToCall`.
410
587
  *
411
- * - When `'data'` is not allowed (`db update` / `db init`), the
412
- * placeholder-emitting strategies short-circuit to `no_match`, leaving
413
- * the issue for the downstream strategies (`storageTypePlanCallStrategy`,
414
- * `notNullAddColumnCallStrategy`) or the `mapNodeIssueToCall` default to
415
- * handle with direct DDL.
588
+ * The strategies that write a placeholder (`notNullBackfillCallStrategy`,
589
+ * `typeChangeCallStrategy`, `nullableTighteningCallStrategy`) act only on a
590
+ * field a `--backfill` or `--convert` statement names, and only when the
591
+ * policy allows `data` (`migration plan`). Every other required field added to
592
+ * an existing table gets the temporary default of
593
+ * `notNullAddColumnCallStrategy`, and every other change the direct DDL of
594
+ * `mapNodeIssueToCall`, under either command.
416
595
  *
417
596
  * Codec-typed storage type entries are dispatched through
418
597
  * `storageTypePlanCallStrategy`.
@@ -422,7 +601,8 @@ const postgresPlannerStrategies = [
422
601
  typeChangeCallStrategy,
423
602
  nullableTighteningCallStrategy,
424
603
  storageTypePlanCallStrategy,
425
- notNullAddColumnCallStrategy
604
+ notNullAddColumnCallStrategy,
605
+ primaryKeyChangeStrategy
426
606
  ];
427
607
  function issueConflict(kind, summary, location) {
428
608
  return {
@@ -459,13 +639,18 @@ function classifyCall(call) {
459
639
  case "dropIndex":
460
640
  case "dropDefault": return "drop";
461
641
  case "addCheckConstraint":
462
- case "renameCheckConstraint": return "unique";
463
- case "createTable": return "table";
642
+ case "renameConstraint": return "unique";
643
+ case "createTable":
644
+ case "renameTable":
645
+ case "setTableSchema":
646
+ case "renameSchema": return "table";
647
+ case "dropSchema": return "dropSchema";
464
648
  case "enableRowLevelSecurity":
465
649
  case "disableRowLevelSecurity": return "rlsEnable";
466
650
  case "createRlsPolicy": return "rlsPolicy";
467
651
  case "dropRlsPolicy": return "drop";
468
- case "addColumn": return "column";
652
+ case "addColumn":
653
+ case "renameColumn": return "column";
469
654
  case "alterColumnType":
470
655
  case "setNotNull":
471
656
  case "dropNotNull":
@@ -476,7 +661,7 @@ function classifyCall(call) {
476
661
  case "renameIndex": return "index";
477
662
  case "addForeignKey": return "foreignKey";
478
663
  case "rawSql":
479
- if (call.op?.target?.details?.objectType === "type") return "dep";
664
+ if (blindCast(call).op?.target?.details?.objectType === "type") return "dep";
480
665
  return "alter";
481
666
  default: return "alter";
482
667
  }
@@ -490,6 +675,13 @@ const DEFAULT_POLICY = { allowedOperationClasses: [
490
675
  function emptySchemaIR() {
491
676
  return new SqlSchemaIR({ tables: {} });
492
677
  }
678
+ /**
679
+ * Foreign key drops run first, then primary key and unique constraint drops, then the rest. A constraint never needs another object dropped before it, and a column or table drop takes its constraints with it, so this order is always valid.
680
+ */
681
+ function dropRank(call) {
682
+ if (call.factoryName !== "dropConstraint") return 2;
683
+ return call.kind === "foreignKey" ? 0 : 1;
684
+ }
493
685
  function conflictKindForCall(call) {
494
686
  switch (call.factoryName) {
495
687
  case "alterColumnType": return "typeMismatch";
@@ -507,7 +699,7 @@ function conflictKindForCall(call) {
507
699
  }
508
700
  }
509
701
  function locationForCall(call) {
510
- const anyCall = call;
702
+ const anyCall = blindCast(call);
511
703
  const location = {};
512
704
  if (anyCall.tableName) {
513
705
  location.entityKind = "table";
@@ -516,7 +708,8 @@ function locationForCall(call) {
516
708
  location.entityKind = "native_enum";
517
709
  location.entityName = anyCall.typeName;
518
710
  }
519
- if (anyCall.columnName) location.column = anyCall.columnName;
711
+ const columnName = columnNameOfCall(call);
712
+ if (columnName) location.column = columnName;
520
713
  if (anyCall.indexName) location.index = anyCall.indexName;
521
714
  else if (anyCall.newIndexName) location.index = anyCall.newIndexName;
522
715
  if (anyCall.constraintName) location.constraint = anyCall.constraintName;
@@ -524,7 +717,7 @@ function locationForCall(call) {
524
717
  if (anyCall.policyName) location.rlsPolicy = anyCall.policyName;
525
718
  else if (anyCall.policy?.name) location.rlsPolicy = anyCall.policy.name;
526
719
  else if (anyCall.newPolicyName) location.rlsPolicy = anyCall.newPolicyName;
527
- return Object.keys(location).length > 0 ? location : void 0;
720
+ return Object.keys(location).length > 0 ? blindCast(location) : void 0;
528
721
  }
529
722
  function conflictForDisallowedCall(call, allowed) {
530
723
  const summary = `Operation "${call.label}" requires class "${call.operationClass}", but policy allows only: ${allowed.join(", ")}`;
@@ -533,6 +726,7 @@ function conflictForDisallowedCall(call, allowed) {
533
726
  kind: conflictKindForCall(call),
534
727
  summary,
535
728
  why: "Use `migration new` to author a custom migration for this change.",
729
+ refusedOperationClass: call.operationClass,
536
730
  ...location ? { location } : {}
537
731
  };
538
732
  }
@@ -566,15 +760,11 @@ function issueColumnName(issue) {
566
760
  * at runtime (`boundSchema`). Recovers the logical namespace id via the
567
761
  * contract and substitutes the unbound sentinel back in when it resolves
568
762
  * there; every other namespace's `ddlSchemaName` already agrees between the
569
- * two resolution paths, so it passes through unchanged.
763
+ * two resolution paths, so it passes through unchanged. A schema the contract
764
+ * does not declare, such as one the origin contract had, stays qualified.
570
765
  */
571
766
  function emissionSchemaName(ctx, ddlSchemaName) {
572
- return resolveNamespaceIdForDdlSchema(ctx.toContract, ddlSchemaName) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchemaName;
573
- }
574
- /** Whether the expected/actual native type (resolved, or raw+many fallback) differs — mirrors `SqlColumnIR.isEqualTo`'s type comparison. */
575
- function columnTypeChanged(expected, actual) {
576
- if (expected.resolvedNativeType !== void 0 && actual.resolvedNativeType !== void 0) return expected.resolvedNativeType !== actual.resolvedNativeType;
577
- return expected.nativeType !== actual.nativeType || Boolean(expected.many) !== Boolean(actual.many);
767
+ return resolveNamespaceIdForDdlSchema(ctx.toContract, ddlSchemaName) === UNBOUND_NAMESPACE_ID && ddlSchemaName === "public" && Object.hasOwn(ctx.toContract.storage.namespaces, UNBOUND_NAMESPACE_ID) ? UNBOUND_NAMESPACE_ID : ddlSchemaName;
578
768
  }
579
769
  /**
580
770
  * The generic differ is total: a missing/extra table (or column) emits an
@@ -588,7 +778,30 @@ function columnTypeChanged(expected, actual) {
588
778
  function coalesceSubtreeIssues(issues) {
589
779
  const collapsingPaths = issues.filter((issue) => issueOutcome(issue) !== "not-equal").map((issue) => issue.path);
590
780
  if (collapsingPaths.length === 0) return issues;
591
- return issues.filter((issue) => !collapsingPaths.some((ancestor) => isStrictDescendantPath(issue.path, ancestor)));
781
+ const isCollapsed = (issue) => collapsingPaths.some((ancestor) => isStrictDescendantPath(issue.path, ancestor));
782
+ const collapsed = issues.filter(isCollapsed);
783
+ const kept = issues.filter((issue) => !isCollapsed(issue));
784
+ const inherited = new Map(kept.map((issue) => [issue, subtreeDependencies(issue, collapsed)]));
785
+ const dependsOnTarget = (from, to) => (inherited.get(from) ?? []).some((path) => samePath(path, to.path));
786
+ return kept.map((issue) => {
787
+ const extra = (inherited.get(issue) ?? []).filter((path) => !kept.some((other) => samePath(other.path, path) && dependsOnTarget(other, issue)));
788
+ return extra.length === 0 ? issue : {
789
+ ...issue,
790
+ dependsOn: [...issue.dependsOn ?? [], ...extra]
791
+ };
792
+ });
793
+ }
794
+ /**
795
+ * The dependencies a dropped issue's collapsed subtree has outside the subtree, such as the tables
796
+ * its foreign keys name, so a whole-table drop runs before the drop of a table it references. Two
797
+ * dropped tables that reference each other keep neither edge.
798
+ */
799
+ function subtreeDependencies(issue, collapsed) {
800
+ if (issueOutcome(issue) !== "not-expected") return [];
801
+ return collapsed.filter((descendant) => isStrictDescendantPath(descendant.path, issue.path)).flatMap((descendant) => descendant.dependsOn ?? []).filter((path) => !isStrictDescendantPath(path, issue.path) && !samePath(path, issue.path));
802
+ }
803
+ function samePath(left, right) {
804
+ return left.length === right.length && left.every((segment, index) => segment === right[index]);
592
805
  }
593
806
  function isStrictDescendantPath(path, ancestor) {
594
807
  if (path.length <= ancestor.length) return false;
@@ -597,7 +810,7 @@ function isStrictDescendantPath(path, ancestor) {
597
810
  }
598
811
  function fkSpecFromNode(fk, tableName) {
599
812
  return {
600
- name: fk.name ?? `${tableName}_${fk.columns.join("_")}_fkey`,
813
+ name: fk.name ?? defaultForeignKeyName(tableName, fk.columns),
601
814
  columns: [...fk.columns],
602
815
  references: {
603
816
  schema: fk.referencedSchema ?? "",
@@ -616,8 +829,8 @@ function fkSpecFromNode(fk, tableName) {
616
829
  * FK / unique constraints are separate calls (re-bucketed downstream). Every
617
830
  * column's DDL is resolved from its `codecRef` via `renderColumnDdl`.
618
831
  */
619
- function buildCreateTableCallsFromNode(schemaName, ddlSchemaName, table, codecHooks) {
620
- const ddlColumns = Object.values(table.columns).map((c) => renderColumnDdl(c.name, c, codecHooks));
832
+ function buildCreateTableCallsFromNode(schemaName, ddlSchemaName, table) {
833
+ const ddlColumns = Object.values(table.columns).map((c) => renderColumnDdl(c.name, c));
621
834
  const primaryKeyConstraints = table.primaryKey ? [contractFree.primaryKey([...table.primaryKey.columns], { ...ifDefined("name", table.primaryKey.name) })] : [];
622
835
  const declaredChecks = (table.checks ?? []).map((c) => contractFree.checkExpression(c.name, c.expression));
623
836
  const allTableConstraints = [...primaryKeyConstraints, ...declaredChecks];
@@ -625,7 +838,7 @@ function buildCreateTableCallsFromNode(schemaName, ddlSchemaName, table, codecHo
625
838
  for (const index of table.indexes) calls.push(createIndexCallFromNode(index, schemaName, table.name));
626
839
  for (const fk of table.foreignKeys) calls.push(new AddForeignKeyCall(schemaName, table.name, fkSpecFromNode(fk, table.name)));
627
840
  for (const unique of table.uniques) {
628
- const constraintName = unique.name ?? `${table.name}_${unique.columns.join("_")}_key`;
841
+ const constraintName = unique.name ?? defaultUniqueName(table.name, unique.columns);
629
842
  calls.push(new AddUniqueCall(schemaName, table.name, constraintName, [...unique.columns]));
630
843
  }
631
844
  if (table.rlsEnabled) calls.push(new EnableRowLevelSecurityCall(ddlSchemaName, table.name));
@@ -649,12 +862,12 @@ function isNativeEnumSuffixAppend(actualMembers, expectedMembers) {
649
862
  }
650
863
  /** Operator-worded refusal for a native-enum member change beyond a suffix append (design ruling — tests match this verbatim). */
651
864
  function nativeEnumMemberChangeRefusal(options) {
652
- return `Native enum type "${options.ddlSchemaName}"."${options.typeName}" changed beyond appending new values (contract declares [${options.expectedMembers.join(", ")}], database has [${options.actualMembers.join(", ")}]). Prisma Next does not modify a native enum's existing values (rename, removal, reorder) — see https://pris.ly/d/postgres-native-enums. Author the change manually with \`migration new\`.`;
865
+ return `Native enum type "${options.ddlSchemaName}"."${options.typeName}" changed beyond appending new values (contract declares [${options.expectedMembers.join(", ")}], database has [${options.actualMembers.join(", ")}]). Prisma 8 does not modify a native enum's existing values (rename, removal, reorder) — see https://pris.ly/d/postgres-native-enums. Author the change manually with \`migration new\`.`;
653
866
  }
654
867
  /**
655
868
  * Managed native-enum issue -> op lowering. A missing declared type creates
656
869
  * it; an unclaimed live type drops it (ownership-scoped upstream by
657
- * `retainUnownedExtras`, destructiveness gated by the operation-class
870
+ * `retainUnownedExtras`, and the `widening` drop gated by the operation-class
658
871
  * policy); a paired member-value mismatch lowers to one `ALTER TYPE ... ADD
659
872
  * VALUE` per appended member when the database's members are a strict,
660
873
  * order-preserving prefix of the contract's — any other change (rename,
@@ -681,8 +894,8 @@ function mapNativeEnumNodeIssue(issue, ctx) {
681
894
  actualMembers: actual.members
682
895
  })));
683
896
  }
684
- function mapTableNodeIssue(issue, schemaName, ddlSchemaName, codecHooks) {
685
- if (issueOutcome(issue) === "not-found") return ok(buildCreateTableCallsFromNode(schemaName, ddlSchemaName, blindCast(issue.expected), codecHooks));
897
+ function mapTableNodeIssue(issue, schemaName, ddlSchemaName) {
898
+ if (issueOutcome(issue) === "not-found") return ok(buildCreateTableCallsFromNode(schemaName, ddlSchemaName, blindCast(issue.expected)));
686
899
  if (issueOutcome(issue) === "not-expected") return ok([new DropTableCall(schemaName, blindCast(issue.actual).name)]);
687
900
  const expected = blindCast(issue.expected);
688
901
  const actual = blindCast(issue.actual);
@@ -690,57 +903,59 @@ function mapTableNodeIssue(issue, schemaName, ddlSchemaName, codecHooks) {
690
903
  if (!expected.rlsEnabled && actual.rlsEnabled) return ok([new DisableRowLevelSecurityCall(ddlSchemaName, expected.name)]);
691
904
  return notOk(nodeConflict("unsupportedOperation", `unhandled table-attribute drift on "${expected.name}": table not-equal with no rlsEnabled delta (a second table attribute drifted)`));
692
905
  }
693
- function mapColumnNodeIssue(issue, schemaName, tableName, codecHooks) {
906
+ function mapColumnNodeIssue(issue, schemaName, tableName, dataTypes) {
694
907
  if (issueOutcome(issue) === "not-found") {
695
908
  const column = blindCast(issue.expected);
696
- return ok([new AddColumnCall(schemaName, tableName, renderColumnDdl(column.name, column, codecHooks))]);
909
+ return ok([new AddColumnCall(schemaName, tableName, renderColumnDdl(column.name, column), dataTypes)]);
697
910
  }
698
911
  if (issueOutcome(issue) === "not-expected") return ok([new DropColumnCall(schemaName, tableName, blindCast(issue.actual).name)]);
699
912
  const expected = blindCast(issue.expected);
700
913
  const actual = blindCast(issue.actual);
701
914
  const calls = [];
702
- if (columnTypeChanged(expected, actual)) {
703
- const { qualifiedTargetType, formatTypeExpected } = renderColumnAlterType(expected, codecHooks);
704
- calls.push(new AlterColumnTypeCall(schemaName, tableName, expected.name, {
705
- qualifiedTargetType,
706
- formatTypeExpected,
707
- rawTargetTypeForLabel: qualifiedTargetType
708
- }));
709
- }
915
+ if (!sqlColumnTypesEqual(expected, actual)) calls.push(new AlterColumnTypeCall({
916
+ schemaName,
917
+ tableName,
918
+ columnName: expected.name,
919
+ type: renderColumnAlterType(expected),
920
+ ...expected.catalogText !== void 0 ? { raw: true } : {},
921
+ dataTypes,
922
+ ownsAutoincrementSequence: hasAutoincrementDefault(actual),
923
+ operationClass: liveColumnWidensSafely(expected, actual) ? "widening" : "destructive"
924
+ }));
710
925
  if (expected.nullable !== actual.nullable) calls.push(expected.nullable ? new DropNotNullCall(schemaName, tableName, expected.name) : new SetNotNullCall(schemaName, tableName, expected.name));
711
926
  return ok(calls);
712
927
  }
713
- function mapColumnDefaultNodeIssue(issue, schemaName, tableName, columnName) {
928
+ function mapColumnDefaultNodeIssue(issue, schemaName, tableName, columnName, types) {
714
929
  if (issueOutcome(issue) === "not-expected") return ok([new DropDefaultCall(schemaName, tableName, columnName)]);
715
930
  if (issue.expected === void 0) return ok([]);
716
- const defaultSql = renderColumnDefaultSql(blindCast(issue.expected));
717
- if (!defaultSql) return ok([]);
718
- return ok([new SetDefaultCall(schemaName, tableName, columnName, defaultSql, issueOutcome(issue) === "not-equal" ? "widening" : "additive")]);
931
+ const column = buildSetDefaultColumn(columnName, blindCast(issue.expected), types);
932
+ if (column === void 0) return ok([]);
933
+ return ok([new SetDefaultCall(schemaName, tableName, column, issueOutcome(issue) === "not-equal" ? "widening" : "additive")]);
719
934
  }
935
+ /** A missing primary key is added. A changed or removed key is planned only by `primaryKeyChangeStrategy`, which also handles the foreign keys that depend on it; one that reaches this mapper is refused. */
720
936
  function mapPrimaryKeyNodeIssue(issue, schemaName, tableName) {
721
- if (issueOutcome(issue) === "not-found") {
722
- const pk = blindCast(issue.expected);
723
- return ok([new AddPrimaryKeyCall(schemaName, tableName, pk.name ?? `${tableName}_pkey`, [...pk.columns])]);
724
- }
725
- if (issueOutcome(issue) === "not-expected") return ok([new DropConstraintCall(schemaName, tableName, blindCast(issue.actual).name ?? `${tableName}_pkey`, "primaryKey")]);
726
- return notOk(nodeConflict("indexIncompatible", issue.path.join("/")));
937
+ if (issueOutcome(issue) !== "not-found") return notOk(nodeConflict("indexIncompatible", issue.path.join("/")));
938
+ const pk = blindCast(issue.expected);
939
+ return ok([new AddPrimaryKeyCall(schemaName, tableName, pk.name ?? defaultPrimaryKeyName(tableName), [...pk.columns])]);
727
940
  }
728
941
  function mapForeignKeyNodeIssue(issue, schemaName, tableName) {
729
942
  if (issueOutcome(issue) === "not-found") return ok([new AddForeignKeyCall(schemaName, tableName, fkSpecFromNode(blindCast(issue.expected), tableName))]);
730
943
  if (issueOutcome(issue) === "not-expected") {
731
944
  const fk = blindCast(issue.actual);
732
- return ok([new DropConstraintCall(schemaName, tableName, fk.name ?? `${tableName}_${fk.columns.join("_")}_fkey`, "foreignKey")]);
945
+ return ok([new DropConstraintCall(schemaName, tableName, fk.name ?? defaultForeignKeyName(tableName, fk.columns), "foreignKey")]);
733
946
  }
734
- return notOk(nodeConflict("foreignKeyConflict", issue.path.join("/")));
947
+ const expected = blindCast(issue.expected);
948
+ const actual = blindCast(issue.actual);
949
+ return ok([new DropConstraintCall(schemaName, tableName, actual.name ?? defaultForeignKeyName(tableName, actual.columns), "foreignKey"), new AddForeignKeyCall(schemaName, tableName, fkSpecFromNode(expected, tableName))]);
735
950
  }
736
951
  function mapUniqueNodeIssue(issue, schemaName, tableName) {
737
952
  if (issueOutcome(issue) === "not-found") {
738
953
  const unique = blindCast(issue.expected);
739
- return ok([new AddUniqueCall(schemaName, tableName, unique.name ?? `${tableName}_${unique.columns.join("_")}_key`, [...unique.columns])]);
954
+ return ok([new AddUniqueCall(schemaName, tableName, unique.name ?? defaultUniqueName(tableName, unique.columns), [...unique.columns])]);
740
955
  }
741
956
  if (issueOutcome(issue) === "not-expected") {
742
957
  const unique = blindCast(issue.actual);
743
- return ok([new DropConstraintCall(schemaName, tableName, unique.name ?? `${tableName}_${unique.columns.join("_")}_key`, "unique")]);
958
+ return ok([new DropConstraintCall(schemaName, tableName, unique.name ?? defaultUniqueName(tableName, unique.columns), "unique")]);
744
959
  }
745
960
  return notOk(nodeConflict("indexIncompatible", issue.path.join("/")));
746
961
  }
@@ -795,12 +1010,12 @@ function mapNodeIssueToCall(issue, ctx) {
795
1010
  if (ddlSchemaName === void 0 || tableName === void 0) return notOk(nodeConflict("unsupportedOperation", `Issue has no schema/table in its path: ${issue.path.join("/")}`));
796
1011
  const schemaName = emissionSchemaName(ctx, ddlSchemaName);
797
1012
  switch (node.nodeKind) {
798
- case PostgresSchemaNodeKind.table: return mapTableNodeIssue(issue, schemaName, ddlSchemaName, ctx.codecHooks);
799
- case RelationalSchemaNodeKind.column: return mapColumnNodeIssue(issue, schemaName, tableName, ctx.codecHooks);
1013
+ case PostgresSchemaNodeKind.table: return mapTableNodeIssue(issue, schemaName, ddlSchemaName);
1014
+ case RelationalSchemaNodeKind.column: return mapColumnNodeIssue(issue, schemaName, tableName, ctx.dataTypes);
800
1015
  case RelationalSchemaNodeKind.columnDefault: {
801
1016
  const columnName = issueColumnName(issue);
802
1017
  if (columnName === void 0) return notOk(nodeConflict("unsupportedOperation", `Default issue has no column in its path: ${issue.path.join("/")}`));
803
- return mapColumnDefaultNodeIssue(issue, schemaName, tableName, columnName);
1018
+ return mapColumnDefaultNodeIssue(issue, schemaName, tableName, columnName, ctx.types);
804
1019
  }
805
1020
  case RelationalSchemaNodeKind.primaryKey: return mapPrimaryKeyNodeIssue(issue, schemaName, tableName);
806
1021
  case RelationalSchemaNodeKind.foreignKey: return mapForeignKeyNodeIssue(issue, schemaName, tableName);
@@ -827,26 +1042,36 @@ function planIssues(options) {
827
1042
  fromContract: options.fromContract,
828
1043
  schemaName: options.schemaName,
829
1044
  codecHooks: options.codecHooks,
830
- storageTypes: options.storageTypes,
1045
+ types: options.types,
831
1046
  schema,
1047
+ startTree: options.startTree,
1048
+ endTree: options.endTree,
1049
+ allIssues: options.issues,
1050
+ foreignKeyDropAuthority: options.foreignKeyDropAuthority,
832
1051
  policy,
833
- frameworkComponents
1052
+ frameworkComponents,
1053
+ statementColumns: options.statementColumns ?? {
1054
+ convert: [],
1055
+ backfill: []
1056
+ },
1057
+ dataTypes: stackDataTypes(frameworkComponents)
834
1058
  };
835
1059
  const strategies = options.strategies ?? postgresPlannerStrategies;
836
1060
  let remaining = options.issues;
837
1061
  const recipeCalls = [];
838
1062
  const bucketablePatternCalls = [];
1063
+ const conflicts = [];
839
1064
  for (const strategy of strategies) {
840
1065
  const result = strategy(remaining, context);
841
1066
  if (result.kind === "match") {
842
1067
  remaining = result.issues;
1068
+ conflicts.push(...result.conflicts ?? []);
843
1069
  if (result.recipe) recipeCalls.push(...result.calls);
844
1070
  else bucketablePatternCalls.push(...result.calls);
845
1071
  }
846
1072
  }
847
1073
  const sorted = orderIssuesByDependencies(remaining);
848
1074
  const defaultCalls = [];
849
- const conflicts = [];
850
1075
  for (const issue of sorted) {
851
1076
  const result = mapNodeIssueToCall(issue, context);
852
1077
  if (result.ok) defaultCalls.push(...result.value);
@@ -879,9 +1104,10 @@ function planIssues(options) {
879
1104
  const byCategory = (cat) => combinedBucketable.filter((c) => classifyCall(c) === cat);
880
1105
  return ok({ calls: [
881
1106
  ...byCategory("dep"),
882
- ...byCategory("drop"),
1107
+ ...byCategory("drop").sort((a, b) => dropRank(a) - dropRank(b)),
883
1108
  ...byCategory("dropType"),
884
1109
  ...byCategory("table"),
1110
+ ...byCategory("dropSchema"),
885
1111
  ...byCategory("column"),
886
1112
  ...gatedRecipe,
887
1113
  ...byCategory("alter"),
@@ -958,7 +1184,7 @@ function postgresCallFields(call) {
958
1184
  return {
959
1185
  ...ifDefined("schemaName", "schemaName" in call ? call.schemaName : void 0),
960
1186
  ...ifDefined("tableName", "tableName" in call ? call.tableName : void 0),
961
- ...ifDefined("columnName", "columnName" in call ? call.columnName : void 0)
1187
+ ...ifDefined("columnName", columnNameOfCall(call))
962
1188
  };
963
1189
  }
964
1190
  function formatSuppressionSubjectLabel(subject, contract) {
@@ -1133,6 +1359,6 @@ function resolvePostgresNodeIssueControlPolicySubject(issue, contract) {
1133
1359
  };
1134
1360
  }
1135
1361
  //#endregion
1136
- export { planIssues as a, renderPostgresSuppression as c, resolvePostgresNodeIssueControlPolicySubject as d, resolvePostgresNodeIssueCreationFactoryName as f, issueSchemaName as i, resolveNamespaceIdForDdlSchema as l, conflictForDisallowedCall as n, postgresNodeStorageCoordinate as o, issueNode as r, postgresPlannerStrategies as s, coalesceSubtreeIssues as t, resolvePostgresCallControlPolicySubject as u };
1362
+ export { planIssues as a, renderPostgresSuppression as c, resolvePostgresNodeIssueControlPolicySubject as d, resolvePostgresNodeIssueCreationFactoryName as f, issueSchemaName as i, resolveNamespaceIdForDdlSchema as l, conflictForDisallowedCall as n, postgresNodeStorageCoordinate as o, tableAt as p, issueNode as r, postgresPlannerStrategies as s, coalesceSubtreeIssues as t, resolvePostgresCallControlPolicySubject as u };
1137
1363
 
1138
- //# sourceMappingURL=control-policy-B53lnBCT-B9K9Cj1x.mjs.map
1364
+ //# sourceMappingURL=control-policy-DtU5u9Dm-44r_OF94.mjs.map