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

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
@@ -0,0 +1,1312 @@
1
+ import { c as postgresError, t as errorPostgresMigrationStackMissing } from "./errors-BrhQYgdL-IvZHPjwL.mjs";
2
+ import { i as PostgresRlsPolicy } from "./postgres-schema-C6w1rzOF-D1fdwqRx.mjs";
3
+ import { n as PostgresSchemaNodeKind, r as PostgresTableSchemaNode } from "./postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs";
4
+ import { n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs";
5
+ import { t as postgresResolveDefault } from "./default-normalizer-BqK6XxdC-2OUb2ybG.mjs";
6
+ import { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage, t as ddlSchemaOfCallSchema } from "./resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs";
7
+ import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs";
8
+ import { i as hasAutoincrementDefault } from "./autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs";
9
+ import { a as stackDataTypes, o as writtenColumnType } from "./planner-sql-checks-D-K44J19-CzvrqzNB.mjs";
10
+ import { A as RenameColumnCall, B as alterColumnTypeCallText, C as DropNativeEnumTypeCall, D as DropTableCall, E as DropSchemaCall, F as RenameTableCall, K as renameTableStatement, L as SetDefaultCall, M as RenameIndexCall, N as RenamePostgresRlsPolicyCall, O as EnableRowLevelSecurityCall, P as RenameSchemaCall, R as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, U as installExtension, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddForeignKeyCall, j as RenameConstraintCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall, z as SetTableSchemaCall } from "./op-factory-call-gGX-mZu--0QUG5xH4.mjs";
11
+ import { l as resolveNamespaceIdForDdlSchema, r as issueNode } from "./control-policy-DtU5u9Dm-44r_OF94.mjs";
12
+ import { n as contractToPostgresDatabaseSchemaNode, t as buildPostgresPlanDiff } from "./diff-database-schema-DAEzWtzU-DoyVgKqh.mjs";
13
+ import { n as PostgresContractView } from "./postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs";
14
+ import { t as dataTransform } from "./data-transform-h9agBu_c-RlC5A7aY.mjs";
15
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
16
+ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
17
+ import { issueOutcome } from "@prisma/orm-framework/components/control";
18
+ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
19
+ import { nameOf, namingOf, namingOfLiveName, parseWireName } from "@prisma/orm-family-sql/schema-ir/naming";
20
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
21
+ import { sqlTextOf } from "@prisma/orm-family-sql/relational-core/contract-free";
22
+ import { PrimaryKey, RelationalSchemaNodeKind, SqlCheckConstraintIR, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR, sqlColumnTypesEqual } from "@prisma/orm-family-sql/schema-ir/types";
23
+ import { isArrayEqual } from "@prisma/orm-framework/utils/array-equal";
24
+ import { resolveColumnRenameAgainst, resolveTableRenameAgainst, sqlTypeLookupsOf, unmatchedColumnRename, unmatchedTableRename } from "@prisma/orm-family-sql/family/control";
25
+ import { errorMigrationOperationOptionRemoved } from "@prisma/orm-framework/errors/migration";
26
+ import { Migration } from "@prisma/orm-family-sql/family/migration";
27
+ import { MigrationContractViews } from "@prisma/orm-toolchain/migration-tools/migration";
28
+ //#region ../../../3-targets/postgres/1-target/dist/postgres-migration-BSWmeRLo.mjs
29
+ /**
30
+ * The Postgres schema tree a contract describes, as the planner's "from" side:
31
+ * the target descriptor's `migrations.contractToSchema` hook and the trees
32
+ * `renameTable` compares to find its companion renames both go through here,
33
+ * so they are built with the same type lookups and default resolver.
34
+ */
35
+ function postgresContractToSchema(contract, frameworkComponents) {
36
+ const types = sqlTypeLookupsOf(frameworkComponents);
37
+ return contractToPostgresDatabaseSchemaNode(blindCast(contract), {
38
+ annotationNamespace: "pg",
39
+ dataTypeLookup: types.dataTypeLookup,
40
+ codecLookup: types.codecLookup,
41
+ resolveDefault: postgresResolveDefault
42
+ });
43
+ }
44
+ /**
45
+ * Rename post-pass for indexes, per `(schema, table)`, widening-only,
46
+ * deterministic by sorted names — the same structure as the policy pass
47
+ * below (which stays untouched: policies pair by hash only).
48
+ *
49
+ * Hash pairing (prefix-only renames): extras whose live names parse as
50
+ * wire names, grouped by `(schema, table, hash)`; missing nodes iterated
51
+ * in sorted-name order consume the sorted-name-first candidate.
52
+ *
53
+ * Content pairing (exact→wire convergence), after hash pairing has
54
+ * consumed its matches: the remaining wire-named-missing nodes
55
+ * (`prefix` defined) against the remaining extras of any name shape,
56
+ * paired iff content-equal (columns ordered-strict both-defined-or-
57
+ * both-undefined, `unique`/`type` strict, `options` loose, bodies
58
+ * byte-equal).
59
+ *
60
+ * Leftovers proceed as create/drop exactly as before; without the
61
+ * widening allowance the pass is skipped and pairing degrades to the
62
+ * additive half, like the policy pass.
63
+ */
64
+ function pairIndexRenames(options, issues) {
65
+ const consumed = /* @__PURE__ */ new Set();
66
+ const calls = [];
67
+ if (!options.policy.allowedOperationClasses.includes("widening")) return {
68
+ calls,
69
+ consumed
70
+ };
71
+ const missing = [];
72
+ const extra = [];
73
+ for (const issue of issues) {
74
+ const node = issueNode(issue);
75
+ if (node === void 0 || !SqlIndexIR.is(node)) continue;
76
+ const ddlSchema = issue.path[1];
77
+ const tableName = issue.path[2];
78
+ if (ddlSchema === void 0 || tableName === void 0) continue;
79
+ if (issueOutcome(issue) === "not-found") missing.push({
80
+ issue,
81
+ node,
82
+ ddlSchema,
83
+ tableName
84
+ });
85
+ else if (issueOutcome(issue) === "not-expected") extra.push({
86
+ issue,
87
+ node,
88
+ ddlSchema,
89
+ tableName
90
+ });
91
+ }
92
+ if (missing.length === 0 || extra.length === 0) return {
93
+ calls,
94
+ consumed
95
+ };
96
+ const byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;
97
+ const emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;
98
+ const pairingKey = (finding, hash) => JSON.stringify([
99
+ finding.ddlSchema,
100
+ finding.tableName,
101
+ hash
102
+ ]);
103
+ const rename = (missingFinding, candidate) => {
104
+ consumed.add(missingFinding.issue);
105
+ consumed.add(candidate.issue);
106
+ calls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));
107
+ };
108
+ const sortedMissing = [...missing].sort(byName);
109
+ const extrasByHash = /* @__PURE__ */ new Map();
110
+ for (const finding of extra) {
111
+ const parsed = parseWireName(finding.node.name);
112
+ if (parsed === void 0) continue;
113
+ const key = pairingKey(finding, parsed.hash);
114
+ const group = extrasByHash.get(key) ?? [];
115
+ group.push(finding);
116
+ extrasByHash.set(key, group);
117
+ }
118
+ for (const group of extrasByHash.values()) group.sort(byName);
119
+ for (const missingFinding of sortedMissing) {
120
+ const parsed = parseWireName(missingFinding.node.name);
121
+ if (parsed === void 0) continue;
122
+ const candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();
123
+ if (candidate === void 0) continue;
124
+ rename(missingFinding, candidate);
125
+ }
126
+ const sortedExtras = [...extra].sort(byName);
127
+ for (const missingFinding of sortedMissing) {
128
+ if (consumed.has(missingFinding.issue)) continue;
129
+ if (missingFinding.node.prefix === void 0) continue;
130
+ const candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {
131
+ columnPresence: "matching",
132
+ bodies: "verbatim"
133
+ }));
134
+ if (candidate === void 0) continue;
135
+ rename(missingFinding, candidate);
136
+ }
137
+ return {
138
+ calls,
139
+ consumed
140
+ };
141
+ }
142
+ /**
143
+ * Check-constraint rename post-pass: a `not-found` and a `not-expected`
144
+ * check on the same table whose wire-name content hashes match but whose
145
+ * prefixes differ is a prefix-only rename, and collapses into one
146
+ * `ALTER TABLE … RENAME CONSTRAINT`.
147
+ *
148
+ * This is the index pass's hash-pairing phase and nothing else. There is
149
+ * deliberately no content-pairing phase: a live check body is whatever
150
+ * Postgres reprinted, so it never byte-matches the authored text, and
151
+ * pairing an exact-named live check by content would bless whatever
152
+ * predicate is actually live. Adoption of an old exact-named check stays
153
+ * drop + add.
154
+ *
155
+ * Runs only when the policy allows `widening` (rename's class). Without it
156
+ * the pass no-ops and the pair degrades to an add and a drop, and the drop,
157
+ * which is `widening` too, is refused as a conflict.
158
+ */
159
+ function pairCheckRenames(options, issues) {
160
+ const consumed = /* @__PURE__ */ new Set();
161
+ const calls = [];
162
+ if (!options.policy.allowedOperationClasses.includes("widening")) return {
163
+ calls,
164
+ consumed
165
+ };
166
+ const missing = [];
167
+ const extra = [];
168
+ for (const issue of issues) {
169
+ const node = issueNode(issue);
170
+ if (node === void 0 || !SqlCheckConstraintIR.is(node)) continue;
171
+ const ddlSchema = issue.path[1];
172
+ const tableName = issue.path[2];
173
+ if (ddlSchema === void 0 || tableName === void 0) continue;
174
+ if (issueOutcome(issue) === "not-found") missing.push({
175
+ issue,
176
+ node,
177
+ ddlSchema,
178
+ tableName
179
+ });
180
+ else if (issueOutcome(issue) === "not-expected") extra.push({
181
+ issue,
182
+ node,
183
+ ddlSchema,
184
+ tableName
185
+ });
186
+ }
187
+ if (missing.length === 0 || extra.length === 0) return {
188
+ calls,
189
+ consumed
190
+ };
191
+ const byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;
192
+ const emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;
193
+ const pairingKey = (finding, hash) => JSON.stringify([
194
+ finding.ddlSchema,
195
+ finding.tableName,
196
+ hash
197
+ ]);
198
+ const sortedMissing = [...missing].sort(byName);
199
+ const extrasByHash = /* @__PURE__ */ new Map();
200
+ for (const finding of extra) {
201
+ const parsed = parseWireName(finding.node.name);
202
+ if (parsed === void 0) continue;
203
+ const key = pairingKey(finding, parsed.hash);
204
+ const group = extrasByHash.get(key) ?? [];
205
+ group.push(finding);
206
+ extrasByHash.set(key, group);
207
+ }
208
+ for (const group of extrasByHash.values()) group.sort(byName);
209
+ for (const missingFinding of sortedMissing) {
210
+ const parsed = parseWireName(missingFinding.node.name);
211
+ if (parsed === void 0) continue;
212
+ const candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();
213
+ if (candidate === void 0) continue;
214
+ consumed.add(missingFinding.issue);
215
+ consumed.add(candidate.issue);
216
+ calls.push(new RenameConstraintCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, "checkConstraint", candidate.node.name, missingFinding.node.name));
217
+ }
218
+ return {
219
+ calls,
220
+ consumed
221
+ };
222
+ }
223
+ /**
224
+ * The tables of a Postgres schema, addressed by `contract`'s namespace ids, each mapped to its DDL
225
+ * schema.
226
+ */
227
+ function postgresSchemaTables(schema, contract) {
228
+ const tableIn = (namespaceId, table) => schema.namespaces[resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId)]?.tables[table];
229
+ const hasTable = (namespaceId, table) => tableIn(namespaceId, table) !== void 0;
230
+ return {
231
+ hasTable,
232
+ hasColumn: (namespaceId, table, column) => Object.hasOwn(tableIn(namespaceId, table)?.columns ?? {}, column),
233
+ tablesNamed: (namespaceId, table) => hasTable(namespaceId, table) ? [table] : [],
234
+ columnsNamed: (namespaceId, table, column) => Object.hasOwn(tableIn(namespaceId, table)?.columns ?? {}, column) ? [column] : [],
235
+ hasNamespace: (namespaceId) => {
236
+ const schemaName = resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId);
237
+ return schema.existingSchemas.includes(schemaName);
238
+ },
239
+ namespacesWithTable: (table) => Object.keys(contract.storage.namespaces).filter((namespaceId) => hasTable(namespaceId, table))
240
+ };
241
+ }
242
+ /**
243
+ * The constraint renames that follow a table rename. Each primary key, unique constraint and
244
+ * foreign key of the renamed table is paired with the destination constraint of the same kind on
245
+ * the same columns, and for a foreign key the same referenced columns. Foreign keys pair first
246
+ * with destination keys to the same referenced table, and the rest then pair with keys to another
247
+ * table, because a later rename in the same plan may change that table and a foreign key's derived
248
+ * name never depends on it. A paired constraint is renamed to the destination's explicit name, or else
249
+ * to the name the planner derives from the new table name, when that differs from its name in the
250
+ * database. Each destination constraint pairs with at most one constraint, in order. An unpaired
251
+ * constraint is being dropped or changed and keeps its name. Indexes and checks are not handled
252
+ * here: their wire names pair by content hash in the index and check rename passes.
253
+ */
254
+ function constraintRenamesForTableRename(input) {
255
+ return pairedConstraintRenames(input, {
256
+ primaryKey: true,
257
+ onColumns: () => true
258
+ });
259
+ }
260
+ /**
261
+ * The renames of the constraints in `scope` that pair with a destination constraint of the same
262
+ * kind on the same columns, to the destination's explicit name or else the derived one.
263
+ */
264
+ function pairedConstraintRenames(input, scope) {
265
+ const { schemaName, previous, next } = input;
266
+ const table = next.name;
267
+ const rename = (kind, actualName, target) => {
268
+ assertDefined(actualName, `the table "${previous.name}" has a ${kind} that has no name; the working schema names every primary key, unique and foreign key a rename can change`);
269
+ return target === void 0 || target === actualName ? [] : [new RenameConstraintCall(schemaName, table, kind, actualName, target)];
270
+ };
271
+ const nextPrimaryKey = next.primaryKey;
272
+ const primaryKey = previous.primaryKey === void 0 || !scope.primaryKey ? [] : rename("primaryKey", previous.primaryKey.name, nextPrimaryKey !== void 0 && isArrayEqual(previous.primaryKey.columns, nextPrimaryKey.columns) ? nextPrimaryKey.name ?? defaultPrimaryKeyName(table) : void 0);
273
+ const pairedUniques = /* @__PURE__ */ new Set();
274
+ const uniques = previous.uniques.filter((unique) => scope.onColumns(unique.columns)).flatMap((unique) => {
275
+ const paired = next.uniques.find((candidate) => !pairedUniques.has(candidate) && isArrayEqual(candidate.columns, unique.columns));
276
+ if (paired !== void 0) pairedUniques.add(paired);
277
+ return rename("unique", unique.name, paired === void 0 ? void 0 : paired.name ?? defaultUniqueName(table, paired.columns));
278
+ });
279
+ const previousForeignKeys = previous.foreignKeys.filter((fk) => scope.onColumns(fk.columns));
280
+ const pairing = pairForeignKeys(previousForeignKeys, next.foreignKeys);
281
+ const foreignKeys = previousForeignKeys.flatMap((fk) => {
282
+ const paired = pairing.get(fk);
283
+ return rename("foreignKey", fk.name, paired === void 0 ? void 0 : paired.name ?? defaultForeignKeyName(table, fk.columns));
284
+ });
285
+ return [
286
+ ...primaryKey,
287
+ ...uniques,
288
+ ...foreignKeys
289
+ ];
290
+ }
291
+ /**
292
+ * Pairs old foreign keys with destination keys on the same columns and referenced columns. Every
293
+ * key to the same referenced table pairs first, so an old key with no such match cannot take the
294
+ * destination key another old key keeps; the remaining keys then pair in order.
295
+ */
296
+ function pairForeignKeys(previous, next) {
297
+ const pairs = /* @__PURE__ */ new Map();
298
+ const taken = /* @__PURE__ */ new Set();
299
+ const pass = (accepts) => {
300
+ for (const fk of previous) {
301
+ if (pairs.has(fk)) continue;
302
+ const paired = next.find((candidate) => !taken.has(candidate) && isArrayEqual(candidate.columns, fk.columns) && isArrayEqual(candidate.referencedColumns, fk.referencedColumns) && accepts(fk, candidate));
303
+ if (paired === void 0) continue;
304
+ pairs.set(fk, paired);
305
+ taken.add(paired);
306
+ }
307
+ };
308
+ pass((fk, candidate) => candidate.referencedTable === fk.referencedTable && candidate.resolvedReferencedNamespace === fk.resolvedReferencedNamespace);
309
+ pass(() => true);
310
+ return pairs;
311
+ }
312
+ /**
313
+ * The constraint renames that follow a column rename. Each unique constraint and foreign key on
314
+ * the renamed column is paired with the destination constraint of the same kind on the same
315
+ * columns, and renamed to the destination's explicit name, or else to the name the planner derives
316
+ * from the table and the new column names, when that differs from its name in the database. The
317
+ * primary key's derived name does not depend on its columns, so it is left alone. `previous` is
318
+ * the table after the column rename, its constraint names as they are in the database.
319
+ */
320
+ function constraintRenamesForColumnRename(input) {
321
+ return pairedConstraintRenames(input, {
322
+ primaryKey: false,
323
+ onColumns: (columns) => columns.includes(input.column)
324
+ });
325
+ }
326
+ function rewriteRefs(refs, rewrite) {
327
+ return refs?.map(rewrite);
328
+ }
329
+ /**
330
+ * Rewrites the step of `kind` and `id` in a ref that runs through the given table, and the table
331
+ * step itself when `kind` is the table kind.
332
+ */
333
+ function stepRewrite(schemaName, tableName, kind, fromId, toId) {
334
+ return (ref) => {
335
+ const namespaceStep = ref[1];
336
+ const tableStep = ref[2];
337
+ if (namespaceStep?.nodeKind !== PostgresSchemaNodeKind.namespace || namespaceStep.id !== schemaName || tableStep?.nodeKind !== PostgresSchemaNodeKind.table || tableStep.id !== tableName) return ref;
338
+ return ref.map((step, index) => index >= 2 && step.nodeKind === kind && step.id === fromId ? {
339
+ nodeKind: kind,
340
+ id: toId
341
+ } : step);
342
+ };
343
+ }
344
+ function withPrimaryKey(primaryKey, name, rewrite, columnName) {
345
+ return new PrimaryKey({
346
+ columns: primaryKey.columns.map(columnName),
347
+ ...ifDefined("name", name),
348
+ ...ifDefined("dependsOn", rewriteRefs(primaryKey.dependsOn, rewrite))
349
+ });
350
+ }
351
+ function withUnique(unique, name, rewrite, columnName) {
352
+ return new SqlUniqueIR({
353
+ columns: unique.columns.map(columnName),
354
+ ...ifDefined("name", name),
355
+ ...ifDefined("annotations", unique.annotations),
356
+ ...ifDefined("dependsOn", rewriteRefs(unique.dependsOn, rewrite))
357
+ });
358
+ }
359
+ function withForeignKey(fk, overrides, rewrite, columnName) {
360
+ return new SqlForeignKeyIR({
361
+ columns: fk.columns.map(columnName),
362
+ referencedTable: overrides.referencedTable,
363
+ referencedColumns: overrides.referencedColumns ?? fk.referencedColumns,
364
+ ...ifDefined("referencedSchema", overrides.referencedSchema ?? fk.referencedSchema),
365
+ ...ifDefined("name", overrides.name),
366
+ ...ifDefined("onDelete", fk.onDelete),
367
+ ...ifDefined("onUpdate", fk.onUpdate),
368
+ ...ifDefined("annotations", fk.annotations),
369
+ ...ifDefined("resolvedReferencedNamespace", overrides.referencedSchema ?? fk.resolvedReferencedNamespace),
370
+ ...ifDefined("dependsOn", rewriteRefs(fk.dependsOn, rewrite))
371
+ });
372
+ }
373
+ /**
374
+ * An index whose definition carries SQL text, an expression or a predicate, keeps its columns as
375
+ * they are: a column named inside the text cannot be renamed here, so the diff plans the index.
376
+ */
377
+ function withIndex(index, naming, rewrite, columnName) {
378
+ const columnsFollow = index.expression === void 0 && index.where === void 0;
379
+ const base = {
380
+ naming,
381
+ where: index.where,
382
+ unique: index.unique,
383
+ partial: index.partial,
384
+ type: index.type,
385
+ options: index.options,
386
+ annotations: index.annotations,
387
+ dependsOn: rewriteRefs(index.dependsOn, rewrite)
388
+ };
389
+ return new SqlIndexIR(index.expression !== void 0 ? {
390
+ ...base,
391
+ expression: index.expression
392
+ } : {
393
+ ...base,
394
+ columns: (index.columns ?? []).map(columnsFollow ? columnName : (c) => c)
395
+ });
396
+ }
397
+ function withCheck(check, naming, rewrite) {
398
+ return new SqlCheckConstraintIR({
399
+ naming,
400
+ expression: check.expression,
401
+ dependsOn: rewriteRefs(check.dependsOn, rewrite)
402
+ });
403
+ }
404
+ function withPolicy(policy, overrides, rewrite) {
405
+ return new PostgresPolicySchemaNode({
406
+ naming: overrides.naming,
407
+ tableName: overrides.tableName,
408
+ namespaceId: overrides.namespaceId ?? policy.namespaceId,
409
+ operation: policy.operation,
410
+ roles: policy.roles,
411
+ using: policy.using,
412
+ withCheck: policy.withCheck,
413
+ permissive: policy.permissive,
414
+ dependsOn: rewriteRefs(policy.dependsOn, rewrite)
415
+ });
416
+ }
417
+ function unchangedEdit(table) {
418
+ return {
419
+ name: table.name,
420
+ primaryKeyName: (primaryKey) => primaryKey.name,
421
+ uniqueName: (unique) => unique.name,
422
+ foreignKey: (fk) => ({
423
+ name: fk.name,
424
+ referencedTable: fk.referencedTable
425
+ }),
426
+ columnName: (column) => column,
427
+ indexNaming: (index) => namingOf(index.name, index.prefix),
428
+ checkNaming: (check) => namingOf(check.name, check.prefix),
429
+ policy: (policy) => ({
430
+ naming: namingOf(policy.name, policy.prefix),
431
+ tableName: policy.tableName
432
+ })
433
+ };
434
+ }
435
+ function rebuildTable(table, edit, rewrite) {
436
+ const { columnName } = edit;
437
+ return new PostgresTableSchemaNode({
438
+ name: edit.name,
439
+ columns: Object.fromEntries(Object.values(table.columns).map((column) => {
440
+ const name = columnName(column.name);
441
+ return [name, name === column.name ? column : column.withName(name)];
442
+ })),
443
+ ...ifDefined("primaryKey", table.primaryKey === void 0 ? void 0 : withPrimaryKey(table.primaryKey, edit.primaryKeyName(table.primaryKey), rewrite, columnName)),
444
+ uniques: table.uniques.map((unique) => withUnique(unique, edit.uniqueName(unique), rewrite, columnName)),
445
+ foreignKeys: table.foreignKeys.map((fk) => withForeignKey(fk, edit.foreignKey(fk), rewrite, columnName)),
446
+ indexes: table.indexes.map((index) => withIndex(index, edit.indexNaming(index), rewrite, columnName)),
447
+ ...ifDefined("checks", table.checks?.map((check) => withCheck(check, edit.checkNaming(check), rewrite))),
448
+ ...ifDefined("annotations", table.annotations),
449
+ policies: table.policies.map((policy) => withPolicy(policy, edit.policy(policy), rewrite)),
450
+ rlsEnabled: table.rlsEnabled
451
+ });
452
+ }
453
+ /**
454
+ * Rebuilds every table of the schema: `editFor` returns the edit for a table, or `undefined` to
455
+ * only rewrite its dependencies.
456
+ */
457
+ function mapTables(schema, rewrite, editFor) {
458
+ return new PostgresDatabaseSchemaNode({
459
+ namespaces: Object.fromEntries(Object.entries(schema.namespaces).map(([key, namespace]) => [key, new PostgresNamespaceSchemaNode({
460
+ schemaName: namespace.schemaName,
461
+ nativeEnums: namespace.nativeEnums,
462
+ tables: Object.fromEntries(Object.values(namespace.tables).map((table) => {
463
+ const rebuilt = rebuildTable(table, editFor(namespace.schemaName, table) ?? unchangedEdit(table), rewrite);
464
+ return [rebuilt.name, rebuilt];
465
+ }))
466
+ })])),
467
+ roles: schema.roles,
468
+ existingSchemas: schema.existingSchemas,
469
+ pgVersion: schema.pgVersion
470
+ });
471
+ }
472
+ /**
473
+ * The schema with one table under its new name. Foreign keys anywhere that reference the table
474
+ * follow it, its policies and every dependency that names it move with it, and row-level security
475
+ * is carried. Constraint, index, check and policy names do not change: a primary key, unique
476
+ * constraint or foreign key whose name was derived from the old table name gets that name spelled
477
+ * out, since it no longer derives from the table it is on.
478
+ */
479
+ function renameTableInPostgresSchema(schema, rename) {
480
+ const { schemaName, from, to } = rename;
481
+ const rewrite = stepRewrite(schemaName, from, PostgresSchemaNodeKind.table, from, to);
482
+ const referencesRenamed = (ownSchema, fk) => (fk.resolvedReferencedNamespace ?? ownSchema) === schemaName && fk.referencedTable === from;
483
+ return mapTables(schema, rewrite, (tableSchema, table) => {
484
+ const unchanged = unchangedEdit(table);
485
+ const followReference = (fk) => ({
486
+ name: fk.name,
487
+ referencedTable: referencesRenamed(tableSchema, fk) ? to : fk.referencedTable
488
+ });
489
+ if (tableSchema !== schemaName || table.name !== from) return {
490
+ ...unchanged,
491
+ foreignKey: followReference
492
+ };
493
+ return {
494
+ ...unchanged,
495
+ name: to,
496
+ primaryKeyName: (primaryKey) => primaryKey.name ?? defaultPrimaryKeyName(from),
497
+ uniqueName: (unique) => unique.name ?? defaultUniqueName(from, unique.columns),
498
+ foreignKey: (fk) => ({
499
+ ...followReference(fk),
500
+ name: fk.name ?? defaultForeignKeyName(from, fk.columns)
501
+ }),
502
+ policy: (policy) => ({
503
+ ...unchanged.policy(policy),
504
+ tableName: to
505
+ })
506
+ };
507
+ });
508
+ }
509
+ /**
510
+ * The schema with one table moved to another schema, as `ALTER TABLE … SET SCHEMA` moves it: its
511
+ * constraints, indexes and policies move with it, foreign keys anywhere that reference it follow
512
+ * it, and every dependency that names it moves with it. The destination schema is added when the
513
+ * schema has no node for it.
514
+ */
515
+ function moveTableInPostgresSchema(schema, move) {
516
+ const { table: tableName, from, to } = move;
517
+ const rewrite = (ref) => {
518
+ const namespaceStep = ref[1];
519
+ const tableStep = ref[2];
520
+ if (namespaceStep?.nodeKind !== PostgresSchemaNodeKind.namespace || namespaceStep.id !== from || tableStep?.nodeKind !== PostgresSchemaNodeKind.table || tableStep.id !== tableName) return ref;
521
+ return ref.map((step, index) => index === 1 ? {
522
+ nodeKind: step.nodeKind,
523
+ id: to
524
+ } : step);
525
+ };
526
+ const rewritten = mapTables(schema, rewrite, (tableSchema, table) => {
527
+ const unchanged = unchangedEdit(table);
528
+ const isMoved = tableSchema === from && table.name === tableName;
529
+ return {
530
+ ...unchanged,
531
+ policy: (policy) => isMoved ? {
532
+ ...unchanged.policy(policy),
533
+ namespaceId: to
534
+ } : unchanged.policy(policy),
535
+ foreignKey: (fk) => {
536
+ const referencedSchema = fk.resolvedReferencedNamespace ?? tableSchema;
537
+ if (referencedSchema === from && fk.referencedTable === tableName) return {
538
+ ...unchanged.foreignKey(fk),
539
+ referencedSchema: to
540
+ };
541
+ return isMoved && fk.resolvedReferencedNamespace === void 0 ? {
542
+ ...unchanged.foreignKey(fk),
543
+ referencedSchema
544
+ } : unchanged.foreignKey(fk);
545
+ }
546
+ };
547
+ });
548
+ const source = rewritten.namespaces[from];
549
+ const moved = source?.tables[tableName];
550
+ if (source === void 0 || moved === void 0) return rewritten;
551
+ const destination = rewritten.namespaces[to];
552
+ return new PostgresDatabaseSchemaNode({
553
+ namespaces: {
554
+ ...rewritten.namespaces,
555
+ [from]: new PostgresNamespaceSchemaNode({
556
+ schemaName: source.schemaName,
557
+ nativeEnums: source.nativeEnums,
558
+ tables: Object.fromEntries(Object.entries(source.tables).filter(([name]) => name !== tableName))
559
+ }),
560
+ [to]: new PostgresNamespaceSchemaNode({
561
+ schemaName: to,
562
+ nativeEnums: destination?.nativeEnums ?? [],
563
+ tables: {
564
+ ...destination?.tables,
565
+ [tableName]: moved
566
+ }
567
+ })
568
+ },
569
+ roles: rewritten.roles,
570
+ existingSchemas: rewritten.existingSchemas,
571
+ pgVersion: rewritten.pgVersion
572
+ });
573
+ }
574
+ /**
575
+ * The schema with one schema renamed, as `ALTER SCHEMA … RENAME TO` renames it: its tables and
576
+ * their policies keep their place in it, and foreign keys and dependencies that name it follow.
577
+ */
578
+ function renameSchemaInPostgresSchema(schema, rename) {
579
+ const { from, to } = rename;
580
+ const rewrite = (ref) => ref[1]?.nodeKind === PostgresSchemaNodeKind.namespace && ref[1].id === from ? ref.map((step, index) => index === 1 ? {
581
+ nodeKind: step.nodeKind,
582
+ id: to
583
+ } : step) : ref;
584
+ const rewritten = mapTables(schema, rewrite, (tableSchema, table) => {
585
+ const unchanged = unchangedEdit(table);
586
+ return {
587
+ ...unchanged,
588
+ policy: (policy) => tableSchema === from ? {
589
+ ...unchanged.policy(policy),
590
+ namespaceId: to
591
+ } : unchanged.policy(policy),
592
+ foreignKey: (fk) => (fk.resolvedReferencedNamespace ?? tableSchema) === from ? {
593
+ ...unchanged.foreignKey(fk),
594
+ referencedSchema: to
595
+ } : unchanged.foreignKey(fk)
596
+ };
597
+ });
598
+ return new PostgresDatabaseSchemaNode({
599
+ namespaces: Object.fromEntries(Object.entries(rewritten.namespaces).filter(([key]) => key !== to).map(([key, namespace]) => key === from ? [to, new PostgresNamespaceSchemaNode({
600
+ schemaName: to,
601
+ nativeEnums: namespace.nativeEnums,
602
+ tables: namespace.tables
603
+ })] : [key, namespace])),
604
+ roles: rewritten.roles,
605
+ existingSchemas: rewritten.existingSchemas.map((name) => name === from ? to : name),
606
+ pgVersion: rewritten.pgVersion
607
+ });
608
+ }
609
+ function withSchema(schema, schemaName) {
610
+ if (schema.existingSchemas.includes(schemaName)) return schema;
611
+ return new PostgresDatabaseSchemaNode({
612
+ namespaces: schema.namespaces,
613
+ roles: schema.roles,
614
+ existingSchemas: [...schema.existingSchemas, schemaName],
615
+ pgVersion: schema.pgVersion
616
+ });
617
+ }
618
+ /**
619
+ * The schema with one column under its new name. The table's primary key, unique constraints,
620
+ * foreign keys and plain column indexes name it under the new name, foreign keys anywhere that
621
+ * reference it follow it, and every dependency that names it moves with it. An index with an
622
+ * expression or a predicate, and a check, keep their SQL text. Constraint and index names do not
623
+ * change: a unique constraint or foreign key on the column whose name was derived from the old
624
+ * column name gets that name spelled out.
625
+ */
626
+ function renameColumnInPostgresSchema(schema, rename) {
627
+ const { schemaName, table: tableName, from, to } = rename;
628
+ const rewrite = stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.column, `column:${from}`, `column:${to}`);
629
+ const renamed = (column) => column === from ? to : column;
630
+ const referencesTable = (ownSchema, fk) => (fk.resolvedReferencedNamespace ?? ownSchema) === schemaName && fk.referencedTable === tableName;
631
+ return mapTables(schema, rewrite, (tableSchema, table) => {
632
+ const unchanged = unchangedEdit(table);
633
+ const followReference = (fk) => ({
634
+ name: fk.name,
635
+ referencedTable: fk.referencedTable,
636
+ referencedColumns: referencesTable(tableSchema, fk) ? fk.referencedColumns.map(renamed) : fk.referencedColumns
637
+ });
638
+ if (tableSchema !== schemaName || table.name !== tableName) return {
639
+ ...unchanged,
640
+ foreignKey: followReference
641
+ };
642
+ return {
643
+ ...unchanged,
644
+ columnName: renamed,
645
+ uniqueName: (unique) => unique.name ?? (unique.columns.includes(from) ? defaultUniqueName(tableName, unique.columns) : void 0),
646
+ foreignKey: (fk) => ({
647
+ ...followReference(fk),
648
+ name: fk.name ?? (fk.columns.includes(from) ? defaultForeignKeyName(tableName, fk.columns) : void 0)
649
+ })
650
+ };
651
+ });
652
+ }
653
+ function renamedNaming(previous, name) {
654
+ return previous.prefix === void 0 ? namingOf(name, void 0) : namingOfLiveName(name);
655
+ }
656
+ function renameConstraint(schema, call) {
657
+ const schemaName = ddlSchemaOfCallSchema(call.schemaName);
658
+ const { tableName, oldConstraintName, newConstraintName } = call;
659
+ const renamed = (name, derived) => (name ?? derived) === oldConstraintName ? newConstraintName : name;
660
+ return mapTables(schema, stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.check, `check:${oldConstraintName}`, `check:${newConstraintName}`), (tableSchema, table) => {
661
+ if (tableSchema !== schemaName || table.name !== tableName) return void 0;
662
+ const unchanged = unchangedEdit(table);
663
+ switch (call.kind) {
664
+ case "primaryKey": return {
665
+ ...unchanged,
666
+ primaryKeyName: (primaryKey) => renamed(primaryKey.name, defaultPrimaryKeyName(tableName))
667
+ };
668
+ case "unique": return {
669
+ ...unchanged,
670
+ uniqueName: (unique) => renamed(unique.name, defaultUniqueName(tableName, unique.columns))
671
+ };
672
+ case "foreignKey": return {
673
+ ...unchanged,
674
+ foreignKey: (fk) => ({
675
+ referencedTable: fk.referencedTable,
676
+ name: renamed(fk.name, defaultForeignKeyName(tableName, fk.columns))
677
+ })
678
+ };
679
+ case "checkConstraint": return {
680
+ ...unchanged,
681
+ checkNaming: (check) => check.name === oldConstraintName ? renamedNaming(check, newConstraintName) : unchanged.checkNaming(check)
682
+ };
683
+ }
684
+ });
685
+ }
686
+ function renameIndex(schema, call) {
687
+ const schemaName = ddlSchemaOfCallSchema(call.schemaName);
688
+ const { tableName, oldIndexName, newIndexName } = call;
689
+ return mapTables(schema, stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.index, `index:${oldIndexName}`, `index:${newIndexName}`), (tableSchema, table) => {
690
+ if (tableSchema !== schemaName || table.name !== tableName) return void 0;
691
+ const unchanged = unchangedEdit(table);
692
+ return {
693
+ ...unchanged,
694
+ indexNaming: (index) => index.name === oldIndexName ? renamedNaming(index, newIndexName) : unchanged.indexNaming(index)
695
+ };
696
+ });
697
+ }
698
+ function renamePolicy(schema, call) {
699
+ const schemaName = ddlSchemaOfCallSchema(call.schemaName);
700
+ const { tableName, oldPolicyName, newPolicyName } = call;
701
+ return mapTables(schema, stepRewrite(schemaName, tableName, PostgresSchemaNodeKind.policy, oldPolicyName, newPolicyName), (tableSchema, table) => {
702
+ if (tableSchema !== schemaName || table.name !== tableName) return void 0;
703
+ const unchanged = unchangedEdit(table);
704
+ return {
705
+ ...unchanged,
706
+ policy: (policy) => policy.name === oldPolicyName ? {
707
+ naming: renamedNaming(policy, newPolicyName),
708
+ tableName: policy.tableName
709
+ } : unchanged.policy(policy)
710
+ };
711
+ });
712
+ }
713
+ function applied(schema, call) {
714
+ if (call instanceof CreateSchemaCall) return withSchema(schema, call.schemaName);
715
+ if (call instanceof RenameSchemaCall) return renameSchemaInPostgresSchema(schema, {
716
+ from: call.schemaName,
717
+ to: call.toSchemaName
718
+ });
719
+ if (call instanceof SetTableSchemaCall) return moveTableInPostgresSchema(schema, {
720
+ table: call.tableName,
721
+ from: ddlSchemaOfCallSchema(call.schemaName),
722
+ to: call.toSchemaName
723
+ });
724
+ if (call instanceof RenameTableCall) {
725
+ const renamed = renameTableInPostgresSchema(schema, {
726
+ schemaName: ddlSchemaOfCallSchema(call.schemaName),
727
+ from: call.oldTableName,
728
+ to: call.tableName
729
+ });
730
+ return call.companions.reduce(applied, renamed);
731
+ }
732
+ if (call instanceof RenameColumnCall) {
733
+ const renamed = renameColumnInPostgresSchema(schema, {
734
+ schemaName: ddlSchemaOfCallSchema(call.schemaName),
735
+ table: call.tableName,
736
+ from: call.oldColumnName,
737
+ to: call.columnName
738
+ });
739
+ return call.companions.reduce(applied, renamed);
740
+ }
741
+ if (call instanceof RenameConstraintCall) return renameConstraint(schema, call);
742
+ if (call instanceof RenameIndexCall) return renameIndex(schema, call);
743
+ return renamePolicy(schema, call);
744
+ }
745
+ /** The working schema of a plan or a migration, starting from `initial`. */
746
+ function createWorkingSchema(initial) {
747
+ return new WorkingSchemaImpl(initial);
748
+ }
749
+ var WorkingSchemaImpl = class {
750
+ #current;
751
+ constructor(initial) {
752
+ this.#current = initial;
753
+ }
754
+ get current() {
755
+ return this.#current;
756
+ }
757
+ apply(call) {
758
+ this.#current = applied(this.#current, call);
759
+ }
760
+ };
761
+ const RENAME_POLICY = { allowedOperationClasses: ["widening"] };
762
+ /**
763
+ * The `renameTable` call a user writes in `migration.ts` for `rename`. `schema` names the namespace
764
+ * the facade resolves the table in, and is left out for the unbound namespace or when not given.
765
+ */
766
+ function renderRenameTableCall(rename) {
767
+ return new RenameTableCall(rename.namespaceId ?? UNBOUND_NAMESPACE_ID, rename.from, rename.to, []).renderTypeScript();
768
+ }
769
+ /** The SQL a user runs against the database to rename the table by hand. */
770
+ function renameTableByHandStatements(contract, rename) {
771
+ return [renameTableStatement(emissionSchemaForNamespace(contract, rename.namespaceId), rename.from, rename.to)];
772
+ }
773
+ /** How a user renames a table of `contract` by hand on Postgres. */
774
+ function postgresTableRenameByHand(contract) {
775
+ return {
776
+ renderTableRename: renderRenameTableCall,
777
+ tableRenameByHand: (rename) => renameTableByHandStatements(contract, rename)
778
+ };
779
+ }
780
+ function tableNode(schema, ddlSchema, tableName) {
781
+ const table = schema.namespaces[ddlSchema]?.tables[tableName];
782
+ assertDefined(table, `a resolved rename names table "${tableName}" in schema "${ddlSchema}"`);
783
+ return table;
784
+ }
785
+ /**
786
+ * The call that renames a table, carrying as companions the renames of the objects on the table
787
+ * whose names derive from the table name: each primary key, unique constraint and foreign key the
788
+ * destination keeps, named as the destination names it, and each wire-named index and check whose
789
+ * prefix changes. `previous` is the schema before the rename; the renamed copy is diffed against
790
+ * the destination built from `contract`.
791
+ */
792
+ function postgresTableRenameCall(input) {
793
+ const { contract, rename } = input;
794
+ const schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);
795
+ const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);
796
+ const renamed = renameTableInPostgresSchema(input.previous, {
797
+ schemaName: ddlSchema,
798
+ from: rename.from,
799
+ to: rename.to
800
+ });
801
+ const { expected, issues } = buildPostgresPlanDiff({
802
+ contract,
803
+ actualSchema: renamed,
804
+ frameworkComponents: input.frameworkComponents
805
+ });
806
+ const onRenamedTable = (call) => call.schemaName === schemaName && call.tableName === rename.to;
807
+ const pairing = {
808
+ contract,
809
+ policy: RENAME_POLICY
810
+ };
811
+ return new RenameTableCall(schemaName, rename.from, rename.to, [
812
+ ...constraintRenamesForTableRename({
813
+ schemaName,
814
+ previous: tableNode(renamed, ddlSchema, rename.to),
815
+ next: tableNode(expected, ddlSchema, rename.to)
816
+ }),
817
+ ...pairIndexRenames(pairing, issues).calls.filter(onRenamedTable),
818
+ ...pairCheckRenames(pairing, issues).calls.filter(onRenamedTable)
819
+ ]);
820
+ }
821
+ /**
822
+ * The call that renames a column, carrying as companions the renames of the objects on its table
823
+ * whose names derive from the column name: each unique constraint and foreign key on the column
824
+ * the destination keeps, named as the destination names it, and each index on the column renamed
825
+ * to the destination's wire name. `previous` is the schema before the rename; the renamed copy is
826
+ * diffed against the destination built from `contract`. A check on the column keeps its name: its
827
+ * expression names the column, so the diff replaces it.
828
+ */
829
+ function postgresColumnRenameCall(input) {
830
+ const { contract, rename } = input;
831
+ const schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);
832
+ const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);
833
+ const renamed = renameColumnInPostgresSchema(input.previous, {
834
+ schemaName: ddlSchema,
835
+ table: rename.table,
836
+ from: rename.from,
837
+ to: rename.to
838
+ });
839
+ const { expected, issues } = buildPostgresPlanDiff({
840
+ contract,
841
+ actualSchema: renamed,
842
+ frameworkComponents: input.frameworkComponents
843
+ });
844
+ const table = tableNode(renamed, ddlSchema, rename.table);
845
+ const destination = expected.namespaces[ddlSchema]?.tables[rename.table];
846
+ const indexesOnColumn = new Set(table.indexes.filter((index) => index.columns?.includes(rename.to)).map((index) => index.name));
847
+ const indexRenames = pairIndexRenames({
848
+ contract,
849
+ policy: RENAME_POLICY
850
+ }, issues).calls.filter((call) => call.schemaName === schemaName && call.tableName === rename.table && indexesOnColumn.has(call.oldIndexName));
851
+ return new RenameColumnCall(schemaName, rename.table, rename.from, rename.to, [...destination === void 0 ? [] : constraintRenamesForColumnRename({
852
+ schemaName,
853
+ column: rename.to,
854
+ previous: table,
855
+ next: destination
856
+ }), ...indexRenames]);
857
+ }
858
+ /**
859
+ * Target-owned base class for Postgres migrations.
860
+ *
861
+ * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
862
+ * abstract `targetId` to the Postgres target-id string literal, so both
863
+ * user-authored migrations and renderer-generated scaffolds (the output of
864
+ * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
865
+ * redeclaring target-local identity.
866
+ *
867
+ * Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer
868
+ * emits `extends Migration` against a facade re-export of this class
869
+ * from `@internal/postgres/migration`, keeping the authoring surface
870
+ * target-scoped rather than family-scoped.
871
+ *
872
+ * The constructor materializes a single Postgres `SqlControlAdapter` from
873
+ * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
874
+ * instance method forwards to the free `dataTransform` factory with that
875
+ * stored adapter, so user migrations can write `this.dataTransform(...)`
876
+ * without threading the adapter through every call.
877
+ *
878
+ * Every method requires an explicit `schema`. Postgres migrations name their
879
+ * schema deliberately — there is no default and no `search_path`-relative
880
+ * option. A migration that left the schema unspecified would resolve against
881
+ * whatever `search_path` the connection happened to carry, and that ambiguity
882
+ * is an antipattern in a migration. (The unbound/unspecified namespace concept
883
+ * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)
884
+ */
885
+ var PostgresMigration = class extends Migration {
886
+ targetId = "postgres";
887
+ /**
888
+ * Materialized Postgres control adapter, created once per migration
889
+ * instance from the injected stack. `undefined` only when the migration
890
+ * was instantiated without a stack (test fixtures); `controlAdapterFor`
891
+ * throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.
892
+ */
893
+ controlAdapter;
894
+ /** The rename calls this read of `operations` has made so far, in order. */
895
+ #renames = [];
896
+ #endView = new MigrationContractViews(this, "PostgresMigration", (json) => PostgresContractView.fromJson(json));
897
+ #startView = new MigrationContractViews(this, "PostgresMigration", (json) => PostgresContractView.fromJson(json));
898
+ constructor(stack) {
899
+ super(stack);
900
+ this.controlAdapter = stack?.adapter ? blindCast(stack.adapter.create(stack)) : void 0;
901
+ }
902
+ frameworkComponents() {
903
+ const stack = this.stack;
904
+ if (stack === void 0) return [];
905
+ return [
906
+ stack.target,
907
+ ...stack.adapter === void 0 ? [] : [stack.adapter],
908
+ ...stack.extensions
909
+ ];
910
+ }
911
+ dataTypes() {
912
+ return stackDataTypes(this.frameworkComponents());
913
+ }
914
+ /**
915
+ * Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming
916
+ * `operation` when the migration was constructed without a `ControlStack`.
917
+ * Single home for the null-check that every DDL/DML method shares.
918
+ */
919
+ controlAdapterFor(operation) {
920
+ if (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);
921
+ return this.controlAdapter;
922
+ }
923
+ /**
924
+ * The typed, schema-qualified Postgres view over this migration's end-state
925
+ * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws
926
+ * if no `endContractJson` was provided.
927
+ */
928
+ get endContract() {
929
+ return this.#endView.endContract;
930
+ }
931
+ /**
932
+ * The typed Postgres view over this migration's start-state contract, or
933
+ * `null` for a baseline migration (no `startContractJson`).
934
+ */
935
+ get startContract() {
936
+ return this.#startView.startContract;
937
+ }
938
+ /**
939
+ * Instance-method wrapper around the free `dataTransform` factory that
940
+ * supplies the stored control adapter. Authors call this from inside
941
+ * `get operations()`; the adapter argument is hidden from the call site.
942
+ */
943
+ dataTransform(contract, name, options) {
944
+ return dataTransform(contract, name, options, this.controlAdapterFor("dataTransform"));
945
+ }
946
+ /**
947
+ * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
948
+ * the supplied options and lowers it through the stored control adapter.
949
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
950
+ */
951
+ createTable(options) {
952
+ return new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor("createTable"));
953
+ }
954
+ /**
955
+ * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
956
+ * the supplied options and lowers it through the stored control adapter.
957
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
958
+ */
959
+ createSchema(options) {
960
+ return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor("createSchema"));
961
+ }
962
+ /**
963
+ * Emit an `ALTER TABLE … SET SCHEMA` operation that moves `table` from `schema` to the schema
964
+ * `to`. Leave out `schema` for a table of the unbound namespace. Indexes, constraints and owned
965
+ * sequences move with the table, and foreign keys from other tables keep pointing at it. Later
966
+ * rename calls find the table in its new schema.
967
+ */
968
+ setTableSchema(options) {
969
+ const call = new SetTableSchemaCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.to);
970
+ const op = call.toOp(this.controlAdapterFor("setTableSchema"));
971
+ this.#renames.push(call);
972
+ return op;
973
+ }
974
+ /**
975
+ * Emit an `ALTER SCHEMA … RENAME TO` operation. Everything in the schema keeps its place in it,
976
+ * and later rename calls find its tables under the new name.
977
+ */
978
+ renameSchema(options) {
979
+ const call = new RenameSchemaCall(options.schema, options.to);
980
+ const op = call.toOp(this.controlAdapterFor("renameSchema"));
981
+ this.#renames.push(call);
982
+ return op;
983
+ }
984
+ /**
985
+ * Emit a `DROP SCHEMA` operation, without `CASCADE`. Drop or move the schema's tables first: the
986
+ * operation fails its precheck while the schema still holds anything.
987
+ */
988
+ dropSchema(options) {
989
+ return new DropSchemaCall(options.schema).toOp(this.controlAdapterFor("dropSchema"));
990
+ }
991
+ /**
992
+ * Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed
993
+ * native enum. Builds a typed DDL node and lowers it through the stored
994
+ * control adapter (members render in declaration order). Throws if no adapter
995
+ * is present.
996
+ */
997
+ createNativeEnumType(options) {
998
+ return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor("createNativeEnumType"));
999
+ }
1000
+ /**
1001
+ * Emit a `DROP TYPE` migration operation for a managed native enum, lowered
1002
+ * through the stored control adapter. Throws if no adapter is present.
1003
+ */
1004
+ dropNativeEnumType(options) {
1005
+ return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor("dropNativeEnumType"));
1006
+ }
1007
+ /**
1008
+ * Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one
1009
+ * member to a managed native enum, lowered through the stored control
1010
+ * adapter. Throws if no adapter is present. Every appended value is its
1011
+ * own operation — call this once per value to append more than one.
1012
+ */
1013
+ addNativeEnumValue(options) {
1014
+ return new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor("addNativeEnumValue"));
1015
+ }
1016
+ addColumn(options) {
1017
+ const adapter = this.controlAdapterFor("addColumn");
1018
+ return new AddColumnCall(options.schema, options.table, options.column, this.dataTypes()).toOp(adapter);
1019
+ }
1020
+ /**
1021
+ * Adds a required column of `type` to a table that may have rows. Every existing row takes
1022
+ * `temporaryDefault`, SQL such as `''` or `0`, and the default is dropped once the column is added.
1023
+ */
1024
+ addColumnWithTemporaryDefault(options) {
1025
+ const adapter = this.controlAdapterFor("addColumnWithTemporaryDefault");
1026
+ return new AddColumnWithTemporaryDefaultCall(options.schema, options.table, options.column, options.type, sqlTextOf(options.temporaryDefault, `addColumnWithTemporaryDefault ${JSON.stringify(options.table)}.${JSON.stringify(options.column)} temporaryDefault`), this.dataTypes()).toOp(adapter);
1027
+ }
1028
+ /** Adds a required column of `type` with no default, checking first that the table is empty. */
1029
+ addRequiredColumnToEmptyTable(options) {
1030
+ const adapter = this.controlAdapterFor("addRequiredColumnToEmptyTable");
1031
+ return new AddRequiredColumnToEmptyTableCall(options.schema, options.table, options.column, options.type, this.dataTypes()).toOp(adapter);
1032
+ }
1033
+ addPrimaryKey(options) {
1034
+ return new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor("addPrimaryKey"));
1035
+ }
1036
+ addUnique(options) {
1037
+ return new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor("addUnique"));
1038
+ }
1039
+ addForeignKey(options) {
1040
+ return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor("addForeignKey"));
1041
+ }
1042
+ addCheckConstraint(options) {
1043
+ return new AddCheckConstraintCall(options.schema, options.table, options.constraint, sqlTextOf(options.expression, `addCheckConstraint ${JSON.stringify(options.constraint)} expression`)).toOp(this.controlAdapterFor("addCheckConstraint"));
1044
+ }
1045
+ renameCheckConstraint(options) {
1046
+ return this.renameConstraint({
1047
+ ...options,
1048
+ kind: "checkConstraint"
1049
+ });
1050
+ }
1051
+ renameConstraint(options) {
1052
+ const call = new RenameConstraintCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.kind, options.from, options.to);
1053
+ const adapter = this.controlAdapterFor("renameConstraint");
1054
+ this.#renames.push(call);
1055
+ return call.toOp(adapter);
1056
+ }
1057
+ dropCheckConstraint(options) {
1058
+ return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor("dropCheckConstraint"));
1059
+ }
1060
+ dropConstraint(options) {
1061
+ return new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? "unique").toOp(this.controlAdapterFor("dropConstraint"));
1062
+ }
1063
+ /**
1064
+ * Emit the operations that rename a table: the table rename, then a rename of each primary key,
1065
+ * unique constraint, foreign key, index and check whose name was derived from the old table name.
1066
+ * The old name is resolved against the schema as this migration's earlier rename calls
1067
+ * (`renameTable`, `renameIndex`, `renameConstraint`, `renameRlsPolicy`) leave it, and the new
1068
+ * name against the end contract, so the companions start from names an earlier rename gave.
1069
+ * Spread the result into `operations`:
1070
+ * `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`. `schema` names the table's
1071
+ * namespace when more than one declares the table. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when
1072
+ * the table does not exist at that point of the migration or the end contract lacks the new name.
1073
+ */
1074
+ renameTable(options) {
1075
+ const adapter = this.controlAdapterFor("renameTable");
1076
+ const rename = {
1077
+ namespaceId: options.schema,
1078
+ from: options.table,
1079
+ to: options.to
1080
+ };
1081
+ const startContract = this.startContract;
1082
+ if (startContract === null) throw unmatchedTableRename(rename, "the migration has no start contract");
1083
+ const current = this.schemaAfterRenames(startContract);
1084
+ const endContract = this.endContract;
1085
+ const resolved = resolveTableRenameAgainst(postgresSchemaTables(current, startContract), endContract, rename);
1086
+ if (!resolved.ok) throw resolved.failure;
1087
+ const call = postgresTableRenameCall({
1088
+ previous: current,
1089
+ contract: endContract,
1090
+ rename: resolved.value,
1091
+ frameworkComponents: this.frameworkComponents()
1092
+ });
1093
+ this.#renames.push(call);
1094
+ return call.toOps(adapter).map(async (op) => op);
1095
+ }
1096
+ /**
1097
+ * Emit the operations that rename a column: the column rename, then a rename of each unique
1098
+ * constraint, foreign key and index on the column whose name was derived from the old column
1099
+ * name, to the name the end contract gives it. The column is resolved against the schema as this
1100
+ * migration's earlier rename calls leave it, so a column of a table an earlier `renameTable`
1101
+ * renamed is named on the table's new name. Spread the result into `operations`:
1102
+ * `...this.renameColumn({ table: 'User', column: 'name', to: 'fullName' })`. `schema` names the
1103
+ * table's namespace when more than one declares the table. Throws
1104
+ * `MIGRATION.COLUMN_RENAME_UNMATCHED` when the table or column does not exist at that point of
1105
+ * the migration, the table already has the new column, or the end contract lacks it.
1106
+ */
1107
+ renameColumn(options) {
1108
+ const adapter = this.controlAdapterFor("renameColumn");
1109
+ const rename = {
1110
+ namespaceId: options.schema,
1111
+ table: options.table,
1112
+ from: options.column,
1113
+ to: options.to
1114
+ };
1115
+ const startContract = this.startContract;
1116
+ if (startContract === null) throw unmatchedColumnRename(rename, "the migration has no start contract");
1117
+ const current = this.schemaAfterRenames(startContract);
1118
+ const endContract = this.endContract;
1119
+ const resolved = resolveColumnRenameAgainst(postgresSchemaTables(current, startContract), endContract, rename);
1120
+ if (!resolved.ok) throw resolved.failure;
1121
+ const call = postgresColumnRenameCall({
1122
+ previous: current,
1123
+ contract: endContract,
1124
+ rename: resolved.value,
1125
+ frameworkComponents: this.frameworkComponents()
1126
+ });
1127
+ this.#renames.push(call);
1128
+ return call.toOps(adapter).map(async (op) => op);
1129
+ }
1130
+ /**
1131
+ * The start contract's schema with this read's rename calls applied in order. It is built only
1132
+ * when a rename or a `setDefault` needs it, so a migration that calls neither never reads its
1133
+ * start contract.
1134
+ */
1135
+ schemaAfterRenames(startContract) {
1136
+ const working = createWorkingSchema(postgresContractToSchema(startContract, this.frameworkComponents()));
1137
+ for (const call of this.#renames) working.apply(call);
1138
+ return working.current;
1139
+ }
1140
+ beginOperationsRead() {
1141
+ this.#renames = [];
1142
+ }
1143
+ dropTable(options) {
1144
+ return new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor("dropTable"));
1145
+ }
1146
+ dropColumn(options) {
1147
+ return new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor("dropColumn"));
1148
+ }
1149
+ alterColumnType(options) {
1150
+ refuseInvalidAlterColumnTypeOptions(options);
1151
+ const adapter = this.controlAdapterFor("alterColumnType");
1152
+ const using = optionalSqlTextOf(options.using, `alterColumnType ${JSON.stringify(options.table)}.${JSON.stringify(options.column)} using`);
1153
+ const call = new AlterColumnTypeCall({
1154
+ schemaName: options.schema,
1155
+ tableName: options.table,
1156
+ columnName: options.column,
1157
+ type: options.type,
1158
+ ...ifDefined("raw", options.raw),
1159
+ ...ifDefined("using", using === void 0 ? void 0 : {
1160
+ kind: "sql",
1161
+ sql: using
1162
+ }),
1163
+ dataTypes: this.dataTypes(),
1164
+ ...ifDefined("operationClass", options.operationClass),
1165
+ ownsAutoincrementSequence: this.startColumnHasAutoincrementDefault(options.schema, options.table, options.column)
1166
+ });
1167
+ if (using !== void 0) this.refuseUnchangedTypeConversion(call);
1168
+ return call.toOp(adapter);
1169
+ }
1170
+ startColumnHasAutoincrementDefault(schema, table, column) {
1171
+ const startColumn = this.startColumnAfterRenames(schema, table, column);
1172
+ return startColumn !== void 0 && hasAutoincrementDefault(startColumn);
1173
+ }
1174
+ /** The column in the start contract's schema after this migration's earlier renames. */
1175
+ startColumnAfterRenames(schema, table, column) {
1176
+ const startContract = this.startContract;
1177
+ if (startContract === null) return void 0;
1178
+ return this.schemaAfterRenames(startContract).namespaces[ddlSchemaOfCallSchema(schema)]?.tables[table]?.columns[column];
1179
+ }
1180
+ /**
1181
+ * Refuses an `alterColumnType` with `using` to the type the start contract, after this migration's earlier renames, already gives the column. Its postcheck compares only the type, which already holds, so the runner would skip the conversion. Other earlier operations of the migration, such as an earlier `alterColumnType`, are not applied to the start contract.
1182
+ */
1183
+ refuseUnchangedTypeConversion(call) {
1184
+ const column = this.startColumnAfterRenames(call.schemaName, call.tableName, call.columnName);
1185
+ if (column === void 0) return;
1186
+ const written = writtenColumnType(call.type, this.dataTypes());
1187
+ if (written === void 0 || !sqlColumnTypesEqual(column, written)) return;
1188
+ const where = alterColumnTypeCallText(call.schemaName, call.tableName, call.columnName);
1189
+ throw postgresError("MIGRATION.ALTER_COLUMN_TYPE_USING_WITHOUT_TYPE_CHANGE", `${where}: the start contract, after the earlier renames in this migration, already gives the column the type ${JSON.stringify(call.type)}, so the conversion in using would never run`, {
1190
+ why: "The runner skips an operation whose postchecks already hold. alterColumnType checks only that the column has the new type, which holds before it runs, so the values would never be converted.",
1191
+ fix: "Write the conversion as a dataTransform, which checks the rows themselves, or change the column to another type.",
1192
+ meta: {
1193
+ where,
1194
+ type: call.type
1195
+ }
1196
+ });
1197
+ }
1198
+ setNotNull(options) {
1199
+ return new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor("setNotNull"));
1200
+ }
1201
+ dropNotNull(options) {
1202
+ return new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor("dropNotNull"));
1203
+ }
1204
+ /**
1205
+ * Emit an `ALTER COLUMN … SET DEFAULT` operation. It is widening when this migration's start contract, after the renames made earlier in the migration, gives the column a default, and additive otherwise.
1206
+ */
1207
+ setDefault(options) {
1208
+ refuseEarlierSetDefaultOptions(options);
1209
+ return new SetDefaultCall(options.schema, options.table, options.column, this.columnHasDefaultAfterRenames(options.schema, options.table, options.column.name) ? "widening" : "additive").toOp(this.controlAdapterFor("setDefault"));
1210
+ }
1211
+ /**
1212
+ * Whether the column, found by schema, table and column name in the start contract after this migration's earlier renames, has a default.
1213
+ */
1214
+ columnHasDefaultAfterRenames(schema, table, column) {
1215
+ return this.startColumnAfterRenames(schema, table, column)?.resolvedDefault !== void 0;
1216
+ }
1217
+ dropDefault(options) {
1218
+ return new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor("dropDefault"));
1219
+ }
1220
+ createIndex(options) {
1221
+ return new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: sqlTextOf(options.expression, `createIndex ${JSON.stringify(options.index)} expression`) }, options.extras === void 0 ? void 0 : createIndexExtrasOf(options.extras, options.index)).toOp(this.controlAdapterFor("createIndex"));
1222
+ }
1223
+ renameIndex(options) {
1224
+ const call = new RenameIndexCall(options.schema, options.table, options.from, options.to);
1225
+ const adapter = this.controlAdapterFor("renameIndex");
1226
+ this.#renames.push(call);
1227
+ return call.toOp(adapter);
1228
+ }
1229
+ dropIndex(options) {
1230
+ return new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor("dropIndex"));
1231
+ }
1232
+ installExtension(options) {
1233
+ return installExtension(options, this.controlAdapterFor("installExtension"));
1234
+ }
1235
+ enableRowLevelSecurity(options) {
1236
+ return new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("enableRowLevelSecurity"));
1237
+ }
1238
+ disableRowLevelSecurity(options) {
1239
+ return new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("disableRowLevelSecurity"));
1240
+ }
1241
+ createRlsPolicy(options) {
1242
+ const policyName = JSON.stringify(nameOf(options.policy.naming));
1243
+ return new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({
1244
+ ...options.policy,
1245
+ using: optionalSqlTextOf(options.policy.using, `createRlsPolicy ${policyName} using`),
1246
+ withCheck: optionalSqlTextOf(options.policy.withCheck, `createRlsPolicy ${policyName} withCheck`)
1247
+ })).toOp(this.controlAdapterFor("createRlsPolicy"));
1248
+ }
1249
+ dropRlsPolicy(options) {
1250
+ return new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor("dropRlsPolicy"));
1251
+ }
1252
+ renameRlsPolicy(options) {
1253
+ const call = new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to);
1254
+ const adapter = this.controlAdapterFor("renameRlsPolicy");
1255
+ this.#renames.push(call);
1256
+ return call.toOp(adapter);
1257
+ }
1258
+ };
1259
+ /**
1260
+ * `setDefault` options an earlier version wrote carry the column's name in `column` and its default as SQL text in `defaultSql`.
1261
+ */
1262
+ function refuseEarlierSetDefaultOptions(options) {
1263
+ const column = options.column;
1264
+ const columnIsName = typeof column === "string";
1265
+ if (!columnIsName && !Object.hasOwn(options, "defaultSql")) return;
1266
+ throw errorMigrationOperationOptionRemoved({
1267
+ operation: "setDefault",
1268
+ option: "defaultSql",
1269
+ subject: `column ${JSON.stringify(columnIsName ? column : options.column.name)} of table ${JSON.stringify(options.table)}`,
1270
+ rewrite: "Pass the column as `col(name, type, { default, codecRef })`, with its default written as `lit(value)` or `fn(expression)`, in place of its name and `defaultSql`.",
1271
+ upgradeEntry: "migration-ts-column-defaults"
1272
+ });
1273
+ }
1274
+ /**
1275
+ * `alterColumnType` options as a hand-written `migration.ts` may pass them, which `node migration.ts` does not type-check: the
1276
+ * `options` object an earlier version wrote, or no `type`.
1277
+ */
1278
+ function refuseInvalidAlterColumnTypeOptions(options) {
1279
+ if (Object.hasOwn(options, "options")) throw errorMigrationOperationOptionRemoved({
1280
+ operation: "alterColumnType",
1281
+ option: "options",
1282
+ subject: `column ${JSON.stringify(options.column)} of table ${JSON.stringify(options.table)}`,
1283
+ rewrite: "Pass `{ schema, table, column, type, using? }`: move `options.qualifiedTargetType` to `type` and `options.using` to `using`, and drop the other options.",
1284
+ upgradeEntry: "postgres-alter-column-type-plain-options"
1285
+ });
1286
+ const type = options.type;
1287
+ if (typeof type === "string") return;
1288
+ const where = alterColumnTypeCallText(options.schema, options.table, options.column);
1289
+ throw postgresError("MIGRATION.COLUMN_TYPE_UNREADABLE", `${where}: it has no \`type\``, {
1290
+ why: "A column type change needs the new type, and node migration.ts does not check the types of the options it is given.",
1291
+ fix: "Pass `{ schema, table, column, type, using? }`, with `type` written as a migration writes it, such as int4 or varchar(20).",
1292
+ meta: {
1293
+ type: String(type),
1294
+ where
1295
+ }
1296
+ });
1297
+ }
1298
+ function optionalSqlTextOf(value, what) {
1299
+ return value === void 0 ? void 0 : sqlTextOf(value, what);
1300
+ }
1301
+ function createIndexExtrasOf(extras, index) {
1302
+ const { where, ...rest } = extras;
1303
+ const what = `createIndex ${JSON.stringify(index)} where`;
1304
+ return {
1305
+ ...rest,
1306
+ ...ifDefined("where", optionalSqlTextOf(where, what))
1307
+ };
1308
+ }
1309
+ //#endregion
1310
+ export { postgresColumnRenameCall as a, postgresTableRenameByHand as c, renderRenameTableCall as d, pairIndexRenames as i, postgresTableRenameCall as l, createWorkingSchema as n, postgresContractToSchema as o, pairCheckRenames as r, postgresSchemaTables as s, PostgresMigration as t, renameTableByHandStatements as u };
1311
+
1312
+ //# sourceMappingURL=postgres-migration-BSWmeRLo-CUfVTUf0.mjs.map