@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
|
@@ -0,0 +1,954 @@
|
|
|
1
|
+
import { i as quoteIdentifier } from "./sql-utils-Bnw3JbWf-BN0gcjZB.mjs";
|
|
2
|
+
import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cxc0dBbO.mjs";
|
|
3
|
+
import { d as isPostgresSchema, i as PostgresRlsPolicy } from "./postgres-schema-C6w1rzOF-D1fdwqRx.mjs";
|
|
4
|
+
import { n as PostgresSchemaNodeKind, r as PostgresTableSchemaNode } from "./postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs";
|
|
5
|
+
import { n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs";
|
|
6
|
+
import { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-D3VNPMSm-BuB6NyOI.mjs";
|
|
7
|
+
import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs";
|
|
8
|
+
import { C as DropNativeEnumTypeCall, D as DropTableCall, E as DropSchemaCall, N as RenamePostgresRlsPolicyCall, P as RenameSchemaCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, j as RenameConstraintCall, k as RawSqlCall, l as AlterColumnTypeCall, m as CreateSchemaCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, y as DropColumnCall, z as SetTableSchemaCall } from "./op-factory-call-gGX-mZu--0QUG5xH4.mjs";
|
|
9
|
+
import { a as planIssues, c as renderPostgresSuppression, d as resolvePostgresNodeIssueControlPolicySubject, f as resolvePostgresNodeIssueCreationFactoryName, i as issueSchemaName, l as resolveNamespaceIdForDdlSchema, n as conflictForDisallowedCall, o as postgresNodeStorageCoordinate, p as tableAt, r as issueNode, s as postgresPlannerStrategies, t as coalesceSubtreeIssues, u as resolvePostgresCallControlPolicySubject } from "./control-policy-DtU5u9Dm-44r_OF94.mjs";
|
|
10
|
+
import { t as buildPostgresPlanDiff } from "./diff-database-schema-DAEzWtzU-DoyVgKqh.mjs";
|
|
11
|
+
import { a as postgresColumnRenameCall, c as postgresTableRenameByHand, d as renderRenameTableCall, i as pairIndexRenames, l as postgresTableRenameCall, n as createWorkingSchema, o as postgresContractToSchema, r as pairCheckRenames, s as postgresSchemaTables, u as renameTableByHandStatements } from "./postgres-migration-BSWmeRLo-CUfVTUf0.mjs";
|
|
12
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BZclL_xO-uflxtYuP.mjs";
|
|
13
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
14
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
15
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
16
|
+
import { isRenameStatement, issueOutcome } from "@prisma/orm-framework/components/control";
|
|
17
|
+
import { namingOf, parseWireName } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
18
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
19
|
+
import { appliedStatementsInOrder, backfillOfDefaultedField, detectTableNameCaseChanges, extractCodecControlHooks, fieldEventStorage, fieldStatementColumns, otherSpaceDeclaring, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventCalls, planStatements, plannerFailure, sqlTypeLookupsOf, storageNameOfOperation, subjectsOfCalls, unknownCallNames } from "@prisma/orm-family-sql/family/control";
|
|
20
|
+
import { ok } from "@prisma/orm-framework/utils/result";
|
|
21
|
+
import { governingControlPolicy } from "@prisma/orm-framework/contract/types";
|
|
22
|
+
//#region ../../../3-targets/postgres/1-target/dist/planner-VuR6URu3.mjs
|
|
23
|
+
/** The constraint of `nextNodes` the diff pairs with `node` and finds unchanged. */
|
|
24
|
+
function unchangedIn(node, nextNodes) {
|
|
25
|
+
return nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The renames of the primary key, unique constraints and foreign keys of one table that the end tree keeps otherwise unchanged but names differently. A constraint's name is its stated name, or the one the planner derives from its table; a start tree read from the database states every name. A constraint whose start and end names differ is renamed to the end name. The diff never compares constraint names, so without these the database keeps the old name. A database may already have the new name, as when Prisma 7 created it and the contract only now states it; the rename's postcheck then holds before it runs, and the runner skips it.
|
|
29
|
+
*/
|
|
30
|
+
function constraintNameRenames(input) {
|
|
31
|
+
const { schemaName, from, to, previous, next, droppedConstraintNames } = input;
|
|
32
|
+
const rename = (kind, oldName, unchanged, derivedName) => {
|
|
33
|
+
if (unchanged === void 0 || droppedConstraintNames.has(oldName)) return [];
|
|
34
|
+
const newName = unchanged.name ?? derivedName;
|
|
35
|
+
return oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];
|
|
36
|
+
};
|
|
37
|
+
const primaryKey = previous.primaryKey === void 0 ? [] : rename("primaryKey", previous.primaryKey.name ?? defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to));
|
|
38
|
+
const uniques = previous.uniques.flatMap((unique) => rename("unique", unique.name ?? defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));
|
|
39
|
+
const foreignKeys = previous.foreignKeys.flatMap((fk) => rename("foreignKey", fk.name ?? defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));
|
|
40
|
+
return [
|
|
41
|
+
...primaryKey,
|
|
42
|
+
...uniques,
|
|
43
|
+
...foreignKeys
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The constraint renames of a plan: {@link constraintNameRenames} for every table the start tree and the end contract both have, with the start tree as the plan's rename statements left it. The start tree comes from the start contract for `migration plan` and from the database for `db update`, so a database Prisma 8 created under derived names is renamed too once the contract states other names. A constraint one of `plannedCalls` drops is skipped: the plan adds it back under its end name, or not at all.
|
|
48
|
+
*/
|
|
49
|
+
function plannedConstraintNameRenames(options, plannedCalls) {
|
|
50
|
+
if (!options.policy.allowedOperationClasses.includes("widening")) return [];
|
|
51
|
+
PostgresDatabaseSchemaNode.assert(options.schema);
|
|
52
|
+
const startTablesBySchema = new Map(Object.values(options.schema.namespaces).map((namespace) => [namespace.schemaName, namespace.tables]));
|
|
53
|
+
const contract = options.contract;
|
|
54
|
+
const end = postgresContractToSchema(contract, options.frameworkComponents);
|
|
55
|
+
return Object.values(end.namespaces).flatMap((namespace) => {
|
|
56
|
+
const startTables = startTablesBySchema.get(namespace.schemaName) ?? {};
|
|
57
|
+
const schemaName = resolveNamespaceIdForDdlSchema(contract, namespace.schemaName) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : namespace.schemaName;
|
|
58
|
+
return Object.entries(namespace.tables).flatMap(([tableName, next]) => {
|
|
59
|
+
const previous = startTables[tableName];
|
|
60
|
+
const droppedConstraintNames = new Set(plannedCalls.flatMap((call) => call.factoryName === "dropConstraint" && call.schemaName === schemaName && call.tableName === tableName ? [call.constraintName] : []));
|
|
61
|
+
return previous === void 0 ? [] : constraintNameRenames({
|
|
62
|
+
schemaName,
|
|
63
|
+
from: tableName,
|
|
64
|
+
to: tableName,
|
|
65
|
+
previous,
|
|
66
|
+
next,
|
|
67
|
+
droppedConstraintNames
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The namespace a schema stands for in the locator's contract, or, for a schema that contract does
|
|
74
|
+
* not declare, such as the new name of a renamed namespace, the schema's own name: a named Postgres
|
|
75
|
+
* namespace's schema is its id.
|
|
76
|
+
*/
|
|
77
|
+
function storageNamespaceId(locator, schemaName) {
|
|
78
|
+
if (schemaName === UNBOUND_NAMESPACE_ID) return UNBOUND_NAMESPACE_ID;
|
|
79
|
+
const namespaceId = resolveNamespaceIdForDdlSchema(locator.contract, schemaName);
|
|
80
|
+
return namespaceId === UNBOUND_NAMESPACE_ID && schemaName !== "public" ? schemaName : namespaceId;
|
|
81
|
+
}
|
|
82
|
+
function qualified(schemaName, name) {
|
|
83
|
+
return schemaName === UNBOUND_NAMESPACE_ID ? name : `${schemaName}.${name}`;
|
|
84
|
+
}
|
|
85
|
+
function target(locator, schemaName, table, column) {
|
|
86
|
+
return {
|
|
87
|
+
storageName: qualified(schemaName, column === void 0 ? table : `${table}.${column}`),
|
|
88
|
+
table: {
|
|
89
|
+
namespaceId: storageNamespaceId(locator, schemaName),
|
|
90
|
+
table,
|
|
91
|
+
column
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function rawSqlTarget(locator, call) {
|
|
96
|
+
const details = call.op.target.details;
|
|
97
|
+
if (details === void 0) return {
|
|
98
|
+
storageName: call.op.id,
|
|
99
|
+
table: void 0
|
|
100
|
+
};
|
|
101
|
+
if (details.objectType === "table") return target(locator, details.schema, details.name, void 0);
|
|
102
|
+
if (details.objectType === "column" && details.table !== void 0) return target(locator, details.schema, details.table, details.name);
|
|
103
|
+
return {
|
|
104
|
+
storageName: storageNameOfOperation(call.op),
|
|
105
|
+
table: void 0
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function knownTarget(locator, call) {
|
|
109
|
+
if (call instanceof DropTableCall) return target(locator, call.schemaName, call.tableName, void 0);
|
|
110
|
+
if (call instanceof DropColumnCall || call instanceof AlterColumnTypeCall) return target(locator, call.schemaName, call.tableName, call.columnName);
|
|
111
|
+
if (call instanceof RawSqlCall) return rawSqlTarget(locator, call);
|
|
112
|
+
const fieldEvent = locator.fieldEvents.get(call);
|
|
113
|
+
return fieldEvent === void 0 ? void 0 : fieldEventStorage(fieldEvent);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A policy's identity across a replacement: its name, or the prefix of a generated (wire) name,
|
|
117
|
+
* whose hash changes with the policy's body.
|
|
118
|
+
*/
|
|
119
|
+
function policyKey(schemaName, tableName, policyName) {
|
|
120
|
+
return JSON.stringify([
|
|
121
|
+
schemaName,
|
|
122
|
+
tableName,
|
|
123
|
+
parseWireName(policyName)?.prefix ?? policyName
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The policies the plan creates. A drop of one of them, by name or by generated-name prefix, is
|
|
128
|
+
* half of a replacement, which leaves a policy in place, so it widens no access.
|
|
129
|
+
*/
|
|
130
|
+
function createdPolicies(calls) {
|
|
131
|
+
return new Set(calls.flatMap((call) => call instanceof CreatePostgresRlsPolicyCall ? [policyKey(call.schemaName, call.tableName, call.policy.name)] : []));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Disabling row-level security widens access: every role with table privileges then reads and
|
|
135
|
+
* writes every row. Dropping a policy changes access either way, since a permissive policy grants
|
|
136
|
+
* access and a restrictive one limits it, unless the plan creates the policy again.
|
|
137
|
+
*/
|
|
138
|
+
function accessChangesOf(locator, call, replaced) {
|
|
139
|
+
if (call instanceof DisableRowLevelSecurityCall) return [{
|
|
140
|
+
...target(locator, call.schemaName, call.tableName, void 0),
|
|
141
|
+
widens: true
|
|
142
|
+
}];
|
|
143
|
+
if (call instanceof DropPostgresRlsPolicyCall && !replaced.has(policyKey(call.schemaName, call.tableName, call.policyName))) return [{
|
|
144
|
+
...target(locator, call.schemaName, call.tableName, void 0),
|
|
145
|
+
widens: false
|
|
146
|
+
}];
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
function operationCountOf(call) {
|
|
150
|
+
return "companions" in call && Array.isArray(call.companions) ? 1 + call.companions.length : 1;
|
|
151
|
+
}
|
|
152
|
+
/** What each call of a Postgres plan loses, and whose access it changes. */
|
|
153
|
+
function postgresCallSubjects(calls, locator) {
|
|
154
|
+
const replaced = createdPolicies(calls);
|
|
155
|
+
const destructive = calls.filter((call) => call.operationClass === "destructive");
|
|
156
|
+
const known = new Map(destructive.map((call) => [call, knownTarget(locator, call)]));
|
|
157
|
+
const unknownNames = unknownCallNames(destructive.filter((call) => known.get(call) === void 0));
|
|
158
|
+
return calls.map((call) => {
|
|
159
|
+
const lossTarget = known.get(call);
|
|
160
|
+
const unknownName = unknownNames.get(call);
|
|
161
|
+
const loss = call instanceof AlterColumnTypeCall ? "typeChange" : "drop";
|
|
162
|
+
return {
|
|
163
|
+
operationCount: operationCountOf(call),
|
|
164
|
+
label: call.label,
|
|
165
|
+
dataLoss: lossTarget !== void 0 ? [{
|
|
166
|
+
...lossTarget,
|
|
167
|
+
loss
|
|
168
|
+
}] : unknownName !== void 0 ? [{
|
|
169
|
+
storageName: unknownName,
|
|
170
|
+
table: void 0,
|
|
171
|
+
loss
|
|
172
|
+
}] : [],
|
|
173
|
+
accessChanges: accessChangesOf(locator, call, replaced),
|
|
174
|
+
temporaryValues: call instanceof AddColumnWithTemporaryDefaultCall ? [{
|
|
175
|
+
table: call.tableName,
|
|
176
|
+
column: call.columnName,
|
|
177
|
+
value: call.temporaryDefault
|
|
178
|
+
}] : []
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function tableIn(tree, ddlSchemaName, tableName) {
|
|
183
|
+
return Object.values(tree.namespaces).find((node) => node.schemaName === ddlSchemaName)?.tables[tableName];
|
|
184
|
+
}
|
|
185
|
+
function escapedForPattern(text) {
|
|
186
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Whether a check's predicate names the column, quoted or bare. The predicate is opaque SQL, so this
|
|
190
|
+
* reads its text, and may name a check that does not depend on the column: dropping and adding
|
|
191
|
+
* such a check again changes nothing.
|
|
192
|
+
*/
|
|
193
|
+
function mentionsColumn(check, column) {
|
|
194
|
+
const quoted = escapedForPattern(quoteIdentifier(column));
|
|
195
|
+
const bare = escapedForPattern(column);
|
|
196
|
+
return new RegExp(`${quoted}|(?<![\\w$"])${bare}(?![\\w$"])`, "i").test(check.expression);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Puts a drop of each check that names a column a type change alters before the first such type
|
|
200
|
+
* change, and the check back after the last. Postgres stores a check bound to the column's old type,
|
|
201
|
+
* such as `array_position(tags, NULL::integer)`, and re-checks it while it alters the type, so a
|
|
202
|
+
* check left in place can fail the alter; a check that names two retyped columns can only be added
|
|
203
|
+
* back once both have their new types. Only checks the plan keeps unchanged are moved: one the plan
|
|
204
|
+
* drops or adds is already planned around the alter. The check is added back as the destination
|
|
205
|
+
* contract writes it.
|
|
206
|
+
*/
|
|
207
|
+
function withChecksAroundTypeChanges(input) {
|
|
208
|
+
const moved = /* @__PURE__ */ new Map();
|
|
209
|
+
input.calls.forEach((call, index) => {
|
|
210
|
+
if (!(call instanceof AlterColumnTypeCall)) return;
|
|
211
|
+
const ddlSchemaName = input.ddlSchemaOf(call.schemaName);
|
|
212
|
+
const kept = tableIn(input.actual, ddlSchemaName, call.tableName)?.checks ?? [];
|
|
213
|
+
for (const check of tableIn(input.expected, ddlSchemaName, call.tableName)?.checks ?? []) {
|
|
214
|
+
if (!mentionsColumn(check, call.columnName)) continue;
|
|
215
|
+
if (!kept.some(({ name }) => name === check.name)) continue;
|
|
216
|
+
const key = JSON.stringify([
|
|
217
|
+
ddlSchemaName,
|
|
218
|
+
call.tableName,
|
|
219
|
+
check.name
|
|
220
|
+
]);
|
|
221
|
+
const entry = moved.get(key);
|
|
222
|
+
if (entry === void 0) moved.set(key, {
|
|
223
|
+
schemaName: call.schemaName,
|
|
224
|
+
tableName: call.tableName,
|
|
225
|
+
check,
|
|
226
|
+
first: index,
|
|
227
|
+
last: index
|
|
228
|
+
});
|
|
229
|
+
else entry.last = index;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const entries = [...moved.values()];
|
|
233
|
+
return input.calls.flatMap((call, index) => [
|
|
234
|
+
...entries.filter(({ first }) => first === index).map(({ schemaName, tableName, check }) => new DropCheckConstraintCall(schemaName, tableName, check.name)),
|
|
235
|
+
call,
|
|
236
|
+
...entries.filter(({ last }) => last === index).map(({ schemaName, tableName, check }) => new AddCheckConstraintCall(schemaName, tableName, check.name, check.expression))
|
|
237
|
+
]);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Resolves the live-database schema name for a given namespace
|
|
241
|
+
* coordinate. Mirrors `resolveDdlSchemaForNamespace` in
|
|
242
|
+
* `planner-strategies.ts` so the verifier's projection and the
|
|
243
|
+
* planner's projection always agree — Postgres-aware namespaces (the
|
|
244
|
+
* production path) dispatch to `ddlSchemaName(storage)`, and bare
|
|
245
|
+
* object payloads (used by some tests) fall back to the coordinate
|
|
246
|
+
* itself.
|
|
247
|
+
*/
|
|
248
|
+
function resolveDdlSchemaName(storage, namespaceId) {
|
|
249
|
+
const namespace = storage.namespaces[namespaceId];
|
|
250
|
+
if (isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);
|
|
251
|
+
return namespaceId;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Reads the introspected list of schema names from the database-root schema
|
|
255
|
+
* node. `existingSchemas` is database-level, so it lives on the
|
|
256
|
+
* `PostgresDatabaseSchemaNode` root — not on the per-schema namespace nodes.
|
|
257
|
+
*
|
|
258
|
+
* Defaults to the always-present `public` schema when the node is not the
|
|
259
|
+
* database root — a fresh Postgres database always carries `public` (unless an
|
|
260
|
+
* operator dropped it manually), so any verifier path that runs without an
|
|
261
|
+
* enriched introspection still suppresses the redundant `CREATE SCHEMA
|
|
262
|
+
* "public"`.
|
|
263
|
+
*
|
|
264
|
+
* Production introspection (`PostgresControlAdapter.introspect`) is the
|
|
265
|
+
* authoritative source: it queries `pg_namespace` and sets `existingSchemas`
|
|
266
|
+
* on the returned root. Tests that want to assert against a richer initial
|
|
267
|
+
* state construct a `PostgresDatabaseSchemaNode` explicitly.
|
|
268
|
+
*/
|
|
269
|
+
function existingSchemasFromSchema(schema) {
|
|
270
|
+
if (PostgresDatabaseSchemaNode.is(schema)) return schema.existingSchemas;
|
|
271
|
+
return [DEFAULT_NAMESPACE_ID];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Emits a `postgres-namespace` `not-found` diff issue for every
|
|
275
|
+
* contract-declared Postgres namespace whose live container does not yet
|
|
276
|
+
* exist. The planner prepends these (node-typed, synthesized) to the
|
|
277
|
+
* relational diff issues so a multi-schema plan emits `CREATE SCHEMA`
|
|
278
|
+
* before the tables that need it — a planner-only concern (verify already
|
|
279
|
+
* rejects via the `not-found` table issues a missing schema already
|
|
280
|
+
* produces), so this is not part of the shared diff.
|
|
281
|
+
*
|
|
282
|
+
* A namespace's live container is the schema returned by its
|
|
283
|
+
* polymorphic `ddlSchemaName(storage)` method — named schemas resolve
|
|
284
|
+
* to their own id; the unbound singleton returns `UNBOUND_NAMESPACE_ID`
|
|
285
|
+
* and is skipped explicitly (late-bound namespaces have no fixed DDL
|
|
286
|
+
* schema). Issues are emitted only when the resolved name is a real,
|
|
287
|
+
* creatable schema (not the unbound sentinel) and is missing from the
|
|
288
|
+
* introspected list. `public` is suppressed implicitly because the
|
|
289
|
+
* introspection (or its sensible default) always carries it.
|
|
290
|
+
*
|
|
291
|
+
* Each emitted issue's path is `['database', ddlName]` — an ancestor of
|
|
292
|
+
* every table path under that schema, so it must never be run through
|
|
293
|
+
* `coalesceSubtreeIssues` alongside the table diff (it would swallow the
|
|
294
|
+
* table-level `not-found` issues that drive `CREATE TABLE`); the planner
|
|
295
|
+
* adds these AFTER coalescing the relational issues, and they are not
|
|
296
|
+
* subject to sibling-space ownership scoping (mirrors the retired
|
|
297
|
+
* coordinate walk, which prepended namespace issues after that filter).
|
|
298
|
+
*/
|
|
299
|
+
function verifyPostgresNamespacePresence(input) {
|
|
300
|
+
const { contract, schema } = input;
|
|
301
|
+
const existing = new Set(existingSchemasFromSchema(schema));
|
|
302
|
+
const issues = [];
|
|
303
|
+
const namespaceIds = Object.keys(contract.storage.namespaces).sort();
|
|
304
|
+
for (const namespaceId of namespaceIds) {
|
|
305
|
+
if (namespaceId === UNBOUND_NAMESPACE_ID) continue;
|
|
306
|
+
const ddlName = resolveDdlSchemaName(contract.storage, namespaceId);
|
|
307
|
+
if (ddlName === UNBOUND_NAMESPACE_ID) continue;
|
|
308
|
+
if (existing.has(ddlName)) continue;
|
|
309
|
+
const namespace = new PostgresNamespaceSchemaNode({
|
|
310
|
+
schemaName: ddlName,
|
|
311
|
+
tables: {}
|
|
312
|
+
});
|
|
313
|
+
issues.push({
|
|
314
|
+
path: ["database", ddlName],
|
|
315
|
+
expected: namespace
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return issues;
|
|
319
|
+
}
|
|
320
|
+
function partitionPostgresCallsByControlPolicy(calls, contract) {
|
|
321
|
+
return partitionCallsByControlPolicy({
|
|
322
|
+
calls,
|
|
323
|
+
contract,
|
|
324
|
+
resolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, contract),
|
|
325
|
+
resolveFactoryName: (call) => call.factoryName
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function createPostgresMigrationPlanner(lowerer) {
|
|
329
|
+
return new PostgresMigrationPlanner(lowerer);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Postgres migration planner — a thin wrapper over `planIssues`.
|
|
333
|
+
*
|
|
334
|
+
* `plan()` diffs the target contract against the live schema via the one
|
|
335
|
+
* differ (`buildPostgresPlanDiff`, producing node-typed `SchemaDiffIssue[]`)
|
|
336
|
+
* and delegates to `planIssues` with the unified `postgresPlannerStrategies`
|
|
337
|
+
* list: NOT-NULL backfill, type-change, nullable-tightening, codec-hook
|
|
338
|
+
* storage types, component-declared dependency installs, and
|
|
339
|
+
* shared-temp-default / empty-table-guarded NOT-NULL add-column. The same
|
|
340
|
+
* strategy list runs for `migration plan`, `db update`, and `db init`;
|
|
341
|
+
* behavior diverges purely on `policy.allowedOperationClasses` (the
|
|
342
|
+
* data-safe strategies short-circuit when `'data'` is excluded). The issue
|
|
343
|
+
* planner applies operation-class policy gates and emits a single
|
|
344
|
+
* `PostgresOpFactoryCall[]` that drives both the runtime-ops view (via
|
|
345
|
+
* `renderOps`) and the `renderTypeScript()` authoring surface. RLS policy
|
|
346
|
+
* drift (the structural half of the same one-differ tree) is handled
|
|
347
|
+
* separately via `planPostgresSchemaDiff`.
|
|
348
|
+
*/
|
|
349
|
+
var PostgresMigrationPlanner = class {
|
|
350
|
+
#lowerer;
|
|
351
|
+
constructor(lowerer) {
|
|
352
|
+
this.#lowerer = lowerer;
|
|
353
|
+
}
|
|
354
|
+
plan(options) {
|
|
355
|
+
return this.planSql(blindCast(options));
|
|
356
|
+
}
|
|
357
|
+
emptyMigration(context, spaceId) {
|
|
358
|
+
return new TypeScriptRenderablePostgresMigration([], {
|
|
359
|
+
from: context.fromHash,
|
|
360
|
+
to: context.toHash
|
|
361
|
+
}, spaceId, context.snapshotsImportPath, this.#lowerer);
|
|
362
|
+
}
|
|
363
|
+
planSql(options) {
|
|
364
|
+
const schemaName = options.schemaName ?? Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;
|
|
365
|
+
const policyResult = this.ensureAdditivePolicy(options.policy);
|
|
366
|
+
if (policyResult) return policyResult;
|
|
367
|
+
PostgresDatabaseSchemaNode.assert(options.schema);
|
|
368
|
+
const statements = this.planStatements(options, options.schema);
|
|
369
|
+
if (!statements.ok) return plannerFailure([statements.failure]);
|
|
370
|
+
const { schema } = statements.value;
|
|
371
|
+
const removedSchemas = removedNamespaceSchemas(options, schema);
|
|
372
|
+
const { issues: rawIssues, expected: expectedSchema } = buildPostgresPlanDiff({
|
|
373
|
+
contract: options.contract,
|
|
374
|
+
actualSchema: schema,
|
|
375
|
+
frameworkComponents: options.frameworkComponents,
|
|
376
|
+
originSchemas: originSchemaNames(options.fromContract)
|
|
377
|
+
});
|
|
378
|
+
const droppedTables = rawIssues.filter((issue) => issueOutcome(issue) === "not-expected" && issueNode(issue)?.nodeKind === PostgresSchemaNodeKind.table);
|
|
379
|
+
const policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue) && !droppedTables.some((table) => isWithin(issue.path, table.path)));
|
|
380
|
+
const relationalDiffIssues = rawIssues.filter((issue) => !isPolicyDiffIssue(issue));
|
|
381
|
+
const strict = options.policy.allowedOperationClasses.includes("widening") || options.policy.allowedOperationClasses.includes("destructive");
|
|
382
|
+
const owned = retainUnownedExtras(coalesceSubtreeIssues(relationalDiffIssues.filter((issue) => !isOriginNamespaceIssue(issue, originSchemaNames(options.fromContract)))), options.ownership, (ddlSchemaName) => namespaceIdOfSchema(options, ddlSchemaName));
|
|
383
|
+
const gated = strict ? owned : owned.filter((issue) => issueOutcome(issue) !== "not-expected");
|
|
384
|
+
const schemaIssues = [...verifyPostgresNamespacePresence({
|
|
385
|
+
contract: options.contract,
|
|
386
|
+
schema
|
|
387
|
+
}), ...gated];
|
|
388
|
+
const indexRenames = pairIndexRenames(options, schemaIssues);
|
|
389
|
+
const checkRenames = pairCheckRenames(options, schemaIssues);
|
|
390
|
+
const renameConsumed = /* @__PURE__ */ new Set([...indexRenames.consumed, ...checkRenames.consumed]);
|
|
391
|
+
const plannableIssues = renameConsumed.size === 0 ? schemaIssues : schemaIssues.filter((issue) => !renameConsumed.has(issue));
|
|
392
|
+
const codecHooks = extractCodecControlHooks(options.frameworkComponents);
|
|
393
|
+
const types = sqlTypeLookupsOf(options.frameworkComponents);
|
|
394
|
+
const relationalSchema = relationalNamespaceNode(schema, schemaName);
|
|
395
|
+
const issuePartition = partitionIssuesByControlPolicy({
|
|
396
|
+
issues: plannableIssues,
|
|
397
|
+
contract: options.contract,
|
|
398
|
+
resolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),
|
|
399
|
+
resolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName
|
|
400
|
+
});
|
|
401
|
+
const caseChangeConflicts = detectTableNameCaseChanges({
|
|
402
|
+
issues: issuePartition.plannable,
|
|
403
|
+
tableOf: (issue) => {
|
|
404
|
+
const node = issueNode(issue);
|
|
405
|
+
return node !== void 0 && PostgresTableSchemaNode.is(node) ? node : void 0;
|
|
406
|
+
},
|
|
407
|
+
namespaceIdOf: (issue) => resolveNamespaceIdForDdlSchema(options.contract, issueSchemaName(issue) ?? schemaName),
|
|
408
|
+
renameByHandStatements: (rename) => renameTableByHandStatements(options.contract, rename),
|
|
409
|
+
renameTableCall: renderRenameTableCall,
|
|
410
|
+
contract: options.contract,
|
|
411
|
+
defaultNamespaceId: DEFAULT_NAMESPACE_ID
|
|
412
|
+
});
|
|
413
|
+
if (caseChangeConflicts.length > 0) return plannerFailure(caseChangeConflicts);
|
|
414
|
+
const defaultedBackfill = backfillOfDefaultedField(options.statements, options.fromContract, options.contract);
|
|
415
|
+
if (defaultedBackfill !== void 0) return plannerFailure([defaultedBackfill]);
|
|
416
|
+
const result = planIssues({
|
|
417
|
+
issues: issuePartition.plannable,
|
|
418
|
+
toContract: options.contract,
|
|
419
|
+
fromContract: options.fromContract,
|
|
420
|
+
schemaName,
|
|
421
|
+
codecHooks,
|
|
422
|
+
types,
|
|
423
|
+
...ifDefined("schema", relationalSchema),
|
|
424
|
+
startTree: schema,
|
|
425
|
+
endTree: expectedSchema,
|
|
426
|
+
foreignKeyDropAuthority: (ddlSchemaName, tableName, foreignKey) => {
|
|
427
|
+
const namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);
|
|
428
|
+
if ((tableAt(options.contract.storage, namespaceId, tableName) === void 0 && options.ownership?.declaresEntity({
|
|
429
|
+
namespaceId,
|
|
430
|
+
entityKind: "table",
|
|
431
|
+
entityName: tableName
|
|
432
|
+
})) === true) return "otherSpace";
|
|
433
|
+
const { plannable } = partitionIssuesByControlPolicy({
|
|
434
|
+
issues: [{
|
|
435
|
+
path: [
|
|
436
|
+
"database",
|
|
437
|
+
ddlSchemaName,
|
|
438
|
+
tableName,
|
|
439
|
+
foreignKey.id
|
|
440
|
+
],
|
|
441
|
+
actual: foreignKey
|
|
442
|
+
}],
|
|
443
|
+
contract: options.contract,
|
|
444
|
+
resolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),
|
|
445
|
+
resolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName
|
|
446
|
+
});
|
|
447
|
+
return plannable.length === 1 ? "allowed" : "controlPolicy";
|
|
448
|
+
},
|
|
449
|
+
policy: options.policy,
|
|
450
|
+
frameworkComponents: options.frameworkComponents,
|
|
451
|
+
statementColumns: fieldStatementColumns(options.statements, options.contract),
|
|
452
|
+
strategies: [...postgresPlannerStrategies, dropRemovedSchemasStrategy(removedSchemas.filter((schemaName) => !keptSchema(options, schemaName)))]
|
|
453
|
+
});
|
|
454
|
+
const schemaDiff = this.planPostgresSchemaDiff(options, policyDiffIssues);
|
|
455
|
+
if (!result.ok || schemaDiff.conflicts.length > 0) return plannerFailure([...result.ok ? [] : result.failure, ...schemaDiff.conflicts]);
|
|
456
|
+
const renamePartition = partitionPostgresCallsByControlPolicy([
|
|
457
|
+
...indexRenames.calls,
|
|
458
|
+
...checkRenames.calls,
|
|
459
|
+
...plannedConstraintNameRenames({
|
|
460
|
+
...options,
|
|
461
|
+
schema
|
|
462
|
+
}, result.value.calls)
|
|
463
|
+
], options.contract);
|
|
464
|
+
const schemaDiffPartition = partitionPostgresCallsByControlPolicy(schemaDiff.calls, options.contract);
|
|
465
|
+
const fieldEventCalls = planFieldEventCalls({
|
|
466
|
+
priorContract: options.origin === null ? null : options.fromContract,
|
|
467
|
+
newContract: options.contract,
|
|
468
|
+
codecHooks,
|
|
469
|
+
tableRenames: statements.value.tableRenames,
|
|
470
|
+
columnRenames: statements.value.columnRenames,
|
|
471
|
+
dataTypes: types.dataTypeLookup
|
|
472
|
+
});
|
|
473
|
+
const fieldEventPartition = partitionPostgresCallsByControlPolicy(blindCast(fieldEventCalls.map(({ call }) => call)), options.contract);
|
|
474
|
+
const ordered = movePolicyDropsBeforeBlockedDdl(withChecksAroundTypeChanges({
|
|
475
|
+
calls: result.value.calls,
|
|
476
|
+
expected: expectedSchema,
|
|
477
|
+
actual: schema,
|
|
478
|
+
ddlSchemaOf: (name) => name === UNBOUND_NAMESPACE_ID ? resolveDdlSchemaForNamespaceStorage(options.contract.storage, UNBOUND_NAMESPACE_ID) : name
|
|
479
|
+
}), schemaDiffPartition.kept);
|
|
480
|
+
const calls = [
|
|
481
|
+
...statements.value.calls,
|
|
482
|
+
...ordered.structural,
|
|
483
|
+
...renamePartition.kept,
|
|
484
|
+
...ordered.policyCalls,
|
|
485
|
+
...fieldEventPartition.kept
|
|
486
|
+
];
|
|
487
|
+
const seenWarnings = /* @__PURE__ */ new Set();
|
|
488
|
+
const warnings = [
|
|
489
|
+
...issuePartition.suppressions,
|
|
490
|
+
...renamePartition.suppressions,
|
|
491
|
+
...schemaDiff.suppressions,
|
|
492
|
+
...schemaDiffPartition.suppressions,
|
|
493
|
+
...fieldEventPartition.suppressions
|
|
494
|
+
].map((record) => renderPostgresSuppression(record, options.contract)).filter((warning) => {
|
|
495
|
+
const key = JSON.stringify(warning);
|
|
496
|
+
if (seenWarnings.has(key)) return false;
|
|
497
|
+
seenWarnings.add(key);
|
|
498
|
+
return true;
|
|
499
|
+
});
|
|
500
|
+
return Object.freeze({
|
|
501
|
+
kind: "success",
|
|
502
|
+
plan: new TypeScriptRenderablePostgresMigration(calls, {
|
|
503
|
+
from: options.origin?.storageHash ?? null,
|
|
504
|
+
to: options.contract.storage.storageHash
|
|
505
|
+
}, options.spaceId, options.snapshotsImportPath, this.#lowerer),
|
|
506
|
+
appliedStatements: appliedStatementsInOrder(options.statements, statements.value.appliedStatements),
|
|
507
|
+
...subjectsOfCalls(postgresCallSubjects(calls, {
|
|
508
|
+
contract: options.fromContract ?? options.contract,
|
|
509
|
+
fieldEvents: new Map(fieldEventCalls.map((fieldEvent) => [fieldEvent.call, fieldEvent]))
|
|
510
|
+
}), {
|
|
511
|
+
fromContract: options.fromContract,
|
|
512
|
+
contract: options.contract,
|
|
513
|
+
origins: statements.value.origins,
|
|
514
|
+
byHand: postgresTableRenameByHand(options.contract)
|
|
515
|
+
}),
|
|
516
|
+
namespaces: {
|
|
517
|
+
removed: removedSchemas.map((schemaName) => namespaceIdOfSchema(options, schemaName)),
|
|
518
|
+
added: addedNamespaceIds(options)
|
|
519
|
+
},
|
|
520
|
+
...warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Maps the RLS policy findings of the one combined tree diff
|
|
525
|
+
* (`buildPostgresPlanDiff`, already ownership-filtered) into
|
|
526
|
+
* `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops — a
|
|
527
|
+
* `not-equal` finding (an exact-named policy whose content drifted)
|
|
528
|
+
* becomes drop + create, or a disallowed-call conflict when the policy
|
|
529
|
+
* forbids the drop, which is `widening`. It
|
|
530
|
+
* does not re-diff — it consumes exactly the policy-node subset of the
|
|
531
|
+
* shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE
|
|
532
|
+
* ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`
|
|
533
|
+
* attribute diff on the relational side.
|
|
534
|
+
*
|
|
535
|
+
* Rename post-pass (the index pass's structure): hash pairing pairs a
|
|
536
|
+
* `not-found` and a `not-expected` policy on the SAME table whose
|
|
537
|
+
* wire-name content hashes match but prefixes differ (prefix-only rename);
|
|
538
|
+
* content pairing then pairs remaining wire-named-missing policies against remaining
|
|
539
|
+
* extras of any name shape by verbatim content (the node-owned `contentEquals` —
|
|
540
|
+
* exact→wire adoption). Multi-candidate groups pair deterministically
|
|
541
|
+
* by sorted name; leftovers proceed as create/drop; an exact-named
|
|
542
|
+
* missing policy never content-pairs.
|
|
543
|
+
*
|
|
544
|
+
* The pairing runs only when the policy allows `widening` (rename's
|
|
545
|
+
* class). Without it (db-init's additive-only set), pairing degrades
|
|
546
|
+
* deliberately to the additive half: the new name is CREATEd and the old
|
|
547
|
+
* policy survives live until a plan that allows `widening` runs —
|
|
548
|
+
* emitting an ungated widening rename would only fail at the runner's
|
|
549
|
+
* class re-enforcement.
|
|
550
|
+
*/
|
|
551
|
+
planPostgresSchemaDiff(options, filteredDiffIssues) {
|
|
552
|
+
const allowsWidening = options.policy.allowedOperationClasses.includes("widening");
|
|
553
|
+
const missing = [];
|
|
554
|
+
const extra = [];
|
|
555
|
+
const changed = [];
|
|
556
|
+
for (const issue of filteredDiffIssues) if (issueOutcome(issue) === "not-equal") {
|
|
557
|
+
const expected = issue.expected;
|
|
558
|
+
PostgresPolicySchemaNode.assert(expected);
|
|
559
|
+
changed.push({
|
|
560
|
+
node: expected,
|
|
561
|
+
schemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)
|
|
562
|
+
});
|
|
563
|
+
} else if (issueOutcome(issue) === "not-found") {
|
|
564
|
+
const expected = issue.expected;
|
|
565
|
+
PostgresPolicySchemaNode.assert(expected);
|
|
566
|
+
missing.push({
|
|
567
|
+
node: expected,
|
|
568
|
+
schemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)
|
|
569
|
+
});
|
|
570
|
+
} else if (issueOutcome(issue) === "not-expected") {
|
|
571
|
+
const actual = issue.actual;
|
|
572
|
+
PostgresPolicySchemaNode.assert(actual);
|
|
573
|
+
extra.push({
|
|
574
|
+
node: actual,
|
|
575
|
+
schemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, actual.namespaceId)
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
const calls = [];
|
|
579
|
+
const conflicts = [];
|
|
580
|
+
const suppressions = [];
|
|
581
|
+
const renamedExtras = /* @__PURE__ */ new Set();
|
|
582
|
+
const renamedMissing = /* @__PURE__ */ new Set();
|
|
583
|
+
const pairingKey = (finding, hash) => JSON.stringify([
|
|
584
|
+
finding.schemaForTable,
|
|
585
|
+
finding.node.tableName,
|
|
586
|
+
hash
|
|
587
|
+
]);
|
|
588
|
+
if (allowsWidening) {
|
|
589
|
+
const extrasByGroup = /* @__PURE__ */ new Map();
|
|
590
|
+
for (const finding of extra) {
|
|
591
|
+
const parsed = parseWireName(finding.node.name);
|
|
592
|
+
if (parsed === void 0) continue;
|
|
593
|
+
const key = pairingKey(finding, parsed.hash);
|
|
594
|
+
const group = extrasByGroup.get(key) ?? [];
|
|
595
|
+
group.push(finding);
|
|
596
|
+
extrasByGroup.set(key, group);
|
|
597
|
+
}
|
|
598
|
+
for (const group of extrasByGroup.values()) group.sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);
|
|
599
|
+
const sortedMissing = [...missing].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);
|
|
600
|
+
for (const missingFinding of sortedMissing) {
|
|
601
|
+
const parsed = parseWireName(missingFinding.node.name);
|
|
602
|
+
if (parsed === void 0) continue;
|
|
603
|
+
const candidate = extrasByGroup.get(pairingKey(missingFinding, parsed.hash))?.shift();
|
|
604
|
+
if (candidate === void 0) continue;
|
|
605
|
+
renamedExtras.add(candidate);
|
|
606
|
+
renamedMissing.add(missingFinding);
|
|
607
|
+
calls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));
|
|
608
|
+
}
|
|
609
|
+
const sortedExtras = [...extra].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);
|
|
610
|
+
for (const missingFinding of sortedMissing) {
|
|
611
|
+
if (renamedMissing.has(missingFinding)) continue;
|
|
612
|
+
if (missingFinding.node.prefix === void 0) continue;
|
|
613
|
+
const candidate = sortedExtras.find((extraFinding) => !renamedExtras.has(extraFinding) && extraFinding.schemaForTable === missingFinding.schemaForTable && extraFinding.node.tableName === missingFinding.node.tableName && missingFinding.node.contentEquals(extraFinding.node));
|
|
614
|
+
if (candidate === void 0) continue;
|
|
615
|
+
renamedExtras.add(candidate);
|
|
616
|
+
renamedMissing.add(missingFinding);
|
|
617
|
+
calls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
for (const finding of changed) {
|
|
621
|
+
const replacement = {
|
|
622
|
+
drop: new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name),
|
|
623
|
+
create: new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node))
|
|
624
|
+
};
|
|
625
|
+
const graded = gradePolicyReplacement(replacement, options.contract, options.policy.allowedOperationClasses);
|
|
626
|
+
if (graded.disposition === "suppress") {
|
|
627
|
+
suppressions.push(graded.record);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (graded.disposition === "conflict") {
|
|
631
|
+
conflicts.push(graded.conflict);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
calls.push(replacement.drop);
|
|
635
|
+
calls.push(replacement.create);
|
|
636
|
+
}
|
|
637
|
+
for (const finding of missing) {
|
|
638
|
+
if (renamedMissing.has(finding)) continue;
|
|
639
|
+
calls.push(new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node)));
|
|
640
|
+
}
|
|
641
|
+
if (allowsWidening) for (const finding of extra) {
|
|
642
|
+
if (renamedExtras.has(finding)) continue;
|
|
643
|
+
calls.push(new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name));
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
calls,
|
|
647
|
+
conflicts,
|
|
648
|
+
suppressions
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Plans the statements against a working copy of `schema`, in order, so each rename's companions
|
|
653
|
+
* are computed against the schema the earlier statements left. The diff then runs on that schema.
|
|
654
|
+
*/
|
|
655
|
+
planStatements(options, schema) {
|
|
656
|
+
const working = createWorkingSchema(schema);
|
|
657
|
+
const ddlSchemaOf = (namespaceId) => resolveDdlSchemaForNamespaceStorage(options.contract.storage, namespaceId);
|
|
658
|
+
const planned = planStatements({
|
|
659
|
+
statements: options.statements.filter(isRenameStatement),
|
|
660
|
+
fromContract: options.fromContract,
|
|
661
|
+
contract: options.contract,
|
|
662
|
+
policy: options.policy,
|
|
663
|
+
ownership: {
|
|
664
|
+
oracle: options.ownership,
|
|
665
|
+
spaceId: options.spaceId
|
|
666
|
+
},
|
|
667
|
+
target: {
|
|
668
|
+
tables: () => postgresSchemaTables(working.current, options.contract),
|
|
669
|
+
namespaces: {
|
|
670
|
+
createNamespaceCalls: (namespaceId) => {
|
|
671
|
+
const schemaName = ddlSchemaOf(namespaceId);
|
|
672
|
+
return working.current.existingSchemas.includes(schemaName) ? [] : [new CreateSchemaCall(schemaName)];
|
|
673
|
+
},
|
|
674
|
+
moveTableCall: (move) => {
|
|
675
|
+
if (options.fromContract === null) throw new InternalError("A table move is planned only from an origin contract");
|
|
676
|
+
return new SetTableSchemaCall(emissionSchemaForNamespace(options.contract.storage.namespaces[move.from] === void 0 ? options.fromContract : options.contract, move.from), move.table, ddlSchemaOf(move.to));
|
|
677
|
+
},
|
|
678
|
+
namespaceRenameRefusal: postgresNamespaceRenameRefusal,
|
|
679
|
+
renameNamespaceCall: (rename) => {
|
|
680
|
+
if (options.fromContract === null) throw new InternalError("A namespace rename is planned only from an origin contract");
|
|
681
|
+
return new RenameSchemaCall(resolveDdlSchemaForNamespaceStorage(options.fromContract.storage, rename.from), ddlSchemaOf(rename.to));
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
renameTableCall: (rename) => postgresTableRenameCall({
|
|
685
|
+
previous: working.current,
|
|
686
|
+
contract: options.contract,
|
|
687
|
+
rename,
|
|
688
|
+
frameworkComponents: options.frameworkComponents
|
|
689
|
+
}),
|
|
690
|
+
renameColumnCall: (rename) => postgresColumnRenameCall({
|
|
691
|
+
previous: working.current,
|
|
692
|
+
contract: options.contract,
|
|
693
|
+
rename,
|
|
694
|
+
frameworkComponents: options.frameworkComponents
|
|
695
|
+
}),
|
|
696
|
+
apply: (call) => working.apply(call),
|
|
697
|
+
...postgresTableRenameByHand(options.contract)
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
if (!planned.ok) return planned;
|
|
701
|
+
return ok({
|
|
702
|
+
...planned.value,
|
|
703
|
+
schema: working.current
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
ensureAdditivePolicy(policy) {
|
|
707
|
+
if (!policy.allowedOperationClasses.includes("additive")) return plannerFailure([{
|
|
708
|
+
kind: "unsupportedOperation",
|
|
709
|
+
summary: "Migration planner requires additive operations be allowed",
|
|
710
|
+
why: "The planner requires the \"additive\" operation class to be allowed in the policy."
|
|
711
|
+
}]);
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
/** Whether `path` lies under `ancestor`: a dropped table's policies go with it. */
|
|
716
|
+
function isWithin(path, ancestor) {
|
|
717
|
+
return path.length > ancestor.length && ancestor.every((segment, index) => path[index] === segment);
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* The DDL schemas in which the origin contract declares tables; none without an origin contract.
|
|
721
|
+
* A namespace with no tables, such as the `public` the target always adds, owns nothing.
|
|
722
|
+
*/
|
|
723
|
+
function originSchemaNames(fromContract) {
|
|
724
|
+
if (fromContract === null) return [];
|
|
725
|
+
return Object.entries(fromContract.storage.namespaces).filter(([namespaceId, namespace]) => namespaceId !== UNBOUND_NAMESPACE_ID && Object.keys(namespace.entries.table ?? {}).length > 0).map(([namespaceId]) => resolveDdlSchemaForNamespaceStorage(fromContract.storage, namespaceId));
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* The namespaces the destination declares and the origin does not, other than `public` and those a
|
|
729
|
+
* statement renames a namespace to: the new names a rename of a removed namespace may give it.
|
|
730
|
+
*/
|
|
731
|
+
function addedNamespaceIds(options) {
|
|
732
|
+
const { fromContract } = options;
|
|
733
|
+
if (fromContract === null) return [];
|
|
734
|
+
const renamedTo = new Set(options.statements.flatMap((statement) => statement.kind === "rename" && statement.entity === "namespace" ? [statement.to] : []));
|
|
735
|
+
return Object.keys(options.contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID && namespaceId !== "public" && !renamedTo.has(namespaceId) && !Object.hasOwn(fromContract.storage.namespaces, namespaceId));
|
|
736
|
+
}
|
|
737
|
+
/** Every DDL schema the contract declares, with or without tables. */
|
|
738
|
+
function declaredSchemaNames(contract) {
|
|
739
|
+
return new Set(Object.keys(contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID).map((namespaceId) => resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId)));
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* The live schemas the origin contract declares and the destination does not: each is dropped,
|
|
743
|
+
* its tables first, each table a data-loss question.
|
|
744
|
+
*/
|
|
745
|
+
function removedNamespaceSchemas(options, schema) {
|
|
746
|
+
const destination = declaredSchemaNames(options.contract);
|
|
747
|
+
return originSchemaNames(options.fromContract).filter((schemaName) => schemaName !== "public" && !destination.has(schemaName) && schema.namespaces[schemaName] !== void 0);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* The issue a schema of the origin contract raises for itself when the destination declares no
|
|
751
|
+
* tables there, which would cover the issues of its tables: they are kept instead, so each table is
|
|
752
|
+
* dropped and asked about on its own, and a removed schema is dropped after them.
|
|
753
|
+
*/
|
|
754
|
+
function isOriginNamespaceIssue(issue, originSchemas) {
|
|
755
|
+
const node = issueNode(issue);
|
|
756
|
+
return node !== void 0 && node.nodeKind === PostgresSchemaNodeKind.namespace && originSchemas.includes(issue.path[1] ?? "");
|
|
757
|
+
}
|
|
758
|
+
/** A removed schema that stays because another contract space declares it. */
|
|
759
|
+
function keptSchema(options, schemaName) {
|
|
760
|
+
if (options.fromContract === null) return true;
|
|
761
|
+
const namespaceId = resolveNamespaceIdForDdlSchema(options.fromContract, schemaName);
|
|
762
|
+
return otherSpaceDeclaring({
|
|
763
|
+
oracle: options.ownership,
|
|
764
|
+
spaceId: options.spaceId
|
|
765
|
+
}, namespaceId) !== void 0;
|
|
766
|
+
}
|
|
767
|
+
function dropRemovedSchemasStrategy(schemaNames) {
|
|
768
|
+
return (issues) => schemaNames.length === 0 ? { kind: "no_match" } : {
|
|
769
|
+
kind: "match",
|
|
770
|
+
issues,
|
|
771
|
+
calls: schemaNames.map((name) => new DropSchemaCall(name))
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Why a namespace cannot be renamed: `public` is the default schema Prisma owns and Postgres puts
|
|
776
|
+
* on every search path, and a schema another contract space declares would be renamed for it too.
|
|
777
|
+
*/
|
|
778
|
+
function postgresNamespaceRenameRefusal(rename) {
|
|
779
|
+
const reason = `"${DEFAULT_NAMESPACE_ID}" is the default schema of every Postgres database`;
|
|
780
|
+
if (rename.from === "public") return {
|
|
781
|
+
reason,
|
|
782
|
+
fix: `Prisma owns schema "${rename.from}", and Postgres puts it on every search path, so a migration does not rename it. Move each model to the new namespace with --rename <Model>:${rename.to}.<Model> instead.`
|
|
783
|
+
};
|
|
784
|
+
if (rename.to === "public") return {
|
|
785
|
+
reason,
|
|
786
|
+
fix: `Every Postgres database already has schema "${rename.to}", so no schema can be renamed to it. Move each model with --rename ${rename.from}.<Model>:<Model> instead.`
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* A diff issue whose node is an RLS policy — the structural half of the one
|
|
791
|
+
* combined tree diff, routed to `planPostgresSchemaDiff` instead of
|
|
792
|
+
* `planIssues`.
|
|
793
|
+
*/
|
|
794
|
+
function isPolicyDiffIssue(issue) {
|
|
795
|
+
const node = issue.expected ?? issue.actual;
|
|
796
|
+
return node !== void 0 && PostgresPolicySchemaNode.is(node);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Postgres refuses these statements while a policy uses the object they touch:
|
|
800
|
+
* - dropping a column (2BP01) or changing its type (0A000);
|
|
801
|
+
* - dropping a table that a policy on another table uses (2BP01); a table's own policies go with it;
|
|
802
|
+
* - dropping a native enum type (2BP01);
|
|
803
|
+
* - a destructive codec type operation (a `RawSqlCall` on a type), such as dropping or rebuilding
|
|
804
|
+
* the type (2BP01) or changing a composite type's attribute type (0A000). Additive and widening
|
|
805
|
+
* type operations, such as adding an enum value or renaming the type, go through.
|
|
806
|
+
*
|
|
807
|
+
* So every policy drop moves to just before the first structural call that a policy can block.
|
|
808
|
+
* Without such a call, the policy calls keep their place after the structural calls.
|
|
809
|
+
*/
|
|
810
|
+
function movePolicyDropsBeforeBlockedDdl(structural, policyCalls) {
|
|
811
|
+
const firstBlockable = structural.findIndex(policyCanBlock);
|
|
812
|
+
if (firstBlockable === -1) return {
|
|
813
|
+
structural,
|
|
814
|
+
policyCalls
|
|
815
|
+
};
|
|
816
|
+
const isPolicyDrop = (call) => call instanceof DropPostgresRlsPolicyCall;
|
|
817
|
+
return {
|
|
818
|
+
structural: [
|
|
819
|
+
...structural.slice(0, firstBlockable),
|
|
820
|
+
...policyCalls.filter(isPolicyDrop),
|
|
821
|
+
...structural.slice(firstBlockable)
|
|
822
|
+
],
|
|
823
|
+
policyCalls: policyCalls.filter((call) => !isPolicyDrop(call))
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function policyCanBlock(call) {
|
|
827
|
+
if (call instanceof RawSqlCall) return call.operationClass === "destructive" && call.op.target.details?.objectType === "type";
|
|
828
|
+
return call instanceof DropColumnCall || call instanceof AlterColumnTypeCall || call instanceof DropTableCall || call instanceof DropNativeEnumTypeCall;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Drops a `not-expected` issue when it is a whole extra storage entity (a table
|
|
832
|
+
* or a native enum) that some space in the composition owns. Each such node
|
|
833
|
+
* yields its own storage coordinate (see {@link postgresNodeStorageCoordinate}),
|
|
834
|
+
* so `declaresEntity` answers over the whole composition on one uniform
|
|
835
|
+
* coordinate: a positive answer means a sibling owns this entity here — leave
|
|
836
|
+
* it; a negative answer means a genuine orphan — drop it. A node with no storage
|
|
837
|
+
* coordinate (a namespace, or a deeper column/constraint drift on an owned
|
|
838
|
+
* table) is this space's own and is always kept. No oracle ⇒ keep everything.
|
|
839
|
+
*/
|
|
840
|
+
/**
|
|
841
|
+
* The namespace a live schema stands for: the destination's, or, for a schema only the origin
|
|
842
|
+
* declares, such as one the destination removed, the origin's.
|
|
843
|
+
*/
|
|
844
|
+
function namespaceIdOfSchema(options, ddlSchemaName) {
|
|
845
|
+
const namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);
|
|
846
|
+
if (namespaceId !== UNBOUND_NAMESPACE_ID || ddlSchemaName === "public" || options.fromContract === null) return namespaceId;
|
|
847
|
+
return resolveNamespaceIdForDdlSchema(options.fromContract, ddlSchemaName);
|
|
848
|
+
}
|
|
849
|
+
function retainUnownedExtras(issues, ownership, namespaceIdOf) {
|
|
850
|
+
if (ownership === void 0) return issues;
|
|
851
|
+
return issues.filter((issue) => {
|
|
852
|
+
if (issueOutcome(issue) !== "not-expected") return true;
|
|
853
|
+
const node = issueNode(issue);
|
|
854
|
+
if (node === void 0) return true;
|
|
855
|
+
const coordinate = postgresNodeStorageCoordinate(node);
|
|
856
|
+
if (coordinate === void 0) return true;
|
|
857
|
+
const ddlSchemaName = issueSchemaName(issue);
|
|
858
|
+
if (ddlSchemaName === void 0) return true;
|
|
859
|
+
return !ownership.declaresEntity({
|
|
860
|
+
namespaceId: namespaceIdOf(ddlSchemaName),
|
|
861
|
+
...coordinate
|
|
862
|
+
});
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Returns the one namespace node the relational strategy layer probes for
|
|
867
|
+
* live-table existence and reads codec-hook context off — the namespace
|
|
868
|
+
* matching the planner's resolved schema name, or the first namespace when
|
|
869
|
+
* none matches. `undefined` when the tree has no namespaces, so the strategy
|
|
870
|
+
* context uses its empty-schema default.
|
|
871
|
+
*
|
|
872
|
+
* The relational strategies key tables by bare name, so they can only probe one
|
|
873
|
+
* namespace at a time; probing across every namespace at once is future work.
|
|
874
|
+
*
|
|
875
|
+
* Returns the real `PostgresNamespaceSchemaNode` reference rather than a
|
|
876
|
+
* projection: `storageTypePlanCallStrategy` hands this same value to codec
|
|
877
|
+
* `planTypeOperations` hooks as `schema`, and hooks read the Postgres-specific
|
|
878
|
+
* `nativeEnums` field off it (via `PostgresNamespaceSchemaNode.is`) to decide
|
|
879
|
+
* whether a native enum type already exists — a projection that only copies
|
|
880
|
+
* `tables` would silently drop that signal. `StrategyContext.schema`'s
|
|
881
|
+
* declared type (`SqlSchemaIR`, shared with SQLite's flat shape) doesn't
|
|
882
|
+
* capture this, so the return is `blindCast` the same way `namespaceSchemaNodes`
|
|
883
|
+
* in the family's relational walk already treats a namespace node as a
|
|
884
|
+
* structurally-`SqlSchemaIR`-shaped value.
|
|
885
|
+
*/
|
|
886
|
+
function relationalNamespaceNode(schema, schemaName) {
|
|
887
|
+
const namespaceNodes = Object.values(schema.namespaces);
|
|
888
|
+
const namespaceNode = namespaceNodes.find((node) => node.schemaName === schemaName) ?? namespaceNodes[0];
|
|
889
|
+
if (namespaceNode === void 0) return void 0;
|
|
890
|
+
return blindCast(namespaceNode);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Grades a {@link PolicyReplacement} as one unit against the table's
|
|
894
|
+
* control policy, BEFORE the pair becomes calls or a conflict. This runs
|
|
895
|
+
* ahead of `partitionCallsByControlPolicy`, which later re-grades the
|
|
896
|
+
* surviving calls per-call — a no-op here, since only managed units
|
|
897
|
+
* survive this grading.
|
|
898
|
+
*
|
|
899
|
+
* A replacement is deliberately STRICTER than the shared
|
|
900
|
+
* `callAllowedUnderControlPolicy` rule: `tolerated` permits whole-object
|
|
901
|
+
* creation, but a replacement's create is the second half of a repair of
|
|
902
|
+
* an existing object, not a new object — so ANY non-managed control
|
|
903
|
+
* (external, observed, tolerated) suppresses the whole unit. Drift on an
|
|
904
|
+
* object the plan does not manage is reported, never repaired; the
|
|
905
|
+
* suppression subject names the drifted policy (`rlsPolicy`) so the
|
|
906
|
+
* report says which policy drifted, matching the conflict path's
|
|
907
|
+
* `location.rlsPolicy`.
|
|
908
|
+
*/
|
|
909
|
+
function gradePolicyReplacement(replacement, contract, allowedOperationClasses) {
|
|
910
|
+
const subject = resolvePostgresCallControlPolicySubject(replacement.drop, contract);
|
|
911
|
+
const controlPolicy = governingControlPolicy(subject, contract.defaultControlPolicy);
|
|
912
|
+
if (controlPolicy !== "managed") return {
|
|
913
|
+
disposition: "suppress",
|
|
914
|
+
record: {
|
|
915
|
+
subject: subject === void 0 ? void 0 : {
|
|
916
|
+
...subject,
|
|
917
|
+
rlsPolicy: replacement.drop.policyName
|
|
918
|
+
},
|
|
919
|
+
policy: controlPolicy,
|
|
920
|
+
factoryName: void 0,
|
|
921
|
+
createsNewObject: false
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
if (!allowedOperationClasses.includes("widening")) return {
|
|
925
|
+
disposition: "conflict",
|
|
926
|
+
conflict: conflictForDisallowedCall(replacement.drop, allowedOperationClasses)
|
|
927
|
+
};
|
|
928
|
+
return { disposition: "plan" };
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Rebuilds the `PostgresRlsPolicy` contract entity `CreatePostgresRlsPolicyCall`
|
|
932
|
+
* carries (its `renderTypeScript`/`createRlsPolicy` paths serialize the whole
|
|
933
|
+
* entity, `namespaceId` included). This reconstructs rather than looking the
|
|
934
|
+
* original up in the contract on purpose: the diff node's `namespaceId` is the
|
|
935
|
+
* *resolved DDL schema* (set when the expected tree was built), which is the
|
|
936
|
+
* value the emitted op must carry; the contract-stored entity holds the raw,
|
|
937
|
+
* pre-resolution coordinate, so a lookup would change the migration output.
|
|
938
|
+
*/
|
|
939
|
+
function policyNodeToContractPolicy(node) {
|
|
940
|
+
return new PostgresRlsPolicy({
|
|
941
|
+
naming: namingOf(node.name, node.prefix),
|
|
942
|
+
tableName: node.tableName,
|
|
943
|
+
namespaceId: node.namespaceId,
|
|
944
|
+
operation: node.operation,
|
|
945
|
+
roles: [...node.roles],
|
|
946
|
+
using: node.using,
|
|
947
|
+
withCheck: node.withCheck,
|
|
948
|
+
permissive: node.permissive
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
//#endregion
|
|
952
|
+
export { createPostgresMigrationPlanner as t };
|
|
953
|
+
|
|
954
|
+
//# sourceMappingURL=planner-VuR6URu3-CCUT2Osx.mjs.map
|