@prisma/orm-target-postgres 8.0.0-rc.2-dev.3 → 8.0.0-rc.20-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/adapter-5qylEP__.d.mts +403 -0
- package/dist/adapter-5qylEP__.d.mts.map +1 -0
- package/dist/{adapter-B0xsc80z-sYcF0RVF.mjs → adapter-svGTIjA2-1p-Iw8D2.mjs} +24 -30
- package/dist/adapter-svGTIjA2-1p-Iw8D2.mjs.map +1 -0
- package/dist/adapter.d.mts +11 -13
- package/dist/adapter.mjs +7 -8
- package/dist/adapter__adapter.d.mts +2 -2
- package/dist/adapter__adapter.mjs +3 -2
- package/dist/adapter__column-types.d.mts +2 -2
- package/dist/adapter__column-types.mjs +2 -2
- package/dist/adapter__control.d.mts +4 -5
- package/dist/adapter__control.mjs +11 -423
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.d.mts +1 -1
- package/dist/adapter__runtime.mjs +29 -19
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.d.mts +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/adapter__types.d.mts +4 -3
- package/dist/aggregates-CEqqEg8k.d.mts +318 -0
- package/dist/aggregates-CEqqEg8k.d.mts.map +1 -0
- package/dist/{aggregates-Dh6HPdvC.mjs → aggregates-Dw-lAutX.mjs} +105 -40
- package/dist/aggregates-Dw-lAutX.mjs.map +1 -0
- package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts +52 -0
- package/dist/authoring-DWd5pnnV-BBX7P1wT.d.mts.map +1 -0
- package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs +1342 -0
- package/dist/authoring-SbdvmVJh-nQ7YliD_.mjs.map +1 -0
- package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs +58 -0
- package/dist/autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs.map +1 -0
- package/dist/{canonicalize-CQlxSR4D-MnrT5gtW.d.mts → canonicalize-B-xvDOdd-G3yUeKj4.d.mts} +7 -3
- package/dist/canonicalize-B-xvDOdd-G3yUeKj4.d.mts.map +1 -0
- package/dist/{canonicalize-CrN3u_xM-D4MrOqcB.mjs → canonicalize-RdxoUHao-FTTkizfe.mjs} +15 -3
- package/dist/canonicalize-RdxoUHao-FTTkizfe.mjs.map +1 -0
- package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs +48 -0
- package/dist/check-expressions-7uCCP01t-DtX2Vak9.mjs.map +1 -0
- package/dist/{check-expressions-DRgG8RN5-DiA-22aC.d.mts → check-expressions-CtTzM58x-LloO-5Vf.d.mts} +14 -13
- package/dist/check-expressions-CtTzM58x-LloO-5Vf.d.mts.map +1 -0
- package/dist/{codec-descriptor-LT7BpQta-BaDM8UQQ.mjs → codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs} +12 -21
- package/dist/codec-descriptor-DoR-cTFZ-BlG5Gj-X.mjs.map +1 -0
- package/dist/codec-descriptor-Fb3UoQGb.d.mts +1 -0
- package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts +47 -0
- package/dist/codec-descriptor-d1ByNBEk-DhrtS_5y.d.mts.map +1 -0
- package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs +41 -0
- package/dist/codec-ids-BMhEpFwv-B8Zh0s_Q.mjs.map +1 -0
- package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts +41 -0
- package/dist/codec-ids-C6II64Wy-CPYTqDTT.d.mts.map +1 -0
- package/dist/codec-ids-CcB5uBNf.d.mts +1 -0
- package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs +61 -0
- package/dist/codec-registry-D7XslgPe-DTZnVB8W.mjs.map +1 -0
- package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts +53 -0
- package/dist/codec-type-map-Fj5xCgwT-BeCXgfuR.d.mts.map +1 -0
- package/dist/codec-types-BBACckHa.d.mts +2 -0
- package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts +84 -0
- package/dist/codec-types-Ct_4iTVc-3tFJcIBo.d.mts.map +1 -0
- package/dist/codecs-CADK7dCR-C8WToYQb.d.mts +724 -0
- package/dist/codecs-CADK7dCR-C8WToYQb.d.mts.map +1 -0
- package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs +1743 -0
- package/dist/codecs-CRl9-i_r-Co-bgYl3.mjs.map +1 -0
- package/dist/codecs-CoEpEqjM.d.mts +31 -0
- package/dist/codecs-CoEpEqjM.d.mts.map +1 -0
- package/dist/column-types-B4zsV-u3.mjs +106 -0
- package/dist/column-types-B4zsV-u3.mjs.map +1 -0
- package/dist/column-types-Bs2V0j8T.d.mts +164 -0
- package/dist/column-types-Bs2V0j8T.d.mts.map +1 -0
- package/dist/{control-adapter-DFr4gS-r-DM3KcZdQ.mjs → contract-contributions-Xz2FpyfI-CeQZqHKf.mjs} +489 -292
- package/dist/contract-contributions-Xz2FpyfI-CeQZqHKf.mjs.map +1 -0
- package/dist/{contract-free-DzpGxLfb.d.mts → contract-free-B6-wuc6M.d.mts} +36 -6
- package/dist/contract-free-B6-wuc6M.d.mts.map +1 -0
- package/dist/{contract-free-aQ4nT-_R.mjs → contract-free-o7olebm9.mjs} +13 -9
- package/dist/contract-free-o7olebm9.mjs.map +1 -0
- package/dist/control--HupSPoV.d.mts +847 -0
- package/dist/control--HupSPoV.d.mts.map +1 -0
- package/dist/{control-BaUpALVp.d.mts → control-CQEjh4P7.d.mts} +2 -2
- package/dist/control-CQEjh4P7.d.mts.map +1 -0
- package/dist/{control-DLTOAEHj.d.mts → control-D4cTcpcJ.d.mts} +22 -48
- package/dist/control-D4cTcpcJ.d.mts.map +1 -0
- package/dist/{control-Y6FxMu3o.mjs → control-DZQwENIP.mjs} +21 -9
- package/dist/control-DZQwENIP.mjs.map +1 -0
- package/dist/{control-policy-B53lnBCT-B9K9Cj1x.mjs → control-policy-DtU5u9Dm-44r_OF94.mjs} +444 -218
- package/dist/control-policy-DtU5u9Dm-44r_OF94.mjs.map +1 -0
- package/dist/{data-transform-ChZzy2dP-CxVCat_8.mjs → data-transform-h9agBu_c-RlC5A7aY.mjs} +12 -5
- package/dist/data-transform-h9agBu_c-RlC5A7aY.mjs.map +1 -0
- package/dist/{data-transform-Ck5FbyNO-BNE7QlAo.d.mts → data-transform-nGy9rz87-CE3DGlgn.d.mts} +15 -4
- package/dist/data-transform-nGy9rz87-CE3DGlgn.d.mts.map +1 -0
- package/dist/data-transform-nqkqNIb8.d.mts +1 -0
- package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs +128 -0
- package/dist/data-type-entries-gQW3-KSb-BIl8vgus.mjs.map +1 -0
- package/dist/data-types--7V9yY1G.d.mts +99 -0
- package/dist/data-types--7V9yY1G.d.mts.map +1 -0
- package/dist/data-types-Chx0mjTP-DczU4S9b.mjs +950 -0
- package/dist/data-types-Chx0mjTP-DczU4S9b.mjs.map +1 -0
- package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts +45 -0
- package/dist/date-time-now-generators-CMkXVbMG-C-GjhReE.d.mts.map +1 -0
- package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs +647 -0
- package/dist/ddl-B7Rqlz6D-B7dRDgYb.mjs.map +1 -0
- package/dist/ddl-B8nQZTWN.d.mts +1 -0
- package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs +18 -0
- package/dist/default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs.map +1 -0
- package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs +311 -0
- package/dist/default-normalizer-BqK6XxdC-2OUb2ybG.mjs.map +1 -0
- package/dist/default-normalizer-DO-cH75Q.d.mts +25 -0
- package/dist/default-normalizer-DO-cH75Q.d.mts.map +1 -0
- package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs +36 -0
- package/dist/descriptor-meta-BkD3nXF_-CZaNqC6r.mjs.map +1 -0
- package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs +64 -0
- package/dist/descriptor-meta-DaFDNnHQ-QjiiAEtC.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs +15 -0
- package/dist/descriptor-meta-runtime-Dft1L7eE-D8vpOz_Z.mjs.map +1 -0
- package/dist/{diff-database-schema-DsoNznGC.d.mts → diff-database-schema-BxzhZaVN.d.mts} +12 -7
- package/dist/diff-database-schema-BxzhZaVN.d.mts.map +1 -0
- package/dist/{diff-database-schema-DKq76rCk-uehceHYz.mjs → diff-database-schema-DAEzWtzU-DoyVgKqh.mjs} +38 -18
- package/dist/diff-database-schema-DAEzWtzU-DoyVgKqh.mjs.map +1 -0
- package/dist/driver.d.mts +3 -3
- package/dist/driver.mjs +3 -2
- package/dist/driver__control.d.mts +1 -1
- package/dist/driver__control.mjs +1 -1
- package/dist/driver__runtime.d.mts +2 -2
- package/dist/driver__runtime.mjs +2 -639
- package/dist/errors-BrhQYgdL-IvZHPjwL.mjs +103 -0
- package/dist/errors-BrhQYgdL-IvZHPjwL.mjs.map +1 -0
- package/dist/{errors-CU4xIwwk.d.mts → errors-D3Mj-x0o.d.mts} +3 -3
- package/dist/errors-D3Mj-x0o.d.mts.map +1 -0
- package/dist/full-text-BYg7EVX2.mjs +39 -0
- package/dist/full-text-BYg7EVX2.mjs.map +1 -0
- package/dist/full-text-SDbfxrE_.d.mts +26 -0
- package/dist/full-text-SDbfxrE_.d.mts.map +1 -0
- package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts +27 -0
- package/dist/full-text-collection-method-BFd2u2cs-Ba3OiWM3.d.mts.map +1 -0
- package/dist/full-text-index-authoring-CN1L9C1k.d.mts +7 -0
- package/dist/full-text-index-authoring-CN1L9C1k.d.mts.map +1 -0
- package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs +195 -0
- package/dist/full-text-index-definition-BPxQQBuC-VLyQ1kEL.mjs.map +1 -0
- package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts +71 -0
- package/dist/full-text-index-definition-D5iBWLss-BEpqiucV.d.mts.map +1 -0
- package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs +139 -0
- package/dist/full-text-parsers-CFFxiOrp-CrZ7VI1m.mjs.map +1 -0
- package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs +54 -0
- package/dist/full-text-search-document-Doy5TF7c-aMWM_1KB.mjs.map +1 -0
- package/dist/index-types-BihjrAAq-C2VnfAyF.mjs +14 -0
- package/dist/index-types-BihjrAAq-C2VnfAyF.mjs.map +1 -0
- package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts +60 -0
- package/dist/indexes-BYf6nXVv-BXwLw7fO.d.mts.map +1 -0
- package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs +1143 -0
- package/dist/infer-psl-contract-BSSHcuRi-ChdFSviw.mjs.map +1 -0
- package/dist/{issue-planner-Biq9Ls7e.d.mts → issue-planner-D-On52xP.d.mts} +39 -9
- package/dist/issue-planner-D-On52xP.d.mts.map +1 -0
- package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts +7 -0
- package/dist/list-decoder-BcrLExnx-DlCwavhu.d.mts.map +1 -0
- package/dist/marker-lock-BviIbusV.d.mts +11 -0
- package/dist/marker-lock-BviIbusV.d.mts.map +1 -0
- package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs +11 -0
- package/dist/marker-lock-DFc1Tfv5-BkBKBRE3.mjs.map +1 -0
- package/dist/{migration-PTHAY9Cv.mjs → migration-Be_iuIpn.mjs} +5 -4
- package/dist/migration-Be_iuIpn.mjs.map +1 -0
- package/dist/migration-D4lMmLVj.d.mts +26 -0
- package/dist/migration-D4lMmLVj.d.mts.map +1 -0
- package/dist/{namespace-ids-xtp_ZY86-Cpp8PTxD.mjs → namespace-ids-xtp_ZY86-Cxc0dBbO.mjs} +2 -2
- package/dist/namespace-ids-xtp_ZY86-Cxc0dBbO.mjs.map +1 -0
- package/dist/native-type-normalizer-BaGa9eeb.d.mts +30 -0
- package/dist/native-type-normalizer-BaGa9eeb.d.mts.map +1 -0
- package/dist/native-type-normalizer-Cn-RGt_E.mjs +24 -0
- package/dist/native-type-normalizer-Cn-RGt_E.mjs.map +1 -0
- package/dist/{nodes-DAvDJLvJ-BBdvFXNa.mjs → nodes-G8VTh4PM-DNvIhHag.mjs} +78 -7
- package/dist/nodes-G8VTh4PM-DNvIhHag.mjs.map +1 -0
- package/dist/{nodes-BU-V-aZA-RqwPH68u.d.mts → nodes-s0Oe37jT-Cw3BU2gL.d.mts} +82 -29
- package/dist/nodes-s0Oe37jT-Cw3BU2gL.d.mts.map +1 -0
- package/dist/op-factory-call-CRaVUOb_.d.mts +1 -0
- package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-gGX-mZu--0QUG5xH4.mjs} +1014 -258
- package/dist/op-factory-call-gGX-mZu--0QUG5xH4.mjs.map +1 -0
- package/dist/{op-factory-call-BAeyLFYf-BAgG1h1C.d.mts → op-factory-call-nLHvNx0O-BTBhGbOF.d.mts} +169 -111
- package/dist/op-factory-call-nLHvNx0O-BTBhGbOF.d.mts.map +1 -0
- package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts +192 -0
- package/dist/operation-types--Wa_cv45-RoRnL1Dn.d.mts.map +1 -0
- package/dist/operation-types-OXILTAOX.d.mts +1 -0
- package/dist/pack-2CYw2w-b.d.mts +1573 -0
- package/dist/pack-2CYw2w-b.d.mts.map +1 -0
- package/dist/{planner-CT-7zSfk.d.mts → planner-AD3Dt57t.d.mts} +23 -51
- package/dist/planner-AD3Dt57t.d.mts.map +1 -0
- package/dist/planner-VuR6URu3-CCUT2Osx.mjs +954 -0
- package/dist/planner-VuR6URu3-CCUT2Osx.mjs.map +1 -0
- package/dist/planner-ddl-builders-CPM3y7cQ.d.mts +16 -0
- package/dist/planner-ddl-builders-CPM3y7cQ.d.mts.map +1 -0
- package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs +28 -0
- package/dist/planner-ddl-builders-cYnH52gC-BWifb_M6.mjs.map +1 -0
- package/dist/planner-identity-values-Dsq989Lh.d.mts +26 -0
- package/dist/planner-identity-values-Dsq989Lh.d.mts.map +1 -0
- package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs +70 -0
- package/dist/planner-identity-values-QstrMJ2U-CcpaRVPY.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration-BBUwtjA_.d.mts +1 -0
- package/dist/{planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs → planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs} +5 -5
- package/dist/planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts → planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts} +4 -4
- package/dist/planner-produced-postgres-migration-DyIXJ3MR-DHO5wn_X.d.mts.map +1 -0
- package/dist/{planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs → planner-schema-lookup-BbUY9oVy.mjs} +2 -2
- package/dist/planner-schema-lookup-BbUY9oVy.mjs.map +1 -0
- package/dist/{planner-schema-lookup-C4DHAddq.d.mts → planner-schema-lookup-ceCNOGFf.d.mts} +2 -2
- package/dist/planner-schema-lookup-ceCNOGFf.d.mts.map +1 -0
- package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs +151 -0
- package/dist/planner-sql-checks-D-K44J19-CzvrqzNB.mjs.map +1 -0
- package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts +37 -0
- package/dist/planner-sql-checks-Ed-WGtge-D9ByMrW4.d.mts.map +1 -0
- package/dist/planner-sql-checks-rEjFx_Jv.d.mts +1 -0
- package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs +14 -0
- package/dist/planner-target-details-CUEF0s90-6g-mOgTI.mjs.map +1 -0
- package/dist/{planner-target-details-HkP4RrRO-_xPQVPF0.d.mts → planner-target-details-HkP4RrRO-D6VtK0jY.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO-D6VtK0jY.d.mts.map +1 -0
- package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs +11 -0
- package/dist/postgres-codec-traits-CnP5Bjxp-Dxdgv0TI.mjs.map +1 -0
- package/dist/{postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts → postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts} +2 -2
- package/dist/postgres-contract-view-BFzIDwwN-hL3QLe_b.d.mts.map +1 -0
- package/dist/{postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs → postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs} +27 -14
- package/dist/postgres-contract-view-BO2elRMz-BqMBzJoJ.mjs.map +1 -0
- package/dist/{postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts → postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts} +4 -4
- package/dist/postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map +1 -0
- package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs +1312 -0
- package/dist/postgres-migration-BSWmeRLo-CUfVTUf0.mjs.map +1 -0
- package/dist/{postgres-migration-BNsrwlxh-CwI5BqAu.d.mts → postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts} +135 -15
- package/dist/postgres-migration-C5deJ3Ne-C4Jxu-e6.d.mts.map +1 -0
- package/dist/{postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs → postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs} +2 -2
- package/dist/postgres-native-enum-CdP3b_-R-DgG3pi5p.mjs.map +1 -0
- package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs +23 -0
- package/dist/postgres-object-name-FPikIvOw-B8FfJI7z.mjs.map +1 -0
- package/dist/{postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts → postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts} +2 -2
- package/dist/postgres-rls-policy-CnDxf3z9-BjpVyUnK.d.mts.map +1 -0
- package/dist/{postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs → postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs} +3 -3
- package/dist/postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs.map +1 -0
- package/dist/{postgres-schema-CF0yHESb-D7n2X21R.mjs → postgres-schema-C6w1rzOF-D1fdwqRx.mjs} +14 -12
- package/dist/postgres-schema-C6w1rzOF-D1fdwqRx.mjs.map +1 -0
- package/dist/{postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts → postgres-schema-Xsjt3RKO-bis-SVSB.d.mts} +4 -4
- package/dist/postgres-schema-Xsjt3RKO-bis-SVSB.d.mts.map +1 -0
- package/dist/{postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs → postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs} +2 -2
- package/dist/postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs.map +1 -0
- package/dist/prisma7-binding-BjiLA9F7.mjs +307 -0
- package/dist/prisma7-binding-BjiLA9F7.mjs.map +1 -0
- package/dist/prisma7-binding-a56klfkc.d.mts +1651 -0
- package/dist/prisma7-binding-a56klfkc.d.mts.map +1 -0
- package/dist/{render-ops-DOsRP0Po-BKn_c_Ia.mjs → render-ops-BgqtCw9Z-T8BPTX85.mjs} +17 -10
- package/dist/render-ops-BgqtCw9Z-T8BPTX85.mjs.map +1 -0
- package/dist/{render-ops-DPwhZt2W.d.mts → render-ops-Bl84i7ut.d.mts} +3 -3
- package/dist/render-ops-Bl84i7ut.d.mts.map +1 -0
- package/dist/{render-typescript-6sCFvMBh.d.mts → render-typescript-BysdXYpH.d.mts} +2 -2
- package/dist/render-typescript-BysdXYpH.d.mts.map +1 -0
- package/dist/{render-typescript-Dqp1Spgn-B128r1qw.mjs → render-typescript-Dqp1Spgn-B4mJhuVr.mjs} +2 -2
- package/dist/render-typescript-Dqp1Spgn-B4mJhuVr.mjs.map +1 -0
- package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs +34 -0
- package/dist/resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs.map +1 -0
- package/dist/{runtime-lHBKgjB9.d.mts → runtime-C0VXuM0b.d.mts} +4 -3
- package/dist/runtime-C0VXuM0b.d.mts.map +1 -0
- package/dist/runtime-CXfxy5ED.mjs +660 -0
- package/dist/runtime-CXfxy5ED.mjs.map +1 -0
- package/dist/{runtime-_TfO66h5.d.mts → runtime-Ci_toEDZ.d.mts} +12 -4
- package/dist/runtime-Ci_toEDZ.d.mts.map +1 -0
- package/dist/{runtime-DOXznQe0.d.mts → runtime-DtjW0GP_.d.mts} +4 -4
- package/dist/runtime-DtjW0GP_.d.mts.map +1 -0
- package/dist/{schema-ir-annotations-DuuYh0gl.d.mts → schema-ir-annotations-BygaWBiC.d.mts} +2 -2
- package/dist/schema-ir-annotations-BygaWBiC.d.mts.map +1 -0
- package/dist/{schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts → schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts} +2 -2
- package/dist/schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts.map +1 -0
- package/dist/{normalize-error-CNjgVO71-CLlZ3CuJ.mjs → server-text-types-DeNPQpv5-DqX0h8WF.mjs} +45 -3
- package/dist/server-text-types-DeNPQpv5-DqX0h8WF.mjs.map +1 -0
- package/dist/{sql-renderer-ComgusFq-BBlqM1fw.mjs → sql-renderer-BdWJPa5F-Ct0CPlXc.mjs} +113 -123
- package/dist/sql-renderer-BdWJPa5F-Ct0CPlXc.mjs.map +1 -0
- package/dist/{sql-renderer-BgC0ZgLS.d.mts → sql-renderer-BiBhge7D.d.mts} +9 -7
- package/dist/sql-renderer-BiBhge7D.d.mts.map +1 -0
- package/dist/{sql-utils-DuzN3JZg-DiXy4Vah.mjs → sql-utils-Bnw3JbWf-BN0gcjZB.mjs} +31 -8
- package/dist/sql-utils-Bnw3JbWf-BN0gcjZB.mjs.map +1 -0
- package/dist/{sql-utils-DW6fkczF.d.mts → sql-utils-CnnGiZBc.d.mts} +12 -4
- package/dist/sql-utils-CnnGiZBc.d.mts.map +1 -0
- package/dist/{table-source-ikHOZmhD-DriY1Lcr.d.mts → table-source-ikHOZmhD-vYcblBYv.d.mts} +2 -2
- package/dist/table-source-ikHOZmhD-vYcblBYv.d.mts.map +1 -0
- package/dist/target.d.mts +61 -49
- package/dist/target.mjs +45 -36
- package/dist/target__aggregates.d.mts +1 -1
- package/dist/target__aggregates.mjs +1 -1
- package/dist/target__codec-descriptor.d.mts +2 -2
- package/dist/target__codec-descriptor.mjs +1 -1
- package/dist/target__codec-ids.d.mts +3 -3
- package/dist/target__codec-ids.mjs +2 -2
- package/dist/target__codec-types.d.mts +4 -4
- package/dist/target__codecs.d.mts +4 -3
- package/dist/target__codecs.mjs +3 -3
- package/dist/target__contract-free.d.mts +3 -3
- package/dist/target__contract-free.mjs +4 -4
- package/dist/target__control.d.mts +4 -2
- package/dist/target__control.mjs +2501 -2
- package/dist/target__control.mjs.map +1 -0
- package/dist/target__data-transform.d.mts +2 -2
- package/dist/target__data-transform.mjs +1 -1
- package/dist/target__data-types.d.mts +2 -0
- package/dist/target__data-types.mjs +3 -0
- package/dist/target__ddl.d.mts +4 -4
- package/dist/target__ddl.mjs +2 -2
- package/dist/target__default-normalizer.d.mts +2 -2
- package/dist/target__default-normalizer.mjs +2 -2
- package/dist/target__diff-database-schema.d.mts +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__errors.d.mts +1 -1
- package/dist/target__errors.mjs +1 -1
- package/dist/target__full-text-index-authoring.d.mts +3 -0
- package/dist/target__full-text-index-authoring.mjs +3 -0
- package/dist/target__full-text.d.mts +4 -0
- package/dist/target__full-text.mjs +3 -0
- package/dist/target__issue-planner.d.mts +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__marker-lock.d.mts +2 -0
- package/dist/target__marker-lock.mjs +2 -0
- package/dist/target__migration.d.mts +4 -4
- package/dist/target__migration.mjs +5 -5
- package/dist/target__native-type-normalizer.d.mts +2 -2
- package/dist/target__native-type-normalizer.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +3 -3
- package/dist/target__op-factory-call.mjs +2 -2
- package/dist/target__operation-types.d.mts +4 -0
- package/dist/target__pack.d.mts +3 -2
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.d.mts +2 -2
- package/dist/target__planner-ddl-builders.mjs +2 -2
- package/dist/target__planner-identity-values.d.mts +1 -1
- package/dist/target__planner-identity-values.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner-schema-lookup.d.mts +1 -1
- package/dist/target__planner-schema-lookup.mjs +1 -1
- package/dist/target__planner-sql-checks.d.mts +3 -2
- package/dist/target__planner-sql-checks.mjs +2 -2
- package/dist/target__planner-target-details.d.mts +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.d.mts +2 -0
- package/dist/target__prisma7-binding.mjs +2 -0
- package/dist/target__render-ops.d.mts +1 -1
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__render-typescript.d.mts +1 -1
- package/dist/target__render-typescript.mjs +1 -1
- package/dist/target__rls-canonicalize.d.mts +2 -2
- package/dist/target__rls-canonicalize.mjs +2 -2
- package/dist/target__runtime.d.mts +6 -3
- package/dist/target__runtime.mjs +193 -4
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__schema-ir-annotations.d.mts +1 -1
- package/dist/target__schema-ir-annotations.mjs +1 -1
- package/dist/target__sql-utils.d.mts +3 -2
- package/dist/target__sql-utils.mjs +4 -2
- package/dist/target__types.d.mts +7 -7
- package/dist/target__types.mjs +5 -5
- package/dist/types-AvjnIUna.d.mts +2 -0
- package/dist/types-D6lgKhE5-D1J9YJnd.d.mts +28 -0
- package/dist/types-D6lgKhE5-D1J9YJnd.d.mts.map +1 -0
- package/dist/{types-CjGjPLr5.d.mts → types-DOmgp_12.d.mts} +8 -8
- package/dist/types-DOmgp_12.d.mts.map +1 -0
- package/dist/{types-ue6jkJyF-BQJzjx1P.d.mts → types-ue6jkJyF-D79DmBTl.d.mts} +2 -2
- package/dist/types-ue6jkJyF-D79DmBTl.d.mts.map +1 -0
- package/package.json +22 -14
- package/dist/adapter-B0xsc80z-sYcF0RVF.mjs.map +0 -1
- package/dist/adapter-CPesdzv0.d.mts +0 -26
- package/dist/adapter-CPesdzv0.d.mts.map +0 -1
- package/dist/adapter__operation-types.d.mts +0 -2
- package/dist/aggregates-CgqNfj2O.d.mts +0 -10
- package/dist/aggregates-CgqNfj2O.d.mts.map +0 -1
- package/dist/aggregates-Dh6HPdvC.mjs.map +0 -1
- package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs +0 -773
- package/dist/authoring-BOpdZa2N-ClrLFiXw.mjs.map +0 -1
- package/dist/canonicalize-CQlxSR4D-MnrT5gtW.d.mts.map +0 -1
- package/dist/canonicalize-CrN3u_xM-D4MrOqcB.mjs.map +0 -1
- package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs +0 -41
- package/dist/check-expressions-5vhxWaFy-CBcjFeur.mjs.map +0 -1
- package/dist/check-expressions-DRgG8RN5-DiA-22aC.d.mts.map +0 -1
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts +0 -37
- package/dist/codec-descriptor-Bec_zukr-BfvtUqhm.d.mts.map +0 -1
- package/dist/codec-descriptor-Bg-_412t.d.mts +0 -1
- package/dist/codec-descriptor-LT7BpQta-BaDM8UQQ.mjs.map +0 -1
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts +0 -35
- package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +0 -1
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs +0 -35
- package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +0 -1
- package/dist/codec-ids-DJ6j6pZc.d.mts +0 -1
- package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts +0 -84
- package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +0 -1
- package/dist/codec-types-bX63JRLf.d.mts +0 -2
- package/dist/codecs-B1HgsJZ2.mjs +0 -15
- package/dist/codecs-B1HgsJZ2.mjs.map +0 -1
- package/dist/codecs-BmPCJWqb-DveZGJvm.mjs +0 -1680
- package/dist/codecs-BmPCJWqb-DveZGJvm.mjs.map +0 -1
- package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts +0 -638
- package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +0 -1
- package/dist/codecs-DmCKO7dg.d.mts +0 -15
- package/dist/codecs-DmCKO7dg.d.mts.map +0 -1
- package/dist/column-types-BH-MU6uU.d.mts +0 -108
- package/dist/column-types-BH-MU6uU.d.mts.map +0 -1
- package/dist/column-types-Bh92dNjD.mjs +0 -126
- package/dist/column-types-Bh92dNjD.mjs.map +0 -1
- package/dist/contract-free-DzpGxLfb.d.mts.map +0 -1
- package/dist/contract-free-aQ4nT-_R.mjs.map +0 -1
- package/dist/control-2F195jJk.d.mts +0 -11
- package/dist/control-2F195jJk.d.mts.map +0 -1
- package/dist/control-BaUpALVp.d.mts.map +0 -1
- package/dist/control-DLTOAEHj.d.mts.map +0 -1
- package/dist/control-V7OkAC55.mjs +0 -1459
- package/dist/control-V7OkAC55.mjs.map +0 -1
- package/dist/control-Y6FxMu3o.mjs.map +0 -1
- package/dist/control-adapter-DFr4gS-r-DM3KcZdQ.mjs.map +0 -1
- package/dist/control-policy-B53lnBCT-B9K9Cj1x.mjs.map +0 -1
- package/dist/data-transform-BSM7TQpE.d.mts +0 -1
- package/dist/data-transform-ChZzy2dP-CxVCat_8.mjs.map +0 -1
- package/dist/data-transform-Ck5FbyNO-BNE7QlAo.d.mts.map +0 -1
- package/dist/ddl-B4Rh8ntj.d.mts +0 -1
- package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs +0 -395
- package/dist/ddl-CNQJds-C-WfZ3y4y8.mjs.map +0 -1
- package/dist/default-normalizer-B36TOul4.d.mts +0 -31
- package/dist/default-normalizer-B36TOul4.d.mts.map +0 -1
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs +0 -253
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +0 -1
- package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs +0 -354
- package/dist/descriptor-meta-KVX21fsl-DBDoB4eg.mjs.map +0 -1
- package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs +0 -30
- package/dist/descriptor-meta-rilAH3ep-dAmiVLpe.mjs.map +0 -1
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs +0 -13
- package/dist/descriptor-meta-runtime-UwYdV8fD-B_m_Ha8r.mjs.map +0 -1
- package/dist/diff-database-schema-DKq76rCk-uehceHYz.mjs.map +0 -1
- package/dist/diff-database-schema-DsoNznGC.d.mts.map +0 -1
- package/dist/driver__runtime.mjs.map +0 -1
- package/dist/errors-CU4xIwwk.d.mts.map +0 -1
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs +0 -39
- package/dist/errors-DKjQzNaN-DFcF1thx.mjs.map +0 -1
- package/dist/issue-planner-Biq9Ls7e.d.mts.map +0 -1
- package/dist/migration-PTHAY9Cv.mjs.map +0 -1
- package/dist/migration-aFeTWTOJ.d.mts +0 -25
- package/dist/migration-aFeTWTOJ.d.mts.map +0 -1
- package/dist/namespace-ids-xtp_ZY86-Cpp8PTxD.mjs.map +0 -1
- package/dist/native-type-normalizer-DqJlOTeX.d.mts +0 -19
- package/dist/native-type-normalizer-DqJlOTeX.d.mts.map +0 -1
- package/dist/native-type-normalizer-yvd3tqv-.mjs +0 -38
- package/dist/native-type-normalizer-yvd3tqv-.mjs.map +0 -1
- package/dist/nodes-BU-V-aZA-RqwPH68u.d.mts.map +0 -1
- package/dist/nodes-DAvDJLvJ-BBdvFXNa.mjs.map +0 -1
- package/dist/normalize-error-CNjgVO71-CLlZ3CuJ.mjs.map +0 -1
- package/dist/op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map +0 -1
- package/dist/op-factory-call-BTU8I_x0.d.mts +0 -1
- package/dist/op-factory-call-H6zeDGLe-_1pAftJk.mjs.map +0 -1
- package/dist/operation-types-BfRocNI8.d.mts +0 -22
- package/dist/operation-types-BfRocNI8.d.mts.map +0 -1
- package/dist/pack-CySS3DQU.d.mts +0 -626
- package/dist/pack-CySS3DQU.d.mts.map +0 -1
- package/dist/planner-CT-7zSfk.d.mts.map +0 -1
- package/dist/planner-D0uogzvT-1WyGIC5p.mjs +0 -671
- package/dist/planner-D0uogzvT-1WyGIC5p.mjs.map +0 -1
- package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs +0 -102
- package/dist/planner-ddl-builders-Chxh-LEQ-DXvwOeeA.mjs.map +0 -1
- package/dist/planner-ddl-builders-ijp60-JO.d.mts +0 -19
- package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +0 -1
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs +0 -90
- package/dist/planner-identity-values-BmHn5C6U-BYBbUAyR.mjs.map +0 -1
- package/dist/planner-identity-values-TfEhnoWa.d.mts +0 -25
- package/dist/planner-identity-values-TfEhnoWa.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-D5m8nK6s-CbZ4hlbv.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-D6C0T2xV.d.mts +0 -1
- package/dist/planner-schema-lookup-C4DHAddq.d.mts.map +0 -1
- package/dist/planner-schema-lookup-kMIVP2y--CdO4VlnF.mjs.map +0 -1
- package/dist/planner-sql-checks-CFgbRTJw.d.mts +0 -20
- package/dist/planner-sql-checks-CFgbRTJw.d.mts.map +0 -1
- package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs +0 -152
- package/dist/planner-sql-checks-ftgzvIO9-BTtBg2Vz.mjs.map +0 -1
- package/dist/planner-target-details-HkP4RrRO-_xPQVPF0.d.mts.map +0 -1
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs +0 -15
- package/dist/planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs.map +0 -1
- package/dist/postgres-contract-view-2OP5JnXl-D2fpy4-8.d.mts.map +0 -1
- package/dist/postgres-contract-view-B8ykf2cO-T2LvWVFZ.mjs.map +0 -1
- package/dist/postgres-database-schema-node-CyfpHXDr-BqyozkQE.d.mts.map +0 -1
- package/dist/postgres-migration-BNsrwlxh-CwI5BqAu.d.mts.map +0 -1
- package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs +0 -205
- package/dist/postgres-migration-Dbq3RGfZ-aMnwfEAb.mjs.map +0 -1
- package/dist/postgres-native-enum-CdP3b_-R-Cgz9KEKx.mjs.map +0 -1
- package/dist/postgres-rls-policy-CnDxf3z9-C3LIHAIG.d.mts.map +0 -1
- package/dist/postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs.map +0 -1
- package/dist/postgres-schema-CF0yHESb-D7n2X21R.mjs.map +0 -1
- package/dist/postgres-schema-Xsjt3RKO-Buv2X8ai.d.mts.map +0 -1
- package/dist/postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs.map +0 -1
- package/dist/render-ops-DOsRP0Po-BKn_c_Ia.mjs.map +0 -1
- package/dist/render-ops-DPwhZt2W.d.mts.map +0 -1
- package/dist/render-typescript-6sCFvMBh.d.mts.map +0 -1
- package/dist/render-typescript-Dqp1Spgn-B128r1qw.mjs.map +0 -1
- package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs +0 -22
- package/dist/resolve-ddl-schema-CoaeNP35-C-UZldpj.mjs.map +0 -1
- package/dist/runtime-DOXznQe0.d.mts.map +0 -1
- package/dist/runtime-_TfO66h5.d.mts.map +0 -1
- package/dist/runtime-lHBKgjB9.d.mts.map +0 -1
- package/dist/schema-ir-annotations-DuuYh0gl.d.mts.map +0 -1
- package/dist/schema-node-kinds-qlnURWJy-Bo30pwTM.d.mts.map +0 -1
- package/dist/sql-renderer-BgC0ZgLS.d.mts.map +0 -1
- package/dist/sql-renderer-ComgusFq-BBlqM1fw.mjs.map +0 -1
- package/dist/sql-utils-DW6fkczF.d.mts.map +0 -1
- package/dist/sql-utils-DuzN3JZg-DiXy4Vah.mjs.map +0 -1
- package/dist/table-source-ikHOZmhD-DriY1Lcr.d.mts.map +0 -1
- package/dist/types-B-4d5_4a.d.mts +0 -1
- package/dist/types-CjGjPLr5.d.mts.map +0 -1
- package/dist/types-CkryN1AS-BcQRGsDn.d.mts +0 -27
- package/dist/types-CkryN1AS-BcQRGsDn.d.mts.map +0 -1
- package/dist/types-ue6jkJyF-BQJzjx1P.d.mts.map +0 -1
- /package/dist/{adapter__operation-types.mjs → target__operation-types.mjs} +0 -0
package/dist/{op-factory-call-H6zeDGLe-_1pAftJk.mjs → op-factory-call-gGX-mZu--0QUG5xH4.mjs}
RENAMED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { C as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { c as postgresError } from "./errors-BrhQYgdL-IvZHPjwL.mjs";
|
|
2
|
+
import { a as quoteQualifiedName, i as quoteIdentifier, n as escapeLiteral, o as validateEnumValueLength, t as POSTGRES_QUOTING } from "./sql-utils-Bnw3JbWf-BN0gcjZB.mjs";
|
|
3
|
+
import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cxc0dBbO.mjs";
|
|
4
|
+
import { A as indexDefinitionAst, B as schemaHoldsNoObjectsAst, C as disableRowLevelSecurity$1, D as dropSchema$1, E as dropPolicy, F as relationKindAst, H as sequenceValuesFitAst, I as rlsEnabledAst, L as rlsPolicyDefinitionAst, M as nativeEnumTypeExistsAst, N as nativeEnumValueExistsAst, O as dropType, P as noNullValuesAst, R as rlsPolicyExistsAst, S as createType, T as dropIndex$1, U as tableExistsAst, V as sequenceNameAvailableAst, W as tableIsEmptyAst, _ as constraintExistsAst, a as alterPolicyRename, b as createSchema, c as alterTableSetSchema, d as columnExistsAst, f as columnNullabilityAst, g as constraintDefinitionAst, h as columnTypeOidAst, i as alterIndexRename, j as indexExistsAst, k as extensionExistsAst, l as columnDefaultAst, m as columnTypeAst, n as addConstraintAction, o as alterSchemaRename, p as columnOwnsSequenceAst, q as unboundTableMovedAst, r as alterColumnTypeAction, s as alterTable, t as addColumnAction, u as columnDefaultSequenceAst, v as createIndex$1, w as dropDefaultAction, x as createTable, y as createPolicy, z as schemaExistsAst } from "./ddl-B7Rqlz6D-B7dRDgYb.mjs";
|
|
5
|
+
import { i as policyRoleList, t as POLICY_COMMAND_SQL } from "./canonicalize-RdxoUHao-FTTkizfe.mjs";
|
|
6
|
+
import { t as postgresObjectName } from "./postgres-object-name-FPikIvOw-B8FfJI7z.mjs";
|
|
7
|
+
import { r as autoincrementWidthOfPseudoType, t as autoincrementWidth } from "./autoincrement-widths-DonNJgfS-CCvZ4u1W.mjs";
|
|
8
|
+
import { i as qualifyTableName, n as columnTypeCheckIfReadable, r as columnTypeCheckText, t as alterTypeCheck } from "./planner-sql-checks-D-K44J19-CzvrqzNB.mjs";
|
|
9
|
+
import { t as buildTargetDetails } from "./planner-target-details-CUEF0s90-6g-mOgTI.mjs";
|
|
10
|
+
import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
8
11
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
|
+
import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
13
|
+
import { type } from "arktype";
|
|
9
14
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
10
|
-
import {
|
|
15
|
+
import { expectAbsent, expectPresent } from "@prisma/orm-framework/components/control";
|
|
11
16
|
import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
17
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
18
|
+
import { checkExpression, col } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
19
|
+
import { checkSqlDefaultText, checkSqlExpressionText, convertedColumnMeta, createSqlTextSources, isUnfilledSlot, requiredColumnMeta, slotSource, sqlOfSlot } from "@prisma/orm-family-sql/family/control";
|
|
20
|
+
import { unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
|
|
21
|
+
import { TsExpression, jsonToTsSource, tsObjectSource } from "@prisma/orm-framework/ts-render";
|
|
16
22
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
17
|
-
//#region ../../../3-targets/
|
|
23
|
+
//#region ../../../3-targets/postgres/1-target/dist/op-factory-call-gGX-mZu-.mjs
|
|
18
24
|
/**
|
|
19
25
|
* Maps a planner schema name to the contract-free DDL builder's optional
|
|
20
26
|
* `schema` field: the unbound sentinel becomes `undefined` (the builder omits
|
|
@@ -23,11 +29,18 @@ import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referent
|
|
|
23
29
|
function boundSchema(schemaName) {
|
|
24
30
|
return schemaName === UNBOUND_NAMESPACE_ID ? void 0 : schemaName;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The name Postgres gives the sequence of a `SERIAL` column: `{table}_{column}_seq`, cut to fit 63 bytes as Postgres cuts it.
|
|
34
|
+
*/
|
|
35
|
+
function defaultSequenceName(tableName, columnName) {
|
|
36
|
+
return postgresObjectName(tableName, columnName, "seq");
|
|
37
|
+
}
|
|
38
|
+
function step(description, sql, params, expectation) {
|
|
27
39
|
return {
|
|
28
40
|
description,
|
|
29
41
|
sql,
|
|
30
|
-
...ifDefined("params", params)
|
|
42
|
+
...ifDefined("params", params),
|
|
43
|
+
...ifDefined("expectation", expectation)
|
|
31
44
|
};
|
|
32
45
|
}
|
|
33
46
|
function targetDetails(objectType, name, schema, table) {
|
|
@@ -48,6 +61,28 @@ async function columnExistsSteps(lowerer, options) {
|
|
|
48
61
|
absent: await lowerer.lowerToExecuteRequest(checks.columnAbsent())
|
|
49
62
|
};
|
|
50
63
|
}
|
|
64
|
+
/** The check that the column has the type `check` recognises: by the text `format_type` prints, or by the type's identity. */
|
|
65
|
+
function columnTypeCheckAst(location, check) {
|
|
66
|
+
return check.kind === "catalog-text" ? columnTypeAst({
|
|
67
|
+
...location,
|
|
68
|
+
expectedType: check.text
|
|
69
|
+
}) : columnTypeOidAst({
|
|
70
|
+
...location,
|
|
71
|
+
type: check.typeName,
|
|
72
|
+
many: check.many
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The postcheck step that the column has the type `type`: as `check` recognises it when the stack's data types read the type, and otherwise by the type's oid, which ignores a type modifier.
|
|
77
|
+
*/
|
|
78
|
+
async function columnTypeStep(lowerer, location, type, check) {
|
|
79
|
+
const lowered = await lowerer.lowerToExecuteRequest(check === void 0 ? columnTypeOidAst({
|
|
80
|
+
...location,
|
|
81
|
+
type,
|
|
82
|
+
many: false
|
|
83
|
+
}) : columnTypeCheckAst(location, check));
|
|
84
|
+
return step(`verify column "${location.column}" has type ${check === void 0 ? `"${type}"` : columnTypeCheckText(check)}`, lowered.sql, lowered.params);
|
|
85
|
+
}
|
|
51
86
|
async function dropColumn(schemaName, tableName, columnName, lowerer) {
|
|
52
87
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
53
88
|
const { present, absent } = await columnExistsSteps(lowerer, {
|
|
@@ -60,44 +95,122 @@ async function dropColumn(schemaName, tableName, columnName, lowerer) {
|
|
|
60
95
|
label: `Drop column "${columnName}" from "${tableName}"`,
|
|
61
96
|
operationClass: "destructive",
|
|
62
97
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
63
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
98
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
64
99
|
execute: [step(`drop column "${columnName}"`, `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`)],
|
|
65
|
-
postcheck: [step(`verify column "${columnName}" does not exist`, absent.sql, absent.params)]
|
|
100
|
+
postcheck: [step(`verify column "${columnName}" does not exist`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function renameColumnStatement(schemaName, tableName, fromName, toName) {
|
|
104
|
+
return `ALTER TABLE ${qualifyTableName(schemaName, tableName)} RENAME COLUMN ${quoteIdentifier(fromName)} TO ${quoteIdentifier(toName)}`;
|
|
105
|
+
}
|
|
106
|
+
function renameColumnOperationId(tableName, fromName) {
|
|
107
|
+
return `renameColumn.${tableName}.${fromName}`;
|
|
108
|
+
}
|
|
109
|
+
async function renameColumn(schemaName, tableName, fromName, toName, lowerer) {
|
|
110
|
+
const from = await columnExistsSteps(lowerer, {
|
|
111
|
+
schema: schemaName,
|
|
112
|
+
table: tableName,
|
|
113
|
+
column: fromName
|
|
114
|
+
});
|
|
115
|
+
const to = await columnExistsSteps(lowerer, {
|
|
116
|
+
schema: schemaName,
|
|
117
|
+
table: tableName,
|
|
118
|
+
column: toName
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
id: renameColumnOperationId(tableName, fromName),
|
|
122
|
+
label: `Rename column "${tableName}"."${fromName}" to "${toName}"`,
|
|
123
|
+
operationClass: "widening",
|
|
124
|
+
target: targetDetails("column", toName, schemaName, tableName),
|
|
125
|
+
precheck: [step(`ensure column "${fromName}" exists`, from.present.sql, from.present.params, expectPresent(`column "${fromName}" on "${tableName}"`)), step(`ensure column "${toName}" does not exist`, to.absent.sql, to.absent.params, expectAbsent(`column "${toName}" on "${tableName}"`))],
|
|
126
|
+
execute: [step(`rename column "${fromName}" to "${toName}"`, renameColumnStatement(schemaName, tableName, fromName, toName))],
|
|
127
|
+
postcheck: [step(`verify column "${toName}" exists`, to.present.sql, to.present.params, expectPresent(`column "${toName}" on "${tableName}"`)), step(`verify column "${fromName}" no longer exists`, from.absent.sql, from.absent.params, expectAbsent(`column "${fromName}" on "${tableName}"`))]
|
|
66
128
|
};
|
|
67
129
|
}
|
|
68
130
|
/**
|
|
69
|
-
* `
|
|
70
|
-
* `
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
131
|
+
* `type` is the new column type as a migration writes it, into the `ALTER COLUMN TYPE` clause.
|
|
132
|
+
* `checkType` is how the postcheck recognises the new type. `sequence` is
|
|
133
|
+
* the width of the sequence the column owns when it has an `autoincrement()` default: the operation
|
|
134
|
+
* finds that sequence in the catalog and changes it to the new width, refusing first when the
|
|
135
|
+
* sequence has handed out a value past that width. A column whose default reads a sequence it does
|
|
136
|
+
* not own changes type and leaves the sequence alone. The postcheck asks for the type, and for the
|
|
137
|
+
* sequence width when the column owns one.
|
|
75
138
|
*/
|
|
76
|
-
async function alterColumnType(schemaName, tableName, columnName, options, lowerer) {
|
|
77
|
-
const qualified = qualifyTableName(schemaName, tableName);
|
|
78
|
-
const usingClause = options.using ? ` USING ${options.using}` : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;
|
|
139
|
+
async function alterColumnType(schemaName, tableName, columnName, options, lowerer, operationClass = "destructive") {
|
|
79
140
|
const { present } = await columnExistsSteps(lowerer, {
|
|
80
141
|
schema: schemaName,
|
|
81
142
|
table: tableName,
|
|
82
143
|
column: columnName
|
|
83
144
|
});
|
|
84
|
-
const typeCheck = await lowerer.lowerToExecuteRequest(
|
|
145
|
+
const typeCheck = await lowerer.lowerToExecuteRequest(columnTypeCheckAst({
|
|
85
146
|
schema: schemaName,
|
|
86
147
|
table: tableName,
|
|
87
|
-
column: columnName
|
|
88
|
-
|
|
148
|
+
column: columnName
|
|
149
|
+
}, options.checkType));
|
|
150
|
+
const alterType = await lowerer.lowerToExecuteRequest(alterTable({
|
|
151
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
152
|
+
table: tableName,
|
|
153
|
+
actions: [alterColumnTypeAction({
|
|
154
|
+
columnName,
|
|
155
|
+
type: options.type,
|
|
156
|
+
...ifDefined("using", options.using)
|
|
157
|
+
})]
|
|
89
158
|
}));
|
|
159
|
+
const sequenceSteps = await ownedSequenceSteps(lowerer, {
|
|
160
|
+
schema: schemaName,
|
|
161
|
+
table: tableName,
|
|
162
|
+
column: columnName
|
|
163
|
+
}, options.sequenceWidth);
|
|
90
164
|
return {
|
|
91
165
|
id: `alterType.${tableName}.${columnName}`,
|
|
92
|
-
label: `Alter type of "${tableName}"."${columnName}" to ${options.
|
|
93
|
-
operationClass
|
|
166
|
+
label: `Alter type of "${tableName}"."${columnName}" to ${options.type}`,
|
|
167
|
+
operationClass,
|
|
94
168
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
95
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
96
|
-
execute: [
|
|
97
|
-
|
|
169
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), ...sequenceSteps.precheck],
|
|
170
|
+
execute: [{
|
|
171
|
+
...step(`alter type of "${columnName}" to ${options.type}`, alterType.sql),
|
|
172
|
+
...options.using !== void 0 ? { meta: convertedColumnMeta(tableName, columnName, "conversion") } : operationClass === "destructive" ? { meta: convertedColumnMeta(tableName, columnName, "cast") } : {}
|
|
173
|
+
}, ...sequenceSteps.execute],
|
|
174
|
+
postcheck: [step(`verify column "${columnName}" has type ${columnTypeCheckText(options.checkType)}`, typeCheck.sql, typeCheck.params), ...sequenceSteps.postcheck],
|
|
98
175
|
meta: { warning: "TABLE_REWRITE" }
|
|
99
176
|
};
|
|
100
177
|
}
|
|
178
|
+
async function ownedSequenceSteps(lowerer, location, width) {
|
|
179
|
+
if (width === void 0) return {
|
|
180
|
+
precheck: [],
|
|
181
|
+
execute: [],
|
|
182
|
+
postcheck: []
|
|
183
|
+
};
|
|
184
|
+
const { sequenceType, maxValue } = width;
|
|
185
|
+
const fits = await lowerer.lowerToExecuteRequest(sequenceValuesFitAst({
|
|
186
|
+
...location,
|
|
187
|
+
maxValue
|
|
188
|
+
}));
|
|
189
|
+
const owns = await lowerer.lowerToExecuteRequest(columnOwnsSequenceAst({
|
|
190
|
+
...location,
|
|
191
|
+
sequenceType,
|
|
192
|
+
orNone: true
|
|
193
|
+
}));
|
|
194
|
+
return {
|
|
195
|
+
precheck: [step(`ensure the sequence column "${location.column}" owns has no value past the ${sequenceType} range`, fits.sql, fits.params)],
|
|
196
|
+
execute: [step(`change the sequence column "${location.column}" owns, if any, to ${sequenceType}`, doBlock(`IF ${ownedSequenceSql(location)} IS NOT NULL THEN ${alterOwnedSequenceTypeStatement(location, sequenceType)} END IF;`))],
|
|
197
|
+
postcheck: [step(`verify the sequence column "${location.column}" owns, if any, is of type ${sequenceType}`, owns.sql, owns.params)]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/** SQL for the sequence the column owns, as a `regclass`, found at run time. */
|
|
201
|
+
function ownedSequenceSql(location) {
|
|
202
|
+
return `pg_get_serial_sequence('${escapeLiteral(qualifyTableName(location.schema, location.table))}', '${escapeLiteral(location.column)}')::regclass`;
|
|
203
|
+
}
|
|
204
|
+
/** A `DO` block around `body`, quoted with a dollar tag that `body` does not contain. */
|
|
205
|
+
function doBlock(body) {
|
|
206
|
+
let tag = "$prisma$";
|
|
207
|
+
for (let n = 1; body.includes(tag); n += 1) tag = `$prisma${n}$`;
|
|
208
|
+
return `DO ${tag} BEGIN ${body} END ${tag}`;
|
|
209
|
+
}
|
|
210
|
+
/** PL/pgSQL that runs `ALTER SEQUENCE … AS <type>` on the sequence the column owns, whatever its name. */
|
|
211
|
+
function alterOwnedSequenceTypeStatement(location, sequenceType) {
|
|
212
|
+
return `EXECUTE format('ALTER SEQUENCE %s AS ${sequenceType}', ${ownedSequenceSql(location)});`;
|
|
213
|
+
}
|
|
101
214
|
async function setNotNull(schemaName, tableName, columnName, lowerer) {
|
|
102
215
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
103
216
|
const { present } = await columnExistsSteps(lowerer, {
|
|
@@ -119,9 +232,12 @@ async function setNotNull(schemaName, tableName, columnName, lowerer) {
|
|
|
119
232
|
return {
|
|
120
233
|
id: `alterNullability.setNotNull.${tableName}.${columnName}`,
|
|
121
234
|
label: `Set NOT NULL on "${tableName}"."${columnName}"`,
|
|
122
|
-
operationClass: "
|
|
235
|
+
operationClass: "widening",
|
|
123
236
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
124
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params
|
|
237
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), {
|
|
238
|
+
...step(`ensure no NULL values in "${columnName}"`, noNulls.sql, noNulls.params),
|
|
239
|
+
meta: requiredColumnMeta(tableName, columnName, "nullValues")
|
|
240
|
+
}],
|
|
125
241
|
execute: [step(`set NOT NULL on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET NOT NULL`)],
|
|
126
242
|
postcheck: [step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params)]
|
|
127
243
|
};
|
|
@@ -144,41 +260,98 @@ async function dropNotNull(schemaName, tableName, columnName, lowerer) {
|
|
|
144
260
|
label: `Drop NOT NULL on "${tableName}"."${columnName}"`,
|
|
145
261
|
operationClass: "widening",
|
|
146
262
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
147
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
263
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
148
264
|
execute: [step(`drop NOT NULL on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`)],
|
|
149
265
|
postcheck: [step(`verify column "${columnName}" is nullable`, nullable.sql, nullable.params)]
|
|
150
266
|
};
|
|
151
267
|
}
|
|
152
268
|
/**
|
|
153
|
-
* `
|
|
154
|
-
*
|
|
155
|
-
*
|
|
269
|
+
* Sets `column`'s default. The adapter writes the `DEFAULT …` clause, reading a literal default with
|
|
270
|
+
* the column's codec first, as every DDL statement that writes a default does. An `autoincrement()`
|
|
271
|
+
* default attaches a sequence instead ({@link setAutoincrementDefault}).
|
|
272
|
+
*
|
|
273
|
+
* `operationClass` is `'additive'` when the column has no default yet and `'widening'` when it replaces one; policy enforcement reads it.
|
|
156
274
|
*
|
|
157
|
-
*
|
|
158
|
-
* that currently has none). The reconciliation planner passes `'widening'`
|
|
159
|
-
* when the column already has a different default — policy enforcement
|
|
160
|
-
* treats that as a widening change rather than an additive one.
|
|
275
|
+
* The operation carries no postcheck. The runner skips an operation whose postchecks already hold before it runs. A check that the column has a default also holds for the old default, so the runner would skip a changed default. A check that compares the value would need the text Postgres stores for the default, predicted at plan time, which is fragile. Instead the run's final schema verification compares the default's value. Running `SET DEFAULT` again on a column that already has that default is harmless.
|
|
161
276
|
*/
|
|
162
|
-
async function setDefault(schemaName, tableName,
|
|
277
|
+
async function setDefault(schemaName, tableName, column, lowerer, operationClass) {
|
|
278
|
+
if (column.default === void 0) throw postgresError("CONTRACT.DEFAULT_INVALID", `setDefault on column "${column.name}" of table "${tableName}" has no default. Pass the column with its default, as in col(name, type, { default: lit(value) }) or col(name, type, { default: fn(expression) }).`, { meta: {
|
|
279
|
+
table: tableName,
|
|
280
|
+
column: column.name,
|
|
281
|
+
reason: "set-default-without-default"
|
|
282
|
+
} });
|
|
283
|
+
if (column.default.kind === "function" && column.default.expression.text === "autoincrement()") return setAutoincrementDefault(schemaName, tableName, column, lowerer, operationClass);
|
|
284
|
+
const columnName = column.name;
|
|
163
285
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
286
|
+
const clause = await lowerer.renderColumnDefault(column, tableName);
|
|
164
287
|
const { present } = await columnExistsSteps(lowerer, {
|
|
165
288
|
schema: schemaName,
|
|
166
289
|
table: tableName,
|
|
167
290
|
column: columnName
|
|
168
291
|
});
|
|
169
|
-
|
|
292
|
+
return {
|
|
293
|
+
id: `setDefault.${tableName}.${columnName}`,
|
|
294
|
+
label: `Set default on "${tableName}"."${columnName}"`,
|
|
295
|
+
operationClass,
|
|
296
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
297
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
298
|
+
execute: [step(`set default on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${clause}`)],
|
|
299
|
+
postcheck: []
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Gives an existing smallint, integer or bigint column an `autoincrement()` default. When the column
|
|
304
|
+
* already owns a sequence, whatever its name (dropping the default leaves it in place, and a rename
|
|
305
|
+
* of the table or column does not rename it), the operation reuses it; otherwise it creates the
|
|
306
|
+
* sequence a SERIAL column of that width would get and makes the column own it. It then sets the
|
|
307
|
+
* sequence to the column's width, sets the column's default to it, and starts it past the column's
|
|
308
|
+
* largest value so existing rows never collide. The precheck refuses, when the column owns no
|
|
309
|
+
* sequence, a name another relation holds. The postcheck asks for the attached sequence and the
|
|
310
|
+
* `nextval(` default, which no earlier default satisfies, and that the sequence has the column's
|
|
311
|
+
* width, which a narrower sequence left from before the column was widened does not satisfy.
|
|
312
|
+
*/
|
|
313
|
+
async function setAutoincrementDefault(schemaName, tableName, column, lowerer, operationClass) {
|
|
314
|
+
const columnName = column.name;
|
|
315
|
+
const sequenceType = autoincrementWidth(column.type)?.sequenceType;
|
|
316
|
+
if (sequenceType === void 0) throw postgresError("CONTRACT.DEFAULT_INVALID", `setDefault can give the column "${columnName}" of table "${tableName}" an autoincrement() default only when its type is smallint, integer or bigint (int2, int4 or int8); its type is "${column.type}".`, { meta: {
|
|
317
|
+
table: tableName,
|
|
318
|
+
column: columnName,
|
|
319
|
+
reason: "set-default-autoincrement"
|
|
320
|
+
} });
|
|
321
|
+
const qualifiedTable = qualifyTableName(schemaName, tableName);
|
|
322
|
+
const qualifiedColumn = quoteIdentifier(columnName);
|
|
323
|
+
const location = {
|
|
170
324
|
schema: schemaName,
|
|
171
325
|
table: tableName,
|
|
172
326
|
column: columnName
|
|
173
|
-
}
|
|
327
|
+
};
|
|
328
|
+
const ownedSequence = ownedSequenceSql(location);
|
|
329
|
+
const sequenceName = defaultSequenceName(tableName, columnName);
|
|
330
|
+
const qualifiedSequence = qualifyTableName(schemaName, sequenceName);
|
|
331
|
+
const { present } = await columnExistsSteps(lowerer, location);
|
|
332
|
+
const nameAvailable = await lowerer.lowerToExecuteRequest(sequenceNameAvailableAst({
|
|
333
|
+
...location,
|
|
334
|
+
sequence: sequenceName
|
|
335
|
+
}));
|
|
336
|
+
const attached = await lowerer.lowerToExecuteRequest(columnDefaultSequenceAst(location));
|
|
337
|
+
const ownsSequence = await lowerer.lowerToExecuteRequest(columnOwnsSequenceAst({
|
|
338
|
+
...location,
|
|
339
|
+
sequenceType,
|
|
340
|
+
orNone: false
|
|
341
|
+
}));
|
|
174
342
|
return {
|
|
175
343
|
id: `setDefault.${tableName}.${columnName}`,
|
|
176
344
|
label: `Set default on "${tableName}"."${columnName}"`,
|
|
177
345
|
operationClass,
|
|
178
346
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
179
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
180
|
-
execute: [
|
|
181
|
-
|
|
347
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), step(`ensure column "${columnName}" owns a sequence or no relation is named ${qualifiedSequence} (rename that relation, or write this migration with migration new)`, nameAvailable.sql, nameAvailable.params)],
|
|
348
|
+
execute: [
|
|
349
|
+
step(`create sequence "${sequenceName}" owned by "${columnName}" unless the column owns one`, doBlock(`IF ${ownedSequence} IS NULL THEN CREATE SEQUENCE ${qualifiedSequence} AS ${sequenceType}; ALTER SEQUENCE ${qualifiedSequence} OWNED BY ${qualifiedTable}.${qualifiedColumn}; END IF;`)),
|
|
350
|
+
step(`change the sequence column "${columnName}" owns to ${sequenceType}`, doBlock(alterOwnedSequenceTypeStatement(location, sequenceType))),
|
|
351
|
+
step(`set default on "${columnName}" to the sequence it owns`, doBlock(`EXECUTE format('ALTER TABLE %s ALTER COLUMN %I SET DEFAULT nextval(%L::regclass)', '${escapeLiteral(qualifiedTable)}', '${escapeLiteral(columnName)}', ${ownedSequence}::text);`)),
|
|
352
|
+
step(`start the sequence column "${columnName}" owns past the largest "${columnName}"`, `SELECT setval(${ownedSequence}, GREATEST(COALESCE(MAX(${qualifiedColumn}), 0), 0) + 1, false) FROM ${qualifiedTable}`)
|
|
353
|
+
],
|
|
354
|
+
postcheck: [step(`verify column "${columnName}" takes its default from an attached sequence`, attached.sql, attached.params), step(`verify column "${columnName}" owns a sequence of type ${sequenceType}`, ownsSequence.sql, ownsSequence.params)]
|
|
182
355
|
};
|
|
183
356
|
}
|
|
184
357
|
async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
@@ -200,9 +373,9 @@ async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
|
200
373
|
return {
|
|
201
374
|
id: `dropDefault.${tableName}.${columnName}`,
|
|
202
375
|
label: `Drop default on "${tableName}"."${columnName}"`,
|
|
203
|
-
operationClass: "
|
|
376
|
+
operationClass: "widening",
|
|
204
377
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
205
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
378
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
206
379
|
execute: [step(`drop default on "${columnName}"`, dropDefaultExec.sql)],
|
|
207
380
|
postcheck: [step(`verify column "${columnName}" has no default`, noDefault.sql, noDefault.params)]
|
|
208
381
|
};
|
|
@@ -213,7 +386,7 @@ async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
|
213
386
|
* empty; the execute step lowers the typed `AddColumn` DDL node through the
|
|
214
387
|
* adapter; postchecks assert the column exists and is NOT NULL.
|
|
215
388
|
*/
|
|
216
|
-
async function
|
|
389
|
+
async function addRequiredColumnToEmptyTable(schemaName, tableName, column, checkType, lowerer) {
|
|
217
390
|
const columnName = column.name;
|
|
218
391
|
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
219
392
|
...ifDefined("schema", boundSchema(schemaName)),
|
|
@@ -237,15 +410,27 @@ async function addNotNullColumnDirect(schemaName, tableName, column, lowerer) {
|
|
|
237
410
|
column: columnName,
|
|
238
411
|
nullable: false
|
|
239
412
|
}));
|
|
413
|
+
const hasType = await columnTypeStep(lowerer, {
|
|
414
|
+
schema: schemaName,
|
|
415
|
+
table: tableName,
|
|
416
|
+
column: columnName
|
|
417
|
+
}, column.type, checkType);
|
|
240
418
|
return {
|
|
241
419
|
id: `column.${tableName}.${columnName}`,
|
|
242
420
|
label: `Add column ${columnName} to ${tableName}`,
|
|
243
421
|
summary: `Adds column ${columnName} to table ${tableName}`,
|
|
244
422
|
operationClass: "additive",
|
|
245
423
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
246
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params
|
|
424
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`)), {
|
|
425
|
+
...step(`ensure table "${tableName}" is empty before adding NOT NULL column without default`, tableEmpty.sql, tableEmpty.params),
|
|
426
|
+
meta: requiredColumnMeta(tableName, columnName, "newField")
|
|
427
|
+
}],
|
|
247
428
|
execute: [step(`add column "${columnName}"`, addColumn.sql)],
|
|
248
|
-
postcheck: [
|
|
429
|
+
postcheck: [
|
|
430
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
431
|
+
step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params),
|
|
432
|
+
hasType
|
|
433
|
+
]
|
|
249
434
|
};
|
|
250
435
|
}
|
|
251
436
|
async function constraintCheckSteps(lowerer, options) {
|
|
@@ -255,6 +440,20 @@ async function constraintCheckSteps(lowerer, options) {
|
|
|
255
440
|
present: await lowerer.lowerToExecuteRequest(checks.constraintPresent())
|
|
256
441
|
};
|
|
257
442
|
}
|
|
443
|
+
async function constraintAbsent(lowerer, options) {
|
|
444
|
+
return lowerer.lowerToExecuteRequest(constraintExistsAst(options).constraintAbsent());
|
|
445
|
+
}
|
|
446
|
+
const REFERENTIAL_ACTION_CODE = {
|
|
447
|
+
noAction: "a",
|
|
448
|
+
restrict: "r",
|
|
449
|
+
cascade: "c",
|
|
450
|
+
setNull: "n",
|
|
451
|
+
setDefault: "d"
|
|
452
|
+
};
|
|
453
|
+
async function constraintDefinedStep(lowerer, description, definition) {
|
|
454
|
+
const defined = await lowerer.lowerToExecuteRequest(constraintDefinitionAst(definition));
|
|
455
|
+
return step(description, defined.sql, defined.params);
|
|
456
|
+
}
|
|
258
457
|
function renderForeignKeySql(schemaName, tableName, fk) {
|
|
259
458
|
let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}
|
|
260
459
|
ADD CONSTRAINT ${quoteIdentifier(fk.name)}
|
|
@@ -275,73 +474,123 @@ REFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.
|
|
|
275
474
|
async function addPrimaryKey(schemaName, tableName, constraintName, columns, lowerer) {
|
|
276
475
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
277
476
|
const columnList = columns.map(quoteIdentifier).join(", ");
|
|
278
|
-
const
|
|
477
|
+
const absent = await constraintAbsent(lowerer, {
|
|
279
478
|
constraintName,
|
|
280
479
|
schema: schemaName,
|
|
281
480
|
table: tableName
|
|
282
481
|
});
|
|
482
|
+
const defined = await constraintDefinedStep(lowerer, `verify primary key "${constraintName}" exists on (${columns.join(", ")})`, {
|
|
483
|
+
schema: schemaName,
|
|
484
|
+
table: tableName,
|
|
485
|
+
constraintName,
|
|
486
|
+
contype: "p",
|
|
487
|
+
columns
|
|
488
|
+
});
|
|
283
489
|
return {
|
|
284
490
|
id: `primaryKey.${tableName}.${constraintName}`,
|
|
285
491
|
label: `Add primary key on "${tableName}"`,
|
|
286
492
|
operationClass: "additive",
|
|
287
493
|
target: targetDetails("primaryKey", constraintName, schemaName, tableName),
|
|
288
|
-
precheck: [step(`ensure primary key "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
494
|
+
precheck: [step(`ensure primary key "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`primary key "${constraintName}" on "${tableName}"`))],
|
|
289
495
|
execute: [step(`add primary key "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`)],
|
|
290
|
-
postcheck: [
|
|
496
|
+
postcheck: [defined]
|
|
291
497
|
};
|
|
292
498
|
}
|
|
293
499
|
async function addUnique(schemaName, tableName, constraintName, columns, lowerer) {
|
|
294
500
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
295
501
|
const columnList = columns.map(quoteIdentifier).join(", ");
|
|
296
|
-
const
|
|
502
|
+
const absent = await constraintAbsent(lowerer, {
|
|
297
503
|
constraintName,
|
|
298
504
|
schema: schemaName,
|
|
299
505
|
table: tableName
|
|
300
506
|
});
|
|
507
|
+
const defined = await constraintDefinedStep(lowerer, `verify unique constraint "${constraintName}" exists on (${columns.join(", ")})`, {
|
|
508
|
+
schema: schemaName,
|
|
509
|
+
table: tableName,
|
|
510
|
+
constraintName,
|
|
511
|
+
contype: "u",
|
|
512
|
+
columns
|
|
513
|
+
});
|
|
301
514
|
return {
|
|
302
515
|
id: `unique.${tableName}.${constraintName}`,
|
|
303
516
|
label: `Add unique constraint on "${tableName}" (${columns.join(", ")})`,
|
|
304
517
|
operationClass: "additive",
|
|
305
518
|
target: targetDetails("unique", constraintName, schemaName, tableName),
|
|
306
|
-
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
519
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
307
520
|
execute: [step(`add unique constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`)],
|
|
308
|
-
postcheck: [
|
|
521
|
+
postcheck: [defined]
|
|
309
522
|
};
|
|
310
523
|
}
|
|
311
524
|
async function addForeignKey(schemaName, tableName, fk, lowerer) {
|
|
312
|
-
const
|
|
525
|
+
const absent = await constraintAbsent(lowerer, {
|
|
313
526
|
constraintName: fk.name,
|
|
314
527
|
schema: schemaName,
|
|
315
528
|
table: tableName
|
|
316
529
|
});
|
|
530
|
+
const defined = await constraintDefinedStep(lowerer, `verify FK "${fk.name}" exists with the planned columns, referenced table and actions`, {
|
|
531
|
+
schema: schemaName,
|
|
532
|
+
table: tableName,
|
|
533
|
+
constraintName: fk.name,
|
|
534
|
+
contype: "f",
|
|
535
|
+
columns: fk.columns,
|
|
536
|
+
foreignKey: {
|
|
537
|
+
referencedSchema: fk.references.schema,
|
|
538
|
+
referencedTable: fk.references.table,
|
|
539
|
+
referencedColumns: fk.references.columns,
|
|
540
|
+
onDelete: REFERENTIAL_ACTION_CODE[fk.onDelete ?? "noAction"],
|
|
541
|
+
onUpdate: REFERENTIAL_ACTION_CODE[fk.onUpdate ?? "noAction"]
|
|
542
|
+
}
|
|
543
|
+
});
|
|
317
544
|
return {
|
|
318
545
|
id: `foreignKey.${tableName}.${fk.name}`,
|
|
319
546
|
label: `Add foreign key "${fk.name}" on "${tableName}"`,
|
|
320
547
|
operationClass: "additive",
|
|
321
548
|
target: targetDetails("foreignKey", fk.name, schemaName, tableName),
|
|
322
|
-
precheck: [step(`ensure FK "${fk.name}" does not exist`, absent.sql, absent.params)],
|
|
549
|
+
precheck: [step(`ensure FK "${fk.name}" does not exist`, absent.sql, absent.params, expectAbsent(`FK "${fk.name}" on "${tableName}"`))],
|
|
323
550
|
execute: [step(`add FK "${fk.name}"`, renderForeignKeySql(schemaName, tableName, fk))],
|
|
324
|
-
postcheck: [
|
|
551
|
+
postcheck: [defined]
|
|
325
552
|
};
|
|
326
553
|
}
|
|
327
554
|
async function addCheckConstraint(schemaName, tableName, constraintName, expression, lowerer) {
|
|
328
|
-
const
|
|
329
|
-
const { absent, present } = await constraintCheckSteps(lowerer, {
|
|
555
|
+
const absent = await constraintAbsent(lowerer, {
|
|
330
556
|
constraintName,
|
|
331
557
|
schema: schemaName,
|
|
332
558
|
table: tableName
|
|
333
559
|
});
|
|
560
|
+
const defined = await constraintDefinedStep(lowerer, `verify check constraint "${constraintName}" exists`, {
|
|
561
|
+
schema: schemaName,
|
|
562
|
+
table: tableName,
|
|
563
|
+
constraintName,
|
|
564
|
+
contype: "c"
|
|
565
|
+
});
|
|
566
|
+
const addCheck = await lowerer.lowerToExecuteRequest(alterTable({
|
|
567
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
568
|
+
table: tableName,
|
|
569
|
+
actions: [addConstraintAction(checkExpression(constraintName, expression))]
|
|
570
|
+
}));
|
|
334
571
|
return {
|
|
335
572
|
id: `checkConstraint.${tableName}.${constraintName}`,
|
|
336
573
|
label: `Add check constraint "${constraintName}" on "${tableName}"`,
|
|
337
574
|
operationClass: "additive",
|
|
338
575
|
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
339
|
-
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
340
|
-
execute: [step(`add check constraint "${constraintName}"`,
|
|
341
|
-
postcheck: [
|
|
576
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
577
|
+
execute: [step(`add check constraint "${constraintName}"`, addCheck.sql)],
|
|
578
|
+
postcheck: [defined]
|
|
342
579
|
};
|
|
343
580
|
}
|
|
344
|
-
|
|
581
|
+
const CONSTRAINT_KIND_LABEL = {
|
|
582
|
+
primaryKey: "primary key",
|
|
583
|
+
unique: "unique constraint",
|
|
584
|
+
foreignKey: "foreign key",
|
|
585
|
+
checkConstraint: "check constraint"
|
|
586
|
+
};
|
|
587
|
+
function renameConstraintLabel(kind, fromName, toName, tableName) {
|
|
588
|
+
return `Rename ${CONSTRAINT_KIND_LABEL[kind]} "${fromName}" to "${toName}" on "${tableName}"`;
|
|
589
|
+
}
|
|
590
|
+
function renameConstraintOperationId(kind, schemaName, tableName, fromName) {
|
|
591
|
+
return `${kind}.${schemaName}.${tableName}.${fromName}.rename`;
|
|
592
|
+
}
|
|
593
|
+
async function renameConstraint(schemaName, tableName, kind, fromName, toName, lowerer) {
|
|
345
594
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
346
595
|
const from = await constraintCheckSteps(lowerer, {
|
|
347
596
|
constraintName: fromName,
|
|
@@ -354,13 +603,13 @@ async function renameCheckConstraint(schemaName, tableName, fromName, toName, lo
|
|
|
354
603
|
table: tableName
|
|
355
604
|
});
|
|
356
605
|
return {
|
|
357
|
-
id:
|
|
358
|
-
label:
|
|
606
|
+
id: renameConstraintOperationId(kind, schemaName, tableName, fromName),
|
|
607
|
+
label: renameConstraintLabel(kind, fromName, toName, tableName),
|
|
359
608
|
operationClass: "widening",
|
|
360
|
-
target: targetDetails(
|
|
361
|
-
precheck: [step(`ensure constraint "${fromName}" exists`, from.present.sql, from.present.params), step(`ensure constraint "${toName}" does not exist`, to.absent.sql, to.absent.params)],
|
|
362
|
-
execute: [step(`rename
|
|
363
|
-
postcheck: [step(`verify constraint "${toName}" exists`, to.present.sql, to.present.params)]
|
|
609
|
+
target: targetDetails(kind, toName, schemaName, tableName),
|
|
610
|
+
precheck: [step(`ensure constraint "${fromName}" exists`, from.present.sql, from.present.params, expectPresent(`constraint "${fromName}" on "${tableName}"`)), step(`ensure constraint "${toName}" does not exist`, to.absent.sql, to.absent.params, expectAbsent(`constraint "${toName}" on "${tableName}"`))],
|
|
611
|
+
execute: [step(`rename ${CONSTRAINT_KIND_LABEL[kind]} "${fromName}" to "${toName}"`, `ALTER TABLE ${qualified} RENAME CONSTRAINT ${quoteIdentifier(fromName)} TO ${quoteIdentifier(toName)}`)],
|
|
612
|
+
postcheck: [step(`verify constraint "${toName}" exists`, to.present.sql, to.present.params, expectPresent(`constraint "${toName}" on "${tableName}"`)), step(`verify constraint "${fromName}" no longer exists`, from.absent.sql, from.absent.params, expectAbsent(`constraint "${fromName}" on "${tableName}"`))]
|
|
364
613
|
};
|
|
365
614
|
}
|
|
366
615
|
async function dropCheckConstraint(schemaName, tableName, constraintName, lowerer) {
|
|
@@ -373,11 +622,11 @@ async function dropCheckConstraint(schemaName, tableName, constraintName, lowere
|
|
|
373
622
|
return {
|
|
374
623
|
id: `dropCheckConstraint.${tableName}.${constraintName}`,
|
|
375
624
|
label: `Drop check constraint "${constraintName}" on "${tableName}"`,
|
|
376
|
-
operationClass: "
|
|
625
|
+
operationClass: "widening",
|
|
377
626
|
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
378
|
-
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params)],
|
|
627
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params, expectPresent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
379
628
|
execute: [step(`drop check constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
380
|
-
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params)]
|
|
629
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))]
|
|
381
630
|
};
|
|
382
631
|
}
|
|
383
632
|
/**
|
|
@@ -397,11 +646,11 @@ async function dropConstraint(schemaName, tableName, constraintName, lowerer, ki
|
|
|
397
646
|
return {
|
|
398
647
|
id: `dropConstraint.${tableName}.${constraintName}`,
|
|
399
648
|
label: `Drop constraint "${constraintName}" on "${tableName}"`,
|
|
400
|
-
operationClass: "
|
|
649
|
+
operationClass: "widening",
|
|
401
650
|
target: targetDetails(kind, constraintName, schemaName, tableName),
|
|
402
|
-
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params)],
|
|
651
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params, expectPresent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
403
652
|
execute: [step(`drop constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
404
|
-
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params)]
|
|
653
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))]
|
|
405
654
|
};
|
|
406
655
|
}
|
|
407
656
|
function createExtension(extensionName) {
|
|
@@ -448,9 +697,9 @@ async function installExtension(options, lowerer) {
|
|
|
448
697
|
name: extensionName
|
|
449
698
|
}
|
|
450
699
|
},
|
|
451
|
-
precheck: [step(`verify extension "${extensionName}" is not already enabled`, absent.sql, absent.params)],
|
|
700
|
+
precheck: [step(`verify extension "${extensionName}" is not already enabled`, absent.sql, absent.params, expectAbsent(`extension "${extensionName}"`))],
|
|
452
701
|
execute: [step(`create extension "${extensionName}"`, `CREATE EXTENSION IF NOT EXISTS ${extensionName}`)],
|
|
453
|
-
postcheck: [step(`confirm extension "${extensionName}" is enabled`, present.sql, present.params)]
|
|
702
|
+
postcheck: [step(`confirm extension "${extensionName}" is enabled`, present.sql, present.params, expectPresent(`extension "${extensionName}"`))]
|
|
454
703
|
};
|
|
455
704
|
}
|
|
456
705
|
async function indexExistsSteps(lowerer, schemaName, indexName) {
|
|
@@ -476,29 +725,37 @@ async function createIndex(schemaName, tableName, indexName, elements, lowerer,
|
|
|
476
725
|
where: extras?.where
|
|
477
726
|
});
|
|
478
727
|
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
479
|
-
const
|
|
728
|
+
const absent = await lowerer.lowerToExecuteRequest(indexExistsAst(schemaName, indexName).indexAbsent());
|
|
729
|
+
const defined = await lowerer.lowerToExecuteRequest(indexDefinitionAst({
|
|
730
|
+
schema: schemaName,
|
|
731
|
+
table: tableName,
|
|
732
|
+
index: indexName,
|
|
733
|
+
unique: extras?.unique === true,
|
|
734
|
+
method: extras?.type ?? "btree",
|
|
735
|
+
elements: "columns" in elements ? { columns: elements.columns } : { expression: true },
|
|
736
|
+
hasPredicate: extras?.where !== void 0
|
|
737
|
+
}));
|
|
480
738
|
return {
|
|
481
739
|
id: `index.${tableName}.${indexName}`,
|
|
482
740
|
label: `Create index "${indexName}" on "${tableName}"`,
|
|
483
741
|
operationClass: "additive",
|
|
484
742
|
target: targetDetails("index", indexName, schemaName, tableName),
|
|
485
|
-
precheck: [step(`ensure index "${indexName}" does not exist`, absent.sql, absent.params)],
|
|
743
|
+
precheck: [step(`ensure index "${indexName}" does not exist`, absent.sql, absent.params, expectAbsent(`index "${indexName}"`))],
|
|
486
744
|
execute: [step(`create index "${indexName}"`, execute.sql, execute.params)],
|
|
487
|
-
postcheck: [step(`verify index "${indexName}" exists`,
|
|
745
|
+
postcheck: [step(`verify index "${indexName}" exists on "${tableName}" with the planned definition`, defined.sql, defined.params)]
|
|
488
746
|
};
|
|
489
747
|
}
|
|
490
|
-
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
* rename widens anything.
|
|
495
|
-
*/
|
|
748
|
+
/** `ALTER INDEX … RENAME TO`: `widening`, because a rename keeps every row and value. */
|
|
749
|
+
function renameIndexOperationId(schemaName, tableName, fromName) {
|
|
750
|
+
return `index.${schemaName}.${tableName}.${fromName}.rename`;
|
|
751
|
+
}
|
|
496
752
|
async function renameIndex(schemaName, tableName, fromName, toName, lowerer) {
|
|
497
753
|
const fromChecks = indexExistsAst(schemaName, fromName);
|
|
498
754
|
const toChecks = indexExistsAst(schemaName, toName);
|
|
499
755
|
const fromPresent = await lowerer.lowerToExecuteRequest(fromChecks.indexPresent());
|
|
500
756
|
const toAbsent = await lowerer.lowerToExecuteRequest(toChecks.indexAbsent());
|
|
501
757
|
const toPresent = await lowerer.lowerToExecuteRequest(toChecks.indexPresent());
|
|
758
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(fromChecks.indexAbsent());
|
|
502
759
|
const ddlNode = alterIndexRename({
|
|
503
760
|
schema: ddlSchemaOf(schemaName),
|
|
504
761
|
from: fromName,
|
|
@@ -506,13 +763,13 @@ async function renameIndex(schemaName, tableName, fromName, toName, lowerer) {
|
|
|
506
763
|
});
|
|
507
764
|
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
508
765
|
return {
|
|
509
|
-
id:
|
|
766
|
+
id: renameIndexOperationId(schemaName, tableName, fromName),
|
|
510
767
|
label: `Rename index "${fromName}" to "${toName}" on "${tableName}"`,
|
|
511
768
|
operationClass: "widening",
|
|
512
769
|
target: targetDetails("index", toName, schemaName, tableName),
|
|
513
|
-
precheck: [step(`ensure index "${fromName}" exists`, fromPresent.sql, fromPresent.params), step(`ensure index "${toName}" does not exist`, toAbsent.sql, toAbsent.params)],
|
|
770
|
+
precheck: [step(`ensure index "${fromName}" exists`, fromPresent.sql, fromPresent.params, expectPresent(`index "${fromName}"`)), step(`ensure index "${toName}" does not exist`, toAbsent.sql, toAbsent.params, expectAbsent(`index "${toName}"`))],
|
|
514
771
|
execute: [step(`rename index "${fromName}" to "${toName}"`, execute.sql, execute.params)],
|
|
515
|
-
postcheck: [step(`verify index "${toName}" exists`, toPresent.sql, toPresent.params)]
|
|
772
|
+
postcheck: [step(`verify index "${toName}" exists`, toPresent.sql, toPresent.params, expectPresent(`index "${toName}"`)), step(`verify index "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params, expectAbsent(`index "${fromName}"`))]
|
|
516
773
|
};
|
|
517
774
|
}
|
|
518
775
|
async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
@@ -525,11 +782,11 @@ async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
|
525
782
|
return {
|
|
526
783
|
id: `dropIndex.${tableName}.${indexName}`,
|
|
527
784
|
label: `Drop index "${indexName}"`,
|
|
528
|
-
operationClass: "
|
|
785
|
+
operationClass: "widening",
|
|
529
786
|
target: targetDetails("index", indexName, schemaName, tableName),
|
|
530
|
-
precheck: [step(`ensure index "${indexName}" exists`, present.sql, present.params)],
|
|
787
|
+
precheck: [step(`ensure index "${indexName}" exists`, present.sql, present.params, expectPresent(`index "${indexName}"`))],
|
|
531
788
|
execute: [step(`drop index "${indexName}"`, execute.sql, execute.params)],
|
|
532
|
-
postcheck: [step(`verify index "${indexName}" does not exist`, absent.sql, absent.params)]
|
|
789
|
+
postcheck: [step(`verify index "${indexName}" does not exist`, absent.sql, absent.params, expectAbsent(`index "${indexName}"`))]
|
|
533
790
|
};
|
|
534
791
|
}
|
|
535
792
|
/**
|
|
@@ -568,7 +825,7 @@ async function dropNativeEnumType(schemaName, typeName, lowerer) {
|
|
|
568
825
|
return {
|
|
569
826
|
id: `dropNativeEnumType.${typeName}`,
|
|
570
827
|
label: `Drop enum type "${typeName}"`,
|
|
571
|
-
operationClass: "
|
|
828
|
+
operationClass: "widening",
|
|
572
829
|
target: targetDetails("type", typeName, schemaName),
|
|
573
830
|
precheck: [],
|
|
574
831
|
execute: [step(`drop enum type "${typeName}"`, statement.sql, statement.params)],
|
|
@@ -583,6 +840,11 @@ function validateRoleName(role) {
|
|
|
583
840
|
} });
|
|
584
841
|
return role;
|
|
585
842
|
}
|
|
843
|
+
/** The roles `pg_policies.roles` lists for a policy created for `roles`: the roles the `TO` clause names, which fold to lower case unquoted. Postgres ignores every other role when the clause names `public`. */
|
|
844
|
+
function catalogPolicyRoles(roles) {
|
|
845
|
+
const named = [...new Set(policyRoleList(roles).map((role) => role.toLowerCase()))];
|
|
846
|
+
return named.includes("public") ? ["public"] : named;
|
|
847
|
+
}
|
|
586
848
|
async function createRlsPolicy(schemaName, tableName, policy, lowerer) {
|
|
587
849
|
const validatedRoles = policy.roles.map(validateRoleName);
|
|
588
850
|
const ddlNode = createPolicy({
|
|
@@ -602,15 +864,22 @@ async function createRlsPolicy(schemaName, tableName, policy, lowerer) {
|
|
|
602
864
|
});
|
|
603
865
|
const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());
|
|
604
866
|
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
605
|
-
const
|
|
867
|
+
const defined = await lowerer.lowerToExecuteRequest(rlsPolicyDefinitionAst({
|
|
868
|
+
schema: schemaName,
|
|
869
|
+
table: tableName,
|
|
870
|
+
policyName: policy.name,
|
|
871
|
+
command: POLICY_COMMAND_SQL[policy.operation],
|
|
872
|
+
permissive: policy.permissive,
|
|
873
|
+
roles: catalogPolicyRoles(validatedRoles)
|
|
874
|
+
}));
|
|
606
875
|
return {
|
|
607
876
|
id: `rlsPolicy.${schemaName}.${tableName}.${policy.name}`,
|
|
608
877
|
label: `Create RLS policy "${policy.name}" on "${tableName}"`,
|
|
609
878
|
operationClass: "additive",
|
|
610
879
|
target: targetDetails("rlsPolicy", policy.name, schemaName, tableName),
|
|
611
|
-
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params)],
|
|
880
|
+
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params, expectAbsent(`RLS policy "${policy.name}" on "${tableName}"`))],
|
|
612
881
|
execute: [step(`create RLS policy "${policy.name}"`, execute.sql, execute.params)],
|
|
613
|
-
postcheck: [step(`verify RLS policy "${policy.name}" exists`,
|
|
882
|
+
postcheck: [step(`verify RLS policy "${policy.name}" exists with the planned command, roles and permissiveness`, defined.sql, defined.params)]
|
|
614
883
|
};
|
|
615
884
|
}
|
|
616
885
|
async function dropRlsPolicy(schemaName, tableName, policyName, lowerer) {
|
|
@@ -630,11 +899,11 @@ async function dropRlsPolicy(schemaName, tableName, policyName, lowerer) {
|
|
|
630
899
|
return {
|
|
631
900
|
id: `rlsPolicy.${schemaName}.${tableName}.${policyName}.drop`,
|
|
632
901
|
label: `Drop RLS policy "${policyName}" on "${tableName}"`,
|
|
633
|
-
operationClass: "
|
|
902
|
+
operationClass: "widening",
|
|
634
903
|
target: targetDetails("rlsPolicy", policyName, schemaName, tableName),
|
|
635
|
-
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params)],
|
|
904
|
+
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params, expectPresent(`RLS policy "${policyName}" on "${tableName}"`))],
|
|
636
905
|
execute: [step(`drop RLS policy "${policyName}"`, execute.sql, execute.params)],
|
|
637
|
-
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params)]
|
|
906
|
+
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params, expectAbsent(`RLS policy "${policyName}" on "${tableName}"`))]
|
|
638
907
|
};
|
|
639
908
|
}
|
|
640
909
|
async function enableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
@@ -663,7 +932,7 @@ async function disableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
|
663
932
|
return {
|
|
664
933
|
id: `rowLevelSecurity.${schemaName}.${tableName}.disable`,
|
|
665
934
|
label: `Disable row-level security on "${tableName}"`,
|
|
666
|
-
operationClass: "
|
|
935
|
+
operationClass: "widening",
|
|
667
936
|
target: targetDetails("rowLevelSecurity", tableName, schemaName),
|
|
668
937
|
precheck: [step(`check RLS is currently enabled on "${tableName}"`, enabled.sql, enabled.params)],
|
|
669
938
|
execute: [step(`disable row-level security on "${tableName}"`, execute.sql, execute.params)],
|
|
@@ -690,14 +959,136 @@ async function renameRlsPolicy(schemaName, tableName, oldPolicyName, newPolicyNa
|
|
|
690
959
|
const oldPresent = await lowerer.lowerToExecuteRequest(oldChecks.policyPresent());
|
|
691
960
|
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
692
961
|
const newPresent = await lowerer.lowerToExecuteRequest(newChecks.policyPresent());
|
|
962
|
+
const newAbsent = await lowerer.lowerToExecuteRequest(newChecks.policyAbsent());
|
|
963
|
+
const oldAbsent = await lowerer.lowerToExecuteRequest(oldChecks.policyAbsent());
|
|
693
964
|
return {
|
|
694
965
|
id: `rlsPolicy.${schemaName}.${tableName}.${oldPolicyName}.rename`,
|
|
695
966
|
label: `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`,
|
|
696
967
|
operationClass: "widening",
|
|
697
968
|
target: targetDetails("rlsPolicy", newPolicyName, schemaName, tableName),
|
|
698
|
-
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params)],
|
|
969
|
+
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params, expectPresent(`RLS policy "${oldPolicyName}" on "${tableName}"`)), step(`ensure RLS policy "${newPolicyName}" does not exist`, newAbsent.sql, newAbsent.params, expectAbsent(`RLS policy "${newPolicyName}" on "${tableName}"`))],
|
|
699
970
|
execute: [step(`rename RLS policy "${oldPolicyName}" to "${newPolicyName}"`, execute.sql, execute.params)],
|
|
700
|
-
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params)]
|
|
971
|
+
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params, expectPresent(`RLS policy "${newPolicyName}" on "${tableName}"`)), step(`verify RLS policy "${oldPolicyName}" no longer exists`, oldAbsent.sql, oldAbsent.params, expectAbsent(`RLS policy "${oldPolicyName}" on "${tableName}"`))]
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
const SchemaContentsMeta = type({ schemaContents: { schema: "string" } });
|
|
975
|
+
/** The meta of a step that fails while a schema still holds objects; the runner then names them. */
|
|
976
|
+
function schemaContentsMeta(schema) {
|
|
977
|
+
return { schemaContents: { schema } };
|
|
978
|
+
}
|
|
979
|
+
function schemaContentsOf(step) {
|
|
980
|
+
const meta = SchemaContentsMeta(step.meta ?? {});
|
|
981
|
+
return meta instanceof type.errors ? void 0 : meta.schemaContents.schema;
|
|
982
|
+
}
|
|
983
|
+
const SCHEMA_OBJECTS_SQL = `SELECT kind, name FROM (
|
|
984
|
+
SELECT CASE c.relkind
|
|
985
|
+
WHEN 'v' THEN 'view'
|
|
986
|
+
WHEN 'm' THEN 'materialized view'
|
|
987
|
+
WHEN 'S' THEN 'sequence'
|
|
988
|
+
WHEN 'f' THEN 'foreign table'
|
|
989
|
+
WHEN 'c' THEN 'type'
|
|
990
|
+
ELSE 'table'
|
|
991
|
+
END AS kind, c.relname::text AS name
|
|
992
|
+
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
993
|
+
WHERE n.nspname = $1 AND c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f', 'c')
|
|
994
|
+
UNION ALL
|
|
995
|
+
SELECT 'type', t.typname::text
|
|
996
|
+
FROM pg_catalog.pg_type t JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
|
997
|
+
WHERE n.nspname = $1 AND t.typrelid = 0 AND t.typelem = 0
|
|
998
|
+
UNION ALL
|
|
999
|
+
SELECT 'function', p.proname::text
|
|
1000
|
+
FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
|
|
1001
|
+
WHERE n.nspname = $1
|
|
1002
|
+
) AS objects ORDER BY name, kind`;
|
|
1003
|
+
const NAMED_OBJECTS = 10;
|
|
1004
|
+
function listed(items) {
|
|
1005
|
+
if (items.length === 1) return items[0] ?? "";
|
|
1006
|
+
return `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
1007
|
+
}
|
|
1008
|
+
const UNQUOTED_IDENTIFIER = /^[a-z_][a-z0-9_$]*$/;
|
|
1009
|
+
/** An identifier as Postgres writes it in its messages: quoted only where it must be. */
|
|
1010
|
+
function identifierText(identifier) {
|
|
1011
|
+
return UNQUOTED_IDENTIFIER.test(identifier) ? identifier : `"${identifier.replaceAll("\"", "\"\"")}"`;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* The objects a schema query found, each named with its schema as Postgres names objects in its
|
|
1015
|
+
* messages, such as a view that depends on a table: the form a blocked drop reports everywhere.
|
|
1016
|
+
*/
|
|
1017
|
+
function schemaBlockingObjects(schema, objects) {
|
|
1018
|
+
return objects.map(({ kind, name }) => ({
|
|
1019
|
+
kind,
|
|
1020
|
+
name: `${identifierText(schema)}.${identifierText(name)}`
|
|
1021
|
+
}));
|
|
1022
|
+
}
|
|
1023
|
+
/** What a runner failure says of the objects that keep a schema from being dropped. */
|
|
1024
|
+
function schemaObjectsSummary(schema, objects) {
|
|
1025
|
+
const named = objects.slice(0, NAMED_OBJECTS).map(({ kind, name }) => `${kind} ${name}`);
|
|
1026
|
+
const more = objects.length - named.length;
|
|
1027
|
+
return `Schema "${schema}" still holds ${listed(more > 0 ? [...named, `${more} more`] : named)}, so it cannot be dropped.`;
|
|
1028
|
+
}
|
|
1029
|
+
async function setTableSchema(schemaName, tableName, toSchemaName, lowerer) {
|
|
1030
|
+
const from = tableExistsAst(schemaName, tableName);
|
|
1031
|
+
const to = tableExistsAst(toSchemaName, tableName);
|
|
1032
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(from.tablePresent());
|
|
1033
|
+
const toSchemaPresent = await lowerer.lowerToExecuteRequest(schemaExistsAst(toSchemaName).schemaPresent());
|
|
1034
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(to.tableAbsent());
|
|
1035
|
+
const statement = await lowerer.lowerToExecuteRequest(alterTableSetSchema({
|
|
1036
|
+
schema: boundSchema(schemaName),
|
|
1037
|
+
table: tableName,
|
|
1038
|
+
to: toSchemaName
|
|
1039
|
+
}));
|
|
1040
|
+
const toPresent = await lowerer.lowerToExecuteRequest(to.tablePresent());
|
|
1041
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(schemaName === UNBOUND_NAMESPACE_ID ? unboundTableMovedAst(tableName, toSchemaName) : from.tableAbsent());
|
|
1042
|
+
return {
|
|
1043
|
+
id: `setTableSchema.${tableName}`,
|
|
1044
|
+
label: `Move table "${tableName}" to schema "${toSchemaName}"`,
|
|
1045
|
+
operationClass: "widening",
|
|
1046
|
+
target: targetDetails("table", tableName, toSchemaName),
|
|
1047
|
+
precheck: [
|
|
1048
|
+
step(`ensure table "${tableName}" exists`, fromPresent.sql, fromPresent.params),
|
|
1049
|
+
step(`ensure schema "${toSchemaName}" exists`, toSchemaPresent.sql, toSchemaPresent.params),
|
|
1050
|
+
step(`ensure schema "${toSchemaName}" has no table "${tableName}"`, toAbsent.sql, toAbsent.params)
|
|
1051
|
+
],
|
|
1052
|
+
execute: [step(`move table "${tableName}" to schema "${toSchemaName}"`, statement.sql, statement.params)],
|
|
1053
|
+
postcheck: [step(`verify table "${tableName}" exists in schema "${toSchemaName}"`, toPresent.sql, toPresent.params), step(`verify table "${tableName}" no longer exists where it was`, fromAbsent.sql, fromAbsent.params)]
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
async function renameSchema(schemaName, toSchemaName, lowerer) {
|
|
1057
|
+
const from = schemaExistsAst(schemaName);
|
|
1058
|
+
const to = schemaExistsAst(toSchemaName);
|
|
1059
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(from.schemaPresent());
|
|
1060
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(to.schemaAbsent());
|
|
1061
|
+
const statement = await lowerer.lowerToExecuteRequest(alterSchemaRename({
|
|
1062
|
+
schema: schemaName,
|
|
1063
|
+
to: toSchemaName
|
|
1064
|
+
}));
|
|
1065
|
+
const toPresent = await lowerer.lowerToExecuteRequest(to.schemaPresent());
|
|
1066
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(from.schemaAbsent());
|
|
1067
|
+
return {
|
|
1068
|
+
id: `renameSchema.${schemaName}`,
|
|
1069
|
+
label: `Rename schema "${schemaName}" to "${toSchemaName}"`,
|
|
1070
|
+
operationClass: "widening",
|
|
1071
|
+
target: { id: "postgres" },
|
|
1072
|
+
precheck: [step(`ensure schema "${schemaName}" exists`, fromPresent.sql, fromPresent.params), step(`ensure schema "${toSchemaName}" does not exist`, toAbsent.sql, toAbsent.params)],
|
|
1073
|
+
execute: [step(`rename schema "${schemaName}" to "${toSchemaName}"`, statement.sql, statement.params)],
|
|
1074
|
+
postcheck: [step(`verify schema "${toSchemaName}" exists`, toPresent.sql, toPresent.params), step(`verify schema "${schemaName}" no longer exists`, fromAbsent.sql, fromAbsent.params)]
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
async function dropSchema(schemaName, lowerer) {
|
|
1078
|
+
const empty = await lowerer.lowerToExecuteRequest(schemaHoldsNoObjectsAst(schemaName));
|
|
1079
|
+
const statement = await lowerer.lowerToExecuteRequest(dropSchema$1({ schema: schemaName }));
|
|
1080
|
+
const absent = await lowerer.lowerToExecuteRequest(schemaExistsAst(schemaName).schemaAbsent());
|
|
1081
|
+
return {
|
|
1082
|
+
id: `dropSchema.${schemaName}`,
|
|
1083
|
+
label: `Drop schema "${schemaName}"`,
|
|
1084
|
+
operationClass: "widening",
|
|
1085
|
+
target: { id: "postgres" },
|
|
1086
|
+
precheck: [{
|
|
1087
|
+
...step(`ensure schema "${schemaName}" holds no tables, views, sequences, types or functions`, empty.sql, empty.params),
|
|
1088
|
+
meta: schemaContentsMeta(schemaName)
|
|
1089
|
+
}],
|
|
1090
|
+
execute: [step(`drop schema "${schemaName}"`, statement.sql, statement.params)],
|
|
1091
|
+
postcheck: [step(`verify schema "${schemaName}" does not exist`, absent.sql, absent.params)]
|
|
701
1092
|
};
|
|
702
1093
|
}
|
|
703
1094
|
async function dropTable(schemaName, tableName, lowerer) {
|
|
@@ -710,17 +1101,32 @@ async function dropTable(schemaName, tableName, lowerer) {
|
|
|
710
1101
|
label: `Drop table "${tableName}"`,
|
|
711
1102
|
operationClass: "destructive",
|
|
712
1103
|
target: targetDetails("table", tableName, schemaName),
|
|
713
|
-
precheck: [step(`ensure table "${tableName}" exists`, present.sql, present.params)],
|
|
1104
|
+
precheck: [step(`ensure table "${tableName}" exists`, present.sql, present.params, expectPresent(`table "${tableName}"`))],
|
|
714
1105
|
execute: [step(`drop table "${tableName}"`, `DROP TABLE ${qualified}`)],
|
|
715
|
-
postcheck: [step(`verify table "${tableName}" does not exist`, absent.sql, absent.params)]
|
|
1106
|
+
postcheck: [step(`verify table "${tableName}" does not exist`, absent.sql, absent.params, expectAbsent(`table "${tableName}"`))]
|
|
716
1107
|
};
|
|
717
1108
|
}
|
|
718
|
-
function
|
|
1109
|
+
function renameTableStatement(schemaName, fromName, toName) {
|
|
1110
|
+
return `ALTER TABLE ${qualifyTableName(schemaName, fromName)} RENAME TO ${quoteIdentifier(toName)}`;
|
|
1111
|
+
}
|
|
1112
|
+
function renameTableOperationId(fromName) {
|
|
1113
|
+
return `renameTable.${fromName}`;
|
|
1114
|
+
}
|
|
1115
|
+
async function renameTable(schemaName, fromName, toName, lowerer) {
|
|
1116
|
+
const fromChecks = tableExistsAst(schemaName, fromName);
|
|
1117
|
+
const toChecks = tableExistsAst(schemaName, toName);
|
|
1118
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(fromChecks.tablePresent());
|
|
1119
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(toChecks.tableAbsent());
|
|
1120
|
+
const toPresent = await lowerer.lowerToExecuteRequest(toChecks.tablePresent());
|
|
1121
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(fromChecks.tableAbsent());
|
|
719
1122
|
return {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1123
|
+
id: renameTableOperationId(fromName),
|
|
1124
|
+
label: `Rename table "${fromName}" to "${toName}"`,
|
|
1125
|
+
operationClass: "widening",
|
|
1126
|
+
target: targetDetails("table", toName, schemaName),
|
|
1127
|
+
precheck: [step(`ensure table "${fromName}" exists`, fromPresent.sql, fromPresent.params, expectPresent(`table "${fromName}"`)), step(`ensure table "${toName}" does not exist`, toAbsent.sql, toAbsent.params, expectAbsent(`table "${toName}"`))],
|
|
1128
|
+
execute: [step(`rename table "${fromName}" to "${toName}"`, renameTableStatement(schemaName, fromName, toName))],
|
|
1129
|
+
postcheck: [step(`verify table "${toName}" exists`, toPresent.sql, toPresent.params, expectPresent(`table "${toName}"`)), step(`verify table "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params, expectAbsent(`table "${fromName}"`))]
|
|
724
1130
|
};
|
|
725
1131
|
}
|
|
726
1132
|
function buildAddColumnOperationIdentity(schema, tableName, columnName) {
|
|
@@ -735,10 +1141,10 @@ function buildAddColumnOperationIdentity(schema, tableName, columnName) {
|
|
|
735
1141
|
};
|
|
736
1142
|
}
|
|
737
1143
|
async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
738
|
-
const { schema, tableName, columnName,
|
|
739
|
-
const ddlColumn = col(columnName,
|
|
1144
|
+
const { schema, tableName, columnName, type, checkType, temporaryDefault, lowerer } = options;
|
|
1145
|
+
const ddlColumn = col(columnName, type, {
|
|
740
1146
|
notNull: true,
|
|
741
|
-
default: new FunctionColumnDefault(temporaryDefault)
|
|
1147
|
+
default: new FunctionColumnDefault(opaqueSql(temporaryDefault))
|
|
742
1148
|
});
|
|
743
1149
|
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
744
1150
|
...ifDefined("schema", boundSchema(schema)),
|
|
@@ -771,10 +1177,15 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
771
1177
|
table: tableName,
|
|
772
1178
|
column: columnName
|
|
773
1179
|
}).noDefault());
|
|
1180
|
+
const hasType = await columnTypeStep(lowerer, {
|
|
1181
|
+
schema,
|
|
1182
|
+
table: tableName,
|
|
1183
|
+
column: columnName
|
|
1184
|
+
}, type, checkType);
|
|
774
1185
|
return {
|
|
775
1186
|
...buildAddColumnOperationIdentity(schema, tableName, columnName),
|
|
776
1187
|
operationClass: "additive",
|
|
777
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
1188
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))],
|
|
778
1189
|
execute: [{
|
|
779
1190
|
description: `add column "${columnName}"`,
|
|
780
1191
|
sql: addColumn.sql
|
|
@@ -783,9 +1194,10 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
783
1194
|
sql: dropTempDefault.sql
|
|
784
1195
|
}],
|
|
785
1196
|
postcheck: [
|
|
786
|
-
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
1197
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
787
1198
|
step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params),
|
|
788
|
-
step(`verify column "${columnName}" has no default after temporary default removal`, noDefault.sql, noDefault.params)
|
|
1199
|
+
step(`verify column "${columnName}" has no default after temporary default removal`, noDefault.sql, noDefault.params),
|
|
1200
|
+
hasType
|
|
789
1201
|
]
|
|
790
1202
|
};
|
|
791
1203
|
}
|
|
@@ -799,7 +1211,7 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
799
1211
|
*
|
|
800
1212
|
* - `toOp()` — converts the IR node to a runtime
|
|
801
1213
|
* `SqlMigrationPlanOperation` by delegating to the matching pure factory
|
|
802
|
-
* under `operations/`. `DataTransformCall.toOp()` always
|
|
1214
|
+
* under `operations/`. `DataTransformCall.toOp()` always rejects with
|
|
803
1215
|
* `MIGRATION.UNFILLED_PLACEHOLDER` because a planner-generated data transform is an
|
|
804
1216
|
* unfilled authoring stub by construction.
|
|
805
1217
|
* - `renderTypeScript()` / `importRequirements()` — inherited from
|
|
@@ -812,6 +1224,10 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
812
1224
|
*/
|
|
813
1225
|
const POSTGRES_MIGRATION_FACADE = "@internal/postgres/migration";
|
|
814
1226
|
var PostgresOpFactoryCallNode = class extends TsExpression {
|
|
1227
|
+
/** The operations this call lowers to, in order: one, unless the call carries companions. */
|
|
1228
|
+
toOps(lowerer) {
|
|
1229
|
+
return [this.toOp(lowerer)];
|
|
1230
|
+
}
|
|
815
1231
|
importRequirements() {
|
|
816
1232
|
return [{
|
|
817
1233
|
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
@@ -822,35 +1238,39 @@ var PostgresOpFactoryCallNode = class extends TsExpression {
|
|
|
822
1238
|
Object.freeze(this);
|
|
823
1239
|
}
|
|
824
1240
|
};
|
|
1241
|
+
/** Whether `call` is one of this target's calls, which lower through {@link PostgresOpFactoryCallNode.toOps}. */
|
|
1242
|
+
function isPostgresOpFactoryCall(call) {
|
|
1243
|
+
return call instanceof PostgresOpFactoryCallNode;
|
|
1244
|
+
}
|
|
825
1245
|
function postgresDefaultToDdlColumnDefault(columnDefault) {
|
|
826
1246
|
if (!columnDefault) return void 0;
|
|
827
1247
|
switch (columnDefault.kind) {
|
|
828
1248
|
case "literal": return new LiteralColumnDefault(columnDefault.value);
|
|
829
1249
|
case "function":
|
|
830
1250
|
if (columnDefault.expression === "autoincrement()") return void 0;
|
|
831
|
-
return new FunctionColumnDefault(columnDefault.expression);
|
|
832
|
-
case "sequence": return new FunctionColumnDefault(`nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`);
|
|
1251
|
+
return new FunctionColumnDefault(opaqueSql(columnDefault.expression));
|
|
1252
|
+
case "sequence": return new FunctionColumnDefault(opaqueSql(`nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`));
|
|
833
1253
|
default: {
|
|
834
1254
|
const exhaustive = columnDefault;
|
|
835
1255
|
return assertNever(exhaustive, `postgresDefaultToDdlColumnDefault: unhandled kind "${blindCast(exhaustive).kind}"`);
|
|
836
1256
|
}
|
|
837
1257
|
}
|
|
838
1258
|
}
|
|
839
|
-
function renderDdlColumnDefault(def) {
|
|
1259
|
+
function renderDdlColumnDefault(def, sql) {
|
|
840
1260
|
if (!def) return "";
|
|
841
1261
|
if (def.kind === "literal") return `lit(${jsonToTsSource(def.value)})`;
|
|
842
|
-
return `fn(${
|
|
1262
|
+
return `fn(${sql.source(def.expression.text)})`;
|
|
843
1263
|
}
|
|
844
|
-
function renderDdlColumnAsTsCall(col) {
|
|
1264
|
+
function renderDdlColumnAsTsCall(col, sql) {
|
|
845
1265
|
const opts = [];
|
|
846
1266
|
if (col.notNull) opts.push("notNull: true");
|
|
847
1267
|
if (col.primaryKey) opts.push("primaryKey: true");
|
|
848
|
-
if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default)}`);
|
|
1268
|
+
if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default, sql)}`);
|
|
849
1269
|
if (col.codecRef) opts.push(`codecRef: ${jsonToTsSource(col.codecRef)}`);
|
|
850
1270
|
const optsStr = opts.length > 0 ? `, { ${opts.join(", ")} }` : "";
|
|
851
1271
|
return `col(${jsonToTsSource(col.name)}, ${jsonToTsSource(col.type)}${optsStr})`;
|
|
852
1272
|
}
|
|
853
|
-
function renderDdlConstraintAsTsCall(constraint) {
|
|
1273
|
+
function renderDdlConstraintAsTsCall(constraint, sql) {
|
|
854
1274
|
switch (constraint.kind) {
|
|
855
1275
|
case "primary-key": {
|
|
856
1276
|
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
@@ -868,7 +1288,7 @@ function renderDdlConstraintAsTsCall(constraint) {
|
|
|
868
1288
|
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
869
1289
|
return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
870
1290
|
}
|
|
871
|
-
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${
|
|
1291
|
+
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${sql.source(constraint.expression.text)})`;
|
|
872
1292
|
}
|
|
873
1293
|
}
|
|
874
1294
|
function needsColOrConstraintImport(columns) {
|
|
@@ -889,6 +1309,8 @@ function defaultImportSymbols(columns) {
|
|
|
889
1309
|
else if (col.default?.kind === "function") symbols.add("fn");
|
|
890
1310
|
return [...symbols];
|
|
891
1311
|
}
|
|
1312
|
+
/** `pg_class.relkind` of an ordinary or a partitioned table. */
|
|
1313
|
+
const TABLE_RELATION_KINDS = ["r", "p"];
|
|
892
1314
|
var CreateTableCall = class extends PostgresOpFactoryCallNode {
|
|
893
1315
|
factoryName = "createTable";
|
|
894
1316
|
operationClass = "additive";
|
|
@@ -917,33 +1339,43 @@ var CreateTableCall = class extends PostgresOpFactoryCallNode {
|
|
|
917
1339
|
const statement = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
918
1340
|
const schemaName = this.schemaName;
|
|
919
1341
|
const tableName = this.tableName;
|
|
920
|
-
const
|
|
921
|
-
const
|
|
922
|
-
|
|
1342
|
+
const absent = await lowerer.lowerToExecuteRequest(tableExistsAst(schemaName, tableName).tableAbsent());
|
|
1343
|
+
const isTable = await lowerer.lowerToExecuteRequest(relationKindAst({
|
|
1344
|
+
schema: schemaName,
|
|
1345
|
+
name: tableName,
|
|
1346
|
+
kinds: TABLE_RELATION_KINDS
|
|
1347
|
+
}));
|
|
923
1348
|
return {
|
|
924
1349
|
id: `table.${tableName}`,
|
|
925
1350
|
label: `Create table "${tableName}"`,
|
|
926
1351
|
summary: `Creates table "${tableName}"`,
|
|
927
1352
|
operationClass: "additive",
|
|
928
1353
|
target: targetDetails("table", tableName, schemaName),
|
|
929
|
-
precheck: [step(`ensure table "${tableName}" does not exist`, absent.sql, absent.params)],
|
|
1354
|
+
precheck: [step(`ensure table "${tableName}" does not exist`, absent.sql, absent.params, expectAbsent(`table "${tableName}"`))],
|
|
930
1355
|
execute: [{
|
|
931
1356
|
description: `create table "${tableName}"`,
|
|
932
1357
|
sql: statement.sql,
|
|
933
1358
|
params: statement.params ?? []
|
|
934
1359
|
}],
|
|
935
|
-
postcheck: [step(`verify table "${tableName}" exists`,
|
|
1360
|
+
postcheck: [step(`verify table "${tableName}" exists`, isTable.sql, isTable.params, expectPresent(`table "${tableName}"`))]
|
|
936
1361
|
};
|
|
937
1362
|
}
|
|
938
1363
|
renderTypeScript() {
|
|
939
|
-
|
|
940
|
-
|
|
1364
|
+
return this.#written().source;
|
|
1365
|
+
}
|
|
1366
|
+
#written() {
|
|
1367
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1368
|
+
const columnsList = this.columns.map((column) => renderDdlColumnAsTsCall(column, sql)).join(", ");
|
|
1369
|
+
const constraintsList = this.constraints ? this.constraints.map((constraint) => renderDdlConstraintAsTsCall(constraint, sql)).join(", ") : void 0;
|
|
941
1370
|
const opts = [];
|
|
942
1371
|
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
943
1372
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
944
1373
|
opts.push(`columns: [${columnsList}]`);
|
|
945
1374
|
if (constraintsList) opts.push(`constraints: [${constraintsList}]`);
|
|
946
|
-
return
|
|
1375
|
+
return {
|
|
1376
|
+
source: `this.createTable({ ${opts.join(", ")} })`,
|
|
1377
|
+
imports: sql.imports()
|
|
1378
|
+
};
|
|
947
1379
|
}
|
|
948
1380
|
importRequirements() {
|
|
949
1381
|
const req = [];
|
|
@@ -961,6 +1393,7 @@ var CreateTableCall = class extends PostgresOpFactoryCallNode {
|
|
|
961
1393
|
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
962
1394
|
symbol: sym
|
|
963
1395
|
});
|
|
1396
|
+
req.push(...this.#written().imports);
|
|
964
1397
|
return req;
|
|
965
1398
|
}
|
|
966
1399
|
};
|
|
@@ -991,18 +1424,61 @@ var DropTableCall = class extends PostgresOpFactoryCallNode {
|
|
|
991
1424
|
return [];
|
|
992
1425
|
}
|
|
993
1426
|
};
|
|
1427
|
+
var RenameTableCall = class extends PostgresOpFactoryCallNode {
|
|
1428
|
+
factoryName = "renameTable";
|
|
1429
|
+
operationClass = "widening";
|
|
1430
|
+
schemaName;
|
|
1431
|
+
oldTableName;
|
|
1432
|
+
/** The new name: the table's contract-side identity after the rename. */
|
|
1433
|
+
tableName;
|
|
1434
|
+
label;
|
|
1435
|
+
/**
|
|
1436
|
+
* The renames of objects whose names derive from the table name. They run after the table rename
|
|
1437
|
+
* and are never rendered on their own.
|
|
1438
|
+
*/
|
|
1439
|
+
companions;
|
|
1440
|
+
constructor(schemaName, oldTableName, tableName, companions) {
|
|
1441
|
+
super();
|
|
1442
|
+
this.schemaName = schemaName;
|
|
1443
|
+
this.oldTableName = oldTableName;
|
|
1444
|
+
this.tableName = tableName;
|
|
1445
|
+
this.label = `Rename table "${oldTableName}" to "${tableName}"`;
|
|
1446
|
+
this.companions = Object.freeze([...companions]);
|
|
1447
|
+
this.freeze();
|
|
1448
|
+
}
|
|
1449
|
+
toOps(lowerer) {
|
|
1450
|
+
return [this.toOp(lowerer), ...this.companions.map((companion) => companion.toOp(lowerer))];
|
|
1451
|
+
}
|
|
1452
|
+
async toOp(lowerer) {
|
|
1453
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `RenameTableCall.toOp: a lowerer is required on the Postgres planner path (table "${this.oldTableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "RenameTableCall" } });
|
|
1454
|
+
return renameTable(this.schemaName, this.oldTableName, this.tableName, lowerer);
|
|
1455
|
+
}
|
|
1456
|
+
renderTypeScript() {
|
|
1457
|
+
const opts = [];
|
|
1458
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1459
|
+
opts.push(`table: ${jsonToTsSource(this.oldTableName)}`);
|
|
1460
|
+
opts.push(`to: ${jsonToTsSource(this.tableName)}`);
|
|
1461
|
+
return `...this.renameTable({ ${opts.join(", ")} })`;
|
|
1462
|
+
}
|
|
1463
|
+
importRequirements() {
|
|
1464
|
+
return [];
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
994
1467
|
var AddColumnCall = class extends PostgresOpFactoryCallNode {
|
|
995
1468
|
factoryName = "addColumn";
|
|
996
1469
|
operationClass = "additive";
|
|
997
1470
|
schemaName;
|
|
998
1471
|
tableName;
|
|
999
1472
|
column;
|
|
1473
|
+
/** How the postcheck recognises the column's type, or `undefined` when the stack's data types do not read it. */
|
|
1474
|
+
checkType;
|
|
1000
1475
|
label;
|
|
1001
|
-
constructor(schemaName, tableName, column) {
|
|
1476
|
+
constructor(schemaName, tableName, column, dataTypes) {
|
|
1002
1477
|
super();
|
|
1003
1478
|
this.schemaName = schemaName;
|
|
1004
1479
|
this.tableName = tableName;
|
|
1005
1480
|
this.column = column;
|
|
1481
|
+
this.checkType = columnTypeCheckIfReadable(column.type, dataTypes);
|
|
1006
1482
|
this.label = `Add column "${column.name}" to "${tableName}"`;
|
|
1007
1483
|
this.freeze();
|
|
1008
1484
|
}
|
|
@@ -1017,29 +1493,48 @@ var AddColumnCall = class extends PostgresOpFactoryCallNode {
|
|
|
1017
1493
|
const schemaName = this.schemaName;
|
|
1018
1494
|
const tableName = this.tableName;
|
|
1019
1495
|
const columnName = this.column.name;
|
|
1020
|
-
const
|
|
1496
|
+
const location = {
|
|
1021
1497
|
schema: schemaName,
|
|
1022
1498
|
table: tableName,
|
|
1023
1499
|
column: columnName
|
|
1024
|
-
}
|
|
1500
|
+
};
|
|
1501
|
+
const colChecks = columnExistsAst(location);
|
|
1025
1502
|
const absent = await lowerer.lowerToExecuteRequest(colChecks.columnAbsent());
|
|
1026
1503
|
const present = await lowerer.lowerToExecuteRequest(colChecks.columnPresent());
|
|
1504
|
+
const hasType = await columnTypeStep(lowerer, location, this.column.type, this.checkType);
|
|
1505
|
+
const notNullable = this.column.notNull === true || this.column.primaryKey === true ? [await lowerer.lowerToExecuteRequest(columnNullabilityAst({
|
|
1506
|
+
...location,
|
|
1507
|
+
nullable: false
|
|
1508
|
+
}))] : [];
|
|
1509
|
+
const sequenceDefault = autoincrementWidthOfPseudoType(this.column.type) === void 0 ? [] : [await lowerer.lowerToExecuteRequest(columnDefaultSequenceAst(location))];
|
|
1027
1510
|
return {
|
|
1028
1511
|
id: `column.${schemaName}.${tableName}.${columnName}`,
|
|
1029
1512
|
label: `Add column "${columnName}" to "${tableName}"`,
|
|
1030
1513
|
operationClass: "additive",
|
|
1031
1514
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
1032
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
1515
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))],
|
|
1033
1516
|
execute: [step(`add column "${columnName}"`, statement.sql)],
|
|
1034
|
-
postcheck: [
|
|
1517
|
+
postcheck: [
|
|
1518
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
1519
|
+
hasType,
|
|
1520
|
+
...notNullable.map((check) => step(`verify column "${columnName}" is NOT NULL`, check.sql, check.params)),
|
|
1521
|
+
...sequenceDefault.map((check) => step(`verify column "${columnName}" takes its default from an attached sequence`, check.sql, check.params))
|
|
1522
|
+
]
|
|
1035
1523
|
};
|
|
1036
1524
|
}
|
|
1037
1525
|
renderTypeScript() {
|
|
1526
|
+
return this.#written().source;
|
|
1527
|
+
}
|
|
1528
|
+
#written() {
|
|
1529
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1038
1530
|
const opts = [];
|
|
1039
1531
|
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1040
1532
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1041
|
-
opts.push(`column: ${renderDdlColumnAsTsCall(this.column)}`);
|
|
1042
|
-
return
|
|
1533
|
+
opts.push(`column: ${renderDdlColumnAsTsCall(this.column, sql)}`);
|
|
1534
|
+
return {
|
|
1535
|
+
source: `this.addColumn({ ${opts.join(", ")} })`,
|
|
1536
|
+
imports: sql.imports()
|
|
1537
|
+
};
|
|
1043
1538
|
}
|
|
1044
1539
|
importRequirements() {
|
|
1045
1540
|
const req = [{
|
|
@@ -1050,9 +1545,53 @@ var AddColumnCall = class extends PostgresOpFactoryCallNode {
|
|
|
1050
1545
|
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
1051
1546
|
symbol: sym
|
|
1052
1547
|
});
|
|
1548
|
+
req.push(...this.#written().imports);
|
|
1053
1549
|
return req;
|
|
1054
1550
|
}
|
|
1055
1551
|
};
|
|
1552
|
+
var RenameColumnCall = class extends PostgresOpFactoryCallNode {
|
|
1553
|
+
factoryName = "renameColumn";
|
|
1554
|
+
operationClass = "widening";
|
|
1555
|
+
schemaName;
|
|
1556
|
+
tableName;
|
|
1557
|
+
oldColumnName;
|
|
1558
|
+
/** The new name: the column's contract-side identity after the rename. */
|
|
1559
|
+
columnName;
|
|
1560
|
+
label;
|
|
1561
|
+
/**
|
|
1562
|
+
* The renames of objects whose names derive from the column name. They run after the column
|
|
1563
|
+
* rename and are never rendered on their own.
|
|
1564
|
+
*/
|
|
1565
|
+
companions;
|
|
1566
|
+
constructor(schemaName, tableName, oldColumnName, columnName, companions) {
|
|
1567
|
+
super();
|
|
1568
|
+
this.schemaName = schemaName;
|
|
1569
|
+
this.tableName = tableName;
|
|
1570
|
+
this.oldColumnName = oldColumnName;
|
|
1571
|
+
this.columnName = columnName;
|
|
1572
|
+
this.label = `Rename column "${tableName}"."${oldColumnName}" to "${columnName}"`;
|
|
1573
|
+
this.companions = Object.freeze([...companions]);
|
|
1574
|
+
this.freeze();
|
|
1575
|
+
}
|
|
1576
|
+
toOps(lowerer) {
|
|
1577
|
+
return [this.toOp(lowerer), ...this.companions.map((companion) => companion.toOp(lowerer))];
|
|
1578
|
+
}
|
|
1579
|
+
async toOp(lowerer) {
|
|
1580
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `RenameColumnCall.toOp: a lowerer is required on the Postgres planner path (column "${this.oldColumnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "RenameColumnCall" } });
|
|
1581
|
+
return renameColumn(this.schemaName, this.tableName, this.oldColumnName, this.columnName, lowerer);
|
|
1582
|
+
}
|
|
1583
|
+
renderTypeScript() {
|
|
1584
|
+
const opts = [];
|
|
1585
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1586
|
+
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1587
|
+
opts.push(`column: ${jsonToTsSource(this.oldColumnName)}`);
|
|
1588
|
+
opts.push(`to: ${jsonToTsSource(this.columnName)}`);
|
|
1589
|
+
return `...this.renameColumn({ ${opts.join(", ")} })`;
|
|
1590
|
+
}
|
|
1591
|
+
importRequirements() {
|
|
1592
|
+
return [];
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1056
1595
|
var DropColumnCall = class extends PostgresOpFactoryCallNode {
|
|
1057
1596
|
factoryName = "dropColumn";
|
|
1058
1597
|
operationClass = "destructive";
|
|
@@ -1083,42 +1622,100 @@ var DropColumnCall = class extends PostgresOpFactoryCallNode {
|
|
|
1083
1622
|
return [];
|
|
1084
1623
|
}
|
|
1085
1624
|
};
|
|
1625
|
+
/** An `alterColumnType` call named by the column it alters, as its errors name it. */
|
|
1626
|
+
function alterColumnTypeCallText(schema, table, column) {
|
|
1627
|
+
return `alterColumnType({ ${columnCallLocation(schema, table, column).join(", ")} })`;
|
|
1628
|
+
}
|
|
1086
1629
|
var AlterColumnTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1087
1630
|
factoryName = "alterColumnType";
|
|
1088
|
-
operationClass
|
|
1631
|
+
operationClass;
|
|
1089
1632
|
schemaName;
|
|
1090
1633
|
tableName;
|
|
1091
1634
|
columnName;
|
|
1092
|
-
|
|
1635
|
+
/** The new type as a migration writes it. */
|
|
1636
|
+
type;
|
|
1637
|
+
/** The new type is a raw type, named by its catalog text (ADR 273), so its text is checked as written. */
|
|
1638
|
+
raw;
|
|
1639
|
+
using;
|
|
1640
|
+
/** How the postcheck recognises the column's new type once the alter has run. */
|
|
1641
|
+
checkType;
|
|
1642
|
+
/** The width the sequence the column owns takes, when the column has an `autoincrement()` default and an integer type. */
|
|
1643
|
+
sequenceWidth;
|
|
1093
1644
|
label;
|
|
1094
|
-
constructor(
|
|
1645
|
+
constructor(input) {
|
|
1095
1646
|
super();
|
|
1096
|
-
this.schemaName = schemaName;
|
|
1097
|
-
this.tableName = tableName;
|
|
1098
|
-
this.columnName = columnName;
|
|
1099
|
-
this.
|
|
1100
|
-
this.
|
|
1647
|
+
this.schemaName = input.schemaName;
|
|
1648
|
+
this.tableName = input.tableName;
|
|
1649
|
+
this.columnName = input.columnName;
|
|
1650
|
+
this.type = input.type;
|
|
1651
|
+
this.raw = input.raw;
|
|
1652
|
+
this.using = input.using;
|
|
1653
|
+
this.sequenceWidth = input.ownsAutoincrementSequence ? autoincrementWidth(input.type) : void 0;
|
|
1654
|
+
this.operationClass = input.operationClass ?? this.#defaultClass();
|
|
1655
|
+
this.#refuseUnsafeUsing();
|
|
1656
|
+
this.checkType = alterTypeCheck(input.type, input.dataTypes, this.#callText(), input.raw === true);
|
|
1657
|
+
this.label = `Alter type of "${input.tableName}"."${input.columnName}" to ${input.type}`;
|
|
1101
1658
|
this.freeze();
|
|
1102
1659
|
}
|
|
1660
|
+
#refuseUnsafeUsing() {
|
|
1661
|
+
if (this.using?.kind !== "sql") return;
|
|
1662
|
+
const refused = checkSqlExpressionText(this.using.sql, POSTGRES_QUOTING);
|
|
1663
|
+
if (refused === void 0) return;
|
|
1664
|
+
const call = this.#callText();
|
|
1665
|
+
throw postgresError("MIGRATION.SQL_EXPRESSION_INVALID", `${call}: using ${JSON.stringify(this.using.sql)} holds ${refused}, which could end or extend the ALTER COLUMN … TYPE statement it is written into`, {
|
|
1666
|
+
why: "The conversion is written into the USING clause of ALTER COLUMN … TYPE. The check refuses a semicolon, a SQL comment, dollar quoting, and a comma or a statement keyword outside parentheses, since each could end or extend that statement; it does not check that the text is valid SQL.",
|
|
1667
|
+
fix: `Write using as one SQL expression over the column, such as "${this.columnName}"::${this.type}. If it holds a comma or a keyword such as FROM outside parentheses, wrap it in parentheses.`,
|
|
1668
|
+
meta: {
|
|
1669
|
+
call,
|
|
1670
|
+
field: "using",
|
|
1671
|
+
expression: this.using.sql,
|
|
1672
|
+
refused
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
#defaultClass() {
|
|
1677
|
+
return this.using === void 0 ? "destructive" : "data";
|
|
1678
|
+
}
|
|
1679
|
+
#callText() {
|
|
1680
|
+
return alterColumnTypeCallText(this.schemaName, this.tableName, this.columnName);
|
|
1681
|
+
}
|
|
1103
1682
|
async toOp(lowerer) {
|
|
1683
|
+
if (isUnfilledSlot(this.using)) return unfilledPlaceholderOperation(this.label);
|
|
1104
1684
|
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `AlterColumnTypeCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "AlterColumnTypeCall" } });
|
|
1105
|
-
return alterColumnType(this.schemaName, this.tableName, this.columnName,
|
|
1685
|
+
return alterColumnType(this.schemaName, this.tableName, this.columnName, {
|
|
1686
|
+
type: this.type,
|
|
1687
|
+
checkType: this.checkType,
|
|
1688
|
+
...ifDefined("using", sqlOfSlot(this.using)),
|
|
1689
|
+
sequenceWidth: this.sequenceWidth
|
|
1690
|
+
}, lowerer, this.operationClass);
|
|
1106
1691
|
}
|
|
1107
1692
|
renderTypeScript() {
|
|
1108
|
-
|
|
1109
|
-
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1110
|
-
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1111
|
-
opts.push(`column: ${jsonToTsSource(this.columnName)}`);
|
|
1112
|
-
opts.push(`options: ${jsonToTsSource(this.options)}`);
|
|
1113
|
-
return `this.alterColumnType({ ${opts.join(", ")} })`;
|
|
1693
|
+
return this.#written().source;
|
|
1114
1694
|
}
|
|
1115
1695
|
importRequirements() {
|
|
1116
|
-
return [
|
|
1696
|
+
return [...isUnfilledSlot(this.using) ? [{
|
|
1697
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
1698
|
+
symbol: "placeholder"
|
|
1699
|
+
}] : [], ...this.#written().imports];
|
|
1700
|
+
}
|
|
1701
|
+
#written() {
|
|
1702
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1703
|
+
const using = this.using === void 0 ? [] : [`using: ${slotSource(this.using, sql)}`];
|
|
1704
|
+
return {
|
|
1705
|
+
source: `this.alterColumnType({ ${[
|
|
1706
|
+
...columnCallLocation(this.schemaName, this.tableName, this.columnName),
|
|
1707
|
+
`type: ${jsonToTsSource(this.type)}`,
|
|
1708
|
+
...this.raw === true ? ["raw: true"] : [],
|
|
1709
|
+
...using,
|
|
1710
|
+
...this.operationClass === this.#defaultClass() ? [] : [`operationClass: ${jsonToTsSource(this.operationClass)}`]
|
|
1711
|
+
].join(", ")} })`,
|
|
1712
|
+
imports: sql.imports()
|
|
1713
|
+
};
|
|
1117
1714
|
}
|
|
1118
1715
|
};
|
|
1119
1716
|
var SetNotNullCall = class extends PostgresOpFactoryCallNode {
|
|
1120
1717
|
factoryName = "setNotNull";
|
|
1121
|
-
operationClass = "
|
|
1718
|
+
operationClass = "widening";
|
|
1122
1719
|
schemaName;
|
|
1123
1720
|
tableName;
|
|
1124
1721
|
columnName;
|
|
@@ -1181,39 +1778,53 @@ var SetDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
|
1181
1778
|
operationClass;
|
|
1182
1779
|
schemaName;
|
|
1183
1780
|
tableName;
|
|
1184
|
-
|
|
1185
|
-
|
|
1781
|
+
/** The column with the default to set, its type and its codec; the adapter writes the clause. */
|
|
1782
|
+
column;
|
|
1186
1783
|
label;
|
|
1187
|
-
constructor(schemaName, tableName,
|
|
1784
|
+
constructor(schemaName, tableName, column, operationClass) {
|
|
1188
1785
|
super();
|
|
1189
1786
|
this.schemaName = schemaName;
|
|
1190
1787
|
this.tableName = tableName;
|
|
1191
|
-
this.
|
|
1192
|
-
this.defaultSql = defaultSql;
|
|
1788
|
+
this.column = column;
|
|
1193
1789
|
this.operationClass = operationClass;
|
|
1194
|
-
this.label = `Set default on "${tableName}"."${
|
|
1790
|
+
this.label = `Set default on "${tableName}"."${column.name}"`;
|
|
1195
1791
|
this.freeze();
|
|
1196
1792
|
}
|
|
1197
1793
|
async toOp(lowerer) {
|
|
1198
|
-
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `SetDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.
|
|
1199
|
-
return setDefault(this.schemaName, this.tableName, this.
|
|
1794
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `SetDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.column.name}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "SetDefaultCall" } });
|
|
1795
|
+
return setDefault(this.schemaName, this.tableName, this.column, lowerer, this.operationClass);
|
|
1200
1796
|
}
|
|
1201
1797
|
renderTypeScript() {
|
|
1798
|
+
return this.#written().source;
|
|
1799
|
+
}
|
|
1800
|
+
#written() {
|
|
1801
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1202
1802
|
const opts = [];
|
|
1203
1803
|
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1204
1804
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1205
|
-
opts.push(`column: ${
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1805
|
+
opts.push(`column: ${renderDdlColumnAsTsCall(this.column, sql)}`);
|
|
1806
|
+
return {
|
|
1807
|
+
source: `this.setDefault({ ${opts.join(", ")} })`,
|
|
1808
|
+
imports: sql.imports()
|
|
1809
|
+
};
|
|
1209
1810
|
}
|
|
1210
1811
|
importRequirements() {
|
|
1211
|
-
return [
|
|
1812
|
+
return [
|
|
1813
|
+
{
|
|
1814
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
1815
|
+
symbol: "col"
|
|
1816
|
+
},
|
|
1817
|
+
...defaultImportSymbols([this.column]).map((symbol) => ({
|
|
1818
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
1819
|
+
symbol
|
|
1820
|
+
})),
|
|
1821
|
+
...this.#written().imports
|
|
1822
|
+
];
|
|
1212
1823
|
}
|
|
1213
1824
|
};
|
|
1214
1825
|
var DropDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
1215
1826
|
factoryName = "dropDefault";
|
|
1216
|
-
operationClass = "
|
|
1827
|
+
operationClass = "widening";
|
|
1217
1828
|
schemaName;
|
|
1218
1829
|
tableName;
|
|
1219
1830
|
columnName;
|
|
@@ -1241,95 +1852,117 @@ var DropDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
|
1241
1852
|
return [];
|
|
1242
1853
|
}
|
|
1243
1854
|
};
|
|
1855
|
+
function columnCallLocation(schemaName, tableName, columnName) {
|
|
1856
|
+
return [
|
|
1857
|
+
...schemaName === UNBOUND_NAMESPACE_ID ? [] : [`schema: ${jsonToTsSource(schemaName)}`],
|
|
1858
|
+
`table: ${jsonToTsSource(tableName)}`,
|
|
1859
|
+
`column: ${jsonToTsSource(columnName)}`
|
|
1860
|
+
];
|
|
1861
|
+
}
|
|
1244
1862
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
* a
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1250
|
-
* planner, never hand-written by migration authors.
|
|
1863
|
+
* Adds a required column with no default to a table that must be empty when the migration runs:
|
|
1864
|
+
* a column in a new primary key, unique constraint or foreign key, where one temporary value in
|
|
1865
|
+
* every row would break the constraint.
|
|
1251
1866
|
*/
|
|
1252
|
-
var
|
|
1253
|
-
factoryName = "
|
|
1867
|
+
var AddRequiredColumnToEmptyTableCall = class extends PostgresOpFactoryCallNode {
|
|
1868
|
+
factoryName = "addRequiredColumnToEmptyTable";
|
|
1254
1869
|
operationClass = "additive";
|
|
1255
1870
|
schemaName;
|
|
1256
1871
|
tableName;
|
|
1257
1872
|
columnName;
|
|
1258
|
-
column
|
|
1873
|
+
/** The column's type as a migration writes it. */
|
|
1874
|
+
type;
|
|
1875
|
+
/** The type `format_type` prints for `type`, or `undefined` when the stack's data types do not read it. */
|
|
1876
|
+
checkType;
|
|
1259
1877
|
label;
|
|
1260
|
-
constructor(schemaName, tableName, columnName,
|
|
1878
|
+
constructor(schemaName, tableName, columnName, type, dataTypes) {
|
|
1261
1879
|
super();
|
|
1262
1880
|
this.schemaName = schemaName;
|
|
1263
1881
|
this.tableName = tableName;
|
|
1264
1882
|
this.columnName = columnName;
|
|
1265
|
-
this.
|
|
1883
|
+
this.type = type;
|
|
1884
|
+
this.checkType = columnTypeCheckIfReadable(type, dataTypes);
|
|
1266
1885
|
this.label = `Add column ${columnName} to ${tableName}`;
|
|
1267
1886
|
this.freeze();
|
|
1268
1887
|
}
|
|
1269
1888
|
async toOp(lowerer) {
|
|
1270
|
-
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `
|
|
1271
|
-
return
|
|
1889
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `AddRequiredColumnToEmptyTableCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "AddRequiredColumnToEmptyTableCall" } });
|
|
1890
|
+
return addRequiredColumnToEmptyTable(this.schemaName, this.tableName, col(this.columnName, this.type, { notNull: true }), this.checkType, lowerer);
|
|
1272
1891
|
}
|
|
1273
1892
|
renderTypeScript() {
|
|
1274
|
-
return `
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
})})`;
|
|
1893
|
+
return `this.addRequiredColumnToEmptyTable({ ${[...columnCallLocation(this.schemaName, this.tableName, this.columnName), `type: ${jsonToTsSource(this.type)}`].join(", ")} })`;
|
|
1894
|
+
}
|
|
1895
|
+
importRequirements() {
|
|
1896
|
+
return [];
|
|
1279
1897
|
}
|
|
1280
1898
|
};
|
|
1281
1899
|
/**
|
|
1282
|
-
*
|
|
1283
|
-
*
|
|
1284
|
-
* needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; both the
|
|
1285
|
-
* typed ADD COLUMN execute step and the pre/postchecks are lowered via the
|
|
1286
|
-
* adapter at `toOp` time.
|
|
1287
|
-
*
|
|
1288
|
-
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1289
|
-
* planner, never hand-written by migration authors.
|
|
1900
|
+
* Adds a required column with no default to a table that may have rows: the column is added with
|
|
1901
|
+
* `temporaryDefault`, a SQL value every existing row takes, and the default is then dropped.
|
|
1290
1902
|
*/
|
|
1291
|
-
var
|
|
1292
|
-
factoryName = "
|
|
1903
|
+
var AddColumnWithTemporaryDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
1904
|
+
factoryName = "addColumnWithTemporaryDefault";
|
|
1293
1905
|
operationClass = "additive";
|
|
1294
1906
|
schemaName;
|
|
1295
1907
|
tableName;
|
|
1296
1908
|
columnName;
|
|
1297
|
-
column
|
|
1298
|
-
|
|
1299
|
-
|
|
1909
|
+
/** The column's type as a migration writes it. */
|
|
1910
|
+
type;
|
|
1911
|
+
/** SQL for the value existing rows take, such as `''` or `0`. */
|
|
1300
1912
|
temporaryDefault;
|
|
1913
|
+
/** The type `format_type` prints for `type`, or `undefined` when the stack's data types do not read it. */
|
|
1914
|
+
checkType;
|
|
1301
1915
|
label;
|
|
1302
|
-
constructor(
|
|
1916
|
+
constructor(schemaName, tableName, columnName, type, temporaryDefault, dataTypes) {
|
|
1303
1917
|
super();
|
|
1304
|
-
this.schemaName =
|
|
1305
|
-
this.tableName =
|
|
1306
|
-
this.columnName =
|
|
1307
|
-
this.
|
|
1308
|
-
this.
|
|
1309
|
-
this.
|
|
1310
|
-
|
|
1311
|
-
|
|
1918
|
+
this.schemaName = schemaName;
|
|
1919
|
+
this.tableName = tableName;
|
|
1920
|
+
this.columnName = columnName;
|
|
1921
|
+
this.type = type;
|
|
1922
|
+
this.temporaryDefault = temporaryDefault;
|
|
1923
|
+
this.checkType = columnTypeCheckIfReadable(type, dataTypes);
|
|
1924
|
+
const refused = checkSqlDefaultText(temporaryDefault);
|
|
1925
|
+
if (refused !== void 0) {
|
|
1926
|
+
const call = `addColumnWithTemporaryDefault({ ${columnCallLocation(schemaName, tableName, columnName).join(", ")} })`;
|
|
1927
|
+
throw postgresError("CONTRACT.DEFAULT_INVALID", `${call}: temporaryDefault ${JSON.stringify(temporaryDefault)} is not a value: ${refused}`, {
|
|
1928
|
+
fix: "Write temporaryDefault as one SQL value, such as '' or 0.",
|
|
1929
|
+
meta: {
|
|
1930
|
+
expression: temporaryDefault,
|
|
1931
|
+
where: call
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
this.label = `Add column ${columnName} to ${tableName}`;
|
|
1312
1936
|
this.freeze();
|
|
1313
1937
|
}
|
|
1314
1938
|
async toOp(lowerer) {
|
|
1315
|
-
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `
|
|
1939
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `AddColumnWithTemporaryDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "AddColumnWithTemporaryDefaultCall" } });
|
|
1316
1940
|
return buildAddNotNullColumnWithTemporaryDefaultOperation({
|
|
1317
1941
|
schema: this.schemaName,
|
|
1318
1942
|
tableName: this.tableName,
|
|
1319
1943
|
columnName: this.columnName,
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
storageTypes: this.storageTypes,
|
|
1944
|
+
type: this.type,
|
|
1945
|
+
checkType: this.checkType,
|
|
1323
1946
|
temporaryDefault: this.temporaryDefault,
|
|
1324
1947
|
lowerer
|
|
1325
1948
|
});
|
|
1326
1949
|
}
|
|
1327
1950
|
renderTypeScript() {
|
|
1328
|
-
return
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1951
|
+
return this.#written().source;
|
|
1952
|
+
}
|
|
1953
|
+
importRequirements() {
|
|
1954
|
+
return this.#written().imports;
|
|
1955
|
+
}
|
|
1956
|
+
#written() {
|
|
1957
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1958
|
+
return {
|
|
1959
|
+
source: `this.addColumnWithTemporaryDefault({ ${[
|
|
1960
|
+
...columnCallLocation(this.schemaName, this.tableName, this.columnName),
|
|
1961
|
+
`type: ${jsonToTsSource(this.type)}`,
|
|
1962
|
+
`temporaryDefault: ${sql.source(this.temporaryDefault)}`
|
|
1963
|
+
].join(", ")} })`,
|
|
1964
|
+
imports: sql.imports()
|
|
1965
|
+
};
|
|
1333
1966
|
}
|
|
1334
1967
|
};
|
|
1335
1968
|
function constraintCallOptions(schemaName, tableName, constraintName) {
|
|
@@ -1427,7 +2060,7 @@ var AddForeignKeyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1427
2060
|
};
|
|
1428
2061
|
var DropConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
1429
2062
|
factoryName = "dropConstraint";
|
|
1430
|
-
operationClass = "
|
|
2063
|
+
operationClass = "widening";
|
|
1431
2064
|
schemaName;
|
|
1432
2065
|
tableName;
|
|
1433
2066
|
constraintName;
|
|
@@ -1455,34 +2088,37 @@ var DropConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
|
1455
2088
|
return [];
|
|
1456
2089
|
}
|
|
1457
2090
|
};
|
|
1458
|
-
var
|
|
1459
|
-
factoryName = "
|
|
2091
|
+
var RenameConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
2092
|
+
factoryName = "renameConstraint";
|
|
1460
2093
|
operationClass = "widening";
|
|
1461
2094
|
schemaName;
|
|
1462
2095
|
tableName;
|
|
2096
|
+
kind;
|
|
1463
2097
|
oldConstraintName;
|
|
1464
2098
|
newConstraintName;
|
|
1465
2099
|
label;
|
|
1466
|
-
constructor(schemaName, tableName, oldConstraintName, newConstraintName) {
|
|
2100
|
+
constructor(schemaName, tableName, kind, oldConstraintName, newConstraintName) {
|
|
1467
2101
|
super();
|
|
1468
2102
|
this.schemaName = schemaName;
|
|
1469
2103
|
this.tableName = tableName;
|
|
2104
|
+
this.kind = kind;
|
|
1470
2105
|
this.oldConstraintName = oldConstraintName;
|
|
1471
2106
|
this.newConstraintName = newConstraintName;
|
|
1472
|
-
this.label =
|
|
2107
|
+
this.label = renameConstraintLabel(kind, oldConstraintName, newConstraintName, tableName);
|
|
1473
2108
|
this.freeze();
|
|
1474
2109
|
}
|
|
1475
2110
|
async toOp(lowerer) {
|
|
1476
|
-
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `
|
|
1477
|
-
return
|
|
2111
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `RenameConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.oldConstraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "RenameConstraintCall" } });
|
|
2112
|
+
return renameConstraint(this.schemaName, this.tableName, this.kind, this.oldConstraintName, this.newConstraintName, lowerer);
|
|
1478
2113
|
}
|
|
1479
2114
|
renderTypeScript() {
|
|
1480
2115
|
const opts = [];
|
|
1481
2116
|
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1482
2117
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
2118
|
+
opts.push(`kind: ${jsonToTsSource(this.kind)}`);
|
|
1483
2119
|
opts.push(`from: ${jsonToTsSource(this.oldConstraintName)}`);
|
|
1484
2120
|
opts.push(`to: ${jsonToTsSource(this.newConstraintName)}`);
|
|
1485
|
-
return `this.
|
|
2121
|
+
return `this.renameConstraint({ ${opts.join(", ")} })`;
|
|
1486
2122
|
}
|
|
1487
2123
|
importRequirements() {
|
|
1488
2124
|
return [];
|
|
@@ -1511,15 +2147,22 @@ var AddCheckConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
|
1511
2147
|
return addCheckConstraint(this.schemaName, this.tableName, this.constraintName, this.expression, lowerer);
|
|
1512
2148
|
}
|
|
1513
2149
|
renderTypeScript() {
|
|
1514
|
-
return
|
|
2150
|
+
return this.#written().source;
|
|
1515
2151
|
}
|
|
1516
2152
|
importRequirements() {
|
|
1517
|
-
return
|
|
2153
|
+
return this.#written().imports;
|
|
2154
|
+
}
|
|
2155
|
+
#written() {
|
|
2156
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
2157
|
+
return {
|
|
2158
|
+
source: `this.addCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, expression: ${sql.source(this.expression)} })`,
|
|
2159
|
+
imports: sql.imports()
|
|
2160
|
+
};
|
|
1518
2161
|
}
|
|
1519
2162
|
};
|
|
1520
2163
|
var DropCheckConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
1521
2164
|
factoryName = "dropCheckConstraint";
|
|
1522
|
-
operationClass = "
|
|
2165
|
+
operationClass = "widening";
|
|
1523
2166
|
schemaName;
|
|
1524
2167
|
tableName;
|
|
1525
2168
|
constraintName;
|
|
@@ -1582,24 +2225,31 @@ var CreateIndexCall = class extends PostgresOpFactoryCallNode {
|
|
|
1582
2225
|
return createIndex(this.schemaName, this.tableName, this.indexName, this.columns !== void 0 ? { columns: this.columns } : { expression: this.expression ?? "" }, lowerer, extras);
|
|
1583
2226
|
}
|
|
1584
2227
|
renderTypeScript() {
|
|
2228
|
+
return this.#written().source;
|
|
2229
|
+
}
|
|
2230
|
+
importRequirements() {
|
|
2231
|
+
return this.#written().imports;
|
|
2232
|
+
}
|
|
2233
|
+
#written() {
|
|
2234
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1585
2235
|
const opts = [];
|
|
1586
2236
|
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1587
2237
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1588
2238
|
opts.push(`index: ${jsonToTsSource(this.indexName)}`);
|
|
1589
2239
|
if (this.columns !== void 0) opts.push(`columns: ${jsonToTsSource(this.columns)}`);
|
|
1590
|
-
else opts.push(`expression: ${
|
|
2240
|
+
else opts.push(`expression: ${sql.source(this.expression ?? "")}`);
|
|
1591
2241
|
if (this.indexType !== void 0 || this.options !== void 0 || this.where !== void 0 || this.unique) {
|
|
1592
2242
|
const extrasParts = [];
|
|
1593
2243
|
if (this.indexType !== void 0) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);
|
|
1594
2244
|
if (this.options !== void 0) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);
|
|
1595
|
-
if (this.where !== void 0) extrasParts.push(`where: ${
|
|
2245
|
+
if (this.where !== void 0) extrasParts.push(`where: ${sql.source(this.where)}`);
|
|
1596
2246
|
if (this.unique) extrasParts.push("unique: true");
|
|
1597
2247
|
opts.push(`extras: { ${extrasParts.join(", ")} }`);
|
|
1598
2248
|
}
|
|
1599
|
-
return
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
2249
|
+
return {
|
|
2250
|
+
source: `this.createIndex({ ${opts.join(", ")} })`,
|
|
2251
|
+
imports: sql.imports()
|
|
2252
|
+
};
|
|
1603
2253
|
}
|
|
1604
2254
|
};
|
|
1605
2255
|
var RenameIndexCall = class extends PostgresOpFactoryCallNode {
|
|
@@ -1637,7 +2287,7 @@ var RenameIndexCall = class extends PostgresOpFactoryCallNode {
|
|
|
1637
2287
|
};
|
|
1638
2288
|
var DropIndexCall = class extends PostgresOpFactoryCallNode {
|
|
1639
2289
|
factoryName = "dropIndex";
|
|
1640
|
-
operationClass = "
|
|
2290
|
+
operationClass = "widening";
|
|
1641
2291
|
schemaName;
|
|
1642
2292
|
tableName;
|
|
1643
2293
|
indexName;
|
|
@@ -1720,6 +2370,7 @@ var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
|
1720
2370
|
operationClass = "additive";
|
|
1721
2371
|
schemaName;
|
|
1722
2372
|
label;
|
|
2373
|
+
companions = [];
|
|
1723
2374
|
constructor(schemaName) {
|
|
1724
2375
|
super();
|
|
1725
2376
|
this.schemaName = schemaName;
|
|
@@ -1755,6 +2406,85 @@ var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
|
1755
2406
|
return [];
|
|
1756
2407
|
}
|
|
1757
2408
|
};
|
|
2409
|
+
function requireLowerer(lowerer, factory, subject) {
|
|
2410
|
+
if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `${factory}.toOp: a lowerer is required on the Postgres planner path (${subject}). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory } });
|
|
2411
|
+
return lowerer;
|
|
2412
|
+
}
|
|
2413
|
+
var SetTableSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2414
|
+
factoryName = "setTableSchema";
|
|
2415
|
+
operationClass = "widening";
|
|
2416
|
+
schemaName;
|
|
2417
|
+
tableName;
|
|
2418
|
+
toSchemaName;
|
|
2419
|
+
label;
|
|
2420
|
+
companions = [];
|
|
2421
|
+
constructor(schemaName, tableName, toSchemaName) {
|
|
2422
|
+
super();
|
|
2423
|
+
this.schemaName = schemaName;
|
|
2424
|
+
this.tableName = tableName;
|
|
2425
|
+
this.toSchemaName = toSchemaName;
|
|
2426
|
+
this.label = `Move table "${tableName}" to schema "${toSchemaName}"`;
|
|
2427
|
+
this.freeze();
|
|
2428
|
+
}
|
|
2429
|
+
async toOp(lowerer) {
|
|
2430
|
+
return setTableSchema(this.schemaName, this.tableName, this.toSchemaName, requireLowerer(lowerer, "SetTableSchemaCall", `table "${this.tableName}"`));
|
|
2431
|
+
}
|
|
2432
|
+
renderTypeScript() {
|
|
2433
|
+
const opts = [];
|
|
2434
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
2435
|
+
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
2436
|
+
opts.push(`to: ${jsonToTsSource(this.toSchemaName)}`);
|
|
2437
|
+
return `this.setTableSchema({ ${opts.join(", ")} })`;
|
|
2438
|
+
}
|
|
2439
|
+
importRequirements() {
|
|
2440
|
+
return [];
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
var RenameSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2444
|
+
factoryName = "renameSchema";
|
|
2445
|
+
operationClass = "widening";
|
|
2446
|
+
schemaName;
|
|
2447
|
+
toSchemaName;
|
|
2448
|
+
label;
|
|
2449
|
+
companions = [];
|
|
2450
|
+
constructor(schemaName, toSchemaName) {
|
|
2451
|
+
super();
|
|
2452
|
+
this.schemaName = schemaName;
|
|
2453
|
+
this.toSchemaName = toSchemaName;
|
|
2454
|
+
this.label = `Rename schema "${schemaName}" to "${toSchemaName}"`;
|
|
2455
|
+
this.freeze();
|
|
2456
|
+
}
|
|
2457
|
+
async toOp(lowerer) {
|
|
2458
|
+
return renameSchema(this.schemaName, this.toSchemaName, requireLowerer(lowerer, "RenameSchemaCall", `schema "${this.schemaName}"`));
|
|
2459
|
+
}
|
|
2460
|
+
renderTypeScript() {
|
|
2461
|
+
return `this.renameSchema({ schema: ${jsonToTsSource(this.schemaName)}, to: ${jsonToTsSource(this.toSchemaName)} })`;
|
|
2462
|
+
}
|
|
2463
|
+
importRequirements() {
|
|
2464
|
+
return [];
|
|
2465
|
+
}
|
|
2466
|
+
};
|
|
2467
|
+
var DropSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
2468
|
+
factoryName = "dropSchema";
|
|
2469
|
+
operationClass = "widening";
|
|
2470
|
+
schemaName;
|
|
2471
|
+
label;
|
|
2472
|
+
constructor(schemaName) {
|
|
2473
|
+
super();
|
|
2474
|
+
this.schemaName = schemaName;
|
|
2475
|
+
this.label = `Drop schema "${schemaName}"`;
|
|
2476
|
+
this.freeze();
|
|
2477
|
+
}
|
|
2478
|
+
async toOp(lowerer) {
|
|
2479
|
+
return dropSchema(this.schemaName, requireLowerer(lowerer, "DropSchemaCall", `schema "${this.schemaName}"`));
|
|
2480
|
+
}
|
|
2481
|
+
renderTypeScript() {
|
|
2482
|
+
return `this.dropSchema({ schema: ${jsonToTsSource(this.schemaName)} })`;
|
|
2483
|
+
}
|
|
2484
|
+
importRequirements() {
|
|
2485
|
+
return [];
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
1758
2488
|
var CreateNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1759
2489
|
factoryName = "createNativeEnumType";
|
|
1760
2490
|
operationClass = "additive";
|
|
@@ -1787,7 +2517,7 @@ var CreateNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
|
1787
2517
|
};
|
|
1788
2518
|
var DropNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1789
2519
|
factoryName = "dropNativeEnumType";
|
|
1790
|
-
operationClass = "
|
|
2520
|
+
operationClass = "widening";
|
|
1791
2521
|
schemaName;
|
|
1792
2522
|
typeName;
|
|
1793
2523
|
label;
|
|
@@ -1862,9 +2592,9 @@ var AddNativeEnumValueCall = class extends PostgresOpFactoryCallNode {
|
|
|
1862
2592
|
summary: this.summary,
|
|
1863
2593
|
operationClass: "additive",
|
|
1864
2594
|
target: targetDetails("type", typeName, schemaName),
|
|
1865
|
-
precheck: [step(`ensure enum type "${typeName}" exists`, typePresent.sql, typePresent.params), step(`ensure value "${value}" is absent from enum type "${typeName}"`, valueAbsent.sql, valueAbsent.params)],
|
|
2595
|
+
precheck: [step(`ensure enum type "${typeName}" exists`, typePresent.sql, typePresent.params, expectPresent(`enum type "${typeName}"`)), step(`ensure value "${value}" is absent from enum type "${typeName}"`, valueAbsent.sql, valueAbsent.params, expectAbsent(`value "${value}" in enum type "${typeName}"`))],
|
|
1866
2596
|
execute: [step(`add value "${value}" to enum type "${typeName}"`, `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`)],
|
|
1867
|
-
postcheck: [step(`verify value "${value}" exists on enum type "${typeName}"`, valuePresent.sql, valuePresent.params)]
|
|
2597
|
+
postcheck: [step(`verify value "${value}" exists on enum type "${typeName}"`, valuePresent.sql, valuePresent.params, expectPresent(`value "${value}" in enum type "${typeName}"`))]
|
|
1868
2598
|
};
|
|
1869
2599
|
}
|
|
1870
2600
|
renderTypeScript() {
|
|
@@ -1881,7 +2611,7 @@ var AddNativeEnumValueCall = class extends PostgresOpFactoryCallNode {
|
|
|
1881
2611
|
/**
|
|
1882
2612
|
* A planner-generated data-transform stub. `checkSlot` and `runSlot` name
|
|
1883
2613
|
* the unfilled authoring slots that the rendered `migration.ts` will expose
|
|
1884
|
-
* to the user via `placeholder("…")` calls. `toOp()` always
|
|
2614
|
+
* to the user via `placeholder("…")` calls. `toOp()` always rejects with
|
|
1885
2615
|
* `MIGRATION.UNFILLED_PLACEHOLDER`: the planner cannot lower a stubbed transform to a runtime
|
|
1886
2616
|
* op — the user must fill the rendered `migration.ts` and re-emit.
|
|
1887
2617
|
*/
|
|
@@ -1891,20 +2621,23 @@ var DataTransformCall = class extends PostgresOpFactoryCallNode {
|
|
|
1891
2621
|
label;
|
|
1892
2622
|
checkSlot;
|
|
1893
2623
|
runSlot;
|
|
1894
|
-
|
|
2624
|
+
backfillsColumn;
|
|
2625
|
+
constructor(label, checkSlot, runSlot, operationClass = "data", backfillsColumn) {
|
|
1895
2626
|
super();
|
|
1896
2627
|
this.label = label;
|
|
1897
2628
|
this.checkSlot = checkSlot;
|
|
1898
2629
|
this.runSlot = runSlot;
|
|
1899
2630
|
this.operationClass = operationClass;
|
|
2631
|
+
this.backfillsColumn = backfillsColumn;
|
|
1900
2632
|
this.freeze();
|
|
1901
2633
|
}
|
|
1902
2634
|
toOp() {
|
|
1903
|
-
|
|
2635
|
+
return unfilledPlaceholderOperation(this.label);
|
|
1904
2636
|
}
|
|
1905
2637
|
renderTypeScript() {
|
|
1906
2638
|
return [
|
|
1907
2639
|
`this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,
|
|
2640
|
+
...this.backfillsColumn === void 0 ? [] : [` backfillsColumn: ${jsonToTsSource(this.backfillsColumn).replaceAll("\n", "\n ")},`],
|
|
1908
2641
|
` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,
|
|
1909
2642
|
` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,
|
|
1910
2643
|
"})"
|
|
@@ -1937,6 +2670,13 @@ var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1937
2670
|
return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
|
|
1938
2671
|
}
|
|
1939
2672
|
renderTypeScript() {
|
|
2673
|
+
return this.#written().source;
|
|
2674
|
+
}
|
|
2675
|
+
importRequirements() {
|
|
2676
|
+
return this.#written().imports;
|
|
2677
|
+
}
|
|
2678
|
+
#written() {
|
|
2679
|
+
const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
|
|
1940
2680
|
const p = this.policy;
|
|
1941
2681
|
const input = {
|
|
1942
2682
|
naming: namingOf(p.name, p.prefix),
|
|
@@ -1948,15 +2688,26 @@ var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1948
2688
|
...ifDefined("withCheck", p.withCheck),
|
|
1949
2689
|
permissive: p.permissive
|
|
1950
2690
|
};
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2691
|
+
const sources = {
|
|
2692
|
+
naming: jsonToTsSource(input.naming),
|
|
2693
|
+
tableName: jsonToTsSource(input.tableName),
|
|
2694
|
+
namespaceId: jsonToTsSource(input.namespaceId),
|
|
2695
|
+
operation: jsonToTsSource(input.operation),
|
|
2696
|
+
roles: jsonToTsSource(input.roles),
|
|
2697
|
+
using: input.using === void 0 ? void 0 : sql.source(input.using),
|
|
2698
|
+
withCheck: input.withCheck === void 0 ? void 0 : sql.source(input.withCheck),
|
|
2699
|
+
permissive: jsonToTsSource(input.permissive)
|
|
2700
|
+
};
|
|
2701
|
+
const policy = tsObjectSource(Object.entries(sources).flatMap(([key, source]) => source === void 0 ? [] : [[key, source]]));
|
|
2702
|
+
return {
|
|
2703
|
+
source: `this.createRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${policy} })`,
|
|
2704
|
+
imports: sql.imports()
|
|
2705
|
+
};
|
|
1955
2706
|
}
|
|
1956
2707
|
};
|
|
1957
2708
|
var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1958
2709
|
factoryName = "dropRlsPolicy";
|
|
1959
|
-
operationClass = "
|
|
2710
|
+
operationClass = "widening";
|
|
1960
2711
|
schemaName;
|
|
1961
2712
|
tableName;
|
|
1962
2713
|
policyName;
|
|
@@ -2006,7 +2757,7 @@ var EnableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
|
2006
2757
|
};
|
|
2007
2758
|
var DisableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
2008
2759
|
factoryName = "disableRowLevelSecurity";
|
|
2009
|
-
operationClass = "
|
|
2760
|
+
operationClass = "widening";
|
|
2010
2761
|
schemaName;
|
|
2011
2762
|
tableName;
|
|
2012
2763
|
label;
|
|
@@ -2056,7 +2807,12 @@ var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
2056
2807
|
return [];
|
|
2057
2808
|
}
|
|
2058
2809
|
};
|
|
2810
|
+
/** The name of the column a call acts on: its `columnName`, or the name of the column it carries. */
|
|
2811
|
+
function columnNameOfCall(call) {
|
|
2812
|
+
if ("columnName" in call) return call.columnName;
|
|
2813
|
+
if ("column" in call && call.column instanceof DdlColumn) return call.column.name;
|
|
2814
|
+
}
|
|
2059
2815
|
//#endregion
|
|
2060
|
-
export {
|
|
2816
|
+
export { RenameColumnCall as A, alterColumnTypeCallText as B, DropNativeEnumTypeCall as C, DropTableCall as D, DropSchemaCall as E, RenameTableCall as F, postgresDefaultToDdlColumnDefault as G, createExtension as H, SCHEMA_OBJECTS_SQL as I, schemaContentsOf as J, renameTableStatement as K, SetDefaultCall as L, RenameIndexCall as M, RenamePostgresRlsPolicyCall as N, EnableRowLevelSecurityCall as O, RenameSchemaCall as P, SetNotNullCall as R, DropIndexCall as S, DropPostgresRlsPolicyCall as T, installExtension as U, columnNameOfCall as V, isPostgresOpFactoryCall as W, schemaObjectsSummary as Y, DisableRowLevelSecurityCall as _, AddNativeEnumValueCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddForeignKeyCall as i, RenameConstraintCall as j, RawSqlCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreatePostgresRlsPolicyCall as p, schemaBlockingObjects as q, AddColumnWithTemporaryDefaultCall as r, AddRequiredColumnToEmptyTableCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y, SetTableSchemaCall as z };
|
|
2061
2817
|
|
|
2062
|
-
//# sourceMappingURL=op-factory-call-
|
|
2818
|
+
//# sourceMappingURL=op-factory-call-gGX-mZu--0QUG5xH4.mjs.map
|