@prisma/orm-target-sqlite 8.0.0-rc.9-dev.13 → 8.0.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/README.md +5 -1
  2. package/dist/adapter-CLQMz42P.d.mts +205 -0
  3. package/dist/adapter-CLQMz42P.d.mts.map +1 -0
  4. package/dist/{adapter-jwxys1MM-CmUELyBs.mjs → adapter-CxzIV2_z-DKbo2Ebu.mjs} +347 -137
  5. package/dist/adapter-CxzIV2_z-DKbo2Ebu.mjs.map +1 -0
  6. package/dist/{adapter-DEYUC-KO-DO_abhIq.d.mts → adapter-xFPDhkod-Bfb8AQQJ.d.mts} +12 -9
  7. package/dist/adapter-xFPDhkod-Bfb8AQQJ.d.mts.map +1 -0
  8. package/dist/adapter.d.mts +14 -15
  9. package/dist/adapter.mjs +7 -6
  10. package/dist/adapter__adapter.d.mts +4 -4
  11. package/dist/adapter__adapter.mjs +3 -2
  12. package/dist/adapter__codec-types.d.mts +3 -3
  13. package/dist/adapter__column-types.d.mts +2 -2
  14. package/dist/adapter__column-types.mjs +2 -2
  15. package/dist/adapter__control.d.mts +5 -5
  16. package/dist/adapter__control.mjs +12 -247
  17. package/dist/adapter__control.mjs.map +1 -1
  18. package/dist/adapter__runtime.d.mts +1 -1
  19. package/dist/adapter__runtime.mjs +30 -16
  20. package/dist/adapter__runtime.mjs.map +1 -1
  21. package/dist/adapter__sql-renderer.d.mts +2 -2
  22. package/dist/adapter__sql-renderer.mjs +1 -1
  23. package/dist/adapter__types.d.mts +3 -2
  24. package/dist/aggregates-CA7Idm1d.d.mts +164 -0
  25. package/dist/aggregates-CA7Idm1d.d.mts.map +1 -0
  26. package/dist/{aggregates-DWyPO7t6.mjs → aggregates-hLiHPHBG.mjs} +44 -26
  27. package/dist/aggregates-hLiHPHBG.mjs.map +1 -0
  28. package/dist/codec-descriptor-3oN7rtrW-Cc_u7U5-.d.mts +1 -0
  29. package/dist/codec-descriptor-C16gQAdS.d.mts +2 -0
  30. package/dist/{codec-descriptor-B9ru99aI-DTkdKFU5.mjs → codec-descriptor-DRmF-crq-BALI5Jtz.mjs} +11 -15
  31. package/dist/codec-descriptor-DRmF-crq-BALI5Jtz.mjs.map +1 -0
  32. package/dist/codec-descriptor-DuW-d9ef-BBRBN0Ri.d.mts +45 -0
  33. package/dist/codec-descriptor-DuW-d9ef-BBRBN0Ri.d.mts.map +1 -0
  34. package/dist/codec-ids-CH8Nqk89-LNT9hksu.d.mts +23 -0
  35. package/dist/codec-ids-CH8Nqk89-LNT9hksu.d.mts.map +1 -0
  36. package/dist/codec-ids-CTshXpbg-tcdbf_VC.mjs +23 -0
  37. package/dist/codec-ids-CTshXpbg-tcdbf_VC.mjs.map +1 -0
  38. package/dist/codec-ids-Do7Ml2pg.d.mts +1 -0
  39. package/dist/codec-types-CBLOfyrr.d.mts +2 -0
  40. package/dist/codec-types-CcuzuROC.d.mts +1 -0
  41. package/dist/codec-types-Ci-h2uxN-41PNpdNL.d.mts +35 -0
  42. package/dist/codec-types-Ci-h2uxN-41PNpdNL.d.mts.map +1 -0
  43. package/dist/codecs-BO3frExA.mjs +49 -0
  44. package/dist/codecs-BO3frExA.mjs.map +1 -0
  45. package/dist/codecs-DBQsDiM--Cy-r45H3.d.mts +378 -0
  46. package/dist/codecs-DBQsDiM--Cy-r45H3.d.mts.map +1 -0
  47. package/dist/codecs-Dou3fR1K.d.mts +1 -0
  48. package/dist/codecs-izq9l1NG-Bb2RnXsx.mjs +1081 -0
  49. package/dist/codecs-izq9l1NG-Bb2RnXsx.mjs.map +1 -0
  50. package/dist/column-types-D3MMpY3X.d.mts +42 -0
  51. package/dist/column-types-D3MMpY3X.d.mts.map +1 -0
  52. package/dist/column-types-D_PjRS6w.mjs +24 -0
  53. package/dist/column-types-D_PjRS6w.mjs.map +1 -0
  54. package/dist/contract-contributions-DEePsuJb-CXE-f6pP.mjs +28 -0
  55. package/dist/contract-contributions-DEePsuJb-CXE-f6pP.mjs.map +1 -0
  56. package/dist/{contract-free-D5cZrgNl.mjs → contract-free-B5S1OSEd.mjs} +8 -7
  57. package/dist/contract-free-B5S1OSEd.mjs.map +1 -0
  58. package/dist/{contract-free-CCLAXZV2.d.mts → contract-free-IqKgq8Pk.d.mts} +6 -6
  59. package/dist/contract-free-IqKgq8Pk.d.mts.map +1 -0
  60. package/dist/{control-D9vMRRgU.d.mts → control-C2TjacST.d.mts} +3 -3
  61. package/dist/control-C2TjacST.d.mts.map +1 -0
  62. package/dist/control-CtCvtwJx.d.mts +408 -0
  63. package/dist/control-CtCvtwJx.d.mts.map +1 -0
  64. package/dist/{control-CLirKz11.d.mts → control-DfWteXy-.d.mts} +31 -45
  65. package/dist/control-DfWteXy-.d.mts.map +1 -0
  66. package/dist/control-V3kPfMTR.mjs +61 -0
  67. package/dist/control-V3kPfMTR.mjs.map +1 -0
  68. package/dist/{control-tables-Dua-YcJL.d.mts → control-tables-DKXLHvMU.d.mts} +2 -2
  69. package/dist/control-tables-DKXLHvMU.d.mts.map +1 -0
  70. package/dist/{control-tables-D_o8dKRB-BXi43noL.mjs → control-tables-D_o8dKRB-n_QqsXcm.mjs} +2 -2
  71. package/dist/control-tables-D_o8dKRB-n_QqsXcm.mjs.map +1 -0
  72. package/dist/data-type-entries-DaT4D2GV-DE0V_N6k.mjs +120 -0
  73. package/dist/data-type-entries-DaT4D2GV-DE0V_N6k.mjs.map +1 -0
  74. package/dist/data-types-C1nzwKt7.d.mts +68 -0
  75. package/dist/data-types-C1nzwKt7.d.mts.map +1 -0
  76. package/dist/data-types-Djvapurb-BR-Y4NWN.mjs +239 -0
  77. package/dist/data-types-Djvapurb-BR-Y4NWN.mjs.map +1 -0
  78. package/dist/date-time-now-generators-DUb3x91B-D0keGG59.mjs +64 -0
  79. package/dist/date-time-now-generators-DUb3x91B-D0keGG59.mjs.map +1 -0
  80. package/dist/datetime-text-DPjoF6HJ-se0mLEbc.mjs +32 -0
  81. package/dist/datetime-text-DPjoF6HJ-se0mLEbc.mjs.map +1 -0
  82. package/dist/ddl-31OBcTco.d.mts +1 -0
  83. package/dist/{ddl-CXduXyOT-nlDP6DGx.mjs → ddl-CgkyurGo-B2o4mSIT.mjs} +45 -8
  84. package/dist/ddl-CgkyurGo-B2o4mSIT.mjs.map +1 -0
  85. package/dist/default-normalizer-BANdMVGr-BiUHyBX1.mjs +124 -0
  86. package/dist/default-normalizer-BANdMVGr-BiUHyBX1.mjs.map +1 -0
  87. package/dist/default-normalizer-CtNsZNRZ.d.mts +25 -0
  88. package/dist/default-normalizer-CtNsZNRZ.d.mts.map +1 -0
  89. package/dist/descriptor-meta-CafFMPhN-x3YQXDSX.mjs +26 -0
  90. package/dist/descriptor-meta-CafFMPhN-x3YQXDSX.mjs.map +1 -0
  91. package/dist/descriptor-meta-CkiPlqDS-n3hDP01X.mjs +137 -0
  92. package/dist/descriptor-meta-CkiPlqDS-n3hDP01X.mjs.map +1 -0
  93. package/dist/descriptor-meta-DEr1ALec-DvT6glGq.mjs +385 -0
  94. package/dist/descriptor-meta-DEr1ALec-DvT6glGq.mjs.map +1 -0
  95. package/dist/driver.d.mts +2 -2
  96. package/dist/driver.mjs +1 -1
  97. package/dist/driver__control.d.mts +1 -1
  98. package/dist/driver__control.mjs +1 -1
  99. package/dist/driver__runtime.d.mts +1 -1
  100. package/dist/driver__runtime.mjs +58 -20
  101. package/dist/driver__runtime.mjs.map +1 -1
  102. package/dist/errors-DxbvEzQp-CeTjoGtL.mjs +146 -0
  103. package/dist/errors-DxbvEzQp-CeTjoGtL.mjs.map +1 -0
  104. package/dist/{migration-DOKPHtxn.mjs → migration-BYRMZiPU.mjs} +6 -5
  105. package/dist/migration-BYRMZiPU.mjs.map +1 -0
  106. package/dist/{migration-uylRe5MP.d.mts → migration-Dekon_QC.d.mts} +6 -5
  107. package/dist/migration-Dekon_QC.d.mts.map +1 -0
  108. package/dist/{nodes-D8EC1yCx-rpfpuJ4T.d.mts → nodes-D8EC1yCx-BS-fKla6.d.mts} +2 -2
  109. package/dist/nodes-D8EC1yCx-BS-fKla6.d.mts.map +1 -0
  110. package/dist/{nodes-DUZSdX86-BBEEaxXY.mjs → nodes-DUZSdX86-DWyLY3OW.mjs} +2 -2
  111. package/dist/nodes-DUZSdX86-DWyLY3OW.mjs.map +1 -0
  112. package/dist/op-factory-call-DjbjegGT-DsQBI5Ll.mjs +2044 -0
  113. package/dist/op-factory-call-DjbjegGT-DsQBI5Ll.mjs.map +1 -0
  114. package/dist/op-factory-call-gQ5ddSys.d.mts +327 -0
  115. package/dist/op-factory-call-gQ5ddSys.d.mts.map +1 -0
  116. package/dist/pack-CHESErO8.d.mts +1477 -0
  117. package/dist/pack-CHESErO8.d.mts.map +1 -0
  118. package/dist/{planner-Bxdi7jZF.d.mts → planner-Bu5XBkHm.d.mts} +21 -10
  119. package/dist/planner-Bu5XBkHm.d.mts.map +1 -0
  120. package/dist/planner-C1OMkqV5-BAv-WPw6.mjs +497 -0
  121. package/dist/planner-C1OMkqV5-BAv-WPw6.mjs.map +1 -0
  122. package/dist/{planner-produced-sqlite-migration-BuJysRxx-CaDUbNVx.d.mts → planner-produced-sqlite-migration-CMjzJW5V-dVv0SjJm.d.mts} +5 -6
  123. package/dist/planner-produced-sqlite-migration-CMjzJW5V-dVv0SjJm.d.mts.map +1 -0
  124. package/dist/{planner-produced-sqlite-migration-C9uVDKrJ-CWbxSANn.mjs → planner-produced-sqlite-migration-CrbMD1ch-O7Mh_aKY.mjs} +13 -23
  125. package/dist/planner-produced-sqlite-migration-CrbMD1ch-O7Mh_aKY.mjs.map +1 -0
  126. package/dist/planner-produced-sqlite-migration-DtytlAAY.d.mts +1 -0
  127. package/dist/{planner-target-details-xR6UfIcz-CMahymzq.d.mts → planner-target-details-B-qtfkmj-DIGpv7YQ.d.mts} +2 -3
  128. package/dist/planner-target-details-B-qtfkmj-DIGpv7YQ.d.mts.map +1 -0
  129. package/dist/{planner-target-details-CIQ789Gc-C5U4yVY9.mjs → planner-target-details-Daaeo8s9-BGAN4JVc.mjs} +2 -4
  130. package/dist/planner-target-details-Daaeo8s9-BGAN4JVc.mjs.map +1 -0
  131. package/dist/render-ops-CQ-Kf4P0-DDUU4OFY.mjs +34 -0
  132. package/dist/render-ops-CQ-Kf4P0-DDUU4OFY.mjs.map +1 -0
  133. package/dist/{render-ops-B10yqmdG.d.mts → render-ops-Wlf_Pawh.d.mts} +3 -3
  134. package/dist/render-ops-Wlf_Pawh.d.mts.map +1 -0
  135. package/dist/require-temporal-CHWqSDF3-ElFTiAh6.mjs +16 -0
  136. package/dist/require-temporal-CHWqSDF3-ElFTiAh6.mjs.map +1 -0
  137. package/dist/{runtime-B1coahKC.d.mts → runtime-BvMPuBrJ.d.mts} +3 -3
  138. package/dist/runtime-BvMPuBrJ.d.mts.map +1 -0
  139. package/dist/runtime-C43fN_cJ.mjs +32 -0
  140. package/dist/runtime-C43fN_cJ.mjs.map +1 -0
  141. package/dist/{runtime-C5J9fusd.d.mts → runtime-CVBk_GlD.d.mts} +4 -4
  142. package/dist/runtime-CVBk_GlD.d.mts.map +1 -0
  143. package/dist/runtime-DqzT70C4.d.mts +67 -0
  144. package/dist/runtime-DqzT70C4.d.mts.map +1 -0
  145. package/dist/sql-renderer-DlZKtvVf.d.mts +1 -0
  146. package/dist/{sql-utils-0SJZOd7Q.d.mts → sql-utils-BqHka8P6.d.mts} +2 -2
  147. package/dist/sql-utils-BqHka8P6.d.mts.map +1 -0
  148. package/dist/{sql-utils-C2O4zVkP-Dz3Hb85I.mjs → sql-utils-CHBxMmv--Dl7wl7n3.mjs} +31 -4
  149. package/dist/sql-utils-CHBxMmv--Dl7wl7n3.mjs.map +1 -0
  150. package/dist/{sqlite-contract-view-BpNMaU2m-COMDaGaq.d.mts → sqlite-contract-view-BDw8T5Cp-BfFajhe4.d.mts} +5 -4
  151. package/dist/sqlite-contract-view-BDw8T5Cp-BfFajhe4.d.mts.map +1 -0
  152. package/dist/sqlite-contract-view-c-qO_pKt-DOCoqwrD.mjs +51 -0
  153. package/dist/sqlite-contract-view-c-qO_pKt-DOCoqwrD.mjs.map +1 -0
  154. package/dist/sqlite-migration-C_9TPlLD-DtKN8bi9.d.mts +227 -0
  155. package/dist/sqlite-migration-C_9TPlLD-DtKN8bi9.d.mts.map +1 -0
  156. package/dist/sqlite-migration-Cmzykasm--GxBXXny.mjs +1363 -0
  157. package/dist/sqlite-migration-Cmzykasm--GxBXXny.mjs.map +1 -0
  158. package/dist/{sqlite-contract-view-BYR10usg-BteDAUZr.mjs → sqlite-unbound-database-CfLXSiVo-Dy5VBXGz.mjs} +6 -47
  159. package/dist/sqlite-unbound-database-CfLXSiVo-Dy5VBXGz.mjs.map +1 -0
  160. package/dist/{shared-BYAX0FaQ--VvRXVRC.d.mts → tables-BY3u6rl_-Coqqy4JK.d.mts} +46 -10
  161. package/dist/tables-BY3u6rl_-Coqqy4JK.d.mts.map +1 -0
  162. package/dist/target.d.mts +30 -29
  163. package/dist/target.mjs +27 -20
  164. package/dist/target__aggregates.d.mts +1 -1
  165. package/dist/target__aggregates.mjs +1 -1
  166. package/dist/target__codec-descriptor.d.mts +2 -2
  167. package/dist/target__codec-descriptor.mjs +1 -1
  168. package/dist/target__codec-ids.d.mts +3 -3
  169. package/dist/target__codec-ids.mjs +2 -2
  170. package/dist/target__codec-types.d.mts +3 -3
  171. package/dist/target__codecs.d.mts +3 -3
  172. package/dist/target__codecs.mjs +4 -2
  173. package/dist/target__contract-free.d.mts +1 -1
  174. package/dist/target__contract-free.mjs +2 -2
  175. package/dist/target__control-tables.d.mts +1 -1
  176. package/dist/target__control-tables.mjs +1 -1
  177. package/dist/target__control.d.mts +3 -3
  178. package/dist/target__control.mjs +332 -114
  179. package/dist/target__control.mjs.map +1 -1
  180. package/dist/target__data-types.d.mts +2 -0
  181. package/dist/target__data-types.mjs +3 -0
  182. package/dist/target__ddl.d.mts +2 -2
  183. package/dist/target__ddl.mjs +1 -1
  184. package/dist/target__default-normalizer.d.mts +2 -2
  185. package/dist/target__default-normalizer.mjs +2 -2
  186. package/dist/target__migration.d.mts +3 -3
  187. package/dist/target__migration.mjs +3 -3
  188. package/dist/target__op-factory-call.d.mts +2 -2
  189. package/dist/target__op-factory-call.mjs +2 -2
  190. package/dist/target__pack.d.mts +1 -1
  191. package/dist/target__pack.mjs +1 -1
  192. package/dist/target__planner-produced-sqlite-migration.d.mts +2 -2
  193. package/dist/target__planner-produced-sqlite-migration.mjs +1 -1
  194. package/dist/target__planner-target-details.d.mts +1 -1
  195. package/dist/target__planner-target-details.mjs +1 -1
  196. package/dist/target__planner.d.mts +1 -1
  197. package/dist/target__planner.mjs +1 -1
  198. package/dist/target__render-ops.d.mts +1 -1
  199. package/dist/target__render-ops.mjs +1 -1
  200. package/dist/target__runtime.d.mts +3 -3
  201. package/dist/target__runtime.mjs +4 -17
  202. package/dist/target__sql-utils.d.mts +1 -1
  203. package/dist/target__sql-utils.mjs +1 -1
  204. package/dist/target__types.d.mts +2 -0
  205. package/dist/target__types.mjs +2 -0
  206. package/dist/{control--wMueaTg.d.mts → types-COqCbSev.d.mts} +3 -8
  207. package/dist/types-COqCbSev.d.mts.map +1 -0
  208. package/dist/types-CexPOm8x.d.mts +2 -0
  209. package/dist/{types-C5FSREvo-CwUlKK34.d.mts → types-RJMd2PlL-BTGAJrBQ.d.mts} +5 -7
  210. package/dist/types-RJMd2PlL-BTGAJrBQ.d.mts.map +1 -0
  211. package/package.json +23 -14
  212. package/dist/adapter-D7zw14p5.d.mts +0 -2
  213. package/dist/adapter-DEYUC-KO-DO_abhIq.d.mts.map +0 -1
  214. package/dist/adapter-jwxys1MM-CmUELyBs.mjs.map +0 -1
  215. package/dist/aggregates-BGuKJwfI.d.mts +0 -10
  216. package/dist/aggregates-BGuKJwfI.d.mts.map +0 -1
  217. package/dist/aggregates-DWyPO7t6.mjs.map +0 -1
  218. package/dist/codec-descriptor-B9ru99aI-DTkdKFU5.mjs.map +0 -1
  219. package/dist/codec-descriptor-BcgD9f3L-yDi5nh_k.d.mts +0 -31
  220. package/dist/codec-descriptor-BcgD9f3L-yDi5nh_k.d.mts.map +0 -1
  221. package/dist/codec-descriptor-rFuZ9DzY-CKRIRxah.d.mts +0 -1
  222. package/dist/codec-descriptor-vwfD3BMy.d.mts +0 -2
  223. package/dist/codec-ids-7WqtUuda.d.mts +0 -1
  224. package/dist/codec-ids-CzeDyMWW-BZAcI50I.d.mts +0 -14
  225. package/dist/codec-ids-CzeDyMWW-BZAcI50I.d.mts.map +0 -1
  226. package/dist/codec-ids-KMliSCRp-BhTbmbGr.mjs +0 -14
  227. package/dist/codec-ids-KMliSCRp-BhTbmbGr.mjs.map +0 -1
  228. package/dist/codec-types-B-TDcvQc.d.mts +0 -1
  229. package/dist/codec-types-CS0bD1kX.d.mts +0 -2
  230. package/dist/codec-types-D7uWRvQ1-DPnvquS8.d.mts +0 -25
  231. package/dist/codec-types-D7uWRvQ1-DPnvquS8.d.mts.map +0 -1
  232. package/dist/codecs-BDdR6FbY.mjs +0 -504
  233. package/dist/codecs-BDdR6FbY.mjs.map +0 -1
  234. package/dist/codecs-BQWqLgCl-CdB8t7HI.d.mts +0 -193
  235. package/dist/codecs-BQWqLgCl-CdB8t7HI.d.mts.map +0 -1
  236. package/dist/codecs-BTv6fRXv.d.mts +0 -1
  237. package/dist/column-types-NVxgsjFA.mjs +0 -34
  238. package/dist/column-types-NVxgsjFA.mjs.map +0 -1
  239. package/dist/column-types-iWGuW-0W.d.mts +0 -33
  240. package/dist/column-types-iWGuW-0W.d.mts.map +0 -1
  241. package/dist/contract-free-CCLAXZV2.d.mts.map +0 -1
  242. package/dist/contract-free-D5cZrgNl.mjs.map +0 -1
  243. package/dist/control--wMueaTg.d.mts.map +0 -1
  244. package/dist/control-B16T9OoX.mjs +0 -51
  245. package/dist/control-B16T9OoX.mjs.map +0 -1
  246. package/dist/control-CLirKz11.d.mts.map +0 -1
  247. package/dist/control-D9vMRRgU.d.mts.map +0 -1
  248. package/dist/control-tables-D_o8dKRB-BXi43noL.mjs.map +0 -1
  249. package/dist/control-tables-Dua-YcJL.d.mts.map +0 -1
  250. package/dist/ddl-CXduXyOT-nlDP6DGx.mjs.map +0 -1
  251. package/dist/ddl-CfSqNT0M.d.mts +0 -1
  252. package/dist/default-normalizer-B9V7TY5u.d.mts +0 -7
  253. package/dist/default-normalizer-B9V7TY5u.d.mts.map +0 -1
  254. package/dist/default-normalizer-DuoHj9-O-DsK7lJZn.mjs +0 -69
  255. package/dist/default-normalizer-DuoHj9-O-DsK7lJZn.mjs.map +0 -1
  256. package/dist/descriptor-meta-C0sCVHMY-1P-YUnEW.mjs +0 -34
  257. package/dist/descriptor-meta-C0sCVHMY-1P-YUnEW.mjs.map +0 -1
  258. package/dist/descriptor-meta-DjKgG4z5-D_0obUB8.mjs +0 -34
  259. package/dist/descriptor-meta-DjKgG4z5-D_0obUB8.mjs.map +0 -1
  260. package/dist/descriptor-meta-runtime-BkXK3OjD-CxZdKHCw.mjs +0 -13
  261. package/dist/descriptor-meta-runtime-BkXK3OjD-CxZdKHCw.mjs.map +0 -1
  262. package/dist/descriptor-meta-vjJkUDsn-Hz3rnAnk.mjs +0 -70
  263. package/dist/descriptor-meta-vjJkUDsn-Hz3rnAnk.mjs.map +0 -1
  264. package/dist/errors-DnR-sMHS-KkMLIP2U.mjs +0 -38
  265. package/dist/errors-DnR-sMHS-KkMLIP2U.mjs.map +0 -1
  266. package/dist/migration-DOKPHtxn.mjs.map +0 -1
  267. package/dist/migration-uylRe5MP.d.mts.map +0 -1
  268. package/dist/native-type-normalizer-CO2wKGL6.d.mts +0 -12
  269. package/dist/native-type-normalizer-CO2wKGL6.d.mts.map +0 -1
  270. package/dist/native-type-normalizer-GpQMEyN5.mjs +0 -14
  271. package/dist/native-type-normalizer-GpQMEyN5.mjs.map +0 -1
  272. package/dist/nodes-D8EC1yCx-rpfpuJ4T.d.mts.map +0 -1
  273. package/dist/nodes-DUZSdX86-BBEEaxXY.mjs.map +0 -1
  274. package/dist/op-factory-call-DoHN7Q7L.d.mts +0 -161
  275. package/dist/op-factory-call-DoHN7Q7L.d.mts.map +0 -1
  276. package/dist/op-factory-call-gc26GqyA-Db5Fasef.mjs +0 -829
  277. package/dist/op-factory-call-gc26GqyA-Db5Fasef.mjs.map +0 -1
  278. package/dist/pack-Cn0GAuEa.d.mts +0 -103
  279. package/dist/pack-Cn0GAuEa.d.mts.map +0 -1
  280. package/dist/planner-Bxdi7jZF.d.mts.map +0 -1
  281. package/dist/planner-Cqjr2usR-4wg3FB78.mjs +0 -824
  282. package/dist/planner-Cqjr2usR-4wg3FB78.mjs.map +0 -1
  283. package/dist/planner-produced-sqlite-migration-BuJysRxx-CaDUbNVx.d.mts.map +0 -1
  284. package/dist/planner-produced-sqlite-migration-C9uVDKrJ-CWbxSANn.mjs.map +0 -1
  285. package/dist/planner-produced-sqlite-migration-uySoqJO-.d.mts +0 -1
  286. package/dist/planner-target-details-CIQ789Gc-C5U4yVY9.mjs.map +0 -1
  287. package/dist/planner-target-details-xR6UfIcz-CMahymzq.d.mts.map +0 -1
  288. package/dist/render-ops-B10yqmdG.d.mts.map +0 -1
  289. package/dist/render-ops-KxAmAz6d-W2xyvA5y.mjs +0 -27
  290. package/dist/render-ops-KxAmAz6d-W2xyvA5y.mjs.map +0 -1
  291. package/dist/runtime-B1coahKC.d.mts.map +0 -1
  292. package/dist/runtime-B99c4n56.d.mts +0 -28
  293. package/dist/runtime-B99c4n56.d.mts.map +0 -1
  294. package/dist/runtime-C5J9fusd.d.mts.map +0 -1
  295. package/dist/shared-BYAX0FaQ--VvRXVRC.d.mts.map +0 -1
  296. package/dist/sql-renderer-KX6hn_tg.d.mts +0 -1
  297. package/dist/sql-utils-0SJZOd7Q.d.mts.map +0 -1
  298. package/dist/sql-utils-C2O4zVkP-Dz3Hb85I.mjs.map +0 -1
  299. package/dist/sqlite-contract-view-BYR10usg-BteDAUZr.mjs.map +0 -1
  300. package/dist/sqlite-contract-view-BpNMaU2m-COMDaGaq.d.mts.map +0 -1
  301. package/dist/sqlite-migration-CjMkH4Id-c6dM9w61.mjs +0 -94
  302. package/dist/sqlite-migration-CjMkH4Id-c6dM9w61.mjs.map +0 -1
  303. package/dist/sqlite-migration-o23JHwzY-CwNJcqwl.d.mts +0 -105
  304. package/dist/sqlite-migration-o23JHwzY-CwNJcqwl.d.mts.map +0 -1
  305. package/dist/target__native-type-normalizer.d.mts +0 -2
  306. package/dist/target__native-type-normalizer.mjs +0 -2
  307. package/dist/target__runtime.mjs.map +0 -1
  308. package/dist/types-B7e2QVEx.d.mts +0 -1
  309. package/dist/types-C5FSREvo-CwUlKK34.d.mts.map +0 -1
@@ -0,0 +1,1363 @@
1
+ import { f as SQLITE_INTEGER_CODEC_ID, h as SQLITE_TEXT_CODEC_ID, t as SQLITE_BIGINT_CODEC_ID } from "./codec-ids-CTshXpbg-tcdbf_VC.mjs";
2
+ import { S as sqliteTime, _ as sqliteInteger, b as sqliteText, c as sqliteDate, h as sqliteDuration, i as sqliteCharacter, o as sqliteCharacterVarying, p as sqliteDecimal, r as sqliteBoolean, t as sqliteBlob, u as sqliteDatetime, v as sqliteJson, y as sqliteReal } from "./data-types-Djvapurb-BR-Y4NWN.mjs";
3
+ import { i as errorSqliteMigrationStackMissing, l as sqliteError } from "./errors-DxbvEzQp-CeTjoGtL.mjs";
4
+ import { n as encodeSqliteDatetime } from "./codecs-izq9l1NG-Bb2RnXsx.mjs";
5
+ import { n as escapeLiteral } from "./sql-utils-CHBxMmv--Dl7wl7n3.mjs";
6
+ import { n as SqliteContractView } from "./sqlite-contract-view-c-qO_pKt-DOCoqwrD.mjs";
7
+ import { n as sqliteResolveDefault } from "./default-normalizer-BANdMVGr-BiUHyBX1.mjs";
8
+ import { A as sqliteDefaultToDdlColumnDefault, C as buildRecreateSummary, E as indexReplacementCalls, S as buildRecreatePostchecks, _ as RenameColumnCall, a as DataTransformCall, b as ReplaceStoredValueCall, c as DropIndexCall, d as INLINE_AUTOINCREMENT_PRIMARY_KEY, g as RemoveStoredValueCall, h as RemoveStoredKeyCall, i as CreateTableCall, j as sqliteIdentifiersCollide, k as renameTableSteps, l as DropTableCall, m as RecreateTableCall, o as DeleteRowsCall, r as CreateIndexCall, s as DropColumnCall, t as AddColumnCall, u as FillStoredKeyCall, v as RenameStoredKeyCall, y as RenameTableCall } from "./op-factory-call-DjbjegGT-DsQBI5Ll.mjs";
9
+ import { t as CONTROL_TABLE_NAMES } from "./control-tables-D_o8dKRB-n_QqsXcm.mjs";
10
+ import { DdlColumn, ForeignKeyConstraint, PrimaryKeyConstraint, UniqueConstraint } from "@prisma/orm-family-sql/relational-core/ast";
11
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
12
+ import { dataTypeParams } from "@prisma/orm-framework/components/codec";
13
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
14
+ import { InternalError } from "@prisma/orm-framework/utils/internal-error";
15
+ import { isSqlDataType, nameIsCatalogText, renderSqlTypeName, sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
16
+ import { diffSchemas, issueOutcome, orderIssuesByDependencies } from "@prisma/orm-framework/components/control";
17
+ import { sqlTextOf } from "@prisma/orm-family-sql/relational-core/contract-free";
18
+ import { UNBOUND_NAMESPACE_ID, entityAt } from "@prisma/orm-framework/components/ir";
19
+ import { contractToSchemaIR, extractCodecControlHooks, resolveColumnRenameAgainst, resolveTableRenameAgainst, scalarTypeNamesOf, sqlTypeLookupsOf, unmatchedColumnRename, unmatchedTableRename } from "@prisma/orm-family-sql/family/control";
20
+ import { PrimaryKey, RelationalSchemaNodeKind, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIR, SqlTableIR, SqlUniqueIR, relationalNodeGranularity, sqlColumnTypesEqual } from "@prisma/orm-family-sql/schema-ir/types";
21
+ import { verifySqlSchemaByDiff } from "@prisma/orm-family-sql/family/diff";
22
+ import { notOk, ok } from "@prisma/orm-framework/utils/result";
23
+ import { namingOf, namingOfLiveName, parseWireName } from "@prisma/orm-family-sql/schema-ir/naming";
24
+ import { isArrayEqual } from "@prisma/orm-framework/utils/array-equal";
25
+ import { Migration } from "@prisma/orm-family-sql/family/migration";
26
+ import { MigrationContractViews } from "@prisma/orm-toolchain/migration-tools/migration";
27
+ //#region ../../../3-targets/sqlite/1-target/dist/sqlite-migration-Cmzykasm.mjs
28
+ /**
29
+ * The SQLite expected-side projection: contract → flat relational schema IR.
30
+ *
31
+ * Each column's type is written from the data type its codec represents.
32
+ * Every expected column also carries its `codecRef` unconditionally
33
+ * (Decision 5) — the planner's op-builders resolve DDL rendering from it at
34
+ * plan time, so no separate render stamper is threaded here.
35
+ */
36
+ function sqliteContractToSchema(contract, types) {
37
+ return contractToSchemaIR(contract, {
38
+ annotationNamespace: "sqlite",
39
+ resolveDefault: sqliteResolveDefault,
40
+ dataTypeLookup: types.dataTypeLookup,
41
+ codecLookup: types.codecLookup
42
+ });
43
+ }
44
+ /**
45
+ * The SQLite schema verify: the full-tree node-diff verdict wrapped in the
46
+ * issue-based result envelope. Used by the runner's post-apply check; the
47
+ * family `verifySchema` runs the same composition via the descriptor hook.
48
+ */
49
+ function verifySqliteDatabaseSchema(input) {
50
+ return verifySqlSchemaByDiff({
51
+ contract: input.contract,
52
+ schema: input.actualSchema,
53
+ strict: input.strict,
54
+ frameworkComponents: input.frameworkComponents,
55
+ diffSchema: diffSqliteSchema,
56
+ granularityOf: relationalNodeGranularity,
57
+ databaseCapabilitiesNotProvided: void 0
58
+ });
59
+ }
60
+ /**
61
+ * Resolves a verdict-diff issue's subject table's declared control policy
62
+ * directly from the contract. SQLite's expected tree is flat, so the issue
63
+ * path carries no namespace segment — `path[1]` is the table name (`path[0]`
64
+ * is the tree root's own id); every contract namespace is searched for that
65
+ * table name (table names are globally unique in the flat tree — duplicates
66
+ * across namespaces are rejected earlier, at `contractToSchemaIR`).
67
+ */
68
+ function resolveControlPolicy(issue, contract) {
69
+ const tableName = issue.path[1];
70
+ if (tableName === void 0) return void 0;
71
+ for (const namespaceId of Object.keys(contract.storage.namespaces)) {
72
+ const table = entityAt(contract.storage, {
73
+ namespaceId,
74
+ entityKind: "table",
75
+ entityName: tableName
76
+ });
77
+ if (table !== void 0) return table.control;
78
+ }
79
+ }
80
+ /**
81
+ * The SQLite full-tree node diff for the family verify verdict: derive the
82
+ * expected flat tree with resolved leaf values (parameterized types written
83
+ * with their parameters; FK nodes born with the flat empty
84
+ * `resolvedReferencedNamespace`), and run the generic differ over the trees
85
+ * as derived. Flat targets need no ownership scoping. The codec `verifyType`
86
+ * hooks run once per contract namespace with tables, each against the sole
87
+ * flat actual root — exactly the legacy per-namespace pairing.
88
+ */
89
+ function diffSqliteSchema(input) {
90
+ const types = sqlTypeLookupsOf(input.frameworkComponents);
91
+ const expected = sqliteContractToSchema(input.contract, types);
92
+ const actual = input.schema instanceof SqlSchemaIR ? input.schema : blindCast(input.schema);
93
+ return {
94
+ issues: diffSchemas(expected, actual),
95
+ resolveControlPolicy: (issue) => resolveControlPolicy(issue, input.contract),
96
+ namespacePairs: Object.values(input.contract.storage.namespaces).filter((ns) => Object.keys(ns.entries.table ?? {}).length > 0).map(() => ({ actual }))
97
+ };
98
+ }
99
+ /**
100
+ * The SQLite planner's diff input: the same tree-building
101
+ * `diffSqliteSchema` uses (FK nodes born flat). One differ
102
+ * drives both verify and plan over the trees as derived; this is the plan-side
103
+ * derivation — column DDL resolves from each expected column's `codecRef` at
104
+ * plan time (`column-ddl-rendering.ts`), so no separate render stamping happens here.
105
+ */
106
+ function buildSqlitePlanDiff(input) {
107
+ const types = sqlTypeLookupsOf(input.frameworkComponents);
108
+ const expected = sqliteContractToSchema(input.contract, types);
109
+ const actual = sqliteActualSchema(input.actualSchema);
110
+ return {
111
+ expected,
112
+ actual,
113
+ issues: diffSchemas(expected, actual)
114
+ };
115
+ }
116
+ /** The schema a plan starts from as a `SqlSchemaIR`, its table and column names taken from their keys. */
117
+ function sqliteActualSchema(actualSchema) {
118
+ return new SqlSchemaIR(withRecordKeyNames(actualSchema));
119
+ }
120
+ /**
121
+ * Every schema-tree builder in this codebase derives a table's / column's
122
+ * `name` from the record key it's stored under (`contractToSchemaIR`,
123
+ * the SQLite introspection adapter) rather than trusting a redundant
124
+ * embedded field — the record key IS the identity. Mirrors that discipline
125
+ * for the actual/live tree before construction, so `SqlTableIR.id` /
126
+ * `SqlColumnIR.id` (both derived from `.name`) are always correct without
127
+ * requiring every caller to duplicate the key onto the value. A no-op for a
128
+ * tree that already carries matching names (the real introspection adapter
129
+ * always does).
130
+ */
131
+ function withRecordKeyNames(actualSchema) {
132
+ const raw = blindCast(actualSchema);
133
+ const tables = {};
134
+ for (const [tableName, table] of Object.entries(raw.tables ?? {})) {
135
+ const rawTable = blindCast(table);
136
+ const columns = {};
137
+ for (const [columnName, column] of Object.entries(blindCast(table).columns ?? {})) columns[columnName] = column instanceof SqlColumnIR ? column.name === columnName ? column : column.withName(columnName) : {
138
+ ...blindCast(column),
139
+ name: columnName
140
+ };
141
+ tables[tableName] = {
142
+ ...rawTable,
143
+ name: tableName,
144
+ columns,
145
+ foreignKeys: rawTable.foreignKeys ?? [],
146
+ uniques: rawTable.uniques ?? [],
147
+ indexes: rawTable.indexes ?? []
148
+ };
149
+ }
150
+ return { tables };
151
+ }
152
+ /**
153
+ * The type DDL writes for a column node: the name of the type it is stored as, with the parameters as the contract writes them, in upper case, or as given for a data type whose name is its catalog text, since verify compares that text exactly (ADR 273).
154
+ */
155
+ function columnTypeSql(column) {
156
+ const type = column.storedType;
157
+ if (type === void 0 || !isSqlDataType(type)) throw new InternalError(`column "${column.name}" has no data type; the expected tree must be derived via contractToSchemaIR for planning`);
158
+ const written = renderSqlTypeName(type, dataTypeParams(type, column.codecRef?.typeParams));
159
+ return nameIsCatalogText(type) ? written : written.toUpperCase();
160
+ }
161
+ /** The default DDL writes: the one the contract authored; `resolvedDefault` exists for the diff comparison. */
162
+ function ddlDefaultOf(column) {
163
+ return column.authoredDefault ?? column.resolvedDefault;
164
+ }
165
+ /**
166
+ * True when the column is rendered inline as `INTEGER PRIMARY KEY
167
+ * AUTOINCREMENT` — the sole member of the table's primary key with an
168
+ * `autoincrement()` default. Node-based sibling of the retired
169
+ * `isInlineAutoincrementPrimaryKey` (which read the raw `StorageTable`);
170
+ * reads the table/column nodes instead.
171
+ */
172
+ function isInlineAutoincrementPrimaryKeyNode(table, column) {
173
+ if (table.primaryKey?.columns.length !== 1) return false;
174
+ if (table.primaryKey.columns[0] !== column.name) return false;
175
+ return column.resolvedDefault?.kind === "function" && column.resolvedDefault.expression === "autoincrement()";
176
+ }
177
+ /**
178
+ * Builds the flat `SqliteColumnSpec` `AddColumnCall` / `RecreateTableCall`
179
+ * need, with the type the column is stored as.
180
+ */
181
+ function columnSpecFromNode(column, inline) {
182
+ const typeSql = columnTypeSql(column);
183
+ return {
184
+ name: column.name,
185
+ typeSql,
186
+ ...inline ? {} : {
187
+ ...ifDefined("default", ddlDefaultOf(column)),
188
+ ...ifDefined("codecRef", column.codecRef)
189
+ },
190
+ nullable: column.nullable,
191
+ ...inline ? { inlineAutoincrementPrimaryKey: true } : {}
192
+ };
193
+ }
194
+ /**
195
+ * Builds the `DdlColumn` the `CreateTableCall` path needs, with the type the
196
+ * column is stored as.
197
+ */
198
+ function ddlColumnFromNode(column, inline) {
199
+ const typeSql = columnTypeSql(column);
200
+ if (inline) return new DdlColumn({
201
+ name: column.name,
202
+ type: `${typeSql}${INLINE_AUTOINCREMENT_PRIMARY_KEY}`
203
+ });
204
+ const colDefault = sqliteDefaultToDdlColumnDefault(ddlDefaultOf(column));
205
+ return new DdlColumn({
206
+ name: column.name,
207
+ type: typeSql,
208
+ ...!column.nullable ? { notNull: true } : {},
209
+ ...colDefault !== void 0 ? { default: colDefault } : {},
210
+ ...column.codecRef !== void 0 ? { codecRef: column.codecRef } : {}
211
+ });
212
+ }
213
+ /**
214
+ * Builds the table-level constraints (PK / unique / FK) for a `CreateTable`
215
+ * path from the table node — the node-sourced sibling of the retired
216
+ * contract-based `tableToDdlParts`'s constraint half.
217
+ *
218
+ * A check constraint on the table node throws rather than being dropped.
219
+ * `@@check` is refused earlier, by the `sql.checkConstraint` capability gate in
220
+ * PSL interpretation. The TS `check()` builder is not gated there — capabilities
221
+ * are adapter-reported and reach the contract only after it is built — so a
222
+ * `check()` declared against SQLite arrives here, and this is where it is
223
+ * refused. It is the primary enforcement point for that surface, and the safety
224
+ * net for a contract that reached storage some other way.
225
+ */
226
+ function tableConstraintsFromNode(table, hasInlinePk) {
227
+ const constraints = [];
228
+ if (table.primaryKey && !hasInlinePk) constraints.push(new PrimaryKeyConstraint({ columns: table.primaryKey.columns }));
229
+ for (const check of table.checks ?? []) throw sqliteError("CONTRACT.CONSTRAINT_INVALID", `The SQLite target does not support CHECK constraints (constraint "${check.name}" on table "${table.name}"). The "checkConstraint" capability is Postgres-only — remove the "@@check" / "check()" declaration, or target Postgres.`, { meta: {
230
+ constraintName: check.name,
231
+ tableName: table.name
232
+ } });
233
+ for (const u of table.uniques) constraints.push(new UniqueConstraint({
234
+ columns: u.columns,
235
+ ...u.name !== void 0 ? { name: u.name } : {}
236
+ }));
237
+ for (const fk of table.foreignKeys) constraints.push(new ForeignKeyConstraint({
238
+ columns: fk.columns,
239
+ refTable: fk.referencedTable,
240
+ refColumns: fk.referencedColumns,
241
+ ...fk.name !== void 0 ? { name: fk.name } : {},
242
+ ...fk.onDelete !== void 0 ? { onDelete: fk.onDelete } : {},
243
+ ...fk.onUpdate !== void 0 ? { onUpdate: fk.onUpdate } : {}
244
+ }));
245
+ return constraints;
246
+ }
247
+ const DATA_TYPE_FILL_VALUES = /* @__PURE__ */ new Map([
248
+ [sqliteDatetime.id, `'${escapeLiteral(encodeSqliteDatetime(/* @__PURE__ */ new Date(0)))}'`],
249
+ [sqliteDate.id, "'1970-01-01'"],
250
+ [sqliteTime.id, "'00:00:00.000'"],
251
+ [sqliteDuration.id, "'PT0S'"],
252
+ [sqliteJson.id, `'{}'`],
253
+ [sqliteInteger.id, "0"],
254
+ [sqliteReal.id, "0"],
255
+ [sqliteText.id, "''"],
256
+ [sqliteDecimal.id, "'0'"],
257
+ [sqliteBoolean.id, "0"],
258
+ [sqliteCharacter.id, "''"],
259
+ [sqliteCharacterVarying.id, "''"],
260
+ [sqliteBlob.id, "X''"]
261
+ ]);
262
+ function isParamRecord(value) {
263
+ return value !== null && typeof value === "object" && !Array.isArray(value);
264
+ }
265
+ /**
266
+ * The SQL value a new required column takes in the rows a table already has, or `undefined` when
267
+ * its type has none: the column's codec hook first, as on Postgres, then a value of its data type.
268
+ */
269
+ function sqliteFillValue(column, codecHooks, types) {
270
+ const codecRef = column.codecRef;
271
+ if (codecRef === void 0 || column.many === true) return void 0;
272
+ const dataType = sqlDataTypeOfCodec(codecRef.codecId, types).id;
273
+ const fromHook = codecHooks.get(codecRef.codecId)?.resolveIdentityValue?.({
274
+ dataType,
275
+ codecId: codecRef.codecId,
276
+ ...isParamRecord(codecRef.typeParams) ? { typeParams: codecRef.typeParams } : {}
277
+ });
278
+ if (fromHook !== void 0) return fromHook ?? void 0;
279
+ return DATA_TYPE_FILL_VALUES.get(dataType);
280
+ }
281
+ /**
282
+ * SQLite migration strategies.
283
+ *
284
+ * Each strategy examines the node-typed issue list, consumes issues it
285
+ * handles, and returns the `SqliteOpFactoryCall[]` to address them. The issue
286
+ * planner runs each strategy in order and routes whatever's left through
287
+ * `mapNodeIssueToCall`.
288
+ *
289
+ * SQLite has no enums and no component-declared database dependencies. The
290
+ * recipe that needs strategy-level multi-issue consumption is `recreateTable`,
291
+ * which absorbs type/nullability/default/constraint mismatches, and required
292
+ * columns added to existing tables, for a given table into one rebuild.
293
+ */
294
+ /**
295
+ * Classifies a node issue into the operation class a recreate absorbing it
296
+ * would need, or `null` when the strategy doesn't handle this node/reason at
297
+ * all (table/column not-found-or-not-expected, and index issues — those are
298
+ * standalone ops, never folded into a recreate).
299
+ *
300
+ * Column drift is a single `not-equal` issue (type and nullability compared
301
+ * together by `SqlColumnIR.isEqualTo`): a type change is destructive, because
302
+ * the copy can change values; a nullability change alone is widening, because
303
+ * a tightening copy fails on a NULL rather than losing it.
304
+ */
305
+ /** The column of a column issue, which `classifyNodeIssue` classes destructive only for a type change. */
306
+ function columnNameOf(issue) {
307
+ return blindCast(issue.expected).name;
308
+ }
309
+ /**
310
+ * The changes of codec a table rebuild's copy makes without losing a value: the column's type
311
+ * affinity stores each old value as the same value of the new type. An integer becomes its decimal
312
+ * text; a real is not listed, since SQLite writes it as text with fifteen significant digits. Keyed
313
+ * by codec, not data type, because `Int` and `BigInt` differ only in their codec.
314
+ */
315
+ const LOSSLESS_COPIES = /* @__PURE__ */ new Set([
316
+ `${SQLITE_INTEGER_CODEC_ID}→${SQLITE_TEXT_CODEC_ID}`,
317
+ `${SQLITE_BIGINT_CODEC_ID}→${SQLITE_TEXT_CODEC_ID}`,
318
+ `${SQLITE_INTEGER_CODEC_ID}→${SQLITE_BIGINT_CODEC_ID}`
319
+ ]);
320
+ function copyKeepsEveryValue(fromCodec, to) {
321
+ const toCodec = to.codecRef?.codecId;
322
+ return fromCodec !== void 0 && toCodec !== void 0 && LOSSLESS_COPIES.has(`${fromCodec}→${toCodec}`);
323
+ }
324
+ function classifyNodeIssue(issue, ctx) {
325
+ const node = issue.expected ?? issue.actual;
326
+ if (node === void 0) return null;
327
+ switch (blindCast(node).nodeKind) {
328
+ case RelationalSchemaNodeKind.column: {
329
+ if (issueOutcome(issue) !== "not-equal") return null;
330
+ const expected = blindCast(issue.expected);
331
+ const actual = blindCast(issue.actual);
332
+ const fromCodec = ctx.originCodecId(String(issue.path[1]), actual.name);
333
+ return !sqlColumnTypesEqual(expected, actual) && !copyKeepsEveryValue(fromCodec, expected) ? "destructive" : "widening";
334
+ }
335
+ case RelationalSchemaNodeKind.columnDefault:
336
+ case RelationalSchemaNodeKind.primaryKey:
337
+ case RelationalSchemaNodeKind.foreignKey:
338
+ case RelationalSchemaNodeKind.unique: return "widening";
339
+ default: return null;
340
+ }
341
+ }
342
+ function columnNode(node) {
343
+ return blindCast(node);
344
+ }
345
+ function isColumnIssue(issue) {
346
+ const node = issue.expected ?? issue.actual;
347
+ return node !== void 0 && blindCast(node).nodeKind === RelationalSchemaNodeKind.column;
348
+ }
349
+ /** The column a `--convert` or `--backfill` statement of `kind` names, if one names it. */
350
+ function statementColumn(ctx, kind, tableName, columnName) {
351
+ if (!ctx.policy.allowedOperationClasses.includes("data")) return void 0;
352
+ return ctx.statementColumns[kind].find((column) => column.table === tableName && column.column === columnName);
353
+ }
354
+ /** A column the plan adds to a table the database already has. */
355
+ function addedColumn(issue, ctx) {
356
+ if (issueOutcome(issue) !== "not-found" || !isColumnIssue(issue)) return void 0;
357
+ const tableName = issue.path[1];
358
+ if (tableName === void 0 || ctx.actual.tables[tableName] === void 0) return void 0;
359
+ return columnNode(issue.expected);
360
+ }
361
+ /**
362
+ * A required column with no default that the plan adds to a table the database already has, so
363
+ * existing rows need a value for it.
364
+ */
365
+ function addedRequiredColumn(issue, ctx) {
366
+ const column = addedColumn(issue, ctx);
367
+ return column === void 0 || column.nullable || column.resolvedDefault !== void 0 ? void 0 : column;
368
+ }
369
+ const CLASS_ORDER = [
370
+ "additive",
371
+ "widening",
372
+ "data",
373
+ "destructive"
374
+ ];
375
+ function highestClass(classes) {
376
+ return classes.reduce((highest, next) => CLASS_ORDER.indexOf(next) > CLASS_ORDER.indexOf(highest) ? next : highest, "additive");
377
+ }
378
+ /**
379
+ * Groups recreate-eligible issues by table and emits one `RecreateTableCall` per table, removing
380
+ * the issues it consumed so `mapNodeIssueToCall` does not handle them again.
381
+ *
382
+ * - A type change is `destructive`, since the copy can change values, unless a `--convert`
383
+ * statement names the column: the copy then goes through a slot the user fills, and the rebuild
384
+ * is `data`. Either way the rebuild checks after its copy that every value took the new type.
385
+ * - A nullability or constraint change alone is `widening`: a tightening copy fails on a NULL
386
+ * rather than losing it.
387
+ * - A required column with no default added to an existing table is copied from a temporary value
388
+ * (`additive`). A column in a key or foreign key, whose values come from a value set, or whose
389
+ * type has no such value is carried with nothing to copy from: the rebuild succeeds on an empty
390
+ * table and fails on `NOT NULL` when the table has rows. A column a `--backfill` statement names
391
+ * was added nullable and filled by earlier calls, so the rebuild copies it like a live column.
392
+ * - A rebuild that leaves a live column out loses its values, so it is `destructive`.
393
+ * - Any other column added to a table the plan rebuilds, optional or with a default, and an index
394
+ * on it, are left to the rebuild, which creates them from the new table's spec. The plan has no
395
+ * separate add, so the rebuild's source table is the live one (`additive`).
396
+ *
397
+ * The table shapes come from `ctx.expected` and `ctx.actual`, keyed by table name: SQLite is a
398
+ * flat, single-namespace target, and one issue only carries its own node.
399
+ */
400
+ const recreateTableStrategy = (issues, ctx) => {
401
+ const byTable = /* @__PURE__ */ new Map();
402
+ const consumed = /* @__PURE__ */ new Set();
403
+ const codecHooks = extractCodecControlHooks(ctx.frameworkComponents);
404
+ const rebuildOf = (tableName) => {
405
+ const existing = byTable.get(tableName);
406
+ if (existing !== void 0) return existing;
407
+ const created = {
408
+ issues: [],
409
+ classes: [],
410
+ retypedColumns: [],
411
+ copyExpressions: {},
412
+ temporaryValues: {},
413
+ addedColumns: []
414
+ };
415
+ byTable.set(tableName, created);
416
+ return created;
417
+ };
418
+ for (const issue of issues) {
419
+ const tableName = issue.path[1];
420
+ if (tableName === void 0) continue;
421
+ const added = addedRequiredColumn(issue, ctx);
422
+ if (added !== void 0) {
423
+ const expectedTable = ctx.expected.tables[tableName];
424
+ if (statementColumn(ctx, "backfill", tableName, added.name) !== void 0) {
425
+ const rebuild = rebuildOf(tableName);
426
+ rebuild.issues.push(issue);
427
+ rebuild.addedColumns.push(added.name);
428
+ rebuild.classes.push("widening");
429
+ consumed.add(issue);
430
+ continue;
431
+ }
432
+ const fill = expectedTable === void 0 || !ctx.takesTemporaryValue(tableName, added.name) ? void 0 : sqliteFillValue(added, codecHooks, ctx.types);
433
+ const rebuild = rebuildOf(tableName);
434
+ rebuild.issues.push(issue);
435
+ if (fill !== void 0) rebuild.temporaryValues[added.name] = {
436
+ kind: "sql",
437
+ sql: fill
438
+ };
439
+ rebuild.classes.push("additive");
440
+ consumed.add(issue);
441
+ continue;
442
+ }
443
+ const cls = classifyNodeIssue(issue, ctx);
444
+ if (!cls) continue;
445
+ const rebuild = rebuildOf(tableName);
446
+ rebuild.issues.push(issue);
447
+ consumed.add(issue);
448
+ if (cls === "widening") {
449
+ rebuild.classes.push("widening");
450
+ continue;
451
+ }
452
+ const column = columnNameOf(issue);
453
+ const converted = statementColumn(ctx, "convert", tableName, column);
454
+ rebuild.retypedColumns.push(column);
455
+ if (converted === void 0) {
456
+ rebuild.classes.push("destructive");
457
+ continue;
458
+ }
459
+ rebuild.copyExpressions[column] = {
460
+ kind: "placeholder",
461
+ slot: `${converted.text}:convert`
462
+ };
463
+ rebuild.classes.push("data");
464
+ }
465
+ for (const issue of issues) {
466
+ const rebuild = byTable.get(issue.path[1] ?? "");
467
+ if (consumed.has(issue) || rebuild === void 0 || addedColumn(issue, ctx) === void 0) continue;
468
+ rebuild.issues.push(issue);
469
+ rebuild.classes.push("additive");
470
+ consumed.add(issue);
471
+ }
472
+ if (byTable.size === 0) return { kind: "no_match" };
473
+ const calls = [];
474
+ for (const [tableName, rebuild] of byTable) {
475
+ const expectedTable = ctx.expected.tables[tableName];
476
+ const actualTable = ctx.actual.tables[tableName];
477
+ if (!expectedTable || !actualTable) continue;
478
+ const leavesColumnsOut = Object.keys(actualTable.columns).some((column) => !Object.hasOwn(expectedTable.columns, column));
479
+ const operationClass = highestClass([...rebuild.classes, ...leavesColumnsOut ? ["destructive"] : []]);
480
+ const tableSpec = tableSpecFromNode(expectedTable);
481
+ const indexes = expectedTable.indexes.map((idx) => ({
482
+ name: idx.name,
483
+ columns: idx.columns ?? []
484
+ }));
485
+ calls.push(new RecreateTableCall({
486
+ tableName,
487
+ contractTable: tableSpec,
488
+ schemaColumnNames: [...Object.keys(actualTable.columns), ...rebuild.addedColumns],
489
+ indexes,
490
+ summary: buildRecreateSummary(tableName, rebuild.issues),
491
+ postchecks: [...buildRecreatePostchecks(tableName, rebuild.issues, tableSpec, /* @__PURE__ */ new Set([...Object.keys(rebuild.copyExpressions), ...Object.keys(rebuild.temporaryValues)]), new Set(tableSpec.columns.filter(({ name }) => statementColumn(ctx, "backfill", tableName, name) !== void 0).map(({ name }) => name)))],
492
+ operationClass,
493
+ copyExpressions: rebuild.copyExpressions,
494
+ temporaryValues: rebuild.temporaryValues,
495
+ retypedColumns: rebuild.retypedColumns
496
+ }));
497
+ }
498
+ return {
499
+ kind: "match",
500
+ issues: issues.filter((i) => !consumed.has(i)),
501
+ calls,
502
+ recipe: true
503
+ };
504
+ };
505
+ /**
506
+ * Writes the calls that come before the rebuild of a column a `--backfill` statement names: for a
507
+ * required column added to an existing table, the nullable add and a data transform whose slot the
508
+ * user fills; for a column made required, the data transform. The rebuild that makes the column
509
+ * NOT NULL comes from `recreateTableStrategy`, so this strategy consumes no issue. Without the
510
+ * statement, a tightening rebuild fails on a NULL rather than guessing a value for it.
511
+ */
512
+ const nullabilityTighteningBackfillStrategy = (issues, ctx) => {
513
+ const calls = [];
514
+ for (const issue of issues) {
515
+ const tableName = issue.path[1];
516
+ if (tableName === void 0 || !isColumnIssue(issue)) continue;
517
+ const added = addedRequiredColumn(issue, ctx);
518
+ const tightened = issueOutcome(issue) === "not-equal" && !columnNode(issue.expected).nullable && columnNode(issue.actual).nullable ? columnNode(issue.expected) : void 0;
519
+ const column = added ?? tightened;
520
+ if (column === void 0) continue;
521
+ const named = statementColumn(ctx, "backfill", tableName, column.name);
522
+ if (named === void 0) continue;
523
+ if (added !== void 0) calls.push(new AddColumnCall(tableName, {
524
+ ...columnSpecFromNode(added, false),
525
+ nullable: true
526
+ }));
527
+ calls.push(new DataTransformCall(`data_migration.backfill-${tableName}-${column.name}`, `Backfill NULLs in "${tableName}"."${column.name}" before NOT NULL tightening`, tableName, column.name, `${named.text}:run`));
528
+ }
529
+ if (calls.length === 0) return { kind: "no_match" };
530
+ return {
531
+ kind: "match",
532
+ issues,
533
+ calls,
534
+ recipe: true
535
+ };
536
+ };
537
+ const sqlitePlannerStrategies = [nullabilityTighteningBackfillStrategy, recreateTableStrategy];
538
+ /**
539
+ * The generic differ is total: a missing/extra table (or column) emits an
540
+ * issue for itself AND for every node in its subtree (columns, defaults,
541
+ * constraints, indexes). `CreateTableCall`/`DropTableCall` and
542
+ * `AddColumnCall`/`DropColumnCall` already account for the whole subtree
543
+ * (reading it directly off the table/column node), so the nested issues are
544
+ * redundant — coalescing them is "the planner's responsibility" the differ's
545
+ * own contract assigns (`schema-diff.ts`). Drops any issue whose path is a
546
+ * strict descendant of a `not-found`/`not-expected` issue's path.
547
+ */
548
+ function coalesceSubtreeIssues(issues) {
549
+ const collapsingPaths = issues.filter((issue) => issueOutcome(issue) === "not-found" || issueOutcome(issue) === "not-expected").map((issue) => issue.path);
550
+ if (collapsingPaths.length === 0) return issues;
551
+ return issues.filter((issue) => !collapsingPaths.some((ancestor) => isStrictDescendantPath(issue.path, ancestor)));
552
+ }
553
+ function isStrictDescendantPath(path, ancestor) {
554
+ if (path.length <= ancestor.length) return false;
555
+ for (let i = 0; i < ancestor.length; i += 1) if (path[i] !== ancestor[i]) return false;
556
+ return true;
557
+ }
558
+ function issueNode(issue) {
559
+ const node = issue.expected ?? issue.actual;
560
+ if (node === void 0) return void 0;
561
+ return blindCast(node);
562
+ }
563
+ /**
564
+ * Builds the flat `SqliteTableSpec` `RecreateTableCall` needs from the
565
+ * expected table node — the node-sourced equivalent of the retired
566
+ * `toTableSpec` (which read a raw contract `StorageTable`). Every column's
567
+ * spec is resolved from its `codecRef` via `columnSpecFromNode`.
568
+ */
569
+ function tableSpecFromNode(table) {
570
+ const columns = Object.values(table.columns).map((c) => columnSpecFromNode(c, isInlineAutoincrementPrimaryKeyNode(table, c)));
571
+ const uniques = table.uniques.map((u) => ({
572
+ columns: u.columns,
573
+ ...u.name !== void 0 ? { name: u.name } : {}
574
+ }));
575
+ const foreignKeys = table.foreignKeys.map((fk) => ({
576
+ columns: fk.columns,
577
+ references: {
578
+ table: fk.referencedTable,
579
+ columns: fk.referencedColumns
580
+ },
581
+ ...fk.name !== void 0 ? { name: fk.name } : {},
582
+ ...fk.onDelete !== void 0 ? { onDelete: fk.onDelete } : {},
583
+ ...fk.onUpdate !== void 0 ? { onUpdate: fk.onUpdate } : {}
584
+ }));
585
+ return {
586
+ columns,
587
+ ...table.primaryKey ? { primaryKey: { columns: table.primaryKey.columns } } : {},
588
+ uniques,
589
+ foreignKeys
590
+ };
591
+ }
592
+ function issueConflict(kind, summary, location) {
593
+ return {
594
+ kind,
595
+ summary,
596
+ why: "Use `migration new` to author a custom migration for this change.",
597
+ ...location ? { location } : {}
598
+ };
599
+ }
600
+ function issueLocation(tableName, columnName) {
601
+ return columnName !== void 0 ? {
602
+ entityKind: "table",
603
+ entityName: tableName,
604
+ column: columnName
605
+ } : {
606
+ entityKind: "table",
607
+ entityName: tableName
608
+ };
609
+ }
610
+ /**
611
+ * Conflict kind for a node kind that `recreateTableStrategy` absorbs for
612
+ * every reachable production issue. Reaching `mapNodeIssueToCall` for one of
613
+ * these means the recreate strategy didn't run — mirrors the legacy
614
+ * `conflictKindForIssue` per-kind categorization.
615
+ */
616
+ function absorbedConflictKind(nodeKind) {
617
+ switch (nodeKind) {
618
+ case RelationalSchemaNodeKind.primaryKey:
619
+ case RelationalSchemaNodeKind.unique: return "indexIncompatible";
620
+ case RelationalSchemaNodeKind.foreignKey: return "foreignKeyConflict";
621
+ default: return "missingButNonAdditive";
622
+ }
623
+ }
624
+ /**
625
+ * Builds the `CreateTableCall` + per-index `CreateIndexCall`s for a
626
+ * newly-expected table. Reads only the table node's own children — indexes
627
+ * (declared + FK-backing, deduped) are already merged and ordered at
628
+ * derivation (`contractToSchemaIR`'s `convertTable`).
629
+ */
630
+ function buildCreateTableCalls(table) {
631
+ const columns = Object.values(table.columns).map((c) => ddlColumnFromNode(c, isInlineAutoincrementPrimaryKeyNode(table, c)));
632
+ const constraints = tableConstraintsFromNode(table, Object.values(table.columns).some((c) => isInlineAutoincrementPrimaryKeyNode(table, c)));
633
+ const calls = [new CreateTableCall(table.name, columns, constraints.length > 0 ? constraints : void 0)];
634
+ for (const index of table.indexes) {
635
+ const indexName = index.name;
636
+ calls.push(new CreateIndexCall(table.name, indexName, index.columns ?? []));
637
+ }
638
+ return calls;
639
+ }
640
+ function mapTableIssue(issue) {
641
+ if (issueOutcome(issue) === "not-found") return ok(buildCreateTableCalls(blindCast(issue.expected)));
642
+ if (issueOutcome(issue) === "not-expected") {
643
+ const table = blindCast(issue.actual);
644
+ if (CONTROL_TABLE_NAMES.has(table.name)) return ok([]);
645
+ return ok([new DropTableCall(table.name)]);
646
+ }
647
+ return notOk(issueConflict("unsupportedOperation", `Unexpected table drift: ${issue.path.join("/")}`));
648
+ }
649
+ function mapColumnIssue(issue, ctx) {
650
+ const tableName = issue.path[1];
651
+ if (tableName === void 0) return notOk(issueConflict("unsupportedOperation", `Column issue has no table in its path: ${issue.path.join("/")}`));
652
+ if (issueOutcome(issue) === "not-found") {
653
+ const column = blindCast(issue.expected);
654
+ const table = ctx.expected.tables[tableName];
655
+ return ok([new AddColumnCall(tableName, columnSpecFromNode(column, table !== void 0 && isInlineAutoincrementPrimaryKeyNode(table, column)))]);
656
+ }
657
+ if (issueOutcome(issue) === "not-expected") return ok([new DropColumnCall(tableName, blindCast(issue.actual).name)]);
658
+ const expected = blindCast(issue.expected);
659
+ return notOk(issueConflict(sqlColumnTypesEqual(expected, blindCast(issue.actual)) ? "nullabilityConflict" : "typeMismatch", issue.path.join("/"), issueLocation(tableName, expected.name)));
660
+ }
661
+ function mapIndexIssue(issue) {
662
+ const tableName = issue.path[1];
663
+ if (tableName === void 0) return notOk(issueConflict("unsupportedOperation", `Index issue has no table in its path: ${issue.path.join("/")}`));
664
+ if (issueOutcome(issue) === "not-found") {
665
+ const index = blindCast(issue.expected);
666
+ const indexName = index.name;
667
+ return ok([new CreateIndexCall(tableName, indexName, index.columns ?? [])]);
668
+ }
669
+ if (issueOutcome(issue) === "not-expected") {
670
+ const indexName = blindCast(issue.actual).name;
671
+ return ok([new DropIndexCall(tableName, indexName)]);
672
+ }
673
+ return notOk(issueConflict("indexIncompatible", issue.path.join("/"), issueLocation(tableName)));
674
+ }
675
+ function mapNodeIssueToCall(issue, ctx) {
676
+ const node = issueNode(issue);
677
+ if (node === void 0) return notOk(issueConflict("unsupportedOperation", `Issue carries neither an expected nor an actual node: ${issue.path.join("/")}`));
678
+ switch (node.nodeKind) {
679
+ case RelationalSchemaNodeKind.table: return mapTableIssue(issue);
680
+ case RelationalSchemaNodeKind.column: return mapColumnIssue(issue, ctx);
681
+ case RelationalSchemaNodeKind.index: return mapIndexIssue(issue);
682
+ case RelationalSchemaNodeKind.columnDefault:
683
+ case RelationalSchemaNodeKind.primaryKey:
684
+ case RelationalSchemaNodeKind.foreignKey:
685
+ case RelationalSchemaNodeKind.unique: return notOk(issueConflict(absorbedConflictKind(node.nodeKind), issue.path.join("/")));
686
+ case RelationalSchemaNodeKind.check: return notOk(issueConflict("unsupportedOperation", `The SQLite target does not support CHECK constraint DDL: ${issue.path.join("/")}`));
687
+ default: return notOk(issueConflict("unsupportedOperation", `Unhandled node kind: ${node.nodeKind}`));
688
+ }
689
+ }
690
+ function classifyCall(call) {
691
+ switch (call.factoryName) {
692
+ case "createTable": return "create-table";
693
+ case "addColumn": return "add-column";
694
+ case "createIndex": return "create-index";
695
+ case "dropColumn": return "drop-column";
696
+ case "dropIndex": return "drop-index";
697
+ case "dropTable": return "drop-table";
698
+ case "recreateTable": return null;
699
+ default: return null;
700
+ }
701
+ }
702
+ const DEFAULT_POLICY = { allowedOperationClasses: [
703
+ "additive",
704
+ "widening",
705
+ "destructive",
706
+ "data"
707
+ ] };
708
+ function planIssues(options) {
709
+ const policyProvided = options.policy !== void 0;
710
+ const policy = options.policy ?? DEFAULT_POLICY;
711
+ const frameworkComponents = options.frameworkComponents ?? [];
712
+ const context = {
713
+ expected: options.expected ?? emptySchemaIR(),
714
+ actual: options.actual ?? emptySchemaIR(),
715
+ policy,
716
+ frameworkComponents,
717
+ types: sqlTypeLookupsOf(frameworkComponents),
718
+ statementColumns: options.statementColumns ?? {
719
+ convert: [],
720
+ backfill: []
721
+ },
722
+ takesTemporaryValue: options.takesTemporaryValue ?? (() => true),
723
+ originCodecId: options.originCodecId ?? (() => void 0)
724
+ };
725
+ const strategies = options.strategies ?? sqlitePlannerStrategies;
726
+ let remaining = options.issues;
727
+ const recipeCalls = [];
728
+ const bucketableCalls = [];
729
+ for (const strategy of strategies) {
730
+ const result = strategy(remaining, context);
731
+ if (result.kind === "match") {
732
+ remaining = result.issues;
733
+ if (result.recipe) recipeCalls.push(...result.calls);
734
+ else bucketableCalls.push(...result.calls);
735
+ }
736
+ }
737
+ const sorted = orderIssuesByDependencies(remaining);
738
+ const defaultCalls = [];
739
+ const conflicts = [];
740
+ for (const issue of sorted) {
741
+ const result = mapNodeIssueToCall(issue, context);
742
+ if (result.ok) defaultCalls.push(...result.value);
743
+ else conflicts.push(result.failure);
744
+ }
745
+ const allowed = policy.allowedOperationClasses;
746
+ let gatedRecipe = recipeCalls;
747
+ let gatedBucketable = bucketableCalls;
748
+ let gatedDefault = defaultCalls;
749
+ if (policyProvided) {
750
+ const sink = (acc) => (call) => {
751
+ if (allowed.includes(call.operationClass)) {
752
+ acc.push(call);
753
+ return;
754
+ }
755
+ conflicts.push(conflictForDisallowedCall(call, allowed));
756
+ };
757
+ const gatedRecipeBucket = [];
758
+ const gatedBucketableBucket = [];
759
+ const gatedDefaultBucket = [];
760
+ recipeCalls.forEach(sink(gatedRecipeBucket));
761
+ bucketableCalls.forEach(sink(gatedBucketableBucket));
762
+ defaultCalls.forEach(sink(gatedDefaultBucket));
763
+ gatedRecipe = gatedRecipeBucket;
764
+ gatedBucketable = gatedBucketableBucket;
765
+ gatedDefault = gatedDefaultBucket;
766
+ }
767
+ if (conflicts.length > 0) return notOk(conflicts);
768
+ const rebuiltIndexes = new Set(gatedRecipe.flatMap((call) => call instanceof RecreateTableCall ? call.indexes.map((index) => indexKey(call.tableName, index.name)) : []));
769
+ const bucketed = [...gatedDefault, ...gatedBucketable];
770
+ const addedBeforeIndexes = new Set(bucketed.flatMap((call) => call instanceof AddColumnCall ? [indexKey(call.tableName, call.columnName)] : []));
771
+ const indexesANewColumn = (call) => {
772
+ const live = Object.hasOwn(context.actual.tables, call.tableName) ? context.actual.tables[call.tableName] : void 0;
773
+ return live !== void 0 && call.columns.some((column) => !Object.hasOwn(live.columns, column) && !addedBeforeIndexes.has(indexKey(call.tableName, column)));
774
+ };
775
+ const combined = bucketed.filter((call) => !(call instanceof CreateIndexCall) || !indexesANewColumn(call) || !rebuiltIndexes.has(indexKey(call.tableName, call.indexName)));
776
+ const byCategory = (cat) => combined.filter((c) => classifyCall(c) === cat);
777
+ return ok({ calls: [
778
+ ...byCategory("create-table"),
779
+ ...byCategory("add-column"),
780
+ ...byCategory("create-index"),
781
+ ...gatedRecipe,
782
+ ...byCategory("drop-column"),
783
+ ...byCategory("drop-index"),
784
+ ...byCategory("drop-table")
785
+ ] });
786
+ }
787
+ function indexKey(tableName, indexName) {
788
+ return JSON.stringify([tableName, indexName]);
789
+ }
790
+ function emptySchemaIR() {
791
+ return new SqlSchemaIR({ tables: {} });
792
+ }
793
+ function conflictForDisallowedCall(call, allowed) {
794
+ const summary = `Operation "${call.label}" requires class "${call.operationClass}", but policy allows only: ${allowed.join(", ")}`;
795
+ const location = locationForCall(call);
796
+ return {
797
+ kind: conflictKindForCall(call),
798
+ summary,
799
+ why: "Use `migration new` to author a custom migration for this change.",
800
+ refusedOperationClass: call.operationClass,
801
+ ...location ? { location } : {}
802
+ };
803
+ }
804
+ function conflictKindForCall(call) {
805
+ switch (call.factoryName) {
806
+ case "createIndex":
807
+ case "dropIndex": return "indexIncompatible";
808
+ default: return "missingButNonAdditive";
809
+ }
810
+ }
811
+ function locationForCall(call) {
812
+ const location = {};
813
+ if ("tableName" in call) {
814
+ location.entityKind = "table";
815
+ location.entityName = call.tableName;
816
+ }
817
+ if ("columnName" in call) location.column = call.columnName;
818
+ if ("indexName" in call) location.index = call.indexName;
819
+ return Object.keys(location).length > 0 ? location : void 0;
820
+ }
821
+ function indexFindings(issues, outcome) {
822
+ return issues.flatMap((issue) => {
823
+ const node = issueNode(issue);
824
+ const tableName = issue.path[1];
825
+ if (node === void 0 || !SqlIndexIR.is(node) || tableName === void 0) return [];
826
+ return issueOutcome(issue) === outcome ? [{
827
+ issue,
828
+ index: node,
829
+ tableName
830
+ }] : [];
831
+ });
832
+ }
833
+ /**
834
+ * An index on a renamed table whose wire name derives from the table name: the old and the new index share their content hash and differ in name.
835
+ */
836
+ function renamedTableIndex(renamedTables) {
837
+ return (old, replacement) => {
838
+ const oldWire = parseWireName(old.index.name);
839
+ const replacementWire = parseWireName(replacement.index.name);
840
+ return renamedTables.has(old.tableName) && old.tableName === replacement.tableName && oldWire !== void 0 && oldWire.hash === replacementWire?.hash && old.index.name !== replacement.index.name;
841
+ };
842
+ }
843
+ /**
844
+ * An index on the renamed column whose wire name derives from the column name: after the rename
845
+ * the old and the new index cover the same columns on the same table and differ in name.
846
+ */
847
+ function renamedColumnIndex(table, column) {
848
+ return (old, replacement) => old.tableName === table && replacement.tableName === table && old.index.name !== replacement.index.name && old.index.expression === void 0 && old.index.where === void 0 && (old.index.columns ?? []).includes(column) && old.index.unique === replacement.index.unique && isArrayEqual(old.index.columns ?? [], replacement.index.columns ?? []);
849
+ }
850
+ /**
851
+ * An index on the same table whose new name SQLite takes for the old one, as after a table renamed by hand. Its content is not compared: the old index must be dropped before the new one can be created whatever either defines, and the new one is created from its own definition.
852
+ */
853
+ const indexNameCaseChange = (old, replacement) => old.tableName === replacement.tableName && old.index.name !== replacement.index.name && sqliteIdentifiersCollide(old.index.name, replacement.index.name);
854
+ /**
855
+ * Pairs each index the plan drops with the index that replaces it, and plans every paired drop before every paired create. SQLite cannot rename an index, and it compares index names without regard to the case of ASCII letters, so a replacement whose name differs from the old one only in that case would otherwise collide with it. The paired issues are returned as consumed so the ordinary diff does not plan them again.
856
+ */
857
+ function pairIndexReplacements(issues, matches) {
858
+ const missing = indexFindings(issues, "not-found");
859
+ const pairs = indexFindings(issues, "not-expected").flatMap((old) => {
860
+ const replacement = missing.find((candidate) => matches(old, candidate));
861
+ if (replacement === void 0) return [];
862
+ missing.splice(missing.indexOf(replacement), 1);
863
+ return [{
864
+ old,
865
+ replacement
866
+ }];
867
+ });
868
+ const replacements = pairs.map(({ old, replacement }) => ({
869
+ drop: new DropIndexCall(old.tableName, old.index.name),
870
+ create: new CreateIndexCall(replacement.tableName, replacement.index.name, replacement.index.columns ?? [])
871
+ }));
872
+ return {
873
+ replacements,
874
+ calls: indexReplacementCalls(replacements),
875
+ consumed: new Set(pairs.flatMap(({ old, replacement }) => [old.issue, replacement.issue]))
876
+ };
877
+ }
878
+ /**
879
+ * The tables of a SQLite schema. SQLite has one namespace, so the namespace id is ignored, and it
880
+ * compares table and column names without regard to the case of ASCII letters.
881
+ */
882
+ function sqliteSchemaTables(schema) {
883
+ const hasTable = (_namespaceId, table) => Object.hasOwn(schema.tables, table);
884
+ return {
885
+ sameName: sqliteIdentifiersCollide,
886
+ hasTable,
887
+ hasColumn: (_namespaceId, table, column) => Object.hasOwn(schema.tables[table]?.columns ?? {}, column),
888
+ tablesNamed: (_namespaceId, table) => Object.keys(schema.tables).filter((existing) => sqliteIdentifiersCollide(existing, table)),
889
+ columnsNamed: (_namespaceId, table, column) => Object.keys(schema.tables[table]?.columns ?? {}).filter((existing) => sqliteIdentifiersCollide(existing, column)),
890
+ namespacesWithTable: (table) => hasTable(UNBOUND_NAMESPACE_ID, table) ? [UNBOUND_NAMESPACE_ID] : [],
891
+ hasNamespace: (namespaceId) => namespaceId === UNBOUND_NAMESPACE_ID
892
+ };
893
+ }
894
+ function rewriteRefs(refs, rewrite) {
895
+ return refs?.map(rewrite);
896
+ }
897
+ /**
898
+ * Rewrites the step of `kind` and `id` in a ref that runs through the given table, and the table
899
+ * step itself when `kind` is the table kind.
900
+ */
901
+ function stepRewrite(tableName, kind, fromId, toId) {
902
+ return (ref) => {
903
+ const tableStep = ref[1];
904
+ if (tableStep?.nodeKind !== RelationalSchemaNodeKind.table || tableStep.id !== tableName) return ref;
905
+ return ref.map((step, index) => index >= 1 && step.nodeKind === kind && step.id === fromId ? {
906
+ nodeKind: kind,
907
+ id: toId
908
+ } : step);
909
+ };
910
+ }
911
+ /**
912
+ * An index whose definition carries SQL text, an expression or a predicate, keeps its columns as
913
+ * they are: a column named inside the text cannot be renamed here, so the diff plans the index.
914
+ */
915
+ function withIndex(index, name, rewrite, columnName) {
916
+ const columnsFollow = index.expression === void 0 && index.where === void 0;
917
+ const base = {
918
+ naming: name === index.name ? namingOf(index.name, index.prefix) : namingOfLiveName(name),
919
+ where: index.where,
920
+ unique: index.unique,
921
+ partial: index.partial,
922
+ type: index.type,
923
+ options: index.options,
924
+ annotations: index.annotations,
925
+ dependsOn: rewriteRefs(index.dependsOn, rewrite)
926
+ };
927
+ return new SqlIndexIR(index.expression !== void 0 ? {
928
+ ...base,
929
+ expression: index.expression
930
+ } : {
931
+ ...base,
932
+ columns: (index.columns ?? []).map(columnsFollow ? columnName : (c) => c)
933
+ });
934
+ }
935
+ function rebuildTable(table, edit, rewrite) {
936
+ const { primaryKey } = table;
937
+ const { columnName } = edit;
938
+ return new SqlTableIR({
939
+ name: edit.name,
940
+ columns: Object.fromEntries(Object.values(table.columns).map((column) => {
941
+ const name = columnName(column.name);
942
+ return [name, name === column.name ? column : column.withName(name)];
943
+ })),
944
+ ...ifDefined("primaryKey", primaryKey === void 0 ? void 0 : new PrimaryKey({
945
+ columns: primaryKey.columns.map(columnName),
946
+ ...ifDefined("name", primaryKey.name),
947
+ ...ifDefined("dependsOn", rewriteRefs(primaryKey.dependsOn, rewrite))
948
+ })),
949
+ uniques: table.uniques.map((unique) => new SqlUniqueIR({
950
+ columns: unique.columns.map(columnName),
951
+ ...ifDefined("name", unique.name),
952
+ ...ifDefined("annotations", unique.annotations),
953
+ ...ifDefined("dependsOn", rewriteRefs(unique.dependsOn, rewrite))
954
+ })),
955
+ foreignKeys: table.foreignKeys.map((fk) => new SqlForeignKeyIR({
956
+ columns: fk.columns.map(columnName),
957
+ referencedTable: edit.referencedTable(fk),
958
+ referencedColumns: edit.referencedColumns(fk),
959
+ ...ifDefined("referencedSchema", fk.referencedSchema),
960
+ ...ifDefined("name", fk.name),
961
+ ...ifDefined("onDelete", fk.onDelete),
962
+ ...ifDefined("onUpdate", fk.onUpdate),
963
+ ...ifDefined("annotations", fk.annotations),
964
+ ...ifDefined("resolvedReferencedNamespace", fk.resolvedReferencedNamespace),
965
+ ...ifDefined("dependsOn", rewriteRefs(fk.dependsOn, rewrite))
966
+ })),
967
+ indexes: table.indexes.map((index) => withIndex(index, edit.indexName(index), rewrite, columnName)),
968
+ ...ifDefined("checks", table.checks?.map((check) => new SqlCheckConstraintIR({
969
+ naming: namingOf(check.name, check.prefix),
970
+ expression: check.expression,
971
+ dependsOn: rewriteRefs(check.dependsOn, rewrite)
972
+ }))),
973
+ ...ifDefined("annotations", table.annotations)
974
+ });
975
+ }
976
+ /** Rebuilds every table: `editFor` returns the edit for a table, or `undefined` to keep it. */
977
+ function mapTables(schema, rewrite, editFor) {
978
+ return new SqlSchemaIR({
979
+ tables: Object.fromEntries(Object.values(schema.tables).map((table) => {
980
+ const rebuilt = rebuildTable(table, {
981
+ name: table.name,
982
+ columnName: (column) => column,
983
+ referencedTable: (fk) => fk.referencedTable,
984
+ referencedColumns: (fk) => fk.referencedColumns,
985
+ indexName: (index) => index.name,
986
+ ...editFor(table)
987
+ }, rewrite);
988
+ return [rebuilt.name, rebuilt];
989
+ })),
990
+ ...ifDefined("annotations", schema.annotations)
991
+ });
992
+ }
993
+ /**
994
+ * The schema with one table under its new name. Foreign keys anywhere that reference the table
995
+ * follow it, and every dependency that names it moves with it. Object names do not change. An
996
+ * unnamed primary key, unique constraint or foreign key stays unnamed: SQLite gives such a
997
+ * constraint no name, so an introspected schema has none either, and the planner never renames
998
+ * one.
999
+ */
1000
+ function renameTableInSqliteSchema(schema, rename) {
1001
+ const { from, to } = rename;
1002
+ return mapTables(schema, stepRewrite(from, RelationalSchemaNodeKind.table, from, to), (table) => ({
1003
+ ...table.name === from ? { name: to } : {},
1004
+ referencedTable: (fk) => fk.referencedTable === from ? to : fk.referencedTable
1005
+ }));
1006
+ }
1007
+ /**
1008
+ * The schema with one column under its new name. The table's primary key, unique constraints,
1009
+ * foreign keys and plain column indexes name it under the new name, foreign keys anywhere that
1010
+ * reference it follow it, and every dependency that names it moves with it. An index with an
1011
+ * expression or a predicate keeps its SQL text, and index names do not change, as in SQLite.
1012
+ */
1013
+ function renameColumnInSqliteSchema(schema, rename) {
1014
+ const { table: tableName, from, to } = rename;
1015
+ const rewrite = stepRewrite(tableName, RelationalSchemaNodeKind.column, `column:${from}`, `column:${to}`);
1016
+ const renamed = (column) => column === from ? to : column;
1017
+ return mapTables(schema, rewrite, (table) => ({
1018
+ ...table.name === tableName ? { columnName: renamed } : {},
1019
+ referencedColumns: (fk) => fk.referencedTable === tableName ? fk.referencedColumns.map(renamed) : fk.referencedColumns
1020
+ }));
1021
+ }
1022
+ function replaceIndex(schema, replacement) {
1023
+ const { tableName, indexName: oldIndexName } = replacement.drop;
1024
+ const newIndexName = replacement.create.indexName;
1025
+ return mapTables(schema, stepRewrite(tableName, RelationalSchemaNodeKind.index, `index:${oldIndexName}`, `index:${newIndexName}`), (table) => table.name === tableName ? { indexName: (index) => index.name === oldIndexName ? newIndexName : index.name } : void 0);
1026
+ }
1027
+ /** The working schema of a plan or a migration, starting from `initial`. */
1028
+ function createWorkingSchema(initial) {
1029
+ return new WorkingSchemaImpl(initial);
1030
+ }
1031
+ var WorkingSchemaImpl = class {
1032
+ #current;
1033
+ constructor(initial) {
1034
+ this.#current = initial;
1035
+ }
1036
+ get current() {
1037
+ return this.#current;
1038
+ }
1039
+ apply(call) {
1040
+ const renamed = call instanceof RenameColumnCall ? renameColumnInSqliteSchema(this.#current, {
1041
+ table: call.tableName,
1042
+ from: call.oldColumnName,
1043
+ to: call.columnName
1044
+ }) : renameTableInSqliteSchema(this.#current, {
1045
+ from: call.oldTableName,
1046
+ to: call.tableName
1047
+ });
1048
+ this.#current = call.indexReplacements.reduce(replaceIndex, renamed);
1049
+ }
1050
+ };
1051
+ /** The SQL a user runs against the database to rename the table by hand. */
1052
+ function renameTableByHandStatements(rename) {
1053
+ return renameTableSteps(rename.from, rename.to).map((renameStep) => renameStep.sql);
1054
+ }
1055
+ /** The `renameTable` call a user writes in `migration.ts` for `rename`; SQLite has no namespaces. */
1056
+ function renderRenameTableCall(rename) {
1057
+ return new RenameTableCall(rename.from, rename.to, []).renderTypeScript();
1058
+ }
1059
+ /** How a user renames a table by hand on SQLite. */
1060
+ const sqliteTableRenameByHand = {
1061
+ renderTableRename: renderRenameTableCall,
1062
+ tableRenameByHand: renameTableByHandStatements
1063
+ };
1064
+ /**
1065
+ * The call that renames a table, carrying as companions a drop and a create under the new name of
1066
+ * each index whose wire name derives from the old table name, since SQLite cannot rename an index.
1067
+ * `previous` is the schema with the table under its old name; the renamed copy is diffed against
1068
+ * `contract`. SQLite names no primary key, unique constraint or foreign key the contract leaves
1069
+ * unnamed, so those need nothing.
1070
+ */
1071
+ function sqliteTableRenameCall(input) {
1072
+ const { from, to } = input.rename;
1073
+ const { issues } = buildSqlitePlanDiff({
1074
+ contract: input.contract,
1075
+ actualSchema: renameTableInSqliteSchema(input.previous, {
1076
+ from,
1077
+ to
1078
+ }),
1079
+ frameworkComponents: input.frameworkComponents
1080
+ });
1081
+ const { replacements } = pairIndexReplacements(coalesceSubtreeIssues(issues), renamedTableIndex(/* @__PURE__ */ new Set([to])));
1082
+ return new RenameTableCall(from, to, replacements);
1083
+ }
1084
+ /**
1085
+ * The call that renames a column, carrying as companions a drop and a create under the new name of
1086
+ * each index on the column whose wire name derives from the column name, since SQLite cannot rename
1087
+ * an index and keeps the old name when it renames the column. `previous` is the schema with the
1088
+ * column under its old name; the renamed copy is diffed against `contract`.
1089
+ */
1090
+ function sqliteColumnRenameCall(input) {
1091
+ const { table, from, to } = input.rename;
1092
+ const { issues } = buildSqlitePlanDiff({
1093
+ contract: input.contract,
1094
+ actualSchema: renameColumnInSqliteSchema(input.previous, {
1095
+ table,
1096
+ from,
1097
+ to
1098
+ }),
1099
+ frameworkComponents: input.frameworkComponents
1100
+ });
1101
+ const { replacements } = pairIndexReplacements(coalesceSubtreeIssues(issues), renamedColumnIndex(table, to));
1102
+ return new RenameColumnCall(table, from, to, replacements);
1103
+ }
1104
+ /**
1105
+ * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
1106
+ * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
1107
+ * SQLite literal, so both user-authored migrations and renderer-generated
1108
+ * scaffolds can extend `SqliteMigration` directly without redeclaring
1109
+ * target-local identity.
1110
+ *
1111
+ * The constructor materializes a single SQLite `SqlControlAdapter` from
1112
+ * `stack.adapter.create(stack)` and stores it; the protected instance methods
1113
+ * forward to the corresponding `*Call` with that stored adapter, so user
1114
+ * migrations can write `this.createTable({...})` without threading the adapter
1115
+ * through every call.
1116
+ *
1117
+ * Binds the framework base's `Start` / `End` contract generics so a subclass
1118
+ * that assigns its snapshot-store `contract.json` imports to
1119
+ * `startContractJson` / `endContractJson` gets fully-typed view accessors:
1120
+ * `this.endContract` is a `SqliteContractView<End>`
1121
+ * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),
1122
+ * built lazily from the JSON fields via the shared `MigrationContractViews`
1123
+ * helper. Mirrors `MongoMigration`'s view getters; the framework base derives
1124
+ * `describe()` from the same JSON.
1125
+ */
1126
+ var SqliteMigration = class extends Migration {
1127
+ targetId = "sqlite";
1128
+ /**
1129
+ * Materialized SQLite control adapter, created once per migration
1130
+ * instance from the injected stack. `undefined` only when the migration
1131
+ * was instantiated without a stack (test fixtures); `controlAdapterFor`
1132
+ * throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING in that case to surface the misuse.
1133
+ */
1134
+ controlAdapter;
1135
+ #endView = new MigrationContractViews(this, "SqliteMigration", (json) => SqliteContractView.fromJson(json));
1136
+ /** The rename calls this read of `operations` has made so far, in order. */
1137
+ #renames = [];
1138
+ #startView = new MigrationContractViews(this, "SqliteMigration", (json) => SqliteContractView.fromJson(json));
1139
+ constructor(stack) {
1140
+ super(stack);
1141
+ this.controlAdapter = stack?.adapter ? blindCast(stack.adapter.create(stack)) : void 0;
1142
+ }
1143
+ frameworkComponents() {
1144
+ const stack = this.stack;
1145
+ if (stack === void 0) return [];
1146
+ return [
1147
+ stack.target,
1148
+ ...stack.adapter === void 0 ? [] : [stack.adapter],
1149
+ ...stack.extensions
1150
+ ];
1151
+ }
1152
+ /** The value object field a key fill fills, checked against the end contract with the stack's codecs, data types and type names; a check needs a stack. */
1153
+ storedKeyFillField(operation, text) {
1154
+ if (text === void 0) return void 0;
1155
+ this.controlAdapterFor(operation);
1156
+ const typeNamespace = this.stack?.authoringContributions.type ?? {};
1157
+ return {
1158
+ text,
1159
+ check: {
1160
+ contract: this.endContract,
1161
+ types: {
1162
+ ...sqlTypeLookupsOf(this.frameworkComponents()),
1163
+ scalarTypeName: scalarTypeNamesOf(typeNamespace)
1164
+ }
1165
+ }
1166
+ };
1167
+ }
1168
+ /** The codec `codecRef` names, built from the stack's codecs; a codec needs a stack. */
1169
+ storedValueCodec(operation, codecRef) {
1170
+ if (codecRef === void 0) return void 0;
1171
+ this.controlAdapterFor(operation);
1172
+ return {
1173
+ codecRef,
1174
+ codecs: sqlTypeLookupsOf(this.frameworkComponents()).codecLookup
1175
+ };
1176
+ }
1177
+ /**
1178
+ * Returns the materialized control adapter, or throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING naming
1179
+ * `operation` when the migration was constructed without a `ControlStack`.
1180
+ * Single home for the null-check that every DDL/DML method shares.
1181
+ */
1182
+ controlAdapterFor(operation) {
1183
+ if (!this.controlAdapter) throw errorSqliteMigrationStackMissing(operation);
1184
+ return this.controlAdapter;
1185
+ }
1186
+ /**
1187
+ * The typed SQLite view over this migration's end-state contract — sole
1188
+ * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.
1189
+ * Throws if no `endContractJson` was provided.
1190
+ */
1191
+ get endContract() {
1192
+ return this.#endView.endContract;
1193
+ }
1194
+ /**
1195
+ * The typed SQLite view over this migration's start-state contract, or
1196
+ * `null` for a baseline migration (no `startContractJson`).
1197
+ */
1198
+ get startContract() {
1199
+ return this.#startView.startContract;
1200
+ }
1201
+ createTable(options) {
1202
+ return new CreateTableCall(options.table, options.columns, options.constraints).toOp(this.controlAdapterFor("createTable"));
1203
+ }
1204
+ dropTable(options) {
1205
+ return new DropTableCall(options.table).toOp(this.controlAdapterFor("dropTable"));
1206
+ }
1207
+ /**
1208
+ * Emit the operations that rename a table: the table rename, then a drop and a create under the
1209
+ * new name of each index whose name was derived from the old table name. The old name is resolved
1210
+ * against the schema as this migration's earlier `renameTable` calls leave it, and the new name
1211
+ * against the end contract. Spread the result into `operations`:
1212
+ * `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`. Throws
1213
+ * `MIGRATION.TABLE_RENAME_UNMATCHED` when the table does not exist at that point of the migration
1214
+ * or the end contract lacks the new name.
1215
+ */
1216
+ renameTable(options) {
1217
+ const adapter = this.controlAdapterFor("renameTable");
1218
+ const rename = {
1219
+ namespaceId: void 0,
1220
+ from: options.table,
1221
+ to: options.to
1222
+ };
1223
+ const startContract = this.startContract;
1224
+ if (startContract === null) throw unmatchedTableRename(rename, "the migration has no start contract");
1225
+ const current = this.schemaAfterRenames(startContract);
1226
+ const endContract = this.endContract;
1227
+ const resolved = resolveTableRenameAgainst(sqliteSchemaTables(current), endContract, rename);
1228
+ if (!resolved.ok) throw resolved.failure;
1229
+ const call = sqliteTableRenameCall({
1230
+ previous: current,
1231
+ contract: endContract,
1232
+ rename: resolved.value,
1233
+ frameworkComponents: this.frameworkComponents()
1234
+ });
1235
+ this.#renames.push(call);
1236
+ return call.toOps(adapter);
1237
+ }
1238
+ /**
1239
+ * Emit the operations that rename a column: the column rename, then a drop and a create under
1240
+ * the new name of each index on the column whose name was derived from the old column name. The
1241
+ * column is resolved against the schema as this migration's earlier rename calls leave it, so a
1242
+ * column of a table an earlier `renameTable` renamed is named on the table's new name. Spread the
1243
+ * result into `operations`: `...this.renameColumn({ table: 'User', column: 'name', to:
1244
+ * 'fullName' })`. Throws `MIGRATION.COLUMN_RENAME_UNMATCHED` when the table or column does not
1245
+ * exist at that point of the migration, the table already has the new column, or the end
1246
+ * contract lacks it.
1247
+ */
1248
+ renameColumn(options) {
1249
+ const adapter = this.controlAdapterFor("renameColumn");
1250
+ const rename = {
1251
+ namespaceId: void 0,
1252
+ table: options.table,
1253
+ from: options.column,
1254
+ to: options.to
1255
+ };
1256
+ const startContract = this.startContract;
1257
+ if (startContract === null) throw unmatchedColumnRename(rename, "the migration has no start contract");
1258
+ const current = this.schemaAfterRenames(startContract);
1259
+ const resolved = resolveColumnRenameAgainst(sqliteSchemaTables(current), this.endContract, rename);
1260
+ if (!resolved.ok) throw resolved.failure;
1261
+ const call = sqliteColumnRenameCall({
1262
+ previous: current,
1263
+ contract: this.endContract,
1264
+ rename: resolved.value,
1265
+ frameworkComponents: this.frameworkComponents()
1266
+ });
1267
+ this.#renames.push(call);
1268
+ return call.toOps(adapter);
1269
+ }
1270
+ /** The start contract's schema with this read's rename calls applied in order. */
1271
+ schemaAfterRenames(startContract) {
1272
+ const working = createWorkingSchema(sqliteContractToSchema(startContract, sqlTypeLookupsOf(this.frameworkComponents())));
1273
+ for (const call of this.#renames) working.apply(call);
1274
+ return working.current;
1275
+ }
1276
+ beginOperationsRead() {
1277
+ this.#renames = [];
1278
+ }
1279
+ addColumn(options) {
1280
+ return new AddColumnCall(options.table, columnSpecOf(options.column, "addColumn", options.table)).toOp(this.controlAdapterFor("addColumn"));
1281
+ }
1282
+ dropColumn(options) {
1283
+ return new DropColumnCall(options.table, options.column).toOp(this.controlAdapterFor("dropColumn"));
1284
+ }
1285
+ /**
1286
+ * Emit an `UPDATE` operation that changes the stored value `from` to `to` in `column`, in every row that holds it. Values are stored values, as the column's codec writes them, and are passed as parameters. Without `codecRef`, pass each value in the form the column stores it, or no row matches.
1287
+ */
1288
+ replaceStoredValue(options) {
1289
+ return new ReplaceStoredValueCall(options.table, options.column, options.from, options.to, this.storedValueCodec("replaceStoredValue", options.codecRef), options.path).toOp();
1290
+ }
1291
+ /**
1292
+ * Emit an `UPDATE` operation that sets `column` to NULL in every row that holds the stored value `value`. On a column that takes no NULL, its check fails while any row holds the value. The operation is destructive.
1293
+ */
1294
+ removeStoredValue(options) {
1295
+ return new RemoveStoredValueCall(options.table, options.column, options.value, this.storedValueCodec("removeStoredValue", options.codecRef), options.enumValue, options.path, options.nullable).toOp();
1296
+ }
1297
+ /**
1298
+ * Emit an `UPDATE` operation that renames the key at the end of `path` to `to`, in every object of `column` the path reaches. `path` is an RFC 9535 JSONPath of member names (`.lat`, `['lat']`) and wildcards (`[*]`, `.*`, each selecting the elements of a list and the member values of an object) from the column's value, `$`, and ends at the key: `'$[*].lat'` renames `lat` in each object of a list. Only rows that hold the key are written. Its check fails, and nothing changes, while an object holds both keys.
1299
+ */
1300
+ renameStoredKey(options) {
1301
+ return Promise.resolve(new RenameStoredKeyCall(options.table, options.column, options.path, options.to).toOp());
1302
+ }
1303
+ /**
1304
+ * Emit an `UPDATE` operation that removes the key at the end of `path` from every object of `column` the path reaches. `path` is written as for `renameStoredKey`. Only rows that hold the key are written. The operation is destructive.
1305
+ */
1306
+ removeStoredKey(options) {
1307
+ return Promise.resolve(new RemoveStoredKeyCall(options.table, options.column, options.path).toOp());
1308
+ }
1309
+ /**
1310
+ * Emit an `UPDATE` operation that sets the key at the end of `path` to `value`, in every object of `column` the path reaches that lacks the key or holds JSON `null` there. `path` is written as for `renameStoredKey`; `value` is a JSON value, passed as a parameter. Only rows with such an object are written.
1311
+ */
1312
+ fillStoredKey(options) {
1313
+ return Promise.resolve(new FillStoredKeyCall(options.table, options.column, options.path, options.value, this.storedKeyFillField("fillStoredKey", options.field)).toOp());
1314
+ }
1315
+ /**
1316
+ * Emit a `DELETE` operation that deletes the rows whose `column` holds the stored value `value`. The value is a stored value, as for `replaceStoredValue`, and is passed as a parameter. The migration runner checks foreign keys after the whole migration, so the apply fails if another table still references a deleted row, unless `cascade` names it. The operation is destructive.
1317
+ */
1318
+ deleteRows(options) {
1319
+ return new DeleteRowsCall(options.table, options.column, options.value, this.storedValueCodec("deleteRows", options.codecRef), options.cascade).toOp();
1320
+ }
1321
+ createIndex(options) {
1322
+ return new CreateIndexCall(options.table, options.index, options.columns).toOp(this.controlAdapterFor("createIndex"));
1323
+ }
1324
+ dropIndex(options) {
1325
+ return new DropIndexCall(options.table, options.index).toOp(this.controlAdapterFor("dropIndex"));
1326
+ }
1327
+ recreateTable(options) {
1328
+ const { copyExpressions, temporaryValues, ...args } = options;
1329
+ return new RecreateTableCall({
1330
+ ...args,
1331
+ contractTable: {
1332
+ ...options.contractTable,
1333
+ columns: options.contractTable.columns.map((column) => columnSpecOf(column, "recreateTable", options.tableName))
1334
+ },
1335
+ ...ifDefined("copyExpressions", copyExpressions === void 0 ? void 0 : copyExpressionSlotsOf(copyExpressions, options.tableName)),
1336
+ ...ifDefined("temporaryValues", temporaryValues === void 0 ? void 0 : copyExpressionSlotsOf(temporaryValues, options.tableName, "temporaryValues"))
1337
+ }).toOp(this.controlAdapterFor("recreateTable"));
1338
+ }
1339
+ };
1340
+ function columnDefaultOf(columnDefault, what) {
1341
+ return columnDefault.kind === "function" ? {
1342
+ kind: "function",
1343
+ expression: sqlTextOf(columnDefault.expression, what)
1344
+ } : columnDefault;
1345
+ }
1346
+ function columnSpecOf(column, operation, table) {
1347
+ const { default: columnDefault, ...rest } = column;
1348
+ const what = `${operation} ${JSON.stringify(table)}.${JSON.stringify(column.name)} default`;
1349
+ return {
1350
+ ...rest,
1351
+ ...ifDefined("default", columnDefault === void 0 ? void 0 : columnDefaultOf(columnDefault, what))
1352
+ };
1353
+ }
1354
+ function copyExpressionSlotsOf(copyExpressions, table, option = "copyExpressions") {
1355
+ return Object.fromEntries(Object.entries(copyExpressions).map(([column, expression]) => [column, {
1356
+ kind: "sql",
1357
+ sql: sqlTextOf(expression, `recreateTable ${JSON.stringify(table)} ${option}.${column}`)
1358
+ }]));
1359
+ }
1360
+ //#endregion
1361
+ export { sqliteSchemaTables as _, createWorkingSchema as a, verifySqliteDatabaseSchema as b, issueNode as c, renameTableByHandStatements as d, renderRenameTableCall as f, sqlitePlannerStrategies as g, sqliteContractToSchema as h, conflictForDisallowedCall as i, pairIndexReplacements as l, sqliteColumnRenameCall as m, buildSqlitePlanDiff as n, diffSqliteSchema as o, sqliteActualSchema as p, coalesceSubtreeIssues as r, indexNameCaseChange as s, SqliteMigration as t, planIssues as u, sqliteTableRenameByHand as v, sqliteTableRenameCall as y };
1362
+
1363
+ //# sourceMappingURL=sqlite-migration-Cmzykasm--GxBXXny.mjs.map