@prisma/orm-target-postgres 8.0.0-rc.16-dev.4 → 8.0.0-rc.16-dev.6
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/dist/{adapter-BB0VVFW2.d.mts → adapter-BXHPMNAg.d.mts} +3 -3
- package/dist/{adapter-BB0VVFW2.d.mts.map → adapter-BXHPMNAg.d.mts.map} +1 -1
- package/dist/{adapter-RtS8vD8U-BvmL3EaF.mjs → adapter-RtS8vD8U-BnPjAiLV.mjs} +5 -5
- package/dist/{adapter-RtS8vD8U-BvmL3EaF.mjs.map → adapter-RtS8vD8U-BnPjAiLV.mjs.map} +1 -1
- package/dist/adapter.d.mts +7 -7
- package/dist/adapter.mjs +6 -6
- package/dist/adapter__adapter.d.mts +1 -1
- package/dist/adapter__adapter.mjs +2 -2
- package/dist/adapter__control.d.mts +2 -2
- package/dist/adapter__control.mjs +7 -7
- package/dist/adapter__runtime.d.mts +1 -1
- package/dist/adapter__runtime.mjs +4 -4
- package/dist/adapter__sql-renderer.d.mts +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/adapter__types.d.mts +3 -3
- package/dist/{authoring-CfPWv_-P-BHAGgGYI.mjs → authoring-B2hHIzvd-D5NgHs0e.mjs} +5 -5
- package/dist/{authoring-CfPWv_-P-BHAGgGYI.mjs.map → authoring-B2hHIzvd-D5NgHs0e.mjs.map} +1 -1
- package/dist/{check-expressions-BRuSxJ5d-CC5OFfR1.mjs → check-expressions-BaFrBceq-ChgvazEN.mjs} +15 -13
- package/dist/check-expressions-BaFrBceq-ChgvazEN.mjs.map +1 -0
- package/dist/{check-expressions-CBIgoKhV-D7oTR8lp.d.mts → check-expressions-CtTzM58x-CsWFEeul.d.mts} +6 -5
- package/dist/check-expressions-CtTzM58x-CsWFEeul.d.mts.map +1 -0
- package/dist/{codec-descriptor-CZAGhM_O-DK9auM7J.mjs → codec-descriptor-C5Ec_6Mw-CpacG1CL.mjs} +3 -2
- package/dist/codec-descriptor-C5Ec_6Mw-CpacG1CL.mjs.map +1 -0
- package/dist/{codec-helpers-D015Pvwa-DR7WMloQ.mjs → codec-helpers-D0ah5Wb8-wdJJZ_8s.mjs} +244 -3
- package/dist/codec-helpers-D0ah5Wb8-wdJJZ_8s.mjs.map +1 -0
- package/dist/{codec-registry-CyhMngN6-BlKEiEni.mjs → codec-registry-CKBDkxX7-Kw84Or3s.mjs} +5 -5
- package/dist/{codec-registry-CyhMngN6-BlKEiEni.mjs.map → codec-registry-CKBDkxX7-Kw84Or3s.mjs.map} +1 -1
- package/dist/{codec-type-map-DftCqvHU-BYkGKRZI.d.mts → codec-type-map-DueQFJ3a-DKLtMn3R.d.mts} +3 -3
- package/dist/{codec-type-map-DftCqvHU-BYkGKRZI.d.mts.map → codec-type-map-DueQFJ3a-DKLtMn3R.d.mts.map} +1 -1
- package/dist/codec-types-CY3pawL3.d.mts +2 -0
- package/dist/{codec-types-CHtW4cn_-ryYZXjOb.d.mts → codec-types-CYsrudBM-DcYPKpS1.d.mts} +4 -4
- package/dist/{codec-types-CHtW4cn_-ryYZXjOb.d.mts.map → codec-types-CYsrudBM-DcYPKpS1.d.mts.map} +1 -1
- package/dist/{codecs-hSJgX8qY-fZSDQFIE.mjs → codecs-BK3J4C0n-B8EnUXZf.mjs} +49 -37
- package/dist/codecs-BK3J4C0n-B8EnUXZf.mjs.map +1 -0
- package/dist/{codecs-Djhvng3f.d.mts → codecs-ChjCJY5k.d.mts} +2 -2
- package/dist/{codecs-Djhvng3f.d.mts.map → codecs-ChjCJY5k.d.mts.map} +1 -1
- package/dist/{codecs-CvG9lv7r-9RlHwf9Y.d.mts → codecs-y1gOMMt--DKWhYGN5.d.mts} +8 -2
- package/dist/codecs-y1gOMMt--DKWhYGN5.d.mts.map +1 -0
- package/dist/{contract-free-DlLLhKi4.d.mts → contract-free-DY8vDIxh.d.mts} +19 -2
- package/dist/contract-free-DY8vDIxh.d.mts.map +1 -0
- package/dist/{contract-free-DAGgx1J-.mjs → contract-free-DaK6wmmo.mjs} +3 -3
- package/dist/contract-free-DaK6wmmo.mjs.map +1 -0
- package/dist/{control-BVAy0J9w.mjs → control-Bpd77Aeq.mjs} +11 -11
- package/dist/{control-BVAy0J9w.mjs.map → control-Bpd77Aeq.mjs.map} +1 -1
- package/dist/{control-CHqdVXHC.d.mts → control-D2JNE1Tz.d.mts} +3 -3
- package/dist/{control-CHqdVXHC.d.mts.map → control-D2JNE1Tz.d.mts.map} +1 -1
- package/dist/{control-adapter-Co30P4lH-B8vk7fsI.mjs → control-adapter-Co30P4lH-e6oCFCC2.mjs} +7 -7
- package/dist/{control-adapter-Co30P4lH-B8vk7fsI.mjs.map → control-adapter-Co30P4lH-e6oCFCC2.mjs.map} +1 -1
- package/dist/{control-policy-C16wMazs-O_wlPuFC.mjs → control-policy-B7t5CB1S-CotIwNO4.mjs} +16 -22
- package/dist/control-policy-B7t5CB1S-CotIwNO4.mjs.map +1 -0
- package/dist/{data-type-entries-C2zpNOAQ-BJh8QNDa.mjs → data-type-entries-DoR61yeO-BB2cY7rI.mjs} +3 -3
- package/dist/{data-type-entries-C2zpNOAQ-BJh8QNDa.mjs.map → data-type-entries-DoR61yeO-BB2cY7rI.mjs.map} +1 -1
- package/dist/{data-types-E1wms1_i.d.mts → data-types-BDkZIUMI.d.mts} +4 -2
- package/dist/{data-types-E1wms1_i.d.mts.map → data-types-BDkZIUMI.d.mts.map} +1 -1
- package/dist/{data-types-BRBW3ouc-ZtyZE7nE.mjs → data-types-DRkmmE9S-C5Q9oH4Q.mjs} +14 -5
- package/dist/data-types-DRkmmE9S-C5Q9oH4Q.mjs.map +1 -0
- package/dist/{ddl-BzsT_-qY-Cdzm0YIK.mjs → ddl-C_vTj7b5-vyGLBKLo.mjs} +50 -5
- package/dist/ddl-C_vTj7b5-vyGLBKLo.mjs.map +1 -0
- package/dist/default-constraint-names-CtcRXhV8-nz3ff6b8.mjs +18 -0
- package/dist/default-constraint-names-CtcRXhV8-nz3ff6b8.mjs.map +1 -0
- package/dist/{default-normalizer-CrMBHF0W-BaUR4Ec8.mjs → default-normalizer-Bf_Fhv4v-CugGfLAe.mjs} +12 -7
- package/dist/default-normalizer-Bf_Fhv4v-CugGfLAe.mjs.map +1 -0
- package/dist/{descriptor-meta-ARufwwWW-DUiQQsOX.mjs → descriptor-meta-ARufwwWW-C5hsT7UQ.mjs} +3 -3
- package/dist/{descriptor-meta-ARufwwWW-DUiQQsOX.mjs.map → descriptor-meta-ARufwwWW-C5hsT7UQ.mjs.map} +1 -1
- package/dist/{descriptor-meta-Dp8tWKKU-5RiFTCA_.mjs → descriptor-meta-C8lkQFHe-Cluy19Tk.mjs} +8 -8
- package/dist/{descriptor-meta-Dp8tWKKU-5RiFTCA_.mjs.map → descriptor-meta-C8lkQFHe-Cluy19Tk.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-BycwK4wx-CuDo_Atu.mjs → descriptor-meta-runtime-iArZEoCE-GhLNDdg-.mjs} +3 -3
- package/dist/{descriptor-meta-runtime-BycwK4wx-CuDo_Atu.mjs.map → descriptor-meta-runtime-iArZEoCE-GhLNDdg-.mjs.map} +1 -1
- package/dist/{diff-database-schema-DRPIV4Ae-BSY-cBm0.mjs → diff-database-schema-KGNaKzKp-Bt2yYSIt.mjs} +6 -6
- package/dist/{diff-database-schema-DRPIV4Ae-BSY-cBm0.mjs.map → diff-database-schema-KGNaKzKp-Bt2yYSIt.mjs.map} +1 -1
- package/dist/{full-text-D5pW25-Y.d.mts → full-text-CCqTEQ9y.d.mts} +2 -2
- package/dist/{full-text-D5pW25-Y.d.mts.map → full-text-CCqTEQ9y.d.mts.map} +1 -1
- package/dist/{full-text-index-expression-2O1p7zJA--CcXJUdq.mjs → full-text-index-expression-Bfp_xWhy-DtbLdkzv.mjs} +4 -4
- package/dist/{full-text-index-expression-2O1p7zJA--CcXJUdq.mjs.map → full-text-index-expression-Bfp_xWhy-DtbLdkzv.mjs.map} +1 -1
- package/dist/{full-text-parsers-BhjgmAe5-CyF7dp_b.d.mts → full-text-parsers-DrS_1B-x-BcAnBoQP.d.mts} +3 -3
- package/dist/{full-text-parsers-BhjgmAe5-CyF7dp_b.d.mts.map → full-text-parsers-DrS_1B-x-BcAnBoQP.d.mts.map} +1 -1
- package/dist/{infer-psl-contract-shHWsRbe-C65aVFOB.mjs → infer-psl-contract-DoIdoifj-Co9thnGu.mjs} +7 -7
- package/dist/{infer-psl-contract-shHWsRbe-C65aVFOB.mjs.map → infer-psl-contract-DoIdoifj-Co9thnGu.mjs.map} +1 -1
- package/dist/migration-PTHAY9Cv.mjs.map +1 -1
- package/dist/{op-factory-call-B-4nf1jC-DkRw5e1q.mjs → op-factory-call-BAgAln5R-BTkhp29z.mjs} +70 -18
- package/dist/op-factory-call-BAgAln5R-BTkhp29z.mjs.map +1 -0
- package/dist/{operation-types-Be5rdu14.d.mts → operation-types-CjJY7prP.d.mts} +2 -2
- package/dist/{operation-types-Be5rdu14.d.mts.map → operation-types-CjJY7prP.d.mts.map} +1 -1
- package/dist/{pack-DHV9zslZ.d.mts → pack-Bq9yq-OS.d.mts} +4 -4
- package/dist/{pack-DHV9zslZ.d.mts.map → pack-Bq9yq-OS.d.mts.map} +1 -1
- package/dist/{planner-B5wkfdZ_-bckhSgt5.mjs → planner-DSTSuAc8-BAfUo5KV.mjs} +16 -12
- package/dist/planner-DSTSuAc8-BAfUo5KV.mjs.map +1 -0
- package/dist/{planner-ddl-builders-ClaAKDuZ-DpDBj2cs.mjs → planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs} +44 -14
- package/dist/planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs.map +1 -0
- package/dist/{planner-identity-values-BZpK0CdX-BJo672Ml.mjs → planner-identity-values-CRS2cQ6v-DakZeIQj.mjs} +3 -3
- package/dist/{planner-identity-values-BZpK0CdX-BJo672Ml.mjs.map → planner-identity-values-CRS2cQ6v-DakZeIQj.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-B3dM0fTf-XkTUm5wR.mjs → planner-produced-postgres-migration-D7-3OBb_-BGHFKj3i.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-B3dM0fTf-XkTUm5wR.mjs.map → planner-produced-postgres-migration-D7-3OBb_-BGHFKj3i.mjs.map} +1 -1
- package/dist/{planner-sql-checks-Bhp0Iq_X-DwwIxJHj.mjs → planner-sql-checks-rqOH8naU-B6xOE5lC.mjs} +4 -4
- package/dist/{planner-sql-checks-Bhp0Iq_X-DwwIxJHj.mjs.map → planner-sql-checks-rqOH8naU-B6xOE5lC.mjs.map} +1 -1
- package/dist/{postgres-contract-view-rT0ZLNqw-DThfALEV.mjs → postgres-contract-view-C1bi3x4v-BAfk6euQ.mjs} +6 -6
- package/dist/{postgres-contract-view-rT0ZLNqw-DThfALEV.mjs.map → postgres-contract-view-C1bi3x4v-BAfk6euQ.mjs.map} +1 -1
- package/dist/{postgres-migration-CmD95Eh_-DGLByWZD.mjs → postgres-migration-CeX6vfEU-DsmCRCnD.mjs} +85 -59
- package/dist/postgres-migration-CeX6vfEU-DsmCRCnD.mjs.map +1 -0
- package/dist/postgres-object-name-FPikIvOw-BNs44hTu.mjs +23 -0
- package/dist/postgres-object-name-FPikIvOw-BNs44hTu.mjs.map +1 -0
- package/dist/{postgres-schema-DXd0mebY-CExd_GcQ.mjs → postgres-schema-AlEVkXXS-ZfXWYddl.mjs} +3 -3
- package/dist/{postgres-schema-DXd0mebY-CExd_GcQ.mjs.map → postgres-schema-AlEVkXXS-ZfXWYddl.mjs.map} +1 -1
- package/dist/{prisma7-binding-CArLf1qk.mjs → prisma7-binding-B4BfqE0o.mjs} +12 -7
- package/dist/prisma7-binding-B4BfqE0o.mjs.map +1 -0
- package/dist/{prisma7-binding-DNckHEx8.d.mts → prisma7-binding-Dm34z6Fq.d.mts} +14 -4
- package/dist/prisma7-binding-Dm34z6Fq.d.mts.map +1 -0
- package/dist/{resolve-ddl-schema-CadTChyu-C7F31wpN.mjs → resolve-ddl-schema-BthOWVjF-DuZ9iUh-.mjs} +3 -3
- package/dist/{resolve-ddl-schema-CadTChyu-C7F31wpN.mjs.map → resolve-ddl-schema-BthOWVjF-DuZ9iUh-.mjs.map} +1 -1
- package/dist/{runtime-aejvKbMy.d.mts → runtime-CNTEAZIz.d.mts} +2 -2
- package/dist/{runtime-aejvKbMy.d.mts.map → runtime-CNTEAZIz.d.mts.map} +1 -1
- package/dist/{sql-renderer-DT4IEOVi-G0Q8NmyB.mjs → sql-renderer-DT4IEOVi-CBE8uTub.mjs} +3 -3
- package/dist/{sql-renderer-DT4IEOVi-G0Q8NmyB.mjs.map → sql-renderer-DT4IEOVi-CBE8uTub.mjs.map} +1 -1
- package/dist/{sql-renderer-B1ZLRgUw.d.mts → sql-renderer-hQ3HTY-B.d.mts} +2 -2
- package/dist/{sql-renderer-B1ZLRgUw.d.mts.map → sql-renderer-hQ3HTY-B.d.mts.map} +1 -1
- package/dist/{sql-utils-BMXJi06b-CAQOplfq.mjs → sql-utils-CVsvXiX4-C7xD0Bgv.mjs} +5 -9
- package/dist/sql-utils-CVsvXiX4-C7xD0Bgv.mjs.map +1 -0
- package/dist/target.d.mts +14 -14
- package/dist/target.mjs +27 -27
- package/dist/target__codec-descriptor.mjs +1 -1
- package/dist/target__codec-types.d.mts +3 -3
- package/dist/target__codecs.d.mts +2 -2
- package/dist/target__codecs.mjs +2 -2
- package/dist/target__contract-free.d.mts +2 -2
- package/dist/target__contract-free.mjs +4 -4
- package/dist/target__control.mjs +3 -3
- package/dist/target__data-types.d.mts +1 -1
- package/dist/target__data-types.mjs +2 -2
- package/dist/target__default-normalizer.mjs +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__full-text.d.mts +2 -2
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__operation-types.d.mts +1 -1
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.mjs +1 -1
- package/dist/target__planner-identity-values.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner-sql-checks.mjs +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.d.mts +1 -1
- package/dist/target__prisma7-binding.mjs +1 -1
- package/dist/target__runtime.mjs +3 -3
- package/dist/target__runtime.mjs.map +1 -1
- package/dist/target__schema-ir-annotations.mjs +1 -1
- package/dist/target__sql-utils.mjs +2 -2
- package/dist/target__types.d.mts +2 -2
- package/dist/target__types.mjs +2 -2
- package/dist/{types-D799eppJ.d.mts → types-BP1e5MBV.d.mts} +2 -2
- package/dist/{types-D799eppJ.d.mts.map → types-BP1e5MBV.d.mts.map} +1 -1
- package/dist/{types-D6lgKhE5-Cu48rrw9.d.mts → types-D6lgKhE5-DYkeCAjr.d.mts} +2 -2
- package/dist/{types-D6lgKhE5-Cu48rrw9.d.mts.map → types-D6lgKhE5-DYkeCAjr.d.mts.map} +1 -1
- package/dist/types-Dnrjripb.d.mts +2 -0
- package/package.json +9 -9
- package/dist/check-expressions-BRuSxJ5d-CC5OFfR1.mjs.map +0 -1
- package/dist/check-expressions-CBIgoKhV-D7oTR8lp.d.mts.map +0 -1
- package/dist/codec-descriptor-CZAGhM_O-DK9auM7J.mjs.map +0 -1
- package/dist/codec-helpers-D015Pvwa-DR7WMloQ.mjs.map +0 -1
- package/dist/codec-types-DQUtpepT.d.mts +0 -2
- package/dist/codecs-CvG9lv7r-9RlHwf9Y.d.mts.map +0 -1
- package/dist/codecs-hSJgX8qY-fZSDQFIE.mjs.map +0 -1
- package/dist/contract-free-DAGgx1J-.mjs.map +0 -1
- package/dist/contract-free-DlLLhKi4.d.mts.map +0 -1
- package/dist/control-policy-C16wMazs-O_wlPuFC.mjs.map +0 -1
- package/dist/data-types-BRBW3ouc-ZtyZE7nE.mjs.map +0 -1
- package/dist/ddl-BzsT_-qY-Cdzm0YIK.mjs.map +0 -1
- package/dist/default-normalizer-CrMBHF0W-BaUR4Ec8.mjs.map +0 -1
- package/dist/op-factory-call-B-4nf1jC-DkRw5e1q.mjs.map +0 -1
- package/dist/planner-B5wkfdZ_-bckhSgt5.mjs.map +0 -1
- package/dist/planner-ddl-builders-ClaAKDuZ-DpDBj2cs.mjs.map +0 -1
- package/dist/postgres-migration-CmD95Eh_-DGLByWZD.mjs.map +0 -1
- package/dist/prisma7-binding-CArLf1qk.mjs.map +0 -1
- package/dist/prisma7-binding-DNckHEx8.d.mts.map +0 -1
- package/dist/sql-utils-BMXJi06b-CAQOplfq.mjs.map +0 -1
- package/dist/types-CdJszzhP.d.mts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-DSTSuAc8-BAfUo5KV.mjs","names":["#lowerer"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-DSTSuAc8.mjs"],"sourcesContent":["import { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { _ as PostgresRlsPolicy, r as isPostgresSchema } from \"./postgres-schema-AlEVkXXS.mjs\";\nimport { t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-BthOWVjF.mjs\";\nimport { t as buildPostgresPlanDiff } from \"./diff-database-schema-KGNaKzKp.mjs\";\nimport { a as resolvePostgresNodeIssueCreationFactoryName, c as issueNode, d as postgresPlannerStrategies, f as postgresNodeStorageCoordinate, i as resolvePostgresNodeIssueControlPolicySubject, l as issueSchemaName, n as resolveNamespaceIdForDdlSchema, o as coalesceSubtreeIssues, r as resolvePostgresCallControlPolicySubject, s as conflictForDisallowedCall, t as renderPostgresSuppression, u as planIssues } from \"./control-policy-B7t5CB1S.mjs\";\nimport { C as DropNativeEnumTypeCall, E as DropTableCall, M as RenameTableCall, O as RawSqlCall, R as renameTableStatement, T as DropPostgresRlsPolicyCall, j as RenamePostgresRlsPolicyCall, l as AlterColumnTypeCall, p as CreatePostgresRlsPolicyCall, y as DropColumnCall } from \"./op-factory-call-BAgAln5R.mjs\";\nimport { a as plannedConstraintNameRenames, i as pairIndexRenames, n as emissionSchemaForNamespace, r as pairCheckRenames } from \"./postgres-migration-CeX6vfEU.mjs\";\nimport { t as TypeScriptRenderablePostgresMigration } from \"./planner-produced-postgres-migration-D7-3OBb_.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { controlPolicyForCall, detectTableNameCaseChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, sqlTypeLookupsOf } from \"@internal/family-sql/control\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/migrations/verify-postgres-namespaces.ts\n/**\n* Resolves the live-database schema name for a given namespace\n* coordinate. Mirrors `resolveDdlSchemaForNamespace` in\n* `planner-strategies.ts` so the verifier's projection and the\n* planner's projection always agree — Postgres-aware namespaces (the\n* production path) dispatch to `ddlSchemaName(storage)`, and bare\n* object payloads (used by some tests) fall back to the coordinate\n* itself.\n*/\nfunction resolveDdlSchemaName(storage, namespaceId) {\n\tconst namespace = storage.namespaces[namespaceId];\n\tif (isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);\n\treturn namespaceId;\n}\n/**\n* Reads the introspected list of schema names from the database-root schema\n* node. `existingSchemas` is database-level, so it lives on the\n* `PostgresDatabaseSchemaNode` root — not on the per-schema namespace nodes.\n*\n* Defaults to the always-present `public` schema when the node is not the\n* database root — a fresh Postgres database always carries `public` (unless an\n* operator dropped it manually), so any verifier path that runs without an\n* enriched introspection still suppresses the redundant `CREATE SCHEMA\n* \"public\"`.\n*\n* Production introspection (`PostgresControlAdapter.introspect`) is the\n* authoritative source: it queries `pg_namespace` and sets `existingSchemas`\n* on the returned root. Tests that want to assert against a richer initial\n* state construct a `PostgresDatabaseSchemaNode` explicitly.\n*/\nfunction existingSchemasFromSchema(schema) {\n\tif (PostgresDatabaseSchemaNode.is(schema)) return schema.existingSchemas;\n\treturn [DEFAULT_NAMESPACE_ID];\n}\n/**\n* Emits a `postgres-namespace` `not-found` diff issue for every\n* contract-declared Postgres namespace whose live container does not yet\n* exist. The planner prepends these (node-typed, synthesized) to the\n* relational diff issues so a multi-schema plan emits `CREATE SCHEMA`\n* before the tables that need it — a planner-only concern (verify already\n* rejects via the `not-found` table issues a missing schema already\n* produces), so this is not part of the shared diff.\n*\n* A namespace's live container is the schema returned by its\n* polymorphic `ddlSchemaName(storage)` method — named schemas resolve\n* to their own id; the unbound singleton returns `UNBOUND_NAMESPACE_ID`\n* and is skipped explicitly (late-bound namespaces have no fixed DDL\n* schema). Issues are emitted only when the resolved name is a real,\n* creatable schema (not the unbound sentinel) and is missing from the\n* introspected list. `public` is suppressed implicitly because the\n* introspection (or its sensible default) always carries it.\n*\n* Each emitted issue's path is `['database', ddlName]` — an ancestor of\n* every table path under that schema, so it must never be run through\n* `coalesceSubtreeIssues` alongside the table diff (it would swallow the\n* table-level `not-found` issues that drive `CREATE TABLE`); the planner\n* adds these AFTER coalescing the relational issues, and they are not\n* subject to sibling-space ownership scoping (mirrors the retired\n* coordinate walk, which prepended namespace issues after that filter).\n*/\nfunction verifyPostgresNamespacePresence(input) {\n\tconst { contract, schema } = input;\n\tconst existing = new Set(existingSchemasFromSchema(schema));\n\tconst issues = [];\n\tconst namespaceIds = Object.keys(contract.storage.namespaces).sort();\n\tfor (const namespaceId of namespaceIds) {\n\t\tif (namespaceId === UNBOUND_NAMESPACE_ID) continue;\n\t\tconst ddlName = resolveDdlSchemaName(contract.storage, namespaceId);\n\t\tif (ddlName === UNBOUND_NAMESPACE_ID) continue;\n\t\tif (existing.has(ddlName)) continue;\n\t\tconst namespace = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlName,\n\t\t\ttables: {}\n\t\t});\n\t\tissues.push({\n\t\t\tpath: [\"database\", ddlName],\n\t\t\texpected: namespace\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/core/migrations/planner.ts\nfunction partitionPostgresCallsByControlPolicy(calls, contract) {\n\treturn partitionCallsByControlPolicy({\n\t\tcalls,\n\t\tcontract,\n\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, contract),\n\t\tresolveFactoryName: (call) => call.factoryName\n\t});\n}\nfunction createPostgresMigrationPlanner(lowerer) {\n\treturn new PostgresMigrationPlanner(lowerer);\n}\n/**\n* Postgres migration planner — a thin wrapper over `planIssues`.\n*\n* `plan()` diffs the target contract against the live schema via the one\n* differ (`buildPostgresPlanDiff`, producing node-typed `SchemaDiffIssue[]`)\n* and delegates to `planIssues` with the unified `postgresPlannerStrategies`\n* list: NOT-NULL backfill, type-change, nullable-tightening, codec-hook\n* storage types, component-declared dependency installs, and\n* shared-temp-default / empty-table-guarded NOT-NULL add-column. The same\n* strategy list runs for `migration plan`, `db update`, and `db init`;\n* behavior diverges purely on `policy.allowedOperationClasses` (the\n* data-safe strategies short-circuit when `'data'` is excluded). The issue\n* planner applies operation-class policy gates and emits a single\n* `PostgresOpFactoryCall[]` that drives both the runtime-ops view (via\n* `renderOps`) and the `renderTypeScript()` authoring surface. RLS policy\n* drift (the structural half of the same one-differ tree) is handled\n* separately via `planPostgresSchemaDiff`.\n*/\nvar PostgresMigrationPlanner = class {\n\t#lowerer;\n\tconstructor(lowerer) {\n\t\tthis.#lowerer = lowerer;\n\t}\n\tplan(options) {\n\t\treturn this.planSql(blindCast(options));\n\t}\n\temptyMigration(context, spaceId) {\n\t\treturn new TypeScriptRenderablePostgresMigration([], {\n\t\t\tfrom: context.fromHash,\n\t\t\tto: context.toHash\n\t\t}, spaceId, context.snapshotsImportPath, this.#lowerer);\n\t}\n\tplanSql(options) {\n\t\tconst schemaName = options.schemaName ?? Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;\n\t\tconst policyResult = this.ensureAdditivePolicy(options.policy);\n\t\tif (policyResult) return policyResult;\n\t\tPostgresDatabaseSchemaNode.assert(options.schema);\n\t\tconst { issues: rawIssues } = buildPostgresPlanDiff({\n\t\t\tcontract: options.contract,\n\t\t\tactualSchema: options.schema,\n\t\t\tframeworkComponents: options.frameworkComponents\n\t\t});\n\t\tconst policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue));\n\t\tconst relationalDiffIssues = rawIssues.filter((issue) => !isPolicyDiffIssue(issue));\n\t\tconst strict = options.policy.allowedOperationClasses.includes(\"widening\") || options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst owned = retainUnownedExtras(coalesceSubtreeIssues(relationalDiffIssues), options.ownership, options.contract);\n\t\tconst gated = strict ? owned : owned.filter((issue) => issueOutcome(issue) !== \"not-expected\");\n\t\tconst schemaIssues = [...verifyPostgresNamespacePresence({\n\t\t\tcontract: options.contract,\n\t\t\tschema: options.schema\n\t\t}), ...gated];\n\t\tconst indexRenames = pairIndexRenames(options, schemaIssues);\n\t\tconst checkRenames = pairCheckRenames(options, schemaIssues);\n\t\tconst renameConsumed = /* @__PURE__ */ new Set([...indexRenames.consumed, ...checkRenames.consumed]);\n\t\tconst plannableIssues = renameConsumed.size === 0 ? schemaIssues : schemaIssues.filter((issue) => !renameConsumed.has(issue));\n\t\tconst codecHooks = extractCodecControlHooks(options.frameworkComponents);\n\t\tconst types = sqlTypeLookupsOf(options.frameworkComponents);\n\t\tconst storageTypes = options.contract.storage.types ?? {};\n\t\tconst relationalSchema = relationalNamespaceNode(options.schema, schemaName);\n\t\tconst issuePartition = partitionIssuesByControlPolicy({\n\t\t\tissues: plannableIssues,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n\t\t\tresolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName\n\t\t});\n\t\tconst caseChangeConflicts = detectTableNameCaseChanges({\n\t\t\tissues: issuePartition.plannable,\n\t\t\ttableOf: (issue) => {\n\t\t\t\tconst node = issueNode(issue);\n\t\t\t\treturn node !== void 0 && PostgresTableSchemaNode.is(node) ? node : void 0;\n\t\t\t},\n\t\t\tnamespaceIdOf: (issue) => resolveNamespaceIdForDdlSchema(options.contract, issueSchemaName(issue) ?? schemaName),\n\t\t\trenameByHandStatements: (rename) => [renameTableStatement(emissionSchemaForNamespace(options.contract, rename.namespaceId), rename.from, rename.to)],\n\t\t\trenameTableCall: (rename) => new RenameTableCall(rename.namespaceId ?? UNBOUND_NAMESPACE_ID, rename.from, rename.to).renderTypeScript(),\n\t\t\tcontract: options.contract,\n\t\t\tdefaultNamespaceId: DEFAULT_NAMESPACE_ID\n\t\t});\n\t\tif (caseChangeConflicts.length > 0) return plannerFailure(caseChangeConflicts);\n\t\tconst result = planIssues({\n\t\t\tissues: issuePartition.plannable,\n\t\t\ttoContract: options.contract,\n\t\t\tfromContract: options.fromContract,\n\t\t\tschemaName,\n\t\t\tcodecHooks,\n\t\t\ttypes,\n\t\t\tstorageTypes,\n\t\t\t...ifDefined(\"schema\", relationalSchema),\n\t\t\tpolicy: options.policy,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\tstrategies: postgresPlannerStrategies\n\t\t});\n\t\tconst schemaDiff = this.planPostgresSchemaDiff(options, policyDiffIssues);\n\t\tif (!result.ok || schemaDiff.conflicts.length > 0) return plannerFailure([...result.ok ? [] : result.failure, ...schemaDiff.conflicts]);\n\t\tconst renamePartition = partitionPostgresCallsByControlPolicy([\n\t\t\t...indexRenames.calls,\n\t\t\t...checkRenames.calls,\n\t\t\t...plannedConstraintNameRenames(options)\n\t\t], options.contract);\n\t\tconst schemaDiffPartition = partitionPostgresCallsByControlPolicy(schemaDiff.calls, options.contract);\n\t\tconst fieldEventPartition = partitionPostgresCallsByControlPolicy(blindCast(planFieldEventOperations({\n\t\t\tpriorContract: options.fromContract,\n\t\t\tnewContract: options.contract,\n\t\t\tcodecHooks\n\t\t})), options.contract);\n\t\tconst ordered = movePolicyDropsBeforeBlockedDdl(result.value.calls, schemaDiffPartition.kept);\n\t\tconst calls = [\n\t\t\t...ordered.structural,\n\t\t\t...renamePartition.kept,\n\t\t\t...ordered.policyCalls,\n\t\t\t...fieldEventPartition.kept\n\t\t];\n\t\tconst seenWarnings = /* @__PURE__ */ new Set();\n\t\tconst warnings = [\n\t\t\t...issuePartition.suppressions,\n\t\t\t...renamePartition.suppressions,\n\t\t\t...schemaDiff.suppressions,\n\t\t\t...schemaDiffPartition.suppressions,\n\t\t\t...fieldEventPartition.suppressions\n\t\t].map((record) => renderPostgresSuppression(record, options.contract)).filter((warning) => {\n\t\t\tconst key = JSON.stringify(warning);\n\t\t\tif (seenWarnings.has(key)) return false;\n\t\t\tseenWarnings.add(key);\n\t\t\treturn true;\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tkind: \"success\",\n\t\t\tplan: new TypeScriptRenderablePostgresMigration(calls, {\n\t\t\t\tfrom: options.fromContract?.storage.storageHash ?? null,\n\t\t\t\tto: options.contract.storage.storageHash\n\t\t\t}, options.spaceId, options.snapshotsImportPath, this.#lowerer),\n\t\t\t...warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}\n\t\t});\n\t}\n\t/**\n\t* Maps the RLS policy findings of the one combined tree diff\n\t* (`buildPostgresPlanDiff`, already ownership-filtered) into\n\t* `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops — a\n\t* `not-equal` finding (an exact-named policy whose content drifted)\n\t* becomes drop + create, or a disallowed-call conflict when the policy\n\t* forbids the destructive drop. It\n\t* does not re-diff — it consumes exactly the policy-node subset of the\n\t* shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE\n\t* ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`\n\t* attribute diff on the relational side.\n\t*\n\t* Rename post-pass (the index pass's structure): hash pairing pairs a\n\t* `not-found` and a `not-expected` policy on the SAME table whose\n\t* wire-name content hashes match but prefixes differ (prefix-only rename);\n\t* content pairing then pairs remaining wire-named-missing policies against remaining\n\t* extras of any name shape by verbatim content (the node-owned `contentEquals` —\n\t* exact→wire adoption). Multi-candidate groups pair deterministically\n\t* by sorted name; leftovers proceed as create/drop; an exact-named\n\t* missing policy never content-pairs.\n\t*\n\t* The pairing runs only when the policy allows `widening` (rename's\n\t* class). Without it (db-init's additive-only set), pairing degrades\n\t* deliberately to the additive half: the new name is CREATEd and the old\n\t* policy survives live until a widening/destructive-allowed plan runs —\n\t* emitting an ungated widening rename would only fail at the runner's\n\t* class re-enforcement.\n\t*/\n\tplanPostgresSchemaDiff(options, filteredDiffIssues) {\n\t\tconst allowsDestructive = options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst allowsWidening = options.policy.allowedOperationClasses.includes(\"widening\");\n\t\tconst missing = [];\n\t\tconst extra = [];\n\t\tconst changed = [];\n\t\tfor (const issue of filteredDiffIssues) if (issueOutcome(issue) === \"not-equal\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tchanged.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-found\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tmissing.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-expected\") {\n\t\t\tconst actual = issue.actual;\n\t\t\tPostgresPolicySchemaNode.assert(actual);\n\t\t\textra.push({\n\t\t\t\tnode: actual,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, actual.namespaceId)\n\t\t\t});\n\t\t}\n\t\tconst calls = [];\n\t\tconst conflicts = [];\n\t\tconst suppressions = [];\n\t\tconst renamedExtras = /* @__PURE__ */ new Set();\n\t\tconst renamedMissing = /* @__PURE__ */ new Set();\n\t\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\t\tfinding.schemaForTable,\n\t\t\tfinding.node.tableName,\n\t\t\thash\n\t\t]);\n\t\tif (allowsWidening) {\n\t\t\tconst extrasByGroup = /* @__PURE__ */ new Map();\n\t\t\tfor (const finding of extra) {\n\t\t\t\tconst parsed = parseWireName(finding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst key = pairingKey(finding, parsed.hash);\n\t\t\t\tconst group = extrasByGroup.get(key) ?? [];\n\t\t\t\tgroup.push(finding);\n\t\t\t\textrasByGroup.set(key, group);\n\t\t\t}\n\t\t\tfor (const group of extrasByGroup.values()) group.sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tconst sortedMissing = [...missing].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst candidate = extrasByGroup.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t\tconst sortedExtras = [...extra].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tif (renamedMissing.has(missingFinding)) continue;\n\t\t\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\t\t\tconst candidate = sortedExtras.find((extraFinding) => !renamedExtras.has(extraFinding) && extraFinding.schemaForTable === missingFinding.schemaForTable && extraFinding.node.tableName === missingFinding.node.tableName && missingFinding.node.contentEquals(extraFinding.node));\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t}\n\t\tfor (const finding of changed) {\n\t\t\tconst replacement = {\n\t\t\t\tdrop: new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name),\n\t\t\t\tcreate: new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node))\n\t\t\t};\n\t\t\tconst graded = gradePolicyReplacement(replacement, options.contract, options.policy.allowedOperationClasses);\n\t\t\tif (graded.disposition === \"suppress\") {\n\t\t\t\tsuppressions.push(graded.record);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (graded.disposition === \"conflict\") {\n\t\t\t\tconflicts.push(graded.conflict);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcalls.push(replacement.drop);\n\t\t\tcalls.push(replacement.create);\n\t\t}\n\t\tfor (const finding of missing) {\n\t\t\tif (renamedMissing.has(finding)) continue;\n\t\t\tcalls.push(new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node)));\n\t\t}\n\t\tif (allowsDestructive) for (const finding of extra) {\n\t\t\tif (renamedExtras.has(finding)) continue;\n\t\t\tcalls.push(new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name));\n\t\t}\n\t\treturn {\n\t\t\tcalls,\n\t\t\tconflicts,\n\t\t\tsuppressions\n\t\t};\n\t}\n\tensureAdditivePolicy(policy) {\n\t\tif (!policy.allowedOperationClasses.includes(\"additive\")) return plannerFailure([{\n\t\t\tkind: \"unsupportedOperation\",\n\t\t\tsummary: \"Migration planner requires additive operations be allowed\",\n\t\t\twhy: \"The planner requires the \\\"additive\\\" operation class to be allowed in the policy.\"\n\t\t}]);\n\t\treturn null;\n\t}\n};\n/**\n* A diff issue whose node is an RLS policy — the structural half of the one\n* combined tree diff, routed to `planPostgresSchemaDiff` instead of\n* `planIssues`.\n*/\nfunction isPolicyDiffIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && PostgresPolicySchemaNode.is(node);\n}\n/**\n* Postgres refuses these statements while a policy uses the object they touch:\n* - dropping a column (2BP01) or changing its type (0A000);\n* - dropping a table that a policy on another table uses (2BP01); a table's own policies go with it;\n* - dropping a native enum type (2BP01);\n* - a destructive codec type operation (a `RawSqlCall` on a type), such as dropping or rebuilding\n* the type (2BP01) or changing a composite type's attribute type (0A000). Additive and widening\n* type operations, such as adding an enum value or renaming the type, go through.\n*\n* So every policy drop moves to just before the first structural call that a policy can block.\n* Without such a call, the policy calls keep their place after the structural calls.\n*/\nfunction movePolicyDropsBeforeBlockedDdl(structural, policyCalls) {\n\tconst firstBlockable = structural.findIndex(policyCanBlock);\n\tif (firstBlockable === -1) return {\n\t\tstructural,\n\t\tpolicyCalls\n\t};\n\tconst isPolicyDrop = (call) => call instanceof DropPostgresRlsPolicyCall;\n\treturn {\n\t\tstructural: [\n\t\t\t...structural.slice(0, firstBlockable),\n\t\t\t...policyCalls.filter(isPolicyDrop),\n\t\t\t...structural.slice(firstBlockable)\n\t\t],\n\t\tpolicyCalls: policyCalls.filter((call) => !isPolicyDrop(call))\n\t};\n}\nfunction policyCanBlock(call) {\n\tif (call instanceof RawSqlCall) return call.operationClass === \"destructive\" && call.op.target.details?.objectType === \"type\";\n\treturn call instanceof DropColumnCall || call instanceof AlterColumnTypeCall || call instanceof DropTableCall || call instanceof DropNativeEnumTypeCall;\n}\n/**\n* Drops a `not-expected` issue when it is a whole extra storage entity (a table\n* or a native enum) that some space in the composition owns. Each such node\n* yields its own storage coordinate (see {@link postgresNodeStorageCoordinate}),\n* so `declaresEntity` answers over the whole composition on one uniform\n* coordinate: a positive answer means a sibling owns this entity here — leave\n* it; a negative answer means a genuine orphan — drop it. A node with no storage\n* coordinate (a namespace, or a deeper column/constraint drift on an owned\n* table) is this space's own and is always kept. No oracle ⇒ keep everything.\n*/\nfunction retainUnownedExtras(issues, ownership, contract) {\n\tif (ownership === void 0) return issues;\n\treturn issues.filter((issue) => {\n\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0) return true;\n\t\tconst coordinate = postgresNodeStorageCoordinate(node);\n\t\tif (coordinate === void 0) return true;\n\t\tconst ddlSchemaName = issueSchemaName(issue);\n\t\tif (ddlSchemaName === void 0) return true;\n\t\tconst namespaceId = resolveNamespaceIdForDdlSchema(contract, ddlSchemaName);\n\t\treturn !ownership.declaresEntity({\n\t\t\tnamespaceId,\n\t\t\t...coordinate\n\t\t});\n\t});\n}\n/**\n* Returns the one namespace node the relational strategy layer probes for\n* live-table existence and reads codec-hook context off — the namespace\n* matching the planner's resolved schema name, or the first namespace when\n* none matches. `undefined` when the tree has no namespaces, so the strategy\n* context uses its empty-schema default.\n*\n* The relational strategies key tables by bare name, so they can only probe one\n* namespace at a time; probing across every namespace at once is future work.\n*\n* Returns the real `PostgresNamespaceSchemaNode` reference rather than a\n* projection: `storageTypePlanCallStrategy` hands this same value to codec\n* `planTypeOperations` hooks as `schema`, and hooks read the Postgres-specific\n* `nativeEnums` field off it (via `PostgresNamespaceSchemaNode.is`) to decide\n* whether a native enum type already exists — a projection that only copies\n* `tables` would silently drop that signal. `StrategyContext.schema`'s\n* declared type (`SqlSchemaIR`, shared with SQLite's flat shape) doesn't\n* capture this, so the return is `blindCast` the same way `namespaceSchemaNodes`\n* in the family's relational walk already treats a namespace node as a\n* structurally-`SqlSchemaIR`-shaped value.\n*/\nfunction relationalNamespaceNode(schema, schemaName) {\n\tconst namespaceNodes = Object.values(schema.namespaces);\n\tconst namespaceNode = namespaceNodes.find((node) => node.schemaName === schemaName) ?? namespaceNodes[0];\n\tif (namespaceNode === void 0) return void 0;\n\treturn blindCast(namespaceNode);\n}\n/**\n* Grades a {@link PolicyReplacement} as one unit against the table's\n* control policy, BEFORE the pair becomes calls or a conflict. This runs\n* ahead of `partitionCallsByControlPolicy`, which later re-grades the\n* surviving calls per-call — a no-op here, since only managed units\n* survive this grading.\n*\n* A replacement is deliberately STRICTER than the shared\n* `callAllowedUnderControlPolicy` rule: `tolerated` permits whole-object\n* creation, but a replacement's create is the second half of a repair of\n* an existing object, not a new object — so ANY non-managed control\n* (external, observed, tolerated) suppresses the whole unit. Drift on an\n* object the plan does not manage is reported, never repaired; the\n* suppression subject names the drifted policy (`rlsPolicy`) so the\n* report says which policy drifted, matching the conflict path's\n* `location.rlsPolicy`.\n*/\nfunction gradePolicyReplacement(replacement, contract, allowedOperationClasses) {\n\tconst subject = resolvePostgresCallControlPolicySubject(replacement.drop, contract);\n\tconst controlPolicy = controlPolicyForCall(subject, contract.defaultControlPolicy);\n\tif (controlPolicy !== \"managed\") return {\n\t\tdisposition: \"suppress\",\n\t\trecord: {\n\t\t\tsubject: subject === void 0 ? void 0 : {\n\t\t\t\t...subject,\n\t\t\t\trlsPolicy: replacement.drop.policyName\n\t\t\t},\n\t\t\tpolicy: controlPolicy,\n\t\t\tfactoryName: void 0,\n\t\t\tcreatesNewObject: false\n\t\t}\n\t};\n\tif (!allowedOperationClasses.includes(\"destructive\")) return {\n\t\tdisposition: \"conflict\",\n\t\tconflict: conflictForDisallowedCall(replacement.drop, allowedOperationClasses)\n\t};\n\treturn { disposition: \"plan\" };\n}\n/**\n* Rebuilds the `PostgresRlsPolicy` contract entity `CreatePostgresRlsPolicyCall`\n* carries (its `renderTypeScript`/`createRlsPolicy` paths serialize the whole\n* entity, `namespaceId` included). This reconstructs rather than looking the\n* original up in the contract on purpose: the diff node's `namespaceId` is the\n* *resolved DDL schema* (set when the expected tree was built), which is the\n* value the emitted op must carry; the contract-stored entity holds the raw,\n* pre-resolution coordinate, so a lookup would change the migration output.\n*/\nfunction policyNodeToContractPolicy(node) {\n\treturn new PostgresRlsPolicy({\n\t\tnaming: namingOf(node.name, node.prefix),\n\t\ttableName: node.tableName,\n\t\tnamespaceId: node.namespaceId,\n\t\toperation: node.operation,\n\t\troles: [...node.roles],\n\t\tusing: node.using,\n\t\twithCheck: node.withCheck,\n\t\tpermissive: node.permissive\n\t});\n}\n//#endregion\nexport { createPostgresMigrationPlanner as t };\n\n//# sourceMappingURL=planner-DSTSuAc8.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAS,qBAAqB,SAAS,aAAa;CACnD,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,iBAAiB,SAAS,GAAG,OAAO,UAAU,cAAc,OAAO;CACvE,OAAO;AACR;;;;;;;;;;;;;;;;;AAiBA,SAAS,0BAA0B,QAAQ;CAC1C,IAAI,2BAA2B,GAAG,MAAM,GAAG,OAAO,OAAO;CACzD,OAAO,CAAC,oBAAoB;AAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,gCAAgC,OAAO;CAC/C,MAAM,EAAE,UAAU,WAAW;CAC7B,MAAM,WAAW,IAAI,IAAI,0BAA0B,MAAM,CAAC;CAC1D,MAAM,SAAS,CAAC;CAChB,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,CAAC,CAAC,KAAK;CACnE,KAAK,MAAM,eAAe,cAAc;EACvC,IAAI,gBAAgB,sBAAsB;EAC1C,MAAM,UAAU,qBAAqB,SAAS,SAAS,WAAW;EAClE,IAAI,YAAY,sBAAsB;EACtC,IAAI,SAAS,IAAI,OAAO,GAAG;EAC3B,MAAM,YAAY,IAAI,4BA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IAAI,kBAAkB;EAC5B,QAAQ,SAAS,KAAK,MAAM,KAAK,MAAM;EACvC,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,OAAO,CAAC,GAAG,KAAK,KAAK;EACrB,OAAO,KAAK;EACZ,WAAW,KAAK;EAChB,YAAY,KAAK;CAClB,CAAC;AACF"}
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import { t as escapeLiteral } from "./sql-utils-
|
|
2
|
-
import { A as pgTimestamptz, E as pgTime, M as pgTimetz, O as pgTimestamp, _ as pgInt8, b as pgJsonb, c as pgDate, g as pgInt4, h as pgInt2, v as pgInterval, y as pgJson } from "./data-types-
|
|
1
|
+
import { t as escapeLiteral } from "./sql-utils-CVsvXiX4-C7xD0Bgv.mjs";
|
|
2
|
+
import { A as pgTimestamptz, E as pgTime, M as pgTimetz, O as pgTimestamp, _ as pgInt8, b as pgJsonb, c as pgDate, g as pgInt4, h as pgInt2, v as pgInterval, y as pgJson } from "./data-types-DRkmmE9S-C5Q9oH4Q.mjs";
|
|
3
3
|
import { dataTypeParams, renderSqlTypeName, sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
|
|
4
|
-
//#region ../../../3-targets/3-targets/postgres/dist/planner-ddl-builders-
|
|
4
|
+
//#region ../../../3-targets/3-targets/postgres/dist/planner-ddl-builders-Y0_96xpe.mjs
|
|
5
|
+
const SMALL = {
|
|
6
|
+
serialType: "SMALLSERIAL",
|
|
7
|
+
sequenceType: "smallint"
|
|
8
|
+
};
|
|
9
|
+
const REGULAR = {
|
|
10
|
+
serialType: "SERIAL",
|
|
11
|
+
sequenceType: "integer"
|
|
12
|
+
};
|
|
13
|
+
const BIG = {
|
|
14
|
+
serialType: "BIGSERIAL",
|
|
15
|
+
sequenceType: "bigint"
|
|
16
|
+
};
|
|
17
|
+
const WIDTH_BY_COLUMN_TYPE = /* @__PURE__ */ new Map([
|
|
18
|
+
["int2", SMALL],
|
|
19
|
+
["smallint", SMALL],
|
|
20
|
+
["int4", REGULAR],
|
|
21
|
+
["integer", REGULAR],
|
|
22
|
+
["int8", BIG],
|
|
23
|
+
["bigint", BIG]
|
|
24
|
+
]);
|
|
25
|
+
/** The autoincrement width of a column of `columnType`; `undefined` for a column that is not a scalar smallint, integer or bigint. */
|
|
26
|
+
function autoincrementWidth(columnType) {
|
|
27
|
+
return WIDTH_BY_COLUMN_TYPE.get(columnType.toLowerCase());
|
|
28
|
+
}
|
|
29
|
+
const WIDTH_BY_DATA_TYPE = /* @__PURE__ */ new Map([
|
|
30
|
+
[pgInt2.id, SMALL],
|
|
31
|
+
[pgInt4.id, REGULAR],
|
|
32
|
+
[pgInt8.id, BIG]
|
|
33
|
+
]);
|
|
34
|
+
/** The autoincrement width of a column whose data type is `dataTypeId`; `undefined` unless it is `pg/int2`, `pg/int4` or `pg/int8`. */
|
|
35
|
+
function autoincrementWidthOfDataType(dataTypeId) {
|
|
36
|
+
return WIDTH_BY_DATA_TYPE.get(dataTypeId);
|
|
37
|
+
}
|
|
5
38
|
const DATE_TIME_TYPES = /* @__PURE__ */ new Set([
|
|
6
39
|
pgDate.id,
|
|
7
40
|
pgTime.id,
|
|
@@ -36,11 +69,6 @@ function postgresDateTimeDdlText(canonical, dataTypeId) {
|
|
|
36
69
|
if (year > 9999) return `${year}${rest}`;
|
|
37
70
|
return `${String(1 - year).padStart(4, "0")}${rest} BC`;
|
|
38
71
|
}
|
|
39
|
-
const SERIAL_TYPES = /* @__PURE__ */ new Map([
|
|
40
|
-
[pgInt4.id, "SERIAL"],
|
|
41
|
-
[pgInt8.id, "BIGSERIAL"],
|
|
42
|
-
[pgInt2.id, "SMALLSERIAL"]
|
|
43
|
-
]);
|
|
44
72
|
const JSON_DATA_TYPES = /* @__PURE__ */ new Set([pgJson.id, pgJsonb.id]);
|
|
45
73
|
/**
|
|
46
74
|
* Renders the SQL type for a column in DDL context: the name its codec's data type is written
|
|
@@ -53,14 +81,16 @@ const JSON_DATA_TYPES = /* @__PURE__ */ new Set([pgJson.id, pgJsonb.id]);
|
|
|
53
81
|
function buildColumnTypeSql(column, types, storageTypes = {}, allowPseudoTypes = true) {
|
|
54
82
|
const resolved = (column.typeRef === void 0 ? void 0 : storageTypes[column.typeRef]) ?? column;
|
|
55
83
|
const dataType = sqlDataTypeOfCodec(resolved.codecId, types);
|
|
56
|
-
if (allowPseudoTypes) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
if (serial !== void 0 && columnDefault?.kind === "function" && columnDefault.expression === "autoincrement()") return serial;
|
|
84
|
+
if (allowPseudoTypes && isAutoincrement(column.default)) {
|
|
85
|
+
const width = autoincrementWidthOfDataType(dataType.id);
|
|
86
|
+
if (width !== void 0) return width.serialType;
|
|
60
87
|
}
|
|
61
88
|
const typeSql = renderSqlTypeName(dataType, dataTypeParams(dataType, resolved.typeParams));
|
|
62
89
|
return column.many ? `${typeSql}[]` : typeSql;
|
|
63
90
|
}
|
|
91
|
+
function isAutoincrement(columnDefault) {
|
|
92
|
+
return columnDefault?.kind === "function" && columnDefault.expression === "autoincrement()";
|
|
93
|
+
}
|
|
64
94
|
function renderDefaultLiteral(value, column) {
|
|
65
95
|
if (column?.many && Array.isArray(value)) return renderArrayLiteralDefault(value, column.baseTypeName, column.dataType);
|
|
66
96
|
if (column !== void 0 && JSON_DATA_TYPES.has(column.dataType) && typeof value === "object" && value !== null && !(value instanceof Date)) return `'${escapeLiteral(JSON.stringify(value))}'::${column.baseTypeName}`;
|
|
@@ -88,6 +118,6 @@ function renderArrayLiteralDefault(elements, baseTypeName, dataType) {
|
|
|
88
118
|
return `${rendered}::${baseTypeName.endsWith("[]") ? baseTypeName : `${baseTypeName}[]`}`;
|
|
89
119
|
}
|
|
90
120
|
//#endregion
|
|
91
|
-
export { renderDefaultLiteral as i,
|
|
121
|
+
export { renderDefaultLiteral as a, postgresDateTimeDdlText as i, buildColumnTypeSql as n, isPostgresDateTimeDataType as r, autoincrementWidth as t };
|
|
92
122
|
|
|
93
|
-
//# sourceMappingURL=planner-ddl-builders-
|
|
123
|
+
//# sourceMappingURL=planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-ddl-builders-Y0_96xpe.mjs"],"sourcesContent":["import { t as escapeLiteral } from \"./sql-utils-CVsvXiX4.mjs\";\nimport { A as pgTimestamptz, E as pgTime, M as pgTimetz, O as pgTimestamp, _ as pgInt8, b as pgJsonb, c as pgDate, g as pgInt4, h as pgInt2, v as pgInterval, y as pgJson } from \"./data-types-DRkmmE9S.mjs\";\nimport { dataTypeParams, renderSqlTypeName, sqlDataTypeOfCodec } from \"@internal/sql-contract/data-type\";\n//#region src/core/migrations/autoincrement-widths.ts\nconst SMALL = {\n\tserialType: \"SMALLSERIAL\",\n\tsequenceType: \"smallint\"\n};\nconst REGULAR = {\n\tserialType: \"SERIAL\",\n\tsequenceType: \"integer\"\n};\nconst BIG = {\n\tserialType: \"BIGSERIAL\",\n\tsequenceType: \"bigint\"\n};\nconst WIDTH_BY_COLUMN_TYPE = /* @__PURE__ */ new Map([\n\t[\"int2\", SMALL],\n\t[\"smallint\", SMALL],\n\t[\"int4\", REGULAR],\n\t[\"integer\", REGULAR],\n\t[\"int8\", BIG],\n\t[\"bigint\", BIG]\n]);\n/** The autoincrement width of a column of `columnType`; `undefined` for a column that is not a scalar smallint, integer or bigint. */\nfunction autoincrementWidth(columnType) {\n\treturn WIDTH_BY_COLUMN_TYPE.get(columnType.toLowerCase());\n}\nconst WIDTH_BY_DATA_TYPE = /* @__PURE__ */ new Map([\n\t[pgInt2.id, SMALL],\n\t[pgInt4.id, REGULAR],\n\t[pgInt8.id, BIG]\n]);\n/** The autoincrement width of a column whose data type is `dataTypeId`; `undefined` unless it is `pg/int2`, `pg/int4` or `pg/int8`. */\nfunction autoincrementWidthOfDataType(dataTypeId) {\n\treturn WIDTH_BY_DATA_TYPE.get(dataTypeId);\n}\n//#endregion\n//#region src/core/date-time-ddl-text.ts\nconst DATE_TIME_TYPES = /* @__PURE__ */ new Set([\n\tpgDate.id,\n\tpgTime.id,\n\tpgTimetz.id,\n\tpgTimestamp.id,\n\tpgTimestamptz.id,\n\tpgInterval.id\n]);\nconst TYPES_WITH_A_YEAR = /* @__PURE__ */ new Set([\n\tpgDate.id,\n\tpgTimestamp.id,\n\tpgTimestamptz.id\n]);\n/** Whether a data type is one of this target's date and time types, whose defaults DDL writes as text. */\nfunction isPostgresDateTimeDataType(dataTypeId) {\n\treturn dataTypeId !== void 0 && DATE_TIME_TYPES.has(dataTypeId);\n}\n/**\n* The text DDL writes for a default of a date or time type, from its canonical form (ADR 254). A\n* year from 1 to 9999 stays as it is. PostgreSQL has no year 0 and reads no signed year, so a later\n* year loses its sign and leading zeros (`10000-01-01`) and a year at or before 0 is written as the\n* year before Christ (`0044-03-15 BC`). Every Postgres DDL path writes a date or time default\n* through this function.\n*/\nfunction postgresDateTimeDdlText(canonical, dataTypeId) {\n\tif (dataTypeId === void 0 || !TYPES_WITH_A_YEAR.has(dataTypeId)) return canonical;\n\tconst match = /^([+-]\\d{6}|\\d{4})(-.*)$/.exec(canonical);\n\tif (match === null) return canonical;\n\tconst [, yearDigits = \"\", rest = \"\"] = match;\n\tconst year = Number(yearDigits);\n\tif (year >= 1 && year <= 9999) return canonical;\n\tif (year > 9999) return `${year}${rest}`;\n\treturn `${String(1 - year).padStart(4, \"0\")}${rest} BC`;\n}\n//#endregion\n//#region src/core/migrations/planner-ddl-builders.ts\nconst JSON_DATA_TYPES = /* @__PURE__ */ new Set([pgJson.id, pgJsonb.id]);\n/**\n* Renders the SQL type for a column in DDL context: the name its codec's data type is written\n* with, and its parameters. A `typeRef` column is written as a column of the referenced type.\n*\n* @param allowPseudoTypes - When true (default), autoincrement integer columns\n* produce SERIAL/BIGSERIAL/SMALLSERIAL pseudo-types. Set to false for contexts\n* like ALTER COLUMN TYPE where pseudo-types are invalid.\n*/\nfunction buildColumnTypeSql(column, types, storageTypes = {}, allowPseudoTypes = true) {\n\tconst resolved = (column.typeRef === void 0 ? void 0 : storageTypes[column.typeRef]) ?? column;\n\tconst dataType = sqlDataTypeOfCodec(resolved.codecId, types);\n\tif (allowPseudoTypes && isAutoincrement(column.default)) {\n\t\tconst width = autoincrementWidthOfDataType(dataType.id);\n\t\tif (width !== void 0) return width.serialType;\n\t}\n\tconst typeSql = renderSqlTypeName(dataType, dataTypeParams(dataType, resolved.typeParams));\n\treturn column.many ? `${typeSql}[]` : typeSql;\n}\nfunction isAutoincrement(columnDefault) {\n\treturn columnDefault?.kind === \"function\" && columnDefault.expression === \"autoincrement()\";\n}\nfunction renderDefaultLiteral(value, column) {\n\tif (column?.many && Array.isArray(value)) return renderArrayLiteralDefault(value, column.baseTypeName, column.dataType);\n\tif (column !== void 0 && JSON_DATA_TYPES.has(column.dataType) && typeof value === \"object\" && value !== null && !(value instanceof Date)) return `'${escapeLiteral(JSON.stringify(value))}'::${column.baseTypeName}`;\n\treturn renderScalarLiteral(value, column?.dataType);\n}\n/** A date or time value is written through the one function every DDL path uses for it. */\nfunction renderScalarLiteral(value, dataType) {\n\tif (value instanceof Date) return `'${escapeLiteral(value.toISOString())}'`;\n\tif (typeof value === \"string\") return `'${escapeLiteral(postgresDateTimeDdlText(value, dataType))}'`;\n\tif (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n\tif (value === null) return \"NULL\";\n\treturn `'${escapeLiteral(JSON.stringify(value))}'`;\n}\n/**\n* An `ARRAY[...]` of quoted elements has type `text[]`, which Postgres does not assign to a list of\n* numbers, decimals, timestamps or enums, so the constructor is cast to the list type. Each element\n* is the text Postgres reads for its type: an `int8` or `numeric` value as decimal text, a date or\n* time value in its type's canonical form. The cast is `baseTypeName` with `[]` appended unless it\n* already ends in `[]`; the name is not quoted here.\n*/\nfunction renderArrayLiteralDefault(elements, baseTypeName, dataType) {\n\tif (elements.length === 0) return \"'{}'\";\n\tconst rendered = `ARRAY[${elements.map((el) => renderScalarLiteral(el, dataType)).join(\", \")}]`;\n\tif (baseTypeName === \"\") return rendered;\n\treturn `${rendered}::${baseTypeName.endsWith(\"[]\") ? baseTypeName : `${baseTypeName}[]`}`;\n}\n//#endregion\nexport { autoincrementWidth as a, postgresDateTimeDdlText as i, renderDefaultLiteral as n, isPostgresDateTimeDataType as r, buildColumnTypeSql as t };\n\n//# sourceMappingURL=planner-ddl-builders-Y0_96xpe.mjs.map"],"mappings":";;;;AAIA,MAAM,QAAQ;CACb,YAAY;CACZ,cAAc;AACf;AACA,MAAM,UAAU;CACf,YAAY;CACZ,cAAc;AACf;AACA,MAAM,MAAM;CACX,YAAY;CACZ,cAAc;AACf;AACA,MAAM,uCAAuC,IAAI,IAAI;CACpD,CAAC,QAAQ,KAAK;CACd,CAAC,YAAY,KAAK;CAClB,CAAC,QAAQ,OAAO;CAChB,CAAC,WAAW,OAAO;CACnB,CAAC,QAAQ,GAAG;CACZ,CAAC,UAAU,GAAG;AACf,CAAC;;AAED,SAAS,mBAAmB,YAAY;CACvC,OAAO,qBAAqB,IAAI,WAAW,YAAY,CAAC;AACzD;AACA,MAAM,qCAAqC,IAAI,IAAI;CAClD,CAAC,OAAO,IAAI,KAAK;CACjB,CAAC,OAAO,IAAI,OAAO;CACnB,CAAC,OAAO,IAAI,GAAG;AAChB,CAAC;;AAED,SAAS,6BAA6B,YAAY;CACjD,OAAO,mBAAmB,IAAI,UAAU;AACzC;AAGA,MAAM,kCAAkC,IAAI,IAAI;CAC/C,OAAO;CACP,OAAO;CACP,SAAS;CACT,YAAY;CACZ,cAAc;CACd,WAAW;AACZ,CAAC;AACD,MAAM,oCAAoC,IAAI,IAAI;CACjD,OAAO;CACP,YAAY;CACZ,cAAc;AACf,CAAC;;AAED,SAAS,2BAA2B,YAAY;CAC/C,OAAO,eAAe,KAAK,KAAK,gBAAgB,IAAI,UAAU;AAC/D;;;;;;;;AAQA,SAAS,wBA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AAO,IAAI,cAAc,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,OAAO;CACtM,OAAO,oBAAoB,OAAO,QAAQ,QAAQ;AACnD;;AAEA,SAAS,oBAAoB,OAAO,UAAU;CAC7C,IAAI,iBAAiB,MAAM,OAAO,IAAI,cAAc,MAAM,YAAY,CAAC,EAAE;CACzE,IAAI,OAAO,UAAU,UAAU,OAAO,IAAI,cAAc,wBAAwB,OAAO,QAAQ,CAAC,EAAE;CAClG,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,OAAO,OAAO,KAAK;CAChF,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,IAAI,cAAc,KAAK,UAAU,KAAK,CAAC,EAAE;AACjD;;;;;;;;AAQA,SAAS,0BAA0B,UAAU,cAAc,UAAU;CACpE,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,MAAM,WAAW,SAAS,SAAS,KAAK,OAAO,oBAAoB,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;CAC7F,IAAI,iBAAiB,IAAI,OAAO;CAChC,OAAO,GAAG,SAAS,IAAI,aAAa,SAAS,IAAI,IAAI,eAAe,GAAG,aAAa;AACrF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as pgTimestamptz, E as pgTime, F as pgUuid, I as pgVarbit, L as pgVarchar, M as pgTimetz, O as pgTimestamp, T as pgTextArray, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, n as pgBit, o as pgChar, p as pgFloat8, v as pgInterval, w as pgText, x as pgNumeric, y as pgJson } from "./data-types-
|
|
1
|
+
import { A as pgTimestamptz, E as pgTime, F as pgUuid, I as pgVarbit, L as pgVarchar, M as pgTimetz, O as pgTimestamp, T as pgTextArray, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, n as pgBit, o as pgChar, p as pgFloat8, v as pgInterval, w as pgText, x as pgNumeric, y as pgJson } from "./data-types-DRkmmE9S-C5Q9oH4Q.mjs";
|
|
2
2
|
import { sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
|
|
3
3
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
4
|
-
//#region ../../../3-targets/3-targets/postgres/dist/planner-identity-values-
|
|
4
|
+
//#region ../../../3-targets/3-targets/postgres/dist/planner-identity-values-CRS2cQ6v.mjs
|
|
5
5
|
/**
|
|
6
6
|
* Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.
|
|
7
7
|
* Checks codec hooks first (extensions can provide type-specific identity values),
|
|
@@ -69,4 +69,4 @@ function buildBitIdentityValue(typeParams) {
|
|
|
69
69
|
//#endregion
|
|
70
70
|
export { resolveIdentityValue as n, buildBuiltinIdentityValue as t };
|
|
71
71
|
|
|
72
|
-
//# sourceMappingURL=planner-identity-values-
|
|
72
|
+
//# sourceMappingURL=planner-identity-values-CRS2cQ6v-DakZeIQj.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-identity-values-
|
|
1
|
+
{"version":3,"file":"planner-identity-values-CRS2cQ6v-DakZeIQj.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-identity-values-CRS2cQ6v.mjs"],"sourcesContent":["import { A as pgTimestamptz, E as pgTime, F as pgUuid, I as pgVarbit, L as pgVarchar, M as pgTimetz, O as pgTimestamp, T as pgTextArray, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, n as pgBit, o as pgChar, p as pgFloat8, v as pgInterval, w as pgText, x as pgNumeric, y as pgJson } from \"./data-types-DRkmmE9S.mjs\";\nimport { sqlDataTypeOfCodec } from \"@internal/sql-contract/data-type\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/migrations/planner-identity-values.ts\n/**\n* Resolves the identity value (monoid neutral element) as a SQL literal for a column's type.\n* Checks codec hooks first (extensions can provide type-specific identity values),\n* then falls back to the built-in map, keyed by the data type the column's codec represents.\n*/\nfunction resolveIdentityValue(column, codecHooks, types, storageTypes = {}) {\n\tconst referencedType = column.typeRef ? storageTypes[column.typeRef] : void 0;\n\tconst codecId = referencedType?.codecId ?? column.codecId;\n\tconst typeParams = referencedType?.typeParams ?? column.typeParams;\n\tif (column.many) return \"'{}'\";\n\tconst dataType = sqlDataTypeOfCodec(codecId, types).id;\n\tconst hookDefault = codecHooks.get(codecId)?.resolveIdentityValue?.({\n\t\tdataType,\n\t\tcodecId,\n\t\t...ifDefined(\"typeParams\", typeParams)\n\t});\n\tif (hookDefault !== void 0) return hookDefault;\n\treturn buildBuiltinIdentityValue(dataType, typeParams);\n}\nconst IDENTITY_VALUES = /* @__PURE__ */ new Map([\n\t[pgText.id, \"''\"],\n\t[pgChar.id, \"''\"],\n\t[pgVarchar.id, \"''\"],\n\t[pgInt2.id, \"0\"],\n\t[pgInt4.id, \"0\"],\n\t[pgInt8.id, \"0\"],\n\t[pgFloat4.id, \"0\"],\n\t[pgFloat8.id, \"0\"],\n\t[pgNumeric.id, \"0\"],\n\t[pgBool.id, \"false\"],\n\t[pgUuid.id, \"'00000000-0000-0000-0000-000000000000'\"],\n\t[pgJson.id, \"'{}'::json\"],\n\t[pgJsonb.id, \"'{}'::jsonb\"],\n\t[pgDate.id, \"'epoch'\"],\n\t[pgTimestamp.id, \"'epoch'\"],\n\t[pgTimestamptz.id, \"'epoch'\"],\n\t[pgTime.id, \"'00:00:00'\"],\n\t[pgTimetz.id, \"'00:00:00+00'\"],\n\t[pgInterval.id, \"'0'\"],\n\t[pgBytea.id, \"''::bytea\"],\n\t[pgVarbit.id, \"B''\"],\n\t[pgTextArray.id, \"'{}'\"]\n]);\n/**\n* Returns the built-in identity value (monoid neutral element) as a SQL literal for the given\n* data type — e.g. 0 for integers, '' for text, false for booleans.\n*\n* This is the planner's fallback when no codec hook provides a type-specific identity value.\n*\n* Returns null for other types (for example enums and extension-owned types without a\n* hook), which causes the planner to fall back to the empty-table precheck.\n*\n* @internal Exported for testing only.\n*/\nfunction buildBuiltinIdentityValue(dataType, typeParams) {\n\tif (dataType === pgBit.id) return buildBitIdentityValue(typeParams);\n\treturn IDENTITY_VALUES.get(dataType) ?? null;\n}\nfunction buildBitIdentityValue(typeParams) {\n\tconst length = typeParams?.[\"length\"];\n\tif (length === void 0) return \"B'0'\";\n\tif (typeof length !== \"number\" || !Number.isInteger(length) || length <= 0) return null;\n\treturn `B'${\"0\".repeat(length)}'`;\n}\n//#endregion\nexport { resolveIdentityValue as n, buildBuiltinIdentityValue as t };\n\n//# sourceMappingURL=planner-identity-values-CRS2cQ6v.mjs.map"],"mappings":";;;;;;;;;AASA,SAAS,qBAAqB,QAAQ,YAAY,OAAO,eAAe,CAAC,GAAG;CAC3E,MAAM,iBAAiB,OAAO,UAAU,aAAa,OAAO,WAAW,KAAK;CAC5E,MAAM,UAAU,gBAAgB,WAAW,OAAO;CAClD,MAAM,aAAa,gBAAgB,cAAc,OAAO;CACxD,IAAI,OAAO,MAAM,OAAO;CACxB,MAAM,WAAW,mBAAmB,SAAS,KAAK,CAAC,CAAC;CACpD,MAAM,cAAc,WAAW,IAAI,OAAO,CAAC,EAAE,uBAAuB;EACnE;EACA;EACA,GAAG,UAAU,cAAc,UAAU;CACtC,CAAC;CACD,IAAI,gBAAgB,KAAK,GAAG,OAAO;CACnC,OAAO,0BAA0B,UAAU,UAAU;AACtD;AACA,MAAM,kCAAkC,IAAI,IAAI;CAC/C,CAAC,OAAO,IAAI,IAAI;CAChB,CAAC,OAAO,IAAI,IAAI;CAChB,CAAC,UAAU,IAAI,IAAI;CACnB,CAAC,OAAO,IAAI,GAAG;CACf,CAAC,OAAO,IAAI,GAAG;CACf,CAAC,OAAO,IAAI,GAAG;CACf,CAAC,SAAS,IAAI,GAAG;CACjB,CAAC,SAAS,IAAI,GAAG;CACjB,CAAC,UAAU,IAAI,GAAG;CAClB,CAAC,OAAO,IAAI,OAAO;CACnB,CAAC,OAAO,IAAI,wCAAwC;CACpD,CAAC,OAAO,IAAI,YAAY;CACxB,CAAC,QAAQ,IAAI,aAAa;CAC1B,CAAC,OAAO,IAAI,SAAS;CACrB,CAAC,YAAY,IAAI,SAAS;CAC1B,CAAC,cAAc,IAAI,SAAS;CAC5B,CAAC,OAAO,IAAI,YAAY;CACxB,CAAC,SAAS,IAAI,eAAe;CAC7B,CAAC,WAAW,IAAI,KAAK;CACrB,CAAC,QAAQ,IAAI,WAAW;CACxB,CAAC,SAAS,IAAI,KAAK;CACnB,CAAC,YAAY,IAAI,MAAM;AACxB,CAAC;;;;;;;;;;;;AAYD,SAAS,0BAA0B,UAAU,YAAY;CACxD,IAAI,aAAa,MAAM,IAAI,OAAO,sBAAsB,UAAU;CAClE,OAAO,gBAAgB,IAAI,QAAQ,KAAK;AACzC;AACA,SAAS,sBAAsB,YAAY;CAC1C,MAAM,SAAS,aAAa;CAC5B,IAAI,WAAW,KAAK,GAAG,OAAO;CAC9B,IAAI,OAAO,WAAW,YAAY,CAAC,OAAO,UAAU,MAAM,KAAK,UAAU,GAAG,OAAO;CACnF,OAAO,KAAK,IAAI,OAAO,MAAM,EAAE;AAChC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
1
|
+
import { t as PostgresMigration } from "./postgres-migration-CeX6vfEU-DsmCRCnD.mjs";
|
|
2
2
|
import { t as renderOps } from "./render-ops-D2vJApKB-B281fzmn.mjs";
|
|
3
3
|
import { t as renderCallsToTypeScript } from "./render-typescript-Dqp1Spgn-B128r1qw.mjs";
|
|
4
|
-
//#region ../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-
|
|
4
|
+
//#region ../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-D7-3OBb_.mjs
|
|
5
5
|
var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
6
6
|
#calls;
|
|
7
7
|
#meta;
|
|
@@ -44,4 +44,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
47
|
+
//# sourceMappingURL=planner-produced-postgres-migration-D7-3OBb_-BGHFKj3i.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-D7-3OBb_-BGHFKj3i.mjs","names":["#calls","#meta","#spaceId","#snapshotsImportPath","#lowerer","#operationsCache"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-D7-3OBb_.mjs"],"sourcesContent":["import { t as PostgresMigration } from \"./postgres-migration-CeX6vfEU.mjs\";\nimport { t as renderOps } from \"./render-ops-D2vJApKB.mjs\";\nimport { t as renderCallsToTypeScript } from \"./render-typescript-Dqp1Spgn.mjs\";\n//#region src/core/migrations/planner-produced-postgres-migration.ts\nvar TypeScriptRenderablePostgresMigration = class extends PostgresMigration {\n\t#calls;\n\t#meta;\n\t#spaceId;\n\t#snapshotsImportPath;\n\t#lowerer;\n\t#operationsCache;\n\tconstructor(calls, meta, spaceId, snapshotsImportPath, lowerer) {\n\t\tsuper();\n\t\tthis.#calls = calls;\n\t\tthis.#meta = meta;\n\t\tthis.#spaceId = spaceId;\n\t\tthis.#snapshotsImportPath = snapshotsImportPath;\n\t\tthis.#lowerer = lowerer;\n\t}\n\tget operations() {\n\t\tthis.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n\t\treturn this.#operationsCache;\n\t}\n\tdescribe() {\n\t\treturn this.#meta;\n\t}\n\t/**\n\t* Contract space this planner-produced plan applies to. Threaded\n\t* from the planner options so the runner keys the marker row by\n\t* the right space when executing the plan.\n\t*/\n\tget spaceId() {\n\t\treturn this.#spaceId;\n\t}\n\trenderTypeScript(resolveImportSpecifier) {\n\t\treturn renderCallsToTypeScript(this.#calls, {\n\t\t\tfrom: this.#meta.from,\n\t\t\tto: this.#meta.to,\n\t\t\tsnapshotsImportPath: this.#snapshotsImportPath,\n\t\t\tresolveImportSpecifier\n\t\t});\n\t}\n};\n//#endregion\nexport { TypeScriptRenderablePostgresMigration as t };\n\n//# sourceMappingURL=planner-produced-postgres-migration-D7-3OBb_.mjs.map"],"mappings":";;;;AAIA,IAAI,wCAAwC,cAAc,kBAAkB;CAC3E;CACA;CACA;CACA;CACA;CACA;CACA,YAAY,OAAO,MAAM,SAAS,qBAAqB,SAAS;EAC/D,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,uBAAuB;EAC5B,KAAKC,WAAW;CACjB;CACA,IAAI,aAAa;EAChB,KAAKC,qBAAqB,UAAU,KAAKL,QAAQ,KAAKI,QAAQ;EAC9D,OAAO,KAAKC;CACb;CACA,WAAW;EACV,OAAO,KAAKJ;CACb;;;;;;CAMA,IAAI,UAAU;EACb,OAAO,KAAKC;CACb;CACA,iBAAiB,wBAAwB;EACxC,OAAO,wBAAwB,KAAKF,QAAQ;GAC3C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,qBAAqB,KAAKE;GAC1B;EACD,CAAC;CACF;AACD"}
|
package/dist/{planner-sql-checks-Bhp0Iq_X-DwwIxJHj.mjs → planner-sql-checks-rqOH8naU-B6xOE5lC.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as quoteIdentifierWhereNeeded } from "./sql-utils-
|
|
2
|
-
import { h as postgresCreateNamespace } from "./postgres-schema-
|
|
1
|
+
import { i as quoteIdentifierWhereNeeded } from "./sql-utils-CVsvXiX4-C7xD0Bgv.mjs";
|
|
2
|
+
import { h as postgresCreateNamespace } from "./postgres-schema-AlEVkXXS-ZfXWYddl.mjs";
|
|
3
3
|
import { dataTypeParams, renderSqlCatalogText, sqlDataTypeOfCodec, unquotedSqlBaseName } from "@prisma/orm-family-sql/contract/data-type";
|
|
4
|
-
//#region ../../../3-targets/3-targets/postgres/dist/planner-sql-checks-
|
|
4
|
+
//#region ../../../3-targets/3-targets/postgres/dist/planner-sql-checks-rqOH8naU.mjs
|
|
5
5
|
function resolveColumnTypeMetadata(column, storageTypes) {
|
|
6
6
|
if (!column.typeRef) return column;
|
|
7
7
|
const referencedType = storageTypes[column.typeRef];
|
|
@@ -43,4 +43,4 @@ function buildExpectedFormatType(column, types, storageTypes = {}) {
|
|
|
43
43
|
//#endregion
|
|
44
44
|
export { qualifyTableName as n, buildExpectedFormatType as t };
|
|
45
45
|
|
|
46
|
-
//# sourceMappingURL=planner-sql-checks-
|
|
46
|
+
//# sourceMappingURL=planner-sql-checks-rqOH8naU-B6xOE5lC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks-
|
|
1
|
+
{"version":3,"file":"planner-sql-checks-rqOH8naU-B6xOE5lC.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-sql-checks-rqOH8naU.mjs"],"sourcesContent":["import { i as quoteIdentifierWhereNeeded } from \"./sql-utils-CVsvXiX4.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-AlEVkXXS.mjs\";\nimport { dataTypeParams, renderSqlCatalogText, sqlDataTypeOfCodec, unquotedSqlBaseName } from \"@internal/sql-contract/data-type\";\n//#region src/core/migrations/planner-type-resolution.ts\nfunction resolveColumnTypeMetadata(column, storageTypes) {\n\tif (!column.typeRef) return column;\n\tconst referencedType = storageTypes[column.typeRef];\n\tif (!referencedType) return column;\n\treturn {\n\t\tcodecId: referencedType.codecId,\n\t\ttypeParams: referencedType.typeParams\n\t};\n}\n//#endregion\n//#region src/core/migrations/planner-sql-checks.ts\n/**\n* String-keyed entry points the migration ops use to render\n* schema-qualified DDL and catalog checks. The `schema` argument is\n* interpreted as a namespace coordinate: the framework `__unbound__`\n* sentinel resolves to the late-bound `PostgresUnboundSchema` singleton\n* (which elides the qualifier so `search_path` decides at runtime); any\n* other id materialises a `PostgresSchema(id)` whose qualifier is the\n* named schema. Helpers route through these `Namespace` concretions so\n* the unbound branch lives in the polymorphic override, not the call\n* site.\n*/\nfunction qualifyTableName(schema, table) {\n\treturn postgresCreateNamespace({\n\t\tid: schema,\n\t\tentries: { table: {} }\n\t}).qualifyTable(table);\n}\n/**\n* The type `format_type` prints, for the column's ALTER COLUMN TYPE postcheck: the catalog text of\n* its data type with normalised parameters, or for an enum its name, quoted where Postgres quotes\n* it.\n*/\nfunction buildExpectedFormatType(column, types, storageTypes = {}) {\n\tconst resolved = resolveColumnTypeMetadata(column, storageTypes);\n\tconst dataType = sqlDataTypeOfCodec(resolved.codecId, types);\n\tconst params = dataTypeParams(dataType, resolved.typeParams);\n\tif (dataType.sql.claimsKind !== void 0) return unquotedSqlBaseName(dataType, params).split(\".\").map(quoteIdentifierWhereNeeded).join(\".\");\n\treturn renderSqlCatalogText(dataType, params);\n}\n//#endregion\nexport { qualifyTableName as n, buildExpectedFormatType as t };\n\n//# sourceMappingURL=planner-sql-checks-rqOH8naU.mjs.map"],"mappings":";;;;AAIA,SAAS,0BAA0B,QAAQ,cAAc;CACxD,IAAI,CAAC,OAAO,SAAS,OAAO;CAC5B,MAAM,iBAAiB,aAAa,OAAO;CAC3C,IAAI,CAAC,gBAAgB,OAAO;CAC5B,OAAO;EACN,SAAS,eAAe;EACxB,YAAY,eAAe;CAC5B;AACD;;;;;;;;;;;;AAcA,SAAS,iBAAiB,QAAQ,OAAO;CACxC,OAAO,wBAAwB;EAC9B,IAAI;EACJ,SAAS,EAAE,OAAO,CAAC,EAAE;CACtB,CAAC,CAAC,CAAC,aAAa,KAAK;AACtB;;;;;;AAMA,SAAS,wBAAwB,QAAQ,OAAO,eAAe,CAAC,GAAG;CAClE,MAAM,WAAW,0BAA0B,QAAQ,YAAY;CAC/D,MAAM,WAAW,mBAAmB,SAAS,SAAS,KAAK;CAC3D,MAAM,SAAS,eAAe,UAAU,SAAS,UAAU;CAC3D,IAAI,SAAS,IAAI,eAAe,KAAK,GAAG,OAAO,oBAAoB,UAAU,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,0BAA0B,CAAC,CAAC,KAAK,GAAG;CACxI,OAAO,qBAAqB,UAAU,MAAM;AAC7C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { S as PG_TEXT_CODEC_ID, _ as PG_INT_CODEC_ID } from "./codec-ids-Cb0yO-IS--e0P2rfI.mjs";
|
|
2
|
-
import { t as createPostgresBuiltinDataTypeLookup } from "./data-types-
|
|
3
|
-
import { r as createPostgresBuiltinCodecLookup } from "./codec-registry-
|
|
4
|
-
import { _ as roleEntityKind, c as PostgresSchema, f as nativeEnumEntityKind, g as rlsEnablementEntityKind, p as policyEntityKind } from "./postgres-schema-
|
|
5
|
-
import { c as postgresAuthoringEntityTypes } from "./authoring-
|
|
2
|
+
import { t as createPostgresBuiltinDataTypeLookup } from "./data-types-DRkmmE9S-C5Q9oH4Q.mjs";
|
|
3
|
+
import { r as createPostgresBuiltinCodecLookup } from "./codec-registry-CKBDkxX7-Kw84Or3s.mjs";
|
|
4
|
+
import { _ as roleEntityKind, c as PostgresSchema, f as nativeEnumEntityKind, g as rlsEnablementEntityKind, p as policyEntityKind } from "./postgres-schema-AlEVkXXS-ZfXWYddl.mjs";
|
|
5
|
+
import { c as postgresAuthoringEntityTypes } from "./authoring-B2hHIzvd-D5NgHs0e.mjs";
|
|
6
6
|
import { requiredSchemaKeys } from "@prisma/orm-framework/components/codec";
|
|
7
7
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
8
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
@@ -12,7 +12,7 @@ import { buildSqlSchemaQualifiedView } from "@prisma/orm-family-sql/contract/con
|
|
|
12
12
|
import { createPreserveEmptyPredicate } from "@prisma/orm-framework/contract/hashing-utils";
|
|
13
13
|
import { SqlContractSerializerBase } from "@prisma/orm-family-sql/family/ir";
|
|
14
14
|
import { sqlContractCanonicalizationHooks } from "@prisma/orm-family-sql/contract/canonicalization-hooks";
|
|
15
|
-
//#region ../../../3-targets/3-targets/postgres/dist/postgres-contract-view-
|
|
15
|
+
//#region ../../../3-targets/3-targets/postgres/dist/postgres-contract-view-C1bi3x4v.mjs
|
|
16
16
|
const POSTGRES_AUTHORING_CTX = {
|
|
17
17
|
family: "sql",
|
|
18
18
|
target: "postgres",
|
|
@@ -143,4 +143,4 @@ const PostgresContractView = {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
export { PostgresContractView as n, PostgresContractSerializer as t };
|
|
145
145
|
|
|
146
|
-
//# sourceMappingURL=postgres-contract-view-
|
|
146
|
+
//# sourceMappingURL=postgres-contract-view-C1bi3x4v-BAfk6euQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-contract-view-
|
|
1
|
+
{"version":3,"file":"postgres-contract-view-C1bi3x4v-BAfk6euQ.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/postgres-contract-view-C1bi3x4v.mjs"],"sourcesContent":["import { S as PG_TEXT_CODEC_ID, _ as PG_INT_CODEC_ID } from \"./codec-ids-Cb0yO-IS.mjs\";\nimport { t as createPostgresBuiltinDataTypeLookup } from \"./data-types-DRkmmE9S.mjs\";\nimport { r as createPostgresBuiltinCodecLookup } from \"./codec-registry-CKBDkxX7.mjs\";\nimport { n as postgresAuthoringEntityTypes } from \"./authoring-B2hHIzvd.mjs\";\nimport { a as nativeEnumEntityKind, c as roleEntityKind, o as policyEntityKind, s as rlsEnablementEntityKind, t as PostgresSchema } from \"./postgres-schema-AlEVkXXS.mjs\";\nimport { requiredSchemaKeys } from \"@internal/framework-components/codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { isAuthoringEntityTypeDescriptor } from \"@internal/framework-components/authoring\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { buildSqlSchemaQualifiedView } from \"@internal/sql-contract/contract-view\";\nimport { createPreserveEmptyPredicate } from \"@internal/contract/hashing-utils\";\nimport { SqlContractSerializerBase } from \"@internal/family-sql/ir\";\nimport { sqlContractCanonicalizationHooks } from \"@internal/sql-contract/canonicalization-hooks\";\n//#region src/core/postgres-contract-serializer.ts\nconst POSTGRES_AUTHORING_CTX = {\n\tfamily: \"sql\",\n\ttarget: \"postgres\",\n\tcodecLookup: createPostgresBuiltinCodecLookup(),\n\tdataTypeLookup: createPostgresBuiltinDataTypeLookup(),\n\tenumInferenceCodecs: {\n\t\ttext: PG_TEXT_CODEC_ID,\n\t\tint: PG_INT_CODEC_ID\n\t}\n};\nfunction isAuthoringEntityTypeFactoryOutput(output) {\n\treturn typeof output === \"object\" && output !== null && \"factory\" in output && typeof output.factory === \"function\";\n}\n/**\n* Walks a pack's entity-type namespace tree and emits hydration factories\n* keyed by the descriptor's `discriminator`. Used for `storage.types`\n* (codec-triple hydration). Namespace entries hydration dispatches by\n* entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n*/\nfunction collectStorageTypesHydrators(namespace) {\n\tconst registry = /* @__PURE__ */ new Map();\n\tconst walk = (node) => {\n\t\tfor (const value of Object.values(node)) {\n\t\t\tif (isAuthoringEntityTypeDescriptor(value)) {\n\t\t\t\tif (isAuthoringEntityTypeFactoryOutput(value.output)) {\n\t\t\t\t\tconst { factory } = value.output;\n\t\t\t\t\tregistry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof value === \"object\" && value !== null) walk(value);\n\t\t}\n\t};\n\twalk(namespace);\n\treturn registry;\n}\n/**\n* The canonicalization walk drops a field whose value equals its type's\n* default, which for a required field of an entity kind means the emitted\n* contract fails that kind's own schema on the next read (a RESTRICTIVE\n* policy's `permissive: false` is the live case). The set of fields that must\n* survive is therefore the required keys of the registered entity kinds —\n* read off the schemas rather than listed by hand, so a kind that gains a\n* required field is covered the day it gains one.\n*/\nfunction requiredEntityFieldsSurviveDefaults(kinds) {\n\treturn createPreserveEmptyPredicate(kinds.flatMap((kind) => requiredKeysOf(kind.schema).map((key) => [\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\tkind.kind,\n\t\t\"*\",\n\t\tkey\n\t])));\n}\nfunction requiredKeysOf(schema) {\n\tconst keys = requiredSchemaKeys(schema);\n\tif (keys === void 0) throw new InternalError(\"entity-kind schema does not expose arktype object props; the required-field preserve set cannot be derived\");\n\treturn keys;\n}\nvar PostgresContractSerializer = class extends SqlContractSerializerBase {\n\tshouldPreserveEmpty;\n\tconstructor(extraPackEntityKinds = []) {\n\t\tconst storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n\t\tconst entityKinds = [\n\t\t\tpolicyEntityKind,\n\t\t\troleEntityKind,\n\t\t\trlsEnablementEntityKind,\n\t\t\tnativeEnumEntityKind,\n\t\t\t...extraPackEntityKinds\n\t\t];\n\t\tsuper(storageTypesHydrators, entityKinds);\n\t\tconst preserveRequired = requiredEntityFieldsSurviveDefaults(entityKinds);\n\t\tthis.shouldPreserveEmpty = (path) => preserveRequired(path) || sqlContractCanonicalizationHooks.shouldPreserveEmpty(path);\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\tconst { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));\n\t\tconst allSlotsEmpty = Object.values(entries).every((slot) => slot === void 0 || Object.keys(slot).length === 0);\n\t\tif (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) return PostgresSchema.unbound;\n\t\tconst valueSetSlot = entries[\"valueSet\"];\n\t\tconst hasValueSets = valueSetSlot !== void 0 && Object.keys(valueSetSlot).length > 0;\n\t\treturn new PostgresSchema({\n\t\t\tid,\n\t\t\tentries: {\n\t\t\t\t...entries,\n\t\t\t\ttable: entries[\"table\"] ?? {},\n\t\t\t\t...hasValueSets ? { valueSet: valueSetSlot } : {}\n\t\t\t}\n\t\t});\n\t}\n\tserializeContract(contract) {\n\t\tconst { storage, ...rest } = contract;\n\t\tconst namespacesJson = {};\n\t\tfor (const [nsId, ns] of Object.entries(storage.namespaces)) {\n\t\t\tconst isUnboundSlot = ns.id === UNBOUND_NAMESPACE_ID;\n\t\t\tnamespacesJson[nsId] = {\n\t\t\t\tid: ns.id,\n\t\t\t\tkind: isUnboundSlot ? \"postgres-unbound-schema\" : \"postgres-schema\",\n\t\t\t\tentries: this.serializeNamespaceEntries(ns.entries)\n\t\t\t};\n\t\t}\n\t\tconst storageOut = {\n\t\t\tstorageHash: String(storage.storageHash),\n\t\t\tnamespaces: namespacesJson\n\t\t};\n\t\tif (storage.types !== void 0) {\n\t\t\tconst typesOut = {};\n\t\t\tfor (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.serializeJsonObject(entry);\n\t\t\tstorageOut[\"types\"] = typesOut;\n\t\t}\n\t\treturn blindCast({\n\t\t\t...rest,\n\t\t\tstorage: storageOut\n\t\t});\n\t}\n};\n//#endregion\n//#region src/core/postgres-contract-view.ts\nconst PostgresContractView = {\n\t/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */\n\tfrom(contract) {\n\t\treturn buildSqlSchemaQualifiedView(contract);\n\t},\n\t/** Deserialize a Postgres contract JSON envelope and wrap it in a view. */\n\tfromJson(json) {\n\t\treturn buildSqlSchemaQualifiedView(new PostgresContractSerializer().deserializeContract(json));\n\t}\n};\n//#endregion\nexport { PostgresContractSerializer as n, PostgresContractView as t };\n\n//# sourceMappingURL=postgres-contract-view-C1bi3x4v.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,yBAAyB;CAC9B,QAAQ;CACR,QAAQ;CACR,aAAa,iCAAiC;CAC9C,gBAAgB,oCAAoC;CACpD,qBAAqB;EACpB,MAAM;EACN,KAAK;CACN;AACD;AACA,SAAS,mCA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D95Eh_-DGLByWZD.mjs → postgres-migration-CeX6vfEU-DsmCRCnD.mjs}
RENAMED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { t as errorPostgresMigrationStackMissing } from "./errors-DYyzTYzE-39CV_aMo.mjs";
|
|
2
|
-
import { i as PostgresRlsPolicy, n as PostgresRlsEnablement } from "./postgres-schema-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as
|
|
9
|
-
import {
|
|
2
|
+
import { i as PostgresRlsPolicy, n as PostgresRlsEnablement } from "./postgres-schema-AlEVkXXS-ZfXWYddl.mjs";
|
|
3
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs";
|
|
4
|
+
import { n as postgresResolveDefault } from "./default-normalizer-Bf_Fhv4v-CugGfLAe.mjs";
|
|
5
|
+
import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-BthOWVjF-DuZ9iUh-.mjs";
|
|
6
|
+
import { a as renderDefaultLiteral } from "./planner-ddl-builders-Y0_96xpe-BzugdEDO.mjs";
|
|
7
|
+
import { A as RenameIndexCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, M as RenameTableCall, N as SetDefaultCall, P as SetNotNullCall, R as installExtension, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as RenamePostgresRlsPolicyCall, k as RenameConstraintCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-BAgAln5R-BTkhp29z.mjs";
|
|
8
|
+
import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-CtcRXhV8-nz3ff6b8.mjs";
|
|
9
|
+
import { l as resolveNamespaceIdForDdlSchema, r as issueNode } from "./control-policy-B7t5CB1S-CotIwNO4.mjs";
|
|
10
|
+
import { n as contractToPostgresDatabaseSchemaNode, t as buildPostgresPlanDiff } from "./diff-database-schema-KGNaKzKp-Bt2yYSIt.mjs";
|
|
11
|
+
import { n as PostgresContractView } from "./postgres-contract-view-C1bi3x4v-BAfk6euQ.mjs";
|
|
10
12
|
import { t as dataTransform } from "./data-transform-Bo32KRbq-BLn1_UG-.mjs";
|
|
11
13
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
14
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
@@ -18,7 +20,77 @@ import { SqlCheckConstraintIR, SqlIndexIR } from "@prisma/orm-family-sql/schema-
|
|
|
18
20
|
import { errorMigrationOperationOptionRemoved } from "@prisma/orm-framework/errors/migration";
|
|
19
21
|
import { Migration } from "@prisma/orm-family-sql/family/migration";
|
|
20
22
|
import { MigrationContractViews } from "@prisma/orm-toolchain/migration-tools/migration";
|
|
21
|
-
//#region ../../../3-targets/3-targets/postgres/dist/postgres-migration-
|
|
23
|
+
//#region ../../../3-targets/3-targets/postgres/dist/postgres-migration-CeX6vfEU.mjs
|
|
24
|
+
function postgresRenderDefault(def, column, type) {
|
|
25
|
+
if (def.kind === "function") return def.expression;
|
|
26
|
+
return renderDefaultLiteral(def.value, {
|
|
27
|
+
many: column.many,
|
|
28
|
+
...type
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The Postgres schema tree a contract describes, as the planner's "from" side:
|
|
33
|
+
* the target descriptor's `migrations.contractToSchema` hook and the trees
|
|
34
|
+
* `renameTable` compares to find its companion renames both go through here,
|
|
35
|
+
* so they are built with the same type lookups, default renderer and default resolver.
|
|
36
|
+
*/
|
|
37
|
+
function postgresContractToSchema(contract, frameworkComponents) {
|
|
38
|
+
const types = sqlTypeLookupsOf(frameworkComponents);
|
|
39
|
+
return contractToPostgresDatabaseSchemaNode(blindCast(contract), {
|
|
40
|
+
annotationNamespace: "pg",
|
|
41
|
+
dataTypeLookup: types.dataTypeLookup,
|
|
42
|
+
codecLookup: types.codecLookup,
|
|
43
|
+
renderDefault: postgresRenderDefault,
|
|
44
|
+
resolveDefault: postgresResolveDefault
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** The constraint of `nextNodes` the diff pairs with `node` and finds unchanged. */
|
|
48
|
+
function unchangedIn(node, nextNodes) {
|
|
49
|
+
return nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 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.
|
|
53
|
+
*/
|
|
54
|
+
function constraintNameRenames(input) {
|
|
55
|
+
const { schemaName, from, to, previous, next } = input;
|
|
56
|
+
const rename = (kind, oldName, unchanged, derivedName) => {
|
|
57
|
+
if (unchanged === void 0) return [];
|
|
58
|
+
const newName = unchanged.name ?? derivedName;
|
|
59
|
+
return oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];
|
|
60
|
+
};
|
|
61
|
+
const primaryKey = previous.primaryKey === void 0 ? [] : rename("primaryKey", previous.primaryKey.name ?? defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to));
|
|
62
|
+
const uniques = previous.uniques.flatMap((unique) => rename("unique", unique.name ?? defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));
|
|
63
|
+
const foreignKeys = previous.foreignKeys.flatMap((fk) => rename("foreignKey", fk.name ?? defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));
|
|
64
|
+
return [
|
|
65
|
+
...primaryKey,
|
|
66
|
+
...uniques,
|
|
67
|
+
...foreignKeys
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The constraint renames of a plan: {@link constraintNameRenames} for every table the start tree the planner was given and the end contract both have. 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.
|
|
72
|
+
*/
|
|
73
|
+
function plannedConstraintNameRenames(options) {
|
|
74
|
+
if (!options.policy.allowedOperationClasses.includes("widening")) return [];
|
|
75
|
+
PostgresDatabaseSchemaNode.assert(options.schema);
|
|
76
|
+
const startTablesBySchema = new Map(Object.values(options.schema.namespaces).map((namespace) => [namespace.schemaName, namespace.tables]));
|
|
77
|
+
const contract = options.contract;
|
|
78
|
+
const end = postgresContractToSchema(contract, options.frameworkComponents);
|
|
79
|
+
return Object.values(end.namespaces).flatMap((namespace) => {
|
|
80
|
+
const startTables = startTablesBySchema.get(namespace.schemaName) ?? {};
|
|
81
|
+
const schemaName = resolveNamespaceIdForDdlSchema(contract, namespace.schemaName) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : namespace.schemaName;
|
|
82
|
+
return Object.entries(namespace.tables).flatMap(([tableName, next]) => {
|
|
83
|
+
const previous = startTables[tableName];
|
|
84
|
+
return previous === void 0 ? [] : constraintNameRenames({
|
|
85
|
+
schemaName,
|
|
86
|
+
from: tableName,
|
|
87
|
+
to: tableName,
|
|
88
|
+
previous,
|
|
89
|
+
next
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
22
94
|
/**
|
|
23
95
|
* Rename post-pass for indexes, per `(schema, table)`, widening-only,
|
|
24
96
|
* deterministic by sorted names — the same structure as the policy pass
|
|
@@ -198,29 +270,6 @@ function pairCheckRenames(options, issues) {
|
|
|
198
270
|
consumed
|
|
199
271
|
};
|
|
200
272
|
}
|
|
201
|
-
function postgresRenderDefault(def, column, type) {
|
|
202
|
-
if (def.kind === "function") return def.expression;
|
|
203
|
-
return renderDefaultLiteral(def.value, {
|
|
204
|
-
many: column.many,
|
|
205
|
-
...type
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* The Postgres schema tree a contract describes, as the planner's "from" side:
|
|
210
|
-
* the target descriptor's `migrations.contractToSchema` hook and the trees
|
|
211
|
-
* `renameTable` compares to find its companion renames both go through here,
|
|
212
|
-
* so they are built with the same type lookups, default renderer and default resolver.
|
|
213
|
-
*/
|
|
214
|
-
function postgresContractToSchema(contract, frameworkComponents) {
|
|
215
|
-
const types = sqlTypeLookupsOf(frameworkComponents);
|
|
216
|
-
return contractToPostgresDatabaseSchemaNode(blindCast(contract), {
|
|
217
|
-
annotationNamespace: "pg",
|
|
218
|
-
dataTypeLookup: types.dataTypeLookup,
|
|
219
|
-
codecLookup: types.codecLookup,
|
|
220
|
-
renderDefault: postgresRenderDefault,
|
|
221
|
-
resolveDefault: postgresResolveDefault
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
273
|
function renamedMarker(marker, rename) {
|
|
225
274
|
if (!(marker instanceof PostgresRlsEnablement) || marker.tableName !== rename.from) return marker;
|
|
226
275
|
return new PostgresRlsEnablement({
|
|
@@ -253,29 +302,6 @@ function renameRlsReferences(entries, rename) {
|
|
|
253
302
|
...policies === void 0 ? {} : { policy: Object.fromEntries(Object.entries(policies).map(([name, policy]) => [name, renamedPolicy(policy, rename)])) }
|
|
254
303
|
};
|
|
255
304
|
}
|
|
256
|
-
/** The constraint of the next table the diff pairs with `node` and finds unchanged, as the diff compares them. */
|
|
257
|
-
function unchangedIn(node, nextNodes) {
|
|
258
|
-
return nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* The constraint renames that follow a table rename. A primary key, unique constraint or foreign key the start contract left unnamed carries a name derived from the old table name. When the end contract keeps the same constraint unchanged, it is renamed to the name the end contract gives it explicitly, or otherwise to the name derived from the new table name. A constraint the end contract changes is not renamed, so it keeps its name in the database. A constraint the start contract named keeps its name. Indexes and checks are not handled here: their wire names pair by content hash in the index and check rename passes.
|
|
262
|
-
*/
|
|
263
|
-
function constraintRenamesForTableRename(input) {
|
|
264
|
-
const { schemaName, from, to, previous, next } = input;
|
|
265
|
-
const rename = (kind, oldName, unchanged, derivedName) => {
|
|
266
|
-
if (unchanged === void 0) return [];
|
|
267
|
-
const newName = unchanged.name ?? derivedName;
|
|
268
|
-
return oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];
|
|
269
|
-
};
|
|
270
|
-
const primaryKey = previous.primaryKey !== void 0 && previous.primaryKey.name === void 0 ? rename("primaryKey", defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to)) : [];
|
|
271
|
-
const uniques = previous.uniques.filter((unique) => unique.name === void 0).flatMap((unique) => rename("unique", defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));
|
|
272
|
-
const foreignKeys = previous.foreignKeys.filter((fk) => fk.name === void 0).flatMap((fk) => rename("foreignKey", defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));
|
|
273
|
-
return [
|
|
274
|
-
...primaryKey,
|
|
275
|
-
...uniques,
|
|
276
|
-
...foreignKeys
|
|
277
|
-
];
|
|
278
|
-
}
|
|
279
305
|
const RENAME_POLICY = { allowedOperationClasses: ["widening"] };
|
|
280
306
|
function emissionSchemaForNamespace(contract, namespaceId) {
|
|
281
307
|
return namespaceId === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId);
|
|
@@ -287,7 +313,7 @@ function renamedTableNode(schema, contract, rename) {
|
|
|
287
313
|
return table;
|
|
288
314
|
}
|
|
289
315
|
/**
|
|
290
|
-
* The calls a migration's `renameTable` emits: the table rename, then a rename of each primary key, unique constraint and foreign key the start contract left unnamed, and of each wire-named index and check whose prefix derives from the table name. Only objects the end contract leaves otherwise unchanged are renamed;
|
|
316
|
+
* The calls a migration's `renameTable` emits: the table rename, then a rename of each primary key, unique constraint and foreign key the start contract left unnamed, and of each wire-named index and check whose prefix derives from the table name. Only objects the end contract leaves otherwise unchanged are renamed; a constraint takes the end contract's stated name, or the name derived from the new table name. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when the start contract lacks the table or the end contract lacks the new name.
|
|
291
317
|
*/
|
|
292
318
|
function postgresTableRenameCalls(input) {
|
|
293
319
|
const applied = applyTableRename({
|
|
@@ -314,7 +340,7 @@ function postgresTableRenameCalls(input) {
|
|
|
314
340
|
};
|
|
315
341
|
return [
|
|
316
342
|
new RenameTableCall(schemaName, rename.from, rename.to),
|
|
317
|
-
...
|
|
343
|
+
...constraintNameRenames({
|
|
318
344
|
schemaName,
|
|
319
345
|
from: rename.from,
|
|
320
346
|
to: rename.to,
|
|
@@ -565,6 +591,6 @@ function refuseEarlierSetDefaultOptions(options) {
|
|
|
565
591
|
});
|
|
566
592
|
}
|
|
567
593
|
//#endregion
|
|
568
|
-
export {
|
|
594
|
+
export { plannedConstraintNameRenames as a, pairIndexRenames as i, emissionSchemaForNamespace as n, postgresContractToSchema as o, pairCheckRenames as r, postgresRenderDefault as s, PostgresMigration as t };
|
|
569
595
|
|
|
570
|
-
//# sourceMappingURL=postgres-migration-
|
|
596
|
+
//# sourceMappingURL=postgres-migration-CeX6vfEU-DsmCRCnD.mjs.map
|