@prisma/orm-target-postgres 8.0.0-rc.21-dev.6 → 8.0.0-rc.21-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/{adapter-BIWKN0d7-B2BpKdVy.mjs → adapter-B84yJpi7-8wwdWq5R.mjs} +6 -6
  2. package/dist/{adapter-BIWKN0d7-B2BpKdVy.mjs.map → adapter-B84yJpi7-8wwdWq5R.mjs.map} +1 -1
  3. package/dist/adapter.d.mts +1 -1
  4. package/dist/adapter.mjs +5 -5
  5. package/dist/adapter__adapter.mjs +2 -2
  6. package/dist/adapter__control.d.mts +1 -1
  7. package/dist/adapter__control.mjs +4 -4
  8. package/dist/adapter__control.mjs.map +1 -1
  9. package/dist/adapter__runtime.mjs +4 -4
  10. package/dist/adapter__runtime.mjs.map +1 -1
  11. package/dist/adapter__sql-renderer.mjs +1 -1
  12. package/dist/{authoring-DOlbnTzz-BWXtiq9i.mjs → authoring-Bm8PD9ls-clXbYDiN.mjs} +209 -48
  13. package/dist/authoring-Bm8PD9ls-clXbYDiN.mjs.map +1 -0
  14. package/dist/{autoincrement-widths-D7Uub-uA-DccZpX6Q.mjs → autoincrement-widths-DkD24r-C-D4O96GJZ.mjs} +3 -3
  15. package/dist/{autoincrement-widths-D7Uub-uA-DccZpX6Q.mjs.map → autoincrement-widths-DkD24r-C-D4O96GJZ.mjs.map} +1 -1
  16. package/dist/{check-expressions-CCFJKC7N-DHEJIG2S.mjs → check-expressions-C_lM7sSK-Dtv6p3hg.mjs} +3 -3
  17. package/dist/{check-expressions-CCFJKC7N-DHEJIG2S.mjs.map → check-expressions-C_lM7sSK-Dtv6p3hg.mjs.map} +1 -1
  18. package/dist/{codec-registry-qdVGkdp_-DCI2nWSt.mjs → codec-registry-DVjibYBY-BeOUp5fk.mjs} +4 -4
  19. package/dist/{codec-registry-qdVGkdp_-DCI2nWSt.mjs.map → codec-registry-DVjibYBY-BeOUp5fk.mjs.map} +1 -1
  20. package/dist/{codecs-BcYLh1iB-Dxi2UgkJ.mjs → codecs-BqCmavY8-CC-ZbbTA.mjs} +12 -5
  21. package/dist/codecs-BqCmavY8-CC-ZbbTA.mjs.map +1 -0
  22. package/dist/{contract-contributions-DTGGTwRZ-BmYIo6M5.mjs → contract-contributions-rxCSM_1W-d9oohAzB.mjs} +16 -41
  23. package/dist/contract-contributions-rxCSM_1W-d9oohAzB.mjs.map +1 -0
  24. package/dist/{contract-free-Bjx-Ktot.mjs → contract-free-BrY8qnvY.mjs} +3 -3
  25. package/dist/{contract-free-Bjx-Ktot.mjs.map → contract-free-BrY8qnvY.mjs.map} +1 -1
  26. package/dist/{control-policy-B1Zvw6VN-DN4QDwpc.mjs → control-policy-BncmQ6LO-B8SXRfP_.mjs} +9 -9
  27. package/dist/{control-policy-B1Zvw6VN-DN4QDwpc.mjs.map → control-policy-BncmQ6LO-B8SXRfP_.mjs.map} +1 -1
  28. package/dist/{control-m9LWRUnY.d.mts → control-s1_5W_8t.d.mts} +179 -74
  29. package/dist/control-s1_5W_8t.d.mts.map +1 -0
  30. package/dist/{data-type-entries-DhUYJbVb-4NUH6vR_.mjs → data-type-entries-ZHPz2h_f-CNUmPGgf.mjs} +3 -3
  31. package/dist/{data-type-entries-DhUYJbVb-4NUH6vR_.mjs.map → data-type-entries-ZHPz2h_f-CNUmPGgf.mjs.map} +1 -1
  32. package/dist/{data-types-B7S_CHZd-C9JA40Ir.mjs → data-types-DklKHVmp-Bl-nwUa-.mjs} +21 -4
  33. package/dist/data-types-DklKHVmp-Bl-nwUa-.mjs.map +1 -0
  34. package/dist/{date-time-now-generators-C2aktlrc-uf9LqU6E.d.mts → date-time-now-generators-BZj5G1E3-BylrCrgW.d.mts} +4 -4
  35. package/dist/date-time-now-generators-BZj5G1E3-BylrCrgW.d.mts.map +1 -0
  36. package/dist/{date-time-now-generators-BrJ1cMzo-CxURsw2O.mjs → date-time-now-generators-Cc4PvFeB-XQWJz_4f.mjs} +21 -11
  37. package/dist/date-time-now-generators-Cc4PvFeB-XQWJz_4f.mjs.map +1 -0
  38. package/dist/{ddl-DiUFjVZe-DETlNlJh.mjs → ddl-LpR9foVX-YBmyKx74.mjs} +3 -3
  39. package/dist/{ddl-DiUFjVZe-DETlNlJh.mjs.map → ddl-LpR9foVX-YBmyKx74.mjs.map} +1 -1
  40. package/dist/{descriptor-meta-CGRsMMdO-tQxNSE_j.mjs → descriptor-meta-C2F_xt0P-D7gfqNS0.mjs} +17 -12
  41. package/dist/descriptor-meta-C2F_xt0P-D7gfqNS0.mjs.map +1 -0
  42. package/dist/{descriptor-meta-I7Ih-0hE-CrOjEir4.mjs → descriptor-meta-C2YuDfV8-B_u19j25.mjs} +4 -4
  43. package/dist/{descriptor-meta-I7Ih-0hE-CrOjEir4.mjs.map → descriptor-meta-C2YuDfV8-B_u19j25.mjs.map} +1 -1
  44. package/dist/{diff-database-schema-ASDRsuei-3Yro3-Tw.mjs → diff-database-schema-CcR7BN-A-BuftnIR2.mjs} +9 -9
  45. package/dist/{diff-database-schema-ASDRsuei-3Yro3-Tw.mjs.map → diff-database-schema-CcR7BN-A-BuftnIR2.mjs.map} +1 -1
  46. package/dist/{errors-Di_apgWJ-BLXRTfFj.mjs → errors-DG6xgXgr-Cb1XcPcb.mjs} +6 -5
  47. package/dist/errors-DG6xgXgr-Cb1XcPcb.mjs.map +1 -0
  48. package/dist/{full-text-CcHf5wkL.mjs → full-text-7szWl7EC.mjs} +3 -3
  49. package/dist/{full-text-CcHf5wkL.mjs.map → full-text-7szWl7EC.mjs.map} +1 -1
  50. package/dist/{full-text-index-definition-B0kQDs_M-8N6Slj3l.mjs → full-text-index-definition-BRNRSgZK-l_2TBarg.mjs} +3 -3
  51. package/dist/{full-text-index-definition-B0kQDs_M-8N6Slj3l.mjs.map → full-text-index-definition-BRNRSgZK-l_2TBarg.mjs.map} +1 -1
  52. package/dist/{full-text-parsers-hI_qtk-Q-DqTMF4n2.mjs → full-text-parsers-Dd5DOdBA-BTeOSzUj.mjs} +4 -4
  53. package/dist/{full-text-parsers-hI_qtk-Q-DqTMF4n2.mjs.map → full-text-parsers-Dd5DOdBA-BTeOSzUj.mjs.map} +1 -1
  54. package/dist/{full-text-search-document-7AKd6oOw-S-rsh3SZ.mjs → full-text-search-document-DWzECXD--BqrLGXsX.mjs} +5 -5
  55. package/dist/{full-text-search-document-7AKd6oOw-S-rsh3SZ.mjs.map → full-text-search-document-DWzECXD--BqrLGXsX.mjs.map} +1 -1
  56. package/dist/{index-types-DfnDGeQU-BWcrd_SP.mjs → index-types-5g7gXoWK-CBvkTIbr.mjs} +3 -3
  57. package/dist/{index-types-DfnDGeQU-BWcrd_SP.mjs.map → index-types-5g7gXoWK-CBvkTIbr.mjs.map} +1 -1
  58. package/dist/{infer-psl-contract-BZnLgJj6-EjqMFHxE.mjs → infer-psl-contract-CT9H9Xnw-l2pNPAyO.mjs} +70 -17
  59. package/dist/infer-psl-contract-CT9H9Xnw-l2pNPAyO.mjs.map +1 -0
  60. package/dist/migration-Be_iuIpn.mjs.map +1 -1
  61. package/dist/{native-type-normalizer-BpTZ6sm1.mjs → native-type-normalizer-DgHcQkwl.mjs} +2 -2
  62. package/dist/{native-type-normalizer-BpTZ6sm1.mjs.map → native-type-normalizer-DgHcQkwl.mjs.map} +1 -1
  63. package/dist/{op-factory-call-CUu2s6l7-CaAVzTwP.mjs → op-factory-call-BRaCqnFh-avSVdAgI.mjs} +8 -8
  64. package/dist/{op-factory-call-CUu2s6l7-CaAVzTwP.mjs.map → op-factory-call-BRaCqnFh-avSVdAgI.mjs.map} +1 -1
  65. package/dist/{pack-DKR4BRIY.d.mts → pack-BtgCVVid.d.mts} +184 -100
  66. package/dist/pack-BtgCVVid.d.mts.map +1 -0
  67. package/dist/{planner-C69ALB15-CasiGSdJ.mjs → planner-BsLpyYHC-IEpACcdS.mjs} +10 -10
  68. package/dist/{planner-C69ALB15-CasiGSdJ.mjs.map → planner-BsLpyYHC-IEpACcdS.mjs.map} +1 -1
  69. package/dist/{planner-ddl-builders-BHvruDX3-Sw7yWuWE.mjs → planner-ddl-builders-Dmr6ph8i-5FWxE6Wu.mjs} +3 -3
  70. package/dist/{planner-ddl-builders-BHvruDX3-Sw7yWuWE.mjs.map → planner-ddl-builders-Dmr6ph8i-5FWxE6Wu.mjs.map} +1 -1
  71. package/dist/{planner-identity-values-Cp0Cvrg7-BxMk9Qaf.mjs → planner-identity-values-BwYhwYeo-CaSwyXgC.mjs} +3 -3
  72. package/dist/{planner-identity-values-Cp0Cvrg7-BxMk9Qaf.mjs.map → planner-identity-values-BwYhwYeo-CaSwyXgC.mjs.map} +1 -1
  73. package/dist/{planner-produced-postgres-migration-BGo--l2b-ww24WTkY.mjs → planner-produced-postgres-migration-CU7D_5IE-Cv-o4-Hh.mjs} +4 -4
  74. package/dist/{planner-produced-postgres-migration-BGo--l2b-ww24WTkY.mjs.map → planner-produced-postgres-migration-CU7D_5IE-Cv-o4-Hh.mjs.map} +1 -1
  75. package/dist/{planner-sql-checks-Dhx-R5GJ-GyHfROia.mjs → planner-sql-checks-DOGD6v7y-BWkRMsXt.mjs} +19 -10
  76. package/dist/{planner-sql-checks-Dhx-R5GJ-GyHfROia.mjs.map → planner-sql-checks-DOGD6v7y-BWkRMsXt.mjs.map} +1 -1
  77. package/dist/{postgres-codec-traits-Cpq3LqzZ-D_WitJjX.mjs → postgres-codec-traits-BhLP9ipO-D5kVsAxr.mjs} +3 -3
  78. package/dist/{postgres-codec-traits-Cpq3LqzZ-D_WitJjX.mjs.map → postgres-codec-traits-BhLP9ipO-D5kVsAxr.mjs.map} +1 -1
  79. package/dist/{postgres-contract-view-CvoOn_Xj-Dr0DQlVT.mjs → postgres-contract-view-DBmVHV5m-DDZR3cBh.mjs} +8 -8
  80. package/dist/{postgres-contract-view-CvoOn_Xj-Dr0DQlVT.mjs.map → postgres-contract-view-DBmVHV5m-DDZR3cBh.mjs.map} +1 -1
  81. package/dist/{postgres-migration-69O9MUBt-BQ1_mj4S.mjs → postgres-migration-DrLpuKus-DOU9Rbkb.mjs} +11 -11
  82. package/dist/{postgres-migration-69O9MUBt-BQ1_mj4S.mjs.map → postgres-migration-DrLpuKus-DOU9Rbkb.mjs.map} +1 -1
  83. package/dist/{postgres-schema-CNNW8eA3-CwosQz5e.mjs → postgres-schema-CEGf780E-cyGo2Sii.mjs} +4 -4
  84. package/dist/{postgres-schema-CNNW8eA3-CwosQz5e.mjs.map → postgres-schema-CEGf780E-cyGo2Sii.mjs.map} +1 -1
  85. package/dist/{prisma7-binding-DFb9yHdO.d.mts → prisma7-binding-0UXq-q2N.d.mts} +191 -100
  86. package/dist/prisma7-binding-0UXq-q2N.d.mts.map +1 -0
  87. package/dist/{prisma7-binding-CcrXBBbM.mjs → prisma7-binding-BvvPWMwt.mjs} +27 -9
  88. package/dist/prisma7-binding-BvvPWMwt.mjs.map +1 -0
  89. package/dist/{render-ops-Dr6RDk6z-CSGJsR6N.mjs → render-ops-CbRkpwwx-C6wSWcTl.mjs} +4 -4
  90. package/dist/{render-ops-Dr6RDk6z-CSGJsR6N.mjs.map → render-ops-CbRkpwwx-C6wSWcTl.mjs.map} +1 -1
  91. package/dist/{resolve-ddl-schema-p68Q5F1u-DZAQNXpi.mjs → resolve-ddl-schema-BhOYD95_-DhUQYNLi.mjs} +3 -3
  92. package/dist/{resolve-ddl-schema-p68Q5F1u-DZAQNXpi.mjs.map → resolve-ddl-schema-BhOYD95_-DhUQYNLi.mjs.map} +1 -1
  93. package/dist/{runtime-DGgnFCG7.d.mts → runtime-BbPgK4gH.d.mts} +2 -2
  94. package/dist/{runtime-DGgnFCG7.d.mts.map → runtime-BbPgK4gH.d.mts.map} +1 -1
  95. package/dist/{sql-renderer-BdWJPa5F-DUvahuXZ.mjs → sql-renderer-BdWJPa5F-B8cdiqmK.mjs} +3 -3
  96. package/dist/{sql-renderer-BdWJPa5F-DUvahuXZ.mjs.map → sql-renderer-BdWJPa5F-B8cdiqmK.mjs.map} +1 -1
  97. package/dist/{sql-utils-CnnGiZBc.d.mts → sql-utils-Bq4nuPvy.d.mts} +6 -2
  98. package/dist/{sql-utils-CnnGiZBc.d.mts.map → sql-utils-Bq4nuPvy.d.mts.map} +1 -1
  99. package/dist/{sql-utils-0j_6QstU-DAfnt5Mu.mjs → sql-utils-ylvfJ1RJ-03xGdSLI.mjs} +34 -4
  100. package/dist/sql-utils-ylvfJ1RJ-03xGdSLI.mjs.map +1 -0
  101. package/dist/target.d.mts +7 -7
  102. package/dist/target.mjs +32 -32
  103. package/dist/target__codecs.mjs +2 -2
  104. package/dist/target__contract-free.mjs +3 -3
  105. package/dist/target__control.d.mts +2 -2
  106. package/dist/target__control.mjs +38 -25
  107. package/dist/target__control.mjs.map +1 -1
  108. package/dist/target__data-types.mjs +2 -2
  109. package/dist/target__diff-database-schema.mjs +1 -1
  110. package/dist/target__errors.mjs +1 -1
  111. package/dist/target__full-text-index-authoring.mjs +2 -2
  112. package/dist/target__full-text.mjs +2 -2
  113. package/dist/target__issue-planner.mjs +1 -1
  114. package/dist/target__migration.mjs +2 -2
  115. package/dist/target__native-type-normalizer.mjs +1 -1
  116. package/dist/target__op-factory-call.mjs +1 -1
  117. package/dist/target__pack.d.mts +1 -1
  118. package/dist/target__pack.mjs +1 -1
  119. package/dist/target__planner-ddl-builders.mjs +1 -1
  120. package/dist/target__planner-identity-values.mjs +1 -1
  121. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  122. package/dist/target__planner-sql-checks.mjs +1 -1
  123. package/dist/target__planner.mjs +2 -2
  124. package/dist/target__prisma7-binding.d.mts +1 -1
  125. package/dist/target__prisma7-binding.mjs +1 -1
  126. package/dist/target__render-ops.mjs +1 -1
  127. package/dist/target__runtime.d.mts +2 -2
  128. package/dist/target__runtime.mjs +7 -7
  129. package/dist/target__runtime.mjs.map +1 -1
  130. package/dist/target__schema-ir-annotations.mjs +1 -1
  131. package/dist/target__sql-utils.d.mts +2 -2
  132. package/dist/target__sql-utils.mjs +4 -4
  133. package/dist/target__types.mjs +2 -2
  134. package/package.json +9 -9
  135. package/dist/authoring-DOlbnTzz-BWXtiq9i.mjs.map +0 -1
  136. package/dist/codecs-BcYLh1iB-Dxi2UgkJ.mjs.map +0 -1
  137. package/dist/contract-contributions-DTGGTwRZ-BmYIo6M5.mjs.map +0 -1
  138. package/dist/control-m9LWRUnY.d.mts.map +0 -1
  139. package/dist/data-types-B7S_CHZd-C9JA40Ir.mjs.map +0 -1
  140. package/dist/date-time-now-generators-BrJ1cMzo-CxURsw2O.mjs.map +0 -1
  141. package/dist/date-time-now-generators-C2aktlrc-uf9LqU6E.d.mts.map +0 -1
  142. package/dist/descriptor-meta-CGRsMMdO-tQxNSE_j.mjs.map +0 -1
  143. package/dist/errors-Di_apgWJ-BLXRTfFj.mjs.map +0 -1
  144. package/dist/infer-psl-contract-BZnLgJj6-EjqMFHxE.mjs.map +0 -1
  145. package/dist/pack-DKR4BRIY.d.mts.map +0 -1
  146. package/dist/prisma7-binding-CcrXBBbM.mjs.map +0 -1
  147. package/dist/prisma7-binding-DFb9yHdO.d.mts.map +0 -1
  148. package/dist/sql-utils-0j_6QstU-DAfnt5Mu.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"planner-C69ALB15-CasiGSdJ.mjs","names":["#lowerer"],"sources":["../../../../3-targets/postgres/1-target/dist/planner-C69ALB15.mjs"],"sourcesContent":["import { i as quoteIdentifier } from \"./sql-utils-0j_6QstU.mjs\";\nimport { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { _ as PostgresRlsPolicy, r as isPostgresSchema } from \"./postgres-schema-CNNW8eA3.mjs\";\nimport { r as PostgresSchemaNodeKind, 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 { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-p68Q5F1u.mjs\";\nimport { t as buildPostgresPlanDiff } from \"./diff-database-schema-ASDRsuei.mjs\";\nimport { a as resolvePostgresNodeIssueCreationFactoryName, c as issueNode, d as postgresPlannerStrategies, f as tableAt, i as resolvePostgresNodeIssueControlPolicySubject, l as issueSchemaName, n as resolveNamespaceIdForDdlSchema, o as coalesceSubtreeIssues, p as postgresNodeStorageCoordinate, r as resolvePostgresCallControlPolicySubject, s as conflictForDisallowedCall, t as renderPostgresSuppression, u as planIssues } from \"./control-policy-B1Zvw6VN.mjs\";\nimport { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from \"./default-constraint-names-Cz9Yoeim.mjs\";\nimport { A as RemoveStoredValueCall, B as SetTableSchemaCall, C as DropNativeEnumTypeCall, D as DropTableCall, E as DropSchemaCall, F as RenameSchemaCall, L as ReplaceStoredValueCall, M as RenameConstraintCall, P as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, k as RawSqlCall, l as AlterColumnTypeCall, m as CreateSchemaCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, y as DropColumnCall } from \"./op-factory-call-CUu2s6l7.mjs\";\nimport { a as renameTableByHandStatements, c as postgresSchemaTables, d as postgresContractToSchema, i as postgresTableRenameCall, l as pairCheckRenames, n as postgresColumnRenameCall, o as renderRenameTableCall, r as postgresTableRenameByHand, s as createWorkingSchema, u as pairIndexRenames } from \"./postgres-migration-69O9MUBt.mjs\";\nimport { t as TypeScriptRenderablePostgresMigration } from \"./planner-produced-postgres-migration-BGo--l2b.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { enumValueCoordinateJson, isRenameStatement, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { appliedStatementsInOrder, backfillOfDefaultedField, detectTableNameCaseChanges, extractCodecControlHooks, fieldEventStorage, fieldStatementColumns, otherSpaceDeclaring, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planEnumValueRewrites, planFieldEventCalls, planStatements, plannerFailure, sqlTypeLookupsOf, storageNameOfOperation, subjectsOfCalls, unknownCallNames, withEnumValueOperations } from \"@internal/family-sql/control\";\nimport { ok } from \"@internal/utils/result\";\nimport { governingControlPolicy } from \"@internal/contract/types\";\n//#region src/core/migrations/constraint-name-renames.ts\n/** The constraint of `nextNodes` the diff pairs with `node` and finds unchanged. */\nfunction unchangedIn(node, nextNodes) {\n\treturn nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));\n}\n/**\n* 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.\n*/\nfunction constraintNameRenames(input) {\n\tconst { schemaName, from, to, previous, next, droppedConstraintNames } = input;\n\tconst rename = (kind, oldName, unchanged, derivedName) => {\n\t\tif (unchanged === void 0 || droppedConstraintNames.has(oldName)) return [];\n\t\tconst newName = unchanged.name ?? derivedName;\n\t\treturn oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];\n\t};\n\tconst primaryKey = previous.primaryKey === void 0 ? [] : rename(\"primaryKey\", previous.primaryKey.name ?? defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to));\n\tconst uniques = previous.uniques.flatMap((unique) => rename(\"unique\", unique.name ?? defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));\n\tconst foreignKeys = previous.foreignKeys.flatMap((fk) => rename(\"foreignKey\", fk.name ?? defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));\n\treturn [\n\t\t...primaryKey,\n\t\t...uniques,\n\t\t...foreignKeys\n\t];\n}\n/**\n* The constraint renames of a plan: {@link constraintNameRenames} for every table the start tree and the end contract both have, with the start tree as the plan's rename statements left it. The start tree comes from the start contract for `migration plan` and from the database for `db update`, so a database Prisma 8 created under derived names is renamed too once the contract states other names. A constraint one of `plannedCalls` drops is skipped: the plan adds it back under its end name, or not at all.\n*/\nfunction plannedConstraintNameRenames(options, plannedCalls) {\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return [];\n\tPostgresDatabaseSchemaNode.assert(options.schema);\n\tconst startTablesBySchema = new Map(Object.values(options.schema.namespaces).map((namespace) => [namespace.schemaName, namespace.tables]));\n\tconst contract = options.contract;\n\tconst end = postgresContractToSchema(contract, options.frameworkComponents);\n\treturn Object.values(end.namespaces).flatMap((namespace) => {\n\t\tconst startTables = startTablesBySchema.get(namespace.schemaName) ?? {};\n\t\tconst schemaName = resolveNamespaceIdForDdlSchema(contract, namespace.schemaName) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : namespace.schemaName;\n\t\treturn Object.entries(namespace.tables).flatMap(([tableName, next]) => {\n\t\t\tconst previous = startTables[tableName];\n\t\t\tconst droppedConstraintNames = new Set(plannedCalls.flatMap((call) => call.factoryName === \"dropConstraint\" && call.schemaName === schemaName && call.tableName === tableName ? [call.constraintName] : []));\n\t\t\treturn previous === void 0 ? [] : constraintNameRenames({\n\t\t\t\tschemaName,\n\t\t\t\tfrom: tableName,\n\t\t\t\tto: tableName,\n\t\t\t\tprevious,\n\t\t\t\tnext,\n\t\t\t\tdroppedConstraintNames\n\t\t\t});\n\t\t});\n\t});\n}\n//#endregion\n//#region src/core/migrations/operation-subjects.ts\n/**\n* The namespace a schema stands for in the locator's contract, or, for a schema that contract does\n* not declare, such as the new name of a renamed namespace, the schema's own name: a named Postgres\n* namespace's schema is its id.\n*/\nfunction storageNamespaceId(locator, schemaName) {\n\tif (schemaName === UNBOUND_NAMESPACE_ID) return UNBOUND_NAMESPACE_ID;\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(locator.contract, schemaName);\n\treturn namespaceId === UNBOUND_NAMESPACE_ID && schemaName !== \"public\" ? schemaName : namespaceId;\n}\nfunction qualified(schemaName, name) {\n\treturn schemaName === UNBOUND_NAMESPACE_ID ? name : `${schemaName}.${name}`;\n}\nfunction target(locator, schemaName, table, column) {\n\treturn {\n\t\tstorageName: qualified(schemaName, column === void 0 ? table : `${table}.${column}`),\n\t\ttable: {\n\t\t\tnamespaceId: storageNamespaceId(locator, schemaName),\n\t\t\ttable,\n\t\t\tcolumn\n\t\t}\n\t};\n}\nfunction rawSqlTarget(locator, call) {\n\tconst details = call.op.target.details;\n\tif (details === void 0) return {\n\t\tstorageName: call.op.id,\n\t\ttable: void 0\n\t};\n\tif (details.objectType === \"table\") return target(locator, details.schema, details.name, void 0);\n\tif (details.objectType === \"column\" && details.table !== void 0) return target(locator, details.schema, details.table, details.name);\n\treturn {\n\t\tstorageName: storageNameOfOperation(call.op),\n\t\ttable: void 0\n\t};\n}\nfunction knownTarget(locator, call) {\n\tif (call instanceof DropTableCall) return target(locator, call.schemaName, call.tableName, void 0);\n\tif (call instanceof DropColumnCall || call instanceof AlterColumnTypeCall) return target(locator, call.schemaName, call.tableName, call.columnName);\n\tif (call instanceof RemoveStoredValueCall) {\n\t\tconst enumValue = locator.storedValues?.get(call)?.enumValue;\n\t\treturn {\n\t\t\t...target(locator, call.schemaName, call.tableName, call.columnName),\n\t\t\t...ifDefined(\"enumValue\", enumValue)\n\t\t};\n\t}\n\tif (call instanceof RawSqlCall) return rawSqlTarget(locator, call);\n\tconst fieldEvent = locator.fieldEvents.get(call);\n\treturn fieldEvent === void 0 ? void 0 : fieldEventStorage(fieldEvent);\n}\n/**\n* A policy's identity across a replacement: its name, or the prefix of a generated (wire) name,\n* whose hash changes with the policy's body.\n*/\nfunction policyKey(schemaName, tableName, policyName) {\n\treturn JSON.stringify([\n\t\tschemaName,\n\t\ttableName,\n\t\tparseWireName(policyName)?.prefix ?? policyName\n\t]);\n}\n/**\n* The policies the plan creates. A drop of one of them, by name or by generated-name prefix, is\n* half of a replacement, which leaves a policy in place, so it widens no access.\n*/\nfunction createdPolicies(calls) {\n\treturn new Set(calls.flatMap((call) => call instanceof CreatePostgresRlsPolicyCall ? [policyKey(call.schemaName, call.tableName, call.policy.name)] : []));\n}\n/**\n* Disabling row-level security widens access: every role with table privileges then reads and\n* writes every row. Dropping a policy changes access either way, since a permissive policy grants\n* access and a restrictive one limits it, unless the plan creates the policy again.\n*/\nfunction accessChangesOf(locator, call, replaced) {\n\tif (call instanceof DisableRowLevelSecurityCall) return [{\n\t\t...target(locator, call.schemaName, call.tableName, void 0),\n\t\twidens: true\n\t}];\n\tif (call instanceof DropPostgresRlsPolicyCall && !replaced.has(policyKey(call.schemaName, call.tableName, call.policyName))) return [{\n\t\t...target(locator, call.schemaName, call.tableName, void 0),\n\t\twidens: false\n\t}];\n\treturn [];\n}\nfunction operationCountOf(call) {\n\treturn \"companions\" in call && Array.isArray(call.companions) ? 1 + call.companions.length : 1;\n}\n/** What each call of a Postgres plan loses, and whose access it changes. */\nfunction postgresCallSubjects(calls, locator) {\n\tconst replaced = createdPolicies(calls);\n\tconst destructive = calls.filter((call) => call.operationClass === \"destructive\");\n\tconst known = new Map(destructive.map((call) => [call, knownTarget(locator, call)]));\n\tconst unknownNames = unknownCallNames(destructive.filter((call) => known.get(call) === void 0));\n\treturn calls.map((call) => {\n\t\tconst lossTarget = known.get(call);\n\t\tconst unknownName = unknownNames.get(call);\n\t\tconst loss = call instanceof AlterColumnTypeCall ? \"typeChange\" : \"drop\";\n\t\treturn {\n\t\t\toperationCount: operationCountOf(call),\n\t\t\tlabel: call.label,\n\t\t\tdataLoss: lossTarget !== void 0 ? [{\n\t\t\t\t...lossTarget,\n\t\t\t\tloss,\n\t\t\t\t...ifDefined(\"keepDataEdit\", locator.storedValues?.get(call)?.keepDataEdit)\n\t\t\t}] : unknownName !== void 0 ? [{\n\t\t\t\tstorageName: unknownName,\n\t\t\t\ttable: void 0,\n\t\t\t\tloss\n\t\t\t}] : [],\n\t\t\taccessChanges: accessChangesOf(locator, call, replaced),\n\t\t\ttemporaryValues: call instanceof AddColumnWithTemporaryDefaultCall ? [{\n\t\t\t\ttable: call.tableName,\n\t\t\t\tcolumn: call.columnName,\n\t\t\t\tvalue: call.temporaryDefault\n\t\t\t}] : []\n\t\t};\n\t});\n}\n//#endregion\n//#region src/core/migrations/stored-value-calls.ts\n/** The calls that carry out a plan's stored value rewrites, each with the rewrite it carries out. */\nfunction postgresStoredValueCalls(rewrites, contract, codecs) {\n\treturn new Map(rewrites.map((rewrite) => {\n\t\tconst schemaName = emissionSchemaForNamespace(contract, rewrite.namespaceId);\n\t\tconst codec = {\n\t\t\tcodecRef: rewrite.codecRef,\n\t\t\tcodecs\n\t\t};\n\t\treturn [rewrite.to === void 0 ? new RemoveStoredValueCall(schemaName, rewrite.table, rewrite.column, rewrite.from, rewrite.many, codec, enumValueCoordinateJson(rewrite.enumValue)) : new ReplaceStoredValueCall(schemaName, rewrite.table, rewrite.column, rewrite.from, rewrite.to, rewrite.many, codec), rewrite];\n\t}));\n}\n/** Puts the stored value calls among the calls the diff plans, which order them. */\nfunction storedValueCallsStrategy(calls) {\n\treturn (issues) => calls.length === 0 ? { kind: \"no_match\" } : {\n\t\tkind: \"match\",\n\t\tissues,\n\t\tcalls\n\t};\n}\n/** The edit that keeps the data a removal loses: the removal, replaced by the replacements, in order. */\nfunction keepDataEdit(call, replacements) {\n\treturn {\n\t\tremove: call.renderTypeScript(),\n\t\treplaceWith: replacements.map(({ from, to }) => new ReplaceStoredValueCall(call.schemaName, call.tableName, call.columnName, from, to, call.many, call.codec).renderTypeScript()).join(\", \")\n\t};\n}\n/**\n* The enum value each removal is about, with the edit that keeps its data when the member keeps\n* its name and only its stored value changes.\n*/\nfunction storedValueSubjects(calls) {\n\tconst subjects = /* @__PURE__ */ new Map();\n\tfor (const [call, rewrite] of calls) {\n\t\tif (!(call instanceof RemoveStoredValueCall)) continue;\n\t\tsubjects.set(call, {\n\t\t\tenumValue: rewrite.enumValue,\n\t\t\t...ifDefined(\"keepDataEdit\", rewrite.keepData === void 0 ? void 0 : {\n\t\t\t\t...keepDataEdit(call, rewrite.keepData),\n\t\t\t\t...rewrite.swapsValues ? { swapsValues: true } : {}\n\t\t\t})\n\t\t});\n\t}\n\treturn subjects;\n}\nconst RENDER_ONLY_CODECS = { descriptorFor: () => void 0 };\n/**\n* The edit that keeps the data a failed removal check found, from the check's mark and its\n* operation's column: the removal as `migration.ts` writes it, replaced by a replacement whose new\n* value is the placeholder `\"<stored value>\"`.\n*/\nfunction keepRowsEdit(details, mark) {\n\tconst codec = mark.codecRef === void 0 ? void 0 : {\n\t\tcodecRef: mark.codecRef,\n\t\tcodecs: RENDER_ONLY_CODECS\n\t};\n\treturn keepDataEdit(new RemoveStoredValueCall(details.schema, details.table, details.name, mark.value, false, codec, mark.enumValue), [{\n\t\tfrom: mark.value,\n\t\tto: \"<stored value>\"\n\t}]);\n}\n/** The positions, among the plan's operations, of the operations that carry out `statement`. */\nfunction storedValueOperationIndexes(planCalls, calls, statement) {\n\tconst indexes = [];\n\tlet position = 0;\n\tfor (const call of planCalls) {\n\t\tif (calls.get(call)?.statement === statement) indexes.push(position);\n\t\tposition += \"companions\" in call && Array.isArray(call.companions) ? 1 + call.companions.length : 1;\n\t}\n\treturn indexes;\n}\n//#endregion\n//#region src/core/migrations/type-change-checks.ts\nfunction tableIn(tree, ddlSchemaName, tableName) {\n\treturn Object.values(tree.namespaces).find((node) => node.schemaName === ddlSchemaName)?.tables[tableName];\n}\nfunction escapedForPattern(text) {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n/**\n* Whether a check's predicate names the column, quoted or bare. The predicate is opaque SQL, so this\n* reads its text, and may name a check that does not depend on the column: dropping and adding\n* such a check again changes nothing.\n*/\nfunction mentionsColumn(check, column) {\n\tconst quoted = escapedForPattern(quoteIdentifier(column));\n\tconst bare = escapedForPattern(column);\n\treturn new RegExp(`${quoted}|(?<![\\\\w$\"])${bare}(?![\\\\w$\"])`, \"i\").test(check.expression);\n}\n/**\n* Puts a drop of each check that names a column a type change alters before the first such type\n* change, and the check back after the last. Postgres stores a check bound to the column's old type,\n* such as `array_position(tags, NULL::integer)`, and re-checks it while it alters the type, so a\n* check left in place can fail the alter; a check that names two retyped columns can only be added\n* back once both have their new types. Only checks the plan keeps unchanged are moved: one the plan\n* drops or adds is already planned around the alter. The check is added back as the destination\n* contract writes it.\n*/\nfunction withChecksAroundTypeChanges(input) {\n\tconst moved = /* @__PURE__ */ new Map();\n\tinput.calls.forEach((call, index) => {\n\t\tif (!(call instanceof AlterColumnTypeCall)) return;\n\t\tconst ddlSchemaName = input.ddlSchemaOf(call.schemaName);\n\t\tconst kept = tableIn(input.actual, ddlSchemaName, call.tableName)?.checks ?? [];\n\t\tfor (const check of tableIn(input.expected, ddlSchemaName, call.tableName)?.checks ?? []) {\n\t\t\tif (!mentionsColumn(check, call.columnName)) continue;\n\t\t\tif (!kept.some(({ name }) => name === check.name)) continue;\n\t\t\tconst key = JSON.stringify([\n\t\t\t\tddlSchemaName,\n\t\t\t\tcall.tableName,\n\t\t\t\tcheck.name\n\t\t\t]);\n\t\t\tconst entry = moved.get(key);\n\t\t\tif (entry === void 0) moved.set(key, {\n\t\t\t\tschemaName: call.schemaName,\n\t\t\t\ttableName: call.tableName,\n\t\t\t\tcheck,\n\t\t\t\tfirst: index,\n\t\t\t\tlast: index\n\t\t\t});\n\t\t\telse entry.last = index;\n\t\t}\n\t});\n\tconst entries = [...moved.values()];\n\treturn input.calls.flatMap((call, index) => [\n\t\t...entries.filter(({ first }) => first === index).map(({ schemaName, tableName, check }) => new DropCheckConstraintCall(schemaName, tableName, check.name)),\n\t\tcall,\n\t\t...entries.filter(({ last }) => last === index).map(({ schemaName, tableName, check }) => new AddCheckConstraintCall(schemaName, tableName, check.name, check.expression))\n\t]);\n}\n//#endregion\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 statements = this.planStatements(options, options.schema);\n\t\tif (!statements.ok) return plannerFailure([statements.failure]);\n\t\tconst { schema } = statements.value;\n\t\tconst removedSchemas = removedNamespaceSchemas(options, schema);\n\t\tconst { issues: rawIssues, expected: expectedSchema } = buildPostgresPlanDiff({\n\t\t\tcontract: options.contract,\n\t\t\tactualSchema: schema,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\toriginSchemas: originSchemaNames(options.fromContract)\n\t\t});\n\t\tconst droppedTables = rawIssues.filter((issue) => issueOutcome(issue) === \"not-expected\" && issueNode(issue)?.nodeKind === PostgresSchemaNodeKind.table);\n\t\tconst policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue) && !droppedTables.some((table) => isWithin(issue.path, table.path)));\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.filter((issue) => !isOriginNamespaceIssue(issue, originSchemaNames(options.fromContract)))), options.ownership, (ddlSchemaName) => namespaceIdOfSchema(options, ddlSchemaName));\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\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 rewrites = planEnumValueRewrites({\n\t\t\tstatements: options.statements,\n\t\t\tfromContract: options.fromContract,\n\t\t\tcontract: options.contract,\n\t\t\ttables: postgresSchemaTables(schema, options.contract),\n\t\t\tcodecs: types.codecLookup\n\t\t});\n\t\tif (!rewrites.ok) return plannerFailure([rewrites.failure]);\n\t\tconst storedValueCalls = postgresStoredValueCalls(rewrites.value, options.contract, types.codecLookup);\n\t\tconst relationalSchema = relationalNamespaceNode(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) => renameTableByHandStatements(options.contract, rename),\n\t\t\trenameTableCall: renderRenameTableCall,\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 defaultedBackfill = backfillOfDefaultedField(options.statements, options.fromContract, options.contract);\n\t\tif (defaultedBackfill !== void 0) return plannerFailure([defaultedBackfill]);\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\t...ifDefined(\"schema\", relationalSchema),\n\t\t\tstartTree: schema,\n\t\t\tendTree: expectedSchema,\n\t\t\tforeignKeyDropAuthority: (ddlSchemaName, tableName, foreignKey) => {\n\t\t\t\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);\n\t\t\t\tif ((tableAt(options.contract.storage, namespaceId, tableName) === void 0 && options.ownership?.declaresEntity({\n\t\t\t\t\tnamespaceId,\n\t\t\t\t\tentityKind: \"table\",\n\t\t\t\t\tentityName: tableName\n\t\t\t\t})) === true) return \"otherSpace\";\n\t\t\t\tconst { plannable } = partitionIssuesByControlPolicy({\n\t\t\t\t\tissues: [{\n\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\"database\",\n\t\t\t\t\t\t\tddlSchemaName,\n\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\tforeignKey.id\n\t\t\t\t\t\t],\n\t\t\t\t\t\tactual: foreignKey\n\t\t\t\t\t}],\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\tresolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n\t\t\t\t\tresolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName\n\t\t\t\t});\n\t\t\t\treturn plannable.length === 1 ? \"allowed\" : \"controlPolicy\";\n\t\t\t},\n\t\t\tpolicy: options.policy,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\tstatementColumns: fieldStatementColumns(options.statements, options.contract),\n\t\t\tstrategies: [\n\t\t\t\t...postgresPlannerStrategies,\n\t\t\t\tdropRemovedSchemasStrategy(removedSchemas.filter((schemaName) => !keptSchema(options, schemaName))),\n\t\t\t\tstoredValueCallsStrategy([...storedValueCalls.keys()])\n\t\t\t]\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({\n\t\t\t\t...options,\n\t\t\t\tschema\n\t\t\t}, result.value.calls)\n\t\t], options.contract);\n\t\tconst schemaDiffPartition = partitionPostgresCallsByControlPolicy(schemaDiff.calls, options.contract);\n\t\tconst fieldEventCalls = planFieldEventCalls({\n\t\t\tpriorContract: options.origin === null ? null : options.fromContract,\n\t\t\tnewContract: options.contract,\n\t\t\tcodecHooks,\n\t\t\ttableRenames: statements.value.tableRenames,\n\t\t\tcolumnRenames: statements.value.columnRenames,\n\t\t\tdataTypes: types.dataTypeLookup\n\t\t});\n\t\tconst fieldEventPartition = partitionPostgresCallsByControlPolicy(blindCast(fieldEventCalls.map(({ call }) => call)), options.contract);\n\t\tconst ordered = movePolicyDropsBeforeBlockedDdl(withChecksAroundTypeChanges({\n\t\t\tcalls: result.value.calls,\n\t\t\texpected: expectedSchema,\n\t\t\tactual: schema,\n\t\t\tddlSchemaOf: (name) => name === UNBOUND_NAMESPACE_ID ? resolveDdlSchemaForNamespaceStorage(options.contract.storage, UNBOUND_NAMESPACE_ID) : name\n\t\t}), schemaDiffPartition.kept);\n\t\tconst calls = [\n\t\t\t...statements.value.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.origin?.storageHash ?? null,\n\t\t\t\tto: options.contract.storage.storageHash\n\t\t\t}, options.spaceId, options.snapshotsImportPath, this.#lowerer),\n\t\t\tappliedStatements: withEnumValueOperations(appliedStatementsInOrder(options.statements, statements.value.appliedStatements), (statement) => storedValueOperationIndexes(calls, storedValueCalls, statement)),\n\t\t\t...subjectsOfCalls(postgresCallSubjects(calls, {\n\t\t\t\tcontract: options.fromContract ?? options.contract,\n\t\t\t\tfieldEvents: new Map(fieldEventCalls.map((fieldEvent) => [fieldEvent.call, fieldEvent])),\n\t\t\t\tstoredValues: storedValueSubjects(storedValueCalls)\n\t\t\t}), {\n\t\t\t\tfromContract: options.fromContract,\n\t\t\t\tcontract: options.contract,\n\t\t\t\torigins: statements.value.origins,\n\t\t\t\tbyHand: postgresTableRenameByHand(options.contract)\n\t\t\t}),\n\t\t\tnamespaces: {\n\t\t\t\tremoved: removedSchemas.map((schemaName) => namespaceIdOfSchema(options, schemaName)),\n\t\t\t\tadded: addedNamespaceIds(options)\n\t\t\t},\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 drop, which is `widening`. 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 plan that allows `widening` 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 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 (allowsWidening) 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\t/**\n\t* Plans the statements against a working copy of `schema`, in order, so each rename's companions\n\t* are computed against the schema the earlier statements left. The diff then runs on that schema.\n\t*/\n\tplanStatements(options, schema) {\n\t\tconst working = createWorkingSchema(schema);\n\t\tconst ddlSchemaOf = (namespaceId) => resolveDdlSchemaForNamespaceStorage(options.contract.storage, namespaceId);\n\t\tconst planned = planStatements({\n\t\t\tstatements: options.statements.filter(isRenameStatement),\n\t\t\tfromContract: options.fromContract,\n\t\t\tcontract: options.contract,\n\t\t\tpolicy: options.policy,\n\t\t\townership: {\n\t\t\t\toracle: options.ownership,\n\t\t\t\tspaceId: options.spaceId\n\t\t\t},\n\t\t\ttarget: {\n\t\t\t\ttables: () => postgresSchemaTables(working.current, options.contract),\n\t\t\t\tnamespaces: {\n\t\t\t\t\tcreateNamespaceCalls: (namespaceId) => {\n\t\t\t\t\t\tconst schemaName = ddlSchemaOf(namespaceId);\n\t\t\t\t\t\treturn working.current.existingSchemas.includes(schemaName) ? [] : [new CreateSchemaCall(schemaName)];\n\t\t\t\t\t},\n\t\t\t\t\tmoveTableCall: (move) => {\n\t\t\t\t\t\tif (options.fromContract === null) throw new InternalError(\"A table move is planned only from an origin contract\");\n\t\t\t\t\t\treturn new SetTableSchemaCall(emissionSchemaForNamespace(options.contract.storage.namespaces[move.from] === void 0 ? options.fromContract : options.contract, move.from), move.table, ddlSchemaOf(move.to));\n\t\t\t\t\t},\n\t\t\t\t\tnamespaceRenameRefusal: postgresNamespaceRenameRefusal,\n\t\t\t\t\trenameNamespaceCall: (rename) => {\n\t\t\t\t\t\tif (options.fromContract === null) throw new InternalError(\"A namespace rename is planned only from an origin contract\");\n\t\t\t\t\t\treturn new RenameSchemaCall(resolveDdlSchemaForNamespaceStorage(options.fromContract.storage, rename.from), ddlSchemaOf(rename.to));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\trenameTableCall: (rename) => postgresTableRenameCall({\n\t\t\t\t\tprevious: working.current,\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\trename,\n\t\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t\t}),\n\t\t\t\trenameColumnCall: (rename) => postgresColumnRenameCall({\n\t\t\t\t\tprevious: working.current,\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\trename,\n\t\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t\t}),\n\t\t\t\tapply: (call) => working.apply(call),\n\t\t\t\t...postgresTableRenameByHand(options.contract)\n\t\t\t}\n\t\t});\n\t\tif (!planned.ok) return planned;\n\t\treturn ok({\n\t\t\t...planned.value,\n\t\t\tschema: working.current\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/** Whether `path` lies under `ancestor`: a dropped table's policies go with it. */\nfunction isWithin(path, ancestor) {\n\treturn path.length > ancestor.length && ancestor.every((segment, index) => path[index] === segment);\n}\n/**\n* The DDL schemas in which the origin contract declares tables; none without an origin contract.\n* A namespace with no tables, such as the `public` the target always adds, owns nothing.\n*/\nfunction originSchemaNames(fromContract) {\n\tif (fromContract === null) return [];\n\treturn Object.entries(fromContract.storage.namespaces).filter(([namespaceId, namespace]) => namespaceId !== UNBOUND_NAMESPACE_ID && Object.keys(namespace.entries.table ?? {}).length > 0).map(([namespaceId]) => resolveDdlSchemaForNamespaceStorage(fromContract.storage, namespaceId));\n}\n/**\n* The namespaces the destination declares and the origin does not, other than `public` and those a\n* statement renames a namespace to: the new names a rename of a removed namespace may give it.\n*/\nfunction addedNamespaceIds(options) {\n\tconst { fromContract } = options;\n\tif (fromContract === null) return [];\n\tconst renamedTo = new Set(options.statements.flatMap((statement) => statement.kind === \"rename\" && statement.entity === \"namespace\" ? [statement.to] : []));\n\treturn Object.keys(options.contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID && namespaceId !== \"public\" && !renamedTo.has(namespaceId) && !Object.hasOwn(fromContract.storage.namespaces, namespaceId));\n}\n/** Every DDL schema the contract declares, with or without tables. */\nfunction declaredSchemaNames(contract) {\n\treturn new Set(Object.keys(contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID).map((namespaceId) => resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId)));\n}\n/**\n* The live schemas the origin contract declares and the destination does not: each is dropped,\n* its tables first, each table a data-loss question.\n*/\nfunction removedNamespaceSchemas(options, schema) {\n\tconst destination = declaredSchemaNames(options.contract);\n\treturn originSchemaNames(options.fromContract).filter((schemaName) => schemaName !== \"public\" && !destination.has(schemaName) && schema.namespaces[schemaName] !== void 0);\n}\n/**\n* The issue a schema of the origin contract raises for itself when the destination declares no\n* tables there, which would cover the issues of its tables: they are kept instead, so each table is\n* dropped and asked about on its own, and a removed schema is dropped after them.\n*/\nfunction isOriginNamespaceIssue(issue, originSchemas) {\n\tconst node = issueNode(issue);\n\treturn node !== void 0 && node.nodeKind === PostgresSchemaNodeKind.namespace && originSchemas.includes(issue.path[1] ?? \"\");\n}\n/** A removed schema that stays because another contract space declares it. */\nfunction keptSchema(options, schemaName) {\n\tif (options.fromContract === null) return true;\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.fromContract, schemaName);\n\treturn otherSpaceDeclaring({\n\t\toracle: options.ownership,\n\t\tspaceId: options.spaceId\n\t}, namespaceId) !== void 0;\n}\nfunction dropRemovedSchemasStrategy(schemaNames) {\n\treturn (issues) => schemaNames.length === 0 ? { kind: \"no_match\" } : {\n\t\tkind: \"match\",\n\t\tissues,\n\t\tcalls: schemaNames.map((name) => new DropSchemaCall(name))\n\t};\n}\n/**\n* Why a namespace cannot be renamed: `public` is the default schema Prisma owns and Postgres puts\n* on every search path, and a schema another contract space declares would be renamed for it too.\n*/\nfunction postgresNamespaceRenameRefusal(rename) {\n\tconst reason = `\"${DEFAULT_NAMESPACE_ID}\" is the default schema of every Postgres database`;\n\tif (rename.from === \"public\") return {\n\t\treason,\n\t\tfix: `Prisma owns schema \"${rename.from}\", and Postgres puts it on every search path, so a migration does not rename it. Move each model to the new namespace with --rename <Model>:${rename.to}.<Model> instead.`\n\t};\n\tif (rename.to === \"public\") return {\n\t\treason,\n\t\tfix: `Every Postgres database already has schema \"${rename.to}\", so no schema can be renamed to it. Move each model with --rename ${rename.from}.<Model>:<Model> instead.`\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*/\n/**\n* The namespace a live schema stands for: the destination's, or, for a schema only the origin\n* declares, such as one the destination removed, the origin's.\n*/\nfunction namespaceIdOfSchema(options, ddlSchemaName) {\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);\n\tif (namespaceId !== UNBOUND_NAMESPACE_ID || ddlSchemaName === \"public\" || options.fromContract === null) return namespaceId;\n\treturn resolveNamespaceIdForDdlSchema(options.fromContract, ddlSchemaName);\n}\nfunction retainUnownedExtras(issues, ownership, namespaceIdOf) {\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\treturn !ownership.declaresEntity({\n\t\t\tnamespaceId: namespaceIdOf(ddlSchemaName),\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 = governingControlPolicy(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(\"widening\")) 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 { keepRowsEdit as n, createPostgresMigrationPlanner as t };\n\n//# sourceMappingURL=planner-C69ALB15.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,YAAY,MAAM,WAAW;CACrC,OAAO,UAAU,MAAM,SAAS,KAAK,OAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAC5E;;;;AAIA,SAAS,sBAAsB,OAAO;CACrC,MAAM,EAAE,YAAY,MAAM,IAAI,UAAU,MAAM,2BAA2B;CACzE,MAAM,UAAU,MAAM,SAAS,WAAW,gBAAgB;EACzD,IAAI,cAAc,KAAK,KAAK,uBAAuB,IAAI,OAAO,GAAG,OAAO,CAAC;EACzE,MAAM,UAAU,UAAU,QAAQ;EAClC,OAAO,YAAY,UAAU,CAAC,IAAI,CAAC,IAAI,qBAAqB,YAAY,IAAI,MAAM,SAAS,OAAO,CAAC;CACpG;CACA,MAAM,aAAa,SAAS,eAAe,KAAK,IAAI,CAAC,IAAI,OAAO,cAAc,SAAS,WAAW,QAAQ,sBAAsB,IAAI,GAAG,YAAY,SAAS,YAAY,KAAK,eAAe,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,GAAG,sBAAsB,EAAE,CAAC;CACvP,MAAM,UAAU,SAAS,QAAQ,SAAS,WAAW,OAAO,UAAU,OAAO,QAAQ,kBAAkB,MAAM,OAAO,OAAO,GAAG,YAAY,QAAQ,KAAK,OAAO,GAAG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GAAG;EACJ,CAAC;CACF,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAS,wBAAwB,QAAQ,YAAY;CACpD,MAAM,iBAAiB,OAAO,OAAO,OAAO,UAAU;CACtD,MAAM,gBAAgB,eAAe,MAAM,SAAS,KAAK,eAAe,UAAU,KAAK,eAAe;CACtG,IAAI,kBAAkB,KAAK,GAAG,OAAO,KAAK;CAC1C,OAAO,UAAU,aAAa;AAC/B;;;;;;;;;;;;;;;;;;AAkBA,SAAS,uBAAuB,aAAa,UAAU,yBAAyB;CAC/E,MAAM,UAAU,wCAAwC,YAAY,MAAM,QAAQ;CAClF,MAAM,gBAAgB,uBAAuB,SAAS,SAAS,oBAAoB;CACnF,IAAI,kBAAkB,WAAW,OAAO;EACvC,aAAa;EACb,QAAQ;GACP,SAAS,YAAY,KAAK,IAAI,KAAK,IAAI;IACtC,GAAG;IACH,WAAW,YAAY,KAAK;GAC7B;GACA,QAAQ;GACR,aAAa,KAAK;GAClB,kBAAkB;EACnB;CACD;CACA,IAAI,CAAC,wBAAwB,SAAS,UAAU,GAAG,OAAO;EACzD,aAAa;EACb,UAAU,0BAA0B,YAAY,MAAM,uBAAuB;CAC9E;CACA,OAAO,EAAE,aAAa,OAAO;AAC9B;;;;;;;;;;AAUA,SAAS,2BAA2B,MAAM;CACzC,OAAO,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
+ {"version":3,"file":"planner-BsLpyYHC-IEpACcdS.mjs","names":["#lowerer"],"sources":["../../../../3-targets/postgres/1-target/dist/planner-BsLpyYHC.mjs"],"sourcesContent":["import { a as quoteIdentifier } from \"./sql-utils-ylvfJ1RJ.mjs\";\nimport { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { _ as PostgresRlsPolicy, r as isPostgresSchema } from \"./postgres-schema-CEGf780E.mjs\";\nimport { r as PostgresSchemaNodeKind, 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 { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-BhOYD95_.mjs\";\nimport { t as buildPostgresPlanDiff } from \"./diff-database-schema-CcR7BN-A.mjs\";\nimport { a as resolvePostgresNodeIssueCreationFactoryName, c as issueNode, d as postgresPlannerStrategies, f as tableAt, i as resolvePostgresNodeIssueControlPolicySubject, l as issueSchemaName, n as resolveNamespaceIdForDdlSchema, o as coalesceSubtreeIssues, p as postgresNodeStorageCoordinate, r as resolvePostgresCallControlPolicySubject, s as conflictForDisallowedCall, t as renderPostgresSuppression, u as planIssues } from \"./control-policy-BncmQ6LO.mjs\";\nimport { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from \"./default-constraint-names-Cz9Yoeim.mjs\";\nimport { A as RemoveStoredValueCall, B as SetTableSchemaCall, C as DropNativeEnumTypeCall, D as DropTableCall, E as DropSchemaCall, F as RenameSchemaCall, L as ReplaceStoredValueCall, M as RenameConstraintCall, P as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, k as RawSqlCall, l as AlterColumnTypeCall, m as CreateSchemaCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, y as DropColumnCall } from \"./op-factory-call-BRaCqnFh.mjs\";\nimport { a as renameTableByHandStatements, c as postgresSchemaTables, d as postgresContractToSchema, i as postgresTableRenameCall, l as pairCheckRenames, n as postgresColumnRenameCall, o as renderRenameTableCall, r as postgresTableRenameByHand, s as createWorkingSchema, u as pairIndexRenames } from \"./postgres-migration-DrLpuKus.mjs\";\nimport { t as TypeScriptRenderablePostgresMigration } from \"./planner-produced-postgres-migration-CU7D_5IE.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { enumValueCoordinateJson, isRenameStatement, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { appliedStatementsInOrder, backfillOfDefaultedField, detectTableNameCaseChanges, extractCodecControlHooks, fieldEventStorage, fieldStatementColumns, otherSpaceDeclaring, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planEnumValueRewrites, planFieldEventCalls, planStatements, plannerFailure, sqlTypeLookupsOf, storageNameOfOperation, subjectsOfCalls, unknownCallNames, withEnumValueOperations } from \"@internal/family-sql/control\";\nimport { ok } from \"@internal/utils/result\";\nimport { governingControlPolicy } from \"@internal/contract/types\";\n//#region src/core/migrations/constraint-name-renames.ts\n/** The constraint of `nextNodes` the diff pairs with `node` and finds unchanged. */\nfunction unchangedIn(node, nextNodes) {\n\treturn nextNodes.find((next) => next.id === node.id && next.isEqualTo(node));\n}\n/**\n* 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.\n*/\nfunction constraintNameRenames(input) {\n\tconst { schemaName, from, to, previous, next, droppedConstraintNames } = input;\n\tconst rename = (kind, oldName, unchanged, derivedName) => {\n\t\tif (unchanged === void 0 || droppedConstraintNames.has(oldName)) return [];\n\t\tconst newName = unchanged.name ?? derivedName;\n\t\treturn oldName === newName ? [] : [new RenameConstraintCall(schemaName, to, kind, oldName, newName)];\n\t};\n\tconst primaryKey = previous.primaryKey === void 0 ? [] : rename(\"primaryKey\", previous.primaryKey.name ?? defaultPrimaryKeyName(from), unchangedIn(previous.primaryKey, next.primaryKey === void 0 ? [] : [next.primaryKey]), defaultPrimaryKeyName(to));\n\tconst uniques = previous.uniques.flatMap((unique) => rename(\"unique\", unique.name ?? defaultUniqueName(from, unique.columns), unchangedIn(unique, next.uniques), defaultUniqueName(to, unique.columns)));\n\tconst foreignKeys = previous.foreignKeys.flatMap((fk) => rename(\"foreignKey\", fk.name ?? defaultForeignKeyName(from, fk.columns), unchangedIn(fk, next.foreignKeys), defaultForeignKeyName(to, fk.columns)));\n\treturn [\n\t\t...primaryKey,\n\t\t...uniques,\n\t\t...foreignKeys\n\t];\n}\n/**\n* The constraint renames of a plan: {@link constraintNameRenames} for every table the start tree and the end contract both have, with the start tree as the plan's rename statements left it. The start tree comes from the start contract for `migration plan` and from the database for `db update`, so a database Prisma 8 created under derived names is renamed too once the contract states other names. A constraint one of `plannedCalls` drops is skipped: the plan adds it back under its end name, or not at all.\n*/\nfunction plannedConstraintNameRenames(options, plannedCalls) {\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return [];\n\tPostgresDatabaseSchemaNode.assert(options.schema);\n\tconst startTablesBySchema = new Map(Object.values(options.schema.namespaces).map((namespace) => [namespace.schemaName, namespace.tables]));\n\tconst contract = options.contract;\n\tconst end = postgresContractToSchema(contract, options.frameworkComponents);\n\treturn Object.values(end.namespaces).flatMap((namespace) => {\n\t\tconst startTables = startTablesBySchema.get(namespace.schemaName) ?? {};\n\t\tconst schemaName = resolveNamespaceIdForDdlSchema(contract, namespace.schemaName) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : namespace.schemaName;\n\t\treturn Object.entries(namespace.tables).flatMap(([tableName, next]) => {\n\t\t\tconst previous = startTables[tableName];\n\t\t\tconst droppedConstraintNames = new Set(plannedCalls.flatMap((call) => call.factoryName === \"dropConstraint\" && call.schemaName === schemaName && call.tableName === tableName ? [call.constraintName] : []));\n\t\t\treturn previous === void 0 ? [] : constraintNameRenames({\n\t\t\t\tschemaName,\n\t\t\t\tfrom: tableName,\n\t\t\t\tto: tableName,\n\t\t\t\tprevious,\n\t\t\t\tnext,\n\t\t\t\tdroppedConstraintNames\n\t\t\t});\n\t\t});\n\t});\n}\n//#endregion\n//#region src/core/migrations/operation-subjects.ts\n/**\n* The namespace a schema stands for in the locator's contract, or, for a schema that contract does\n* not declare, such as the new name of a renamed namespace, the schema's own name: a named Postgres\n* namespace's schema is its id.\n*/\nfunction storageNamespaceId(locator, schemaName) {\n\tif (schemaName === UNBOUND_NAMESPACE_ID) return UNBOUND_NAMESPACE_ID;\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(locator.contract, schemaName);\n\treturn namespaceId === UNBOUND_NAMESPACE_ID && schemaName !== \"public\" ? schemaName : namespaceId;\n}\nfunction qualified(schemaName, name) {\n\treturn schemaName === UNBOUND_NAMESPACE_ID ? name : `${schemaName}.${name}`;\n}\nfunction target(locator, schemaName, table, column) {\n\treturn {\n\t\tstorageName: qualified(schemaName, column === void 0 ? table : `${table}.${column}`),\n\t\ttable: {\n\t\t\tnamespaceId: storageNamespaceId(locator, schemaName),\n\t\t\ttable,\n\t\t\tcolumn\n\t\t}\n\t};\n}\nfunction rawSqlTarget(locator, call) {\n\tconst details = call.op.target.details;\n\tif (details === void 0) return {\n\t\tstorageName: call.op.id,\n\t\ttable: void 0\n\t};\n\tif (details.objectType === \"table\") return target(locator, details.schema, details.name, void 0);\n\tif (details.objectType === \"column\" && details.table !== void 0) return target(locator, details.schema, details.table, details.name);\n\treturn {\n\t\tstorageName: storageNameOfOperation(call.op),\n\t\ttable: void 0\n\t};\n}\nfunction knownTarget(locator, call) {\n\tif (call instanceof DropTableCall) return target(locator, call.schemaName, call.tableName, void 0);\n\tif (call instanceof DropColumnCall || call instanceof AlterColumnTypeCall) return target(locator, call.schemaName, call.tableName, call.columnName);\n\tif (call instanceof RemoveStoredValueCall) {\n\t\tconst enumValue = locator.storedValues?.get(call)?.enumValue;\n\t\treturn {\n\t\t\t...target(locator, call.schemaName, call.tableName, call.columnName),\n\t\t\t...ifDefined(\"enumValue\", enumValue)\n\t\t};\n\t}\n\tif (call instanceof RawSqlCall) return rawSqlTarget(locator, call);\n\tconst fieldEvent = locator.fieldEvents.get(call);\n\treturn fieldEvent === void 0 ? void 0 : fieldEventStorage(fieldEvent);\n}\n/**\n* A policy's identity across a replacement: its name, or the prefix of a generated (wire) name,\n* whose hash changes with the policy's body.\n*/\nfunction policyKey(schemaName, tableName, policyName) {\n\treturn JSON.stringify([\n\t\tschemaName,\n\t\ttableName,\n\t\tparseWireName(policyName)?.prefix ?? policyName\n\t]);\n}\n/**\n* The policies the plan creates. A drop of one of them, by name or by generated-name prefix, is\n* half of a replacement, which leaves a policy in place, so it widens no access.\n*/\nfunction createdPolicies(calls) {\n\treturn new Set(calls.flatMap((call) => call instanceof CreatePostgresRlsPolicyCall ? [policyKey(call.schemaName, call.tableName, call.policy.name)] : []));\n}\n/**\n* Disabling row-level security widens access: every role with table privileges then reads and\n* writes every row. Dropping a policy changes access either way, since a permissive policy grants\n* access and a restrictive one limits it, unless the plan creates the policy again.\n*/\nfunction accessChangesOf(locator, call, replaced) {\n\tif (call instanceof DisableRowLevelSecurityCall) return [{\n\t\t...target(locator, call.schemaName, call.tableName, void 0),\n\t\twidens: true\n\t}];\n\tif (call instanceof DropPostgresRlsPolicyCall && !replaced.has(policyKey(call.schemaName, call.tableName, call.policyName))) return [{\n\t\t...target(locator, call.schemaName, call.tableName, void 0),\n\t\twidens: false\n\t}];\n\treturn [];\n}\nfunction operationCountOf(call) {\n\treturn \"companions\" in call && Array.isArray(call.companions) ? 1 + call.companions.length : 1;\n}\n/** What each call of a Postgres plan loses, and whose access it changes. */\nfunction postgresCallSubjects(calls, locator) {\n\tconst replaced = createdPolicies(calls);\n\tconst destructive = calls.filter((call) => call.operationClass === \"destructive\");\n\tconst known = new Map(destructive.map((call) => [call, knownTarget(locator, call)]));\n\tconst unknownNames = unknownCallNames(destructive.filter((call) => known.get(call) === void 0));\n\treturn calls.map((call) => {\n\t\tconst lossTarget = known.get(call);\n\t\tconst unknownName = unknownNames.get(call);\n\t\tconst loss = call instanceof AlterColumnTypeCall ? \"typeChange\" : \"drop\";\n\t\treturn {\n\t\t\toperationCount: operationCountOf(call),\n\t\t\tlabel: call.label,\n\t\t\tdataLoss: lossTarget !== void 0 ? [{\n\t\t\t\t...lossTarget,\n\t\t\t\tloss,\n\t\t\t\t...ifDefined(\"keepDataEdit\", locator.storedValues?.get(call)?.keepDataEdit)\n\t\t\t}] : unknownName !== void 0 ? [{\n\t\t\t\tstorageName: unknownName,\n\t\t\t\ttable: void 0,\n\t\t\t\tloss\n\t\t\t}] : [],\n\t\t\taccessChanges: accessChangesOf(locator, call, replaced),\n\t\t\ttemporaryValues: call instanceof AddColumnWithTemporaryDefaultCall ? [{\n\t\t\t\ttable: call.tableName,\n\t\t\t\tcolumn: call.columnName,\n\t\t\t\tvalue: call.temporaryDefault\n\t\t\t}] : []\n\t\t};\n\t});\n}\n//#endregion\n//#region src/core/migrations/stored-value-calls.ts\n/** The calls that carry out a plan's stored value rewrites, each with the rewrite it carries out. */\nfunction postgresStoredValueCalls(rewrites, contract, codecs) {\n\treturn new Map(rewrites.map((rewrite) => {\n\t\tconst schemaName = emissionSchemaForNamespace(contract, rewrite.namespaceId);\n\t\tconst codec = {\n\t\t\tcodecRef: rewrite.codecRef,\n\t\t\tcodecs\n\t\t};\n\t\treturn [rewrite.to === void 0 ? new RemoveStoredValueCall(schemaName, rewrite.table, rewrite.column, rewrite.from, rewrite.many, codec, enumValueCoordinateJson(rewrite.enumValue)) : new ReplaceStoredValueCall(schemaName, rewrite.table, rewrite.column, rewrite.from, rewrite.to, rewrite.many, codec), rewrite];\n\t}));\n}\n/** Puts the stored value calls among the calls the diff plans, which order them. */\nfunction storedValueCallsStrategy(calls) {\n\treturn (issues) => calls.length === 0 ? { kind: \"no_match\" } : {\n\t\tkind: \"match\",\n\t\tissues,\n\t\tcalls\n\t};\n}\n/** The edit that keeps the data a removal loses: the removal, replaced by the replacements, in order. */\nfunction keepDataEdit(call, replacements) {\n\treturn {\n\t\tremove: call.renderTypeScript(),\n\t\treplaceWith: replacements.map(({ from, to }) => new ReplaceStoredValueCall(call.schemaName, call.tableName, call.columnName, from, to, call.many, call.codec).renderTypeScript()).join(\", \")\n\t};\n}\n/**\n* The enum value each removal is about, with the edit that keeps its data when the member keeps\n* its name and only its stored value changes.\n*/\nfunction storedValueSubjects(calls) {\n\tconst subjects = /* @__PURE__ */ new Map();\n\tfor (const [call, rewrite] of calls) {\n\t\tif (!(call instanceof RemoveStoredValueCall)) continue;\n\t\tsubjects.set(call, {\n\t\t\tenumValue: rewrite.enumValue,\n\t\t\t...ifDefined(\"keepDataEdit\", rewrite.keepData === void 0 ? void 0 : {\n\t\t\t\t...keepDataEdit(call, rewrite.keepData),\n\t\t\t\t...rewrite.swapsValues ? { swapsValues: true } : {}\n\t\t\t})\n\t\t});\n\t}\n\treturn subjects;\n}\nconst RENDER_ONLY_CODECS = { descriptorFor: () => void 0 };\n/**\n* The edit that keeps the data a failed removal check found, from the check's mark and its\n* operation's column: the removal as `migration.ts` writes it, replaced by a replacement whose new\n* value is the placeholder `\"<stored value>\"`.\n*/\nfunction keepRowsEdit(details, mark) {\n\tconst codec = mark.codecRef === void 0 ? void 0 : {\n\t\tcodecRef: mark.codecRef,\n\t\tcodecs: RENDER_ONLY_CODECS\n\t};\n\treturn keepDataEdit(new RemoveStoredValueCall(details.schema, details.table, details.name, mark.value, false, codec, mark.enumValue), [{\n\t\tfrom: mark.value,\n\t\tto: \"<stored value>\"\n\t}]);\n}\n/** The positions, among the plan's operations, of the operations that carry out `statement`. */\nfunction storedValueOperationIndexes(planCalls, calls, statement) {\n\tconst indexes = [];\n\tlet position = 0;\n\tfor (const call of planCalls) {\n\t\tif (calls.get(call)?.statement === statement) indexes.push(position);\n\t\tposition += \"companions\" in call && Array.isArray(call.companions) ? 1 + call.companions.length : 1;\n\t}\n\treturn indexes;\n}\n//#endregion\n//#region src/core/migrations/type-change-checks.ts\nfunction tableIn(tree, ddlSchemaName, tableName) {\n\treturn Object.values(tree.namespaces).find((node) => node.schemaName === ddlSchemaName)?.tables[tableName];\n}\nfunction escapedForPattern(text) {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n/**\n* Whether a check's predicate names the column, quoted or bare. The predicate is opaque SQL, so this\n* reads its text, and may name a check that does not depend on the column: dropping and adding\n* such a check again changes nothing.\n*/\nfunction mentionsColumn(check, column) {\n\tconst quoted = escapedForPattern(quoteIdentifier(column));\n\tconst bare = escapedForPattern(column);\n\treturn new RegExp(`${quoted}|(?<![\\\\w$\"])${bare}(?![\\\\w$\"])`, \"i\").test(check.expression);\n}\n/**\n* Puts a drop of each check that names a column a type change alters before the first such type\n* change, and the check back after the last. Postgres stores a check bound to the column's old type,\n* such as `array_position(tags, NULL::integer)`, and re-checks it while it alters the type, so a\n* check left in place can fail the alter; a check that names two retyped columns can only be added\n* back once both have their new types. Only checks the plan keeps unchanged are moved: one the plan\n* drops or adds is already planned around the alter. The check is added back as the destination\n* contract writes it.\n*/\nfunction withChecksAroundTypeChanges(input) {\n\tconst moved = /* @__PURE__ */ new Map();\n\tinput.calls.forEach((call, index) => {\n\t\tif (!(call instanceof AlterColumnTypeCall)) return;\n\t\tconst ddlSchemaName = input.ddlSchemaOf(call.schemaName);\n\t\tconst kept = tableIn(input.actual, ddlSchemaName, call.tableName)?.checks ?? [];\n\t\tfor (const check of tableIn(input.expected, ddlSchemaName, call.tableName)?.checks ?? []) {\n\t\t\tif (!mentionsColumn(check, call.columnName)) continue;\n\t\t\tif (!kept.some(({ name }) => name === check.name)) continue;\n\t\t\tconst key = JSON.stringify([\n\t\t\t\tddlSchemaName,\n\t\t\t\tcall.tableName,\n\t\t\t\tcheck.name\n\t\t\t]);\n\t\t\tconst entry = moved.get(key);\n\t\t\tif (entry === void 0) moved.set(key, {\n\t\t\t\tschemaName: call.schemaName,\n\t\t\t\ttableName: call.tableName,\n\t\t\t\tcheck,\n\t\t\t\tfirst: index,\n\t\t\t\tlast: index\n\t\t\t});\n\t\t\telse entry.last = index;\n\t\t}\n\t});\n\tconst entries = [...moved.values()];\n\treturn input.calls.flatMap((call, index) => [\n\t\t...entries.filter(({ first }) => first === index).map(({ schemaName, tableName, check }) => new DropCheckConstraintCall(schemaName, tableName, check.name)),\n\t\tcall,\n\t\t...entries.filter(({ last }) => last === index).map(({ schemaName, tableName, check }) => new AddCheckConstraintCall(schemaName, tableName, check.name, check.expression))\n\t]);\n}\n//#endregion\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 statements = this.planStatements(options, options.schema);\n\t\tif (!statements.ok) return plannerFailure([statements.failure]);\n\t\tconst { schema } = statements.value;\n\t\tconst removedSchemas = removedNamespaceSchemas(options, schema);\n\t\tconst { issues: rawIssues, expected: expectedSchema } = buildPostgresPlanDiff({\n\t\t\tcontract: options.contract,\n\t\t\tactualSchema: schema,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\toriginSchemas: originSchemaNames(options.fromContract)\n\t\t});\n\t\tconst droppedTables = rawIssues.filter((issue) => issueOutcome(issue) === \"not-expected\" && issueNode(issue)?.nodeKind === PostgresSchemaNodeKind.table);\n\t\tconst policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue) && !droppedTables.some((table) => isWithin(issue.path, table.path)));\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.filter((issue) => !isOriginNamespaceIssue(issue, originSchemaNames(options.fromContract)))), options.ownership, (ddlSchemaName) => namespaceIdOfSchema(options, ddlSchemaName));\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\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 rewrites = planEnumValueRewrites({\n\t\t\tstatements: options.statements,\n\t\t\tfromContract: options.fromContract,\n\t\t\tcontract: options.contract,\n\t\t\ttables: postgresSchemaTables(schema, options.contract),\n\t\t\tcodecs: types.codecLookup\n\t\t});\n\t\tif (!rewrites.ok) return plannerFailure([rewrites.failure]);\n\t\tconst storedValueCalls = postgresStoredValueCalls(rewrites.value, options.contract, types.codecLookup);\n\t\tconst relationalSchema = relationalNamespaceNode(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) => renameTableByHandStatements(options.contract, rename),\n\t\t\trenameTableCall: renderRenameTableCall,\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 defaultedBackfill = backfillOfDefaultedField(options.statements, options.fromContract, options.contract);\n\t\tif (defaultedBackfill !== void 0) return plannerFailure([defaultedBackfill]);\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\t...ifDefined(\"schema\", relationalSchema),\n\t\t\tstartTree: schema,\n\t\t\tendTree: expectedSchema,\n\t\t\tforeignKeyDropAuthority: (ddlSchemaName, tableName, foreignKey) => {\n\t\t\t\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);\n\t\t\t\tif ((tableAt(options.contract.storage, namespaceId, tableName) === void 0 && options.ownership?.declaresEntity({\n\t\t\t\t\tnamespaceId,\n\t\t\t\t\tentityKind: \"table\",\n\t\t\t\t\tentityName: tableName\n\t\t\t\t})) === true) return \"otherSpace\";\n\t\t\t\tconst { plannable } = partitionIssuesByControlPolicy({\n\t\t\t\t\tissues: [{\n\t\t\t\t\t\tpath: [\n\t\t\t\t\t\t\t\"database\",\n\t\t\t\t\t\t\tddlSchemaName,\n\t\t\t\t\t\t\ttableName,\n\t\t\t\t\t\t\tforeignKey.id\n\t\t\t\t\t\t],\n\t\t\t\t\t\tactual: foreignKey\n\t\t\t\t\t}],\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\tresolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n\t\t\t\t\tresolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName\n\t\t\t\t});\n\t\t\t\treturn plannable.length === 1 ? \"allowed\" : \"controlPolicy\";\n\t\t\t},\n\t\t\tpolicy: options.policy,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\tstatementColumns: fieldStatementColumns(options.statements, options.contract),\n\t\t\tstrategies: [\n\t\t\t\t...postgresPlannerStrategies,\n\t\t\t\tdropRemovedSchemasStrategy(removedSchemas.filter((schemaName) => !keptSchema(options, schemaName))),\n\t\t\t\tstoredValueCallsStrategy([...storedValueCalls.keys()])\n\t\t\t]\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({\n\t\t\t\t...options,\n\t\t\t\tschema\n\t\t\t}, result.value.calls)\n\t\t], options.contract);\n\t\tconst schemaDiffPartition = partitionPostgresCallsByControlPolicy(schemaDiff.calls, options.contract);\n\t\tconst fieldEventCalls = planFieldEventCalls({\n\t\t\tpriorContract: options.origin === null ? null : options.fromContract,\n\t\t\tnewContract: options.contract,\n\t\t\tcodecHooks,\n\t\t\ttableRenames: statements.value.tableRenames,\n\t\t\tcolumnRenames: statements.value.columnRenames,\n\t\t\tdataTypes: types.dataTypeLookup\n\t\t});\n\t\tconst fieldEventPartition = partitionPostgresCallsByControlPolicy(blindCast(fieldEventCalls.map(({ call }) => call)), options.contract);\n\t\tconst ordered = movePolicyDropsBeforeBlockedDdl(withChecksAroundTypeChanges({\n\t\t\tcalls: result.value.calls,\n\t\t\texpected: expectedSchema,\n\t\t\tactual: schema,\n\t\t\tddlSchemaOf: (name) => name === UNBOUND_NAMESPACE_ID ? resolveDdlSchemaForNamespaceStorage(options.contract.storage, UNBOUND_NAMESPACE_ID) : name\n\t\t}), schemaDiffPartition.kept);\n\t\tconst calls = [\n\t\t\t...statements.value.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.origin?.storageHash ?? null,\n\t\t\t\tto: options.contract.storage.storageHash\n\t\t\t}, options.spaceId, options.snapshotsImportPath, this.#lowerer),\n\t\t\tappliedStatements: withEnumValueOperations(appliedStatementsInOrder(options.statements, statements.value.appliedStatements), (statement) => storedValueOperationIndexes(calls, storedValueCalls, statement)),\n\t\t\t...subjectsOfCalls(postgresCallSubjects(calls, {\n\t\t\t\tcontract: options.fromContract ?? options.contract,\n\t\t\t\tfieldEvents: new Map(fieldEventCalls.map((fieldEvent) => [fieldEvent.call, fieldEvent])),\n\t\t\t\tstoredValues: storedValueSubjects(storedValueCalls)\n\t\t\t}), {\n\t\t\t\tfromContract: options.fromContract,\n\t\t\t\tcontract: options.contract,\n\t\t\t\torigins: statements.value.origins,\n\t\t\t\tbyHand: postgresTableRenameByHand(options.contract)\n\t\t\t}),\n\t\t\tnamespaces: {\n\t\t\t\tremoved: removedSchemas.map((schemaName) => namespaceIdOfSchema(options, schemaName)),\n\t\t\t\tadded: addedNamespaceIds(options)\n\t\t\t},\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 drop, which is `widening`. 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 plan that allows `widening` 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 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 (allowsWidening) 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\t/**\n\t* Plans the statements against a working copy of `schema`, in order, so each rename's companions\n\t* are computed against the schema the earlier statements left. The diff then runs on that schema.\n\t*/\n\tplanStatements(options, schema) {\n\t\tconst working = createWorkingSchema(schema);\n\t\tconst ddlSchemaOf = (namespaceId) => resolveDdlSchemaForNamespaceStorage(options.contract.storage, namespaceId);\n\t\tconst planned = planStatements({\n\t\t\tstatements: options.statements.filter(isRenameStatement),\n\t\t\tfromContract: options.fromContract,\n\t\t\tcontract: options.contract,\n\t\t\tpolicy: options.policy,\n\t\t\townership: {\n\t\t\t\toracle: options.ownership,\n\t\t\t\tspaceId: options.spaceId\n\t\t\t},\n\t\t\ttarget: {\n\t\t\t\ttables: () => postgresSchemaTables(working.current, options.contract),\n\t\t\t\tnamespaces: {\n\t\t\t\t\tcreateNamespaceCalls: (namespaceId) => {\n\t\t\t\t\t\tconst schemaName = ddlSchemaOf(namespaceId);\n\t\t\t\t\t\treturn working.current.existingSchemas.includes(schemaName) ? [] : [new CreateSchemaCall(schemaName)];\n\t\t\t\t\t},\n\t\t\t\t\tmoveTableCall: (move) => {\n\t\t\t\t\t\tif (options.fromContract === null) throw new InternalError(\"A table move is planned only from an origin contract\");\n\t\t\t\t\t\treturn new SetTableSchemaCall(emissionSchemaForNamespace(options.contract.storage.namespaces[move.from] === void 0 ? options.fromContract : options.contract, move.from), move.table, ddlSchemaOf(move.to));\n\t\t\t\t\t},\n\t\t\t\t\tnamespaceRenameRefusal: postgresNamespaceRenameRefusal,\n\t\t\t\t\trenameNamespaceCall: (rename) => {\n\t\t\t\t\t\tif (options.fromContract === null) throw new InternalError(\"A namespace rename is planned only from an origin contract\");\n\t\t\t\t\t\treturn new RenameSchemaCall(resolveDdlSchemaForNamespaceStorage(options.fromContract.storage, rename.from), ddlSchemaOf(rename.to));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\trenameTableCall: (rename) => postgresTableRenameCall({\n\t\t\t\t\tprevious: working.current,\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\trename,\n\t\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t\t}),\n\t\t\t\trenameColumnCall: (rename) => postgresColumnRenameCall({\n\t\t\t\t\tprevious: working.current,\n\t\t\t\t\tcontract: options.contract,\n\t\t\t\t\trename,\n\t\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t\t}),\n\t\t\t\tapply: (call) => working.apply(call),\n\t\t\t\t...postgresTableRenameByHand(options.contract)\n\t\t\t}\n\t\t});\n\t\tif (!planned.ok) return planned;\n\t\treturn ok({\n\t\t\t...planned.value,\n\t\t\tschema: working.current\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/** Whether `path` lies under `ancestor`: a dropped table's policies go with it. */\nfunction isWithin(path, ancestor) {\n\treturn path.length > ancestor.length && ancestor.every((segment, index) => path[index] === segment);\n}\n/**\n* The DDL schemas in which the origin contract declares tables; none without an origin contract.\n* A namespace with no tables, such as the `public` the target always adds, owns nothing.\n*/\nfunction originSchemaNames(fromContract) {\n\tif (fromContract === null) return [];\n\treturn Object.entries(fromContract.storage.namespaces).filter(([namespaceId, namespace]) => namespaceId !== UNBOUND_NAMESPACE_ID && Object.keys(namespace.entries.table ?? {}).length > 0).map(([namespaceId]) => resolveDdlSchemaForNamespaceStorage(fromContract.storage, namespaceId));\n}\n/**\n* The namespaces the destination declares and the origin does not, other than `public` and those a\n* statement renames a namespace to: the new names a rename of a removed namespace may give it.\n*/\nfunction addedNamespaceIds(options) {\n\tconst { fromContract } = options;\n\tif (fromContract === null) return [];\n\tconst renamedTo = new Set(options.statements.flatMap((statement) => statement.kind === \"rename\" && statement.entity === \"namespace\" ? [statement.to] : []));\n\treturn Object.keys(options.contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID && namespaceId !== \"public\" && !renamedTo.has(namespaceId) && !Object.hasOwn(fromContract.storage.namespaces, namespaceId));\n}\n/** Every DDL schema the contract declares, with or without tables. */\nfunction declaredSchemaNames(contract) {\n\treturn new Set(Object.keys(contract.storage.namespaces).filter((namespaceId) => namespaceId !== UNBOUND_NAMESPACE_ID).map((namespaceId) => resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId)));\n}\n/**\n* The live schemas the origin contract declares and the destination does not: each is dropped,\n* its tables first, each table a data-loss question.\n*/\nfunction removedNamespaceSchemas(options, schema) {\n\tconst destination = declaredSchemaNames(options.contract);\n\treturn originSchemaNames(options.fromContract).filter((schemaName) => schemaName !== \"public\" && !destination.has(schemaName) && schema.namespaces[schemaName] !== void 0);\n}\n/**\n* The issue a schema of the origin contract raises for itself when the destination declares no\n* tables there, which would cover the issues of its tables: they are kept instead, so each table is\n* dropped and asked about on its own, and a removed schema is dropped after them.\n*/\nfunction isOriginNamespaceIssue(issue, originSchemas) {\n\tconst node = issueNode(issue);\n\treturn node !== void 0 && node.nodeKind === PostgresSchemaNodeKind.namespace && originSchemas.includes(issue.path[1] ?? \"\");\n}\n/** A removed schema that stays because another contract space declares it. */\nfunction keptSchema(options, schemaName) {\n\tif (options.fromContract === null) return true;\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.fromContract, schemaName);\n\treturn otherSpaceDeclaring({\n\t\toracle: options.ownership,\n\t\tspaceId: options.spaceId\n\t}, namespaceId) !== void 0;\n}\nfunction dropRemovedSchemasStrategy(schemaNames) {\n\treturn (issues) => schemaNames.length === 0 ? { kind: \"no_match\" } : {\n\t\tkind: \"match\",\n\t\tissues,\n\t\tcalls: schemaNames.map((name) => new DropSchemaCall(name))\n\t};\n}\n/**\n* Why a namespace cannot be renamed: `public` is the default schema Prisma owns and Postgres puts\n* on every search path, and a schema another contract space declares would be renamed for it too.\n*/\nfunction postgresNamespaceRenameRefusal(rename) {\n\tconst reason = `\"${DEFAULT_NAMESPACE_ID}\" is the default schema of every Postgres database`;\n\tif (rename.from === \"public\") return {\n\t\treason,\n\t\tfix: `Prisma owns schema \"${rename.from}\", and Postgres puts it on every search path, so a migration does not rename it. Move each model to the new namespace with --rename <Model>:${rename.to}.<Model> instead.`\n\t};\n\tif (rename.to === \"public\") return {\n\t\treason,\n\t\tfix: `Every Postgres database already has schema \"${rename.to}\", so no schema can be renamed to it. Move each model with --rename ${rename.from}.<Model>:<Model> instead.`\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*/\n/**\n* The namespace a live schema stands for: the destination's, or, for a schema only the origin\n* declares, such as one the destination removed, the origin's.\n*/\nfunction namespaceIdOfSchema(options, ddlSchemaName) {\n\tconst namespaceId = resolveNamespaceIdForDdlSchema(options.contract, ddlSchemaName);\n\tif (namespaceId !== UNBOUND_NAMESPACE_ID || ddlSchemaName === \"public\" || options.fromContract === null) return namespaceId;\n\treturn resolveNamespaceIdForDdlSchema(options.fromContract, ddlSchemaName);\n}\nfunction retainUnownedExtras(issues, ownership, namespaceIdOf) {\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\treturn !ownership.declaresEntity({\n\t\t\tnamespaceId: namespaceIdOf(ddlSchemaName),\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 = governingControlPolicy(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(\"widening\")) 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 { keepRowsEdit as n, createPostgresMigrationPlanner as t };\n\n//# sourceMappingURL=planner-BsLpyYHC.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,YAAY,MAAM,WAAW;CACrC,OAAO,UAAU,MAAM,SAAS,KAAK,OAAO,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAC5E;;;;AAIA,SAAS,sBAAsB,OAAO;CACrC,MAAM,EAAE,YAAY,MAAM,IAAI,UAAU,MAAM,2BAA2B;CACzE,MAAM,UAAU,MAAM,SAAS,WAAW,gBAAgB;EACzD,IAAI,cAAc,KAAK,KAAK,uBAAuB,IAAI,OAAO,GAAG,OAAO,CAAC;EACzE,MAAM,UAAU,UAAU,QAAQ;EAClC,OAAO,YAAY,UAAU,CAAC,IAAI,CAAC,IAAI,qBAAqB,YAAY,IAAI,MAAM,SAAS,OAAO,CAAC;CACpG;CACA,MAAM,a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AK;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,7 @@
1
- import { n as autoincrementWidthOfDataType } from "./autoincrement-widths-D7Uub-uA-DccZpX6Q.mjs";
1
+ import { n as autoincrementWidthOfDataType } from "./autoincrement-widths-DkD24r-C-D4O96GJZ.mjs";
2
2
  import { dataTypeParams } from "@prisma/orm-framework/components/codec";
3
3
  import { renderSqlTypeName, sqlDataTypeOfCodec } from "@prisma/orm-family-sql/contract/data-type";
4
- //#region ../../../3-targets/postgres/1-target/dist/planner-ddl-builders-BHvruDX3.mjs
4
+ //#region ../../../3-targets/postgres/1-target/dist/planner-ddl-builders-Dmr6ph8i.mjs
5
5
  /**
6
6
  * Renders the SQL type for a column in DDL context: the name its codec's data type is written
7
7
  * with, and its parameters.
@@ -25,4 +25,4 @@ function isAutoincrement(columnDefault) {
25
25
  //#endregion
26
26
  export { buildColumnTypeSql as t };
27
27
 
28
- //# sourceMappingURL=planner-ddl-builders-BHvruDX3-Sw7yWuWE.mjs.map
28
+ //# sourceMappingURL=planner-ddl-builders-Dmr6ph8i-5FWxE6Wu.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-ddl-builders-BHvruDX3-Sw7yWuWE.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-ddl-builders-BHvruDX3.mjs"],"sourcesContent":["import { n as autoincrementWidthOfDataType } from \"./autoincrement-widths-D7Uub-uA.mjs\";\nimport { dataTypeParams } from \"@internal/framework-components/codec\";\nimport { renderSqlTypeName, sqlDataTypeOfCodec } from \"@internal/sql-contract/data-type\";\n//#region src/core/migrations/planner-ddl-builders.ts\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.\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, allowPseudoTypes = true) {\n\tconst dataType = sqlDataTypeOfCodec(column.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, column.typeParams));\n\treturn column.many ? `${typeSql}[]` : typeSql;\n}\nfunction isAutoincrement(columnDefault) {\n\treturn columnDefault?.kind === \"function\" && columnDefault.expression === \"autoincrement()\";\n}\n//#endregion\nexport { buildColumnTypeSql as t };\n\n//# sourceMappingURL=planner-ddl-builders-BHvruDX3.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,mBAAmB,QAAQ,OAAO,mBAAmB,MAAM;CACnE,MAAM,WAAW,mBAAmB,OAAO,SAAS,KAAK;CACzD,IAAI,oBAAoB,gBAAgB,OAAO,OAAO,GAAG;EACxD,MAAM,QAAQ,6BAA6B,SAAS,EAAE;EACtD,IAAI,UAAU,KAAK,GAAG,OAAO,MAAM;CACpC;CACA,MAAM,UAAU,kBAAkB,UAAU,eAAe,UAAU,OAAO,UAAU,CAAC;CACvF,OAAO,OAAO,OAAO,GAAG,QAAQ,MAAM;AACvC;AACA,SAAS,gBAAgB,eAAe;CACvC,OAAO,eAAe,SAAS,cAAc,cAAc,eAAe;AAC3E"}
1
+ {"version":3,"file":"planner-ddl-builders-Dmr6ph8i-5FWxE6Wu.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-ddl-builders-Dmr6ph8i.mjs"],"sourcesContent":["import { n as autoincrementWidthOfDataType } from \"./autoincrement-widths-DkD24r-C.mjs\";\nimport { dataTypeParams } from \"@internal/framework-components/codec\";\nimport { renderSqlTypeName, sqlDataTypeOfCodec } from \"@internal/sql-contract/data-type\";\n//#region src/core/migrations/planner-ddl-builders.ts\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.\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, allowPseudoTypes = true) {\n\tconst dataType = sqlDataTypeOfCodec(column.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, column.typeParams));\n\treturn column.many ? `${typeSql}[]` : typeSql;\n}\nfunction isAutoincrement(columnDefault) {\n\treturn columnDefault?.kind === \"function\" && columnDefault.expression === \"autoincrement()\";\n}\n//#endregion\nexport { buildColumnTypeSql as t };\n\n//# sourceMappingURL=planner-ddl-builders-Dmr6ph8i.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,mBAAmB,QAAQ,OAAO,mBAAmB,MAAM;CACnE,MAAM,WAAW,mBAAmB,OAAO,SAAS,KAAK;CACzD,IAAI,oBAAoB,gBAAgB,OAAO,OAAO,GAAG;EACxD,MAAM,QAAQ,6BAA6B,SAAS,EAAE;EACtD,IAAI,UAAU,KAAK,GAAG,OAAO,MAAM;CACpC;CACA,MAAM,UAAU,kBAAkB,UAAU,eAAe,UAAU,OAAO,UAAU,CAAC;CACvF,OAAO,OAAO,OAAO,GAAG,QAAQ,MAAM;AACvC;AACA,SAAS,gBAAgB,eAAe;CACvC,OAAO,eAAe,SAAS,cAAc,cAAc,eAAe;AAC3E"}
@@ -1,7 +1,7 @@
1
- import { A as pgJsonb, D as pgInterval, E as pgInt8, F as pgText, I as pgTextArray, J as pgVarchar, K as pgUuid, L as pgTime, M as pgNumeric, S as pgFloat8, T as pgInt4, U as pgTimetz, V as pgTimestamptz, _ as pgDate, d as pgBool, f as pgBytea, h as pgChar, k as pgJson, l as pgBit, q as pgVarbit, w as pgInt2, x as pgFloat4, z as pgTimestamp } from "./data-types-B7S_CHZd-C9JA40Ir.mjs";
1
+ import { A as pgJsonb, D as pgInterval, E as pgInt8, F as pgText, I as pgTextArray, J as pgVarchar, K as pgUuid, L as pgTime, M as pgNumeric, S as pgFloat8, T as pgInt4, U as pgTimetz, V as pgTimestamptz, _ as pgDate, d as pgBool, f as pgBytea, h as pgChar, k as pgJson, l as pgBit, q as pgVarbit, w as pgInt2, x as pgFloat4, z as pgTimestamp } from "./data-types-DklKHVmp-Bl-nwUa-.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/postgres/1-target/dist/planner-identity-values-Cp0Cvrg7.mjs
4
+ //#region ../../../3-targets/postgres/1-target/dist/planner-identity-values-BwYhwYeo.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),
@@ -67,4 +67,4 @@ function buildBitIdentityValue(typeParams) {
67
67
  //#endregion
68
68
  export { resolveIdentityValue as n, buildBuiltinIdentityValue as t };
69
69
 
70
- //# sourceMappingURL=planner-identity-values-Cp0Cvrg7-BxMk9Qaf.mjs.map
70
+ //# sourceMappingURL=planner-identity-values-BwYhwYeo-CaSwyXgC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-identity-values-Cp0Cvrg7-BxMk9Qaf.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-identity-values-Cp0Cvrg7.mjs"],"sourcesContent":["import { D as pgTime, E as pgTextArray, I as pgUuid, L as pgVarbit, N as pgTimetz, R as pgVarchar, S as pgNumeric, T as pgText, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, j as pgTimestamptz, k as pgTimestamp, n as pgBit, o as pgChar, p as pgFloat8, v as pgInterval, y as pgJson } from \"./data-types-B7S_CHZd.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) {\n\tconst { codecId, typeParams } = column;\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-Cp0Cvrg7.mjs.map"],"mappings":";;;;;;;;;AASA,SAAS,qBAAqB,QAAQ,YAAY,OAAO;CACxD,MAAM,EAAE,SAAS,eAAe;CAChC,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
+ {"version":3,"file":"planner-identity-values-BwYhwYeo-CaSwyXgC.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-identity-values-BwYhwYeo.mjs"],"sourcesContent":["import { D as pgTime, E as pgTextArray, I as pgUuid, L as pgVarbit, N as pgTimetz, R as pgVarchar, S as pgNumeric, T as pgText, _ as pgInt8, a as pgBytea, b as pgJsonb, c as pgDate, f as pgFloat4, g as pgInt4, h as pgInt2, i as pgBool, j as pgTimestamptz, k as pgTimestamp, n as pgBit, o as pgChar, p as pgFloat8, v as pgInterval, y as pgJson } from \"./data-types-DklKHVmp.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) {\n\tconst { codecId, typeParams } = column;\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-BwYhwYeo.mjs.map"],"mappings":";;;;;;;;;AASA,SAAS,qBAAqB,QAAQ,YAAY,OAAO;CACxD,MAAM,EAAE,SAAS,eAAe;CAChC,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-69O9MUBt-BQ1_mj4S.mjs";
2
- import { t as renderOps } from "./render-ops-Dr6RDk6z-CSGJsR6N.mjs";
1
+ import { t as PostgresMigration } from "./postgres-migration-DrLpuKus-DOU9Rbkb.mjs";
2
+ import { t as renderOps } from "./render-ops-CbRkpwwx-C6wSWcTl.mjs";
3
3
  import { t as renderCallsToTypeScript } from "./render-typescript-Dqp1Spgn-B4mJhuVr.mjs";
4
- //#region ../../../3-targets/postgres/1-target/dist/planner-produced-postgres-migration-BGo--l2b.mjs
4
+ //#region ../../../3-targets/postgres/1-target/dist/planner-produced-postgres-migration-CU7D_5IE.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-BGo--l2b-ww24WTkY.mjs.map
47
+ //# sourceMappingURL=planner-produced-postgres-migration-CU7D_5IE-Cv-o4-Hh.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-produced-postgres-migration-BGo--l2b-ww24WTkY.mjs","names":["#calls","#meta","#spaceId","#snapshotsImportPath","#lowerer","#operationsCache"],"sources":["../../../../3-targets/postgres/1-target/dist/planner-produced-postgres-migration-BGo--l2b.mjs"],"sourcesContent":["import { t as PostgresMigration } from \"./postgres-migration-69O9MUBt.mjs\";\nimport { t as renderOps } from \"./render-ops-Dr6RDk6z.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-BGo--l2b.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"}
1
+ {"version":3,"file":"planner-produced-postgres-migration-CU7D_5IE-Cv-o4-Hh.mjs","names":["#calls","#meta","#spaceId","#snapshotsImportPath","#lowerer","#operationsCache"],"sources":["../../../../3-targets/postgres/1-target/dist/planner-produced-postgres-migration-CU7D_5IE.mjs"],"sourcesContent":["import { t as PostgresMigration } from \"./postgres-migration-DrLpuKus.mjs\";\nimport { t as renderOps } from \"./render-ops-CbRkpwwx.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-CU7D_5IE.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"}
@@ -1,9 +1,9 @@
1
- import { l as postgresError } from "./errors-Di_apgWJ-BLXRTfFj.mjs";
2
- import { h as postgresCreateNamespace } from "./postgres-schema-CNNW8eA3-CwosQz5e.mjs";
3
- import { r as autoincrementWidthOfPseudoType } from "./autoincrement-widths-D7Uub-uA-DccZpX6Q.mjs";
1
+ import { l as postgresError } from "./errors-DG6xgXgr-Cb1XcPcb.mjs";
2
+ import { h as postgresCreateNamespace } from "./postgres-schema-CEGf780E-cyGo2Sii.mjs";
3
+ import { r as autoincrementWidthOfPseudoType } from "./autoincrement-widths-DkD24r-C-D4O96GJZ.mjs";
4
4
  import { assembleDataTypes } from "@prisma/orm-framework/components/codec";
5
5
  import { checkRawTypeText, isSqlDataType, renderSqlCatalogText, renderSqlTypeName, resolveReportedSqlType, resolveWrittenSqlTypes } from "@prisma/orm-family-sql/contract/data-type";
6
- //#region ../../../3-targets/postgres/1-target/dist/planner-sql-checks-Dhx-R5GJ.mjs
6
+ //#region ../../../3-targets/postgres/1-target/dist/planner-sql-checks-DOGD6v7y.mjs
7
7
  /**
8
8
  * String-keyed entry points the migration ops use to render
9
9
  * schema-qualified DDL and catalog checks. The `schema` argument is
@@ -100,15 +100,24 @@ function readWrittenType(type, dataTypes) {
100
100
  ok: false,
101
101
  reason: `more than one data type of the configured stack reads the type "${type}", as ${byText.map((resolved) => resolved.dataType.id).join(" and ")}`
102
102
  };
103
- const resolved = byText[0] ?? resolvedByKind(base, sqlTypes);
104
- if (resolved === void 0) return {
103
+ const [written] = byText;
104
+ if (written !== void 0) return {
105
+ ok: true,
106
+ type: written.dataType,
107
+ typeParams: written.typeParams,
108
+ writtenTypeParams: written.writtenTypeParams,
109
+ many: array !== null
110
+ };
111
+ const byKind = resolvedByKind(base, sqlTypes);
112
+ if (byKind === void 0) return {
105
113
  ok: false,
106
114
  reason: `no data type of the configured stack reads the type "${type}"`
107
115
  };
108
116
  return {
109
117
  ok: true,
110
- type: resolved.dataType,
111
- typeParams: resolved.typeParams,
118
+ type: byKind.dataType,
119
+ typeParams: byKind.typeParams,
120
+ writtenTypeParams: byKind.typeParams,
112
121
  many: array !== null
113
122
  };
114
123
  }
@@ -127,7 +136,7 @@ function readColumnTypeCheck(type, dataTypes) {
127
136
  ok: true,
128
137
  check: {
129
138
  kind: "catalog-text",
130
- text: `${renderSqlCatalogText(read.type, read.typeParams)}${read.many ? "[]" : ""}`
139
+ text: `${renderSqlCatalogText(read.type, read.writtenTypeParams)}${read.many ? "[]" : ""}`
131
140
  }
132
141
  };
133
142
  }
@@ -148,4 +157,4 @@ function resolvedByKind(base, dataTypes) {
148
157
  //#endregion
149
158
  export { stackDataTypes as a, qualifyTableName as i, columnTypeCheckIfReadable as n, writtenColumnType as o, columnTypeCheckText as r, alterTypeCheck as t };
150
159
 
151
- //# sourceMappingURL=planner-sql-checks-Dhx-R5GJ-GyHfROia.mjs.map
160
+ //# sourceMappingURL=planner-sql-checks-DOGD6v7y-BWkRMsXt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-sql-checks-Dhx-R5GJ-GyHfROia.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-sql-checks-Dhx-R5GJ.mjs"],"sourcesContent":["import { l as postgresError } from \"./errors-Di_apgWJ.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-CNNW8eA3.mjs\";\nimport { r as autoincrementWidthOfPseudoType } from \"./autoincrement-widths-D7Uub-uA.mjs\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { checkRawTypeText, isSqlDataType, renderSqlCatalogText, renderSqlTypeName, resolveReportedSqlType, resolveWrittenSqlTypes } from \"@internal/sql-contract/data-type\";\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/** The data types the components of a stack register. */\nfunction stackDataTypes(frameworkComponents) {\n\treturn assembleDataTypes(frameworkComponents).declared.map(({ type }) => type);\n}\nconst ARRAY_SUFFIX = /^(.*?)(?:\\s*\\[\\s*\\])+$/s;\nconst QUOTED_SEGMENT = /^\"((?:[^\"]|\"\")+)\"/;\n/** The segments of a name written as one or two double-quoted identifiers, `\"Mood\"` or `\"app\".\"status\"`. */\nfunction quotedName(text) {\n\tconst segments = [];\n\tlet rest = text;\n\twhile (rest !== \"\") {\n\t\tconst match = QUOTED_SEGMENT.exec(rest);\n\t\tif (match === null) return void 0;\n\t\tsegments.push((match[1] ?? \"\").replaceAll(\"\\\"\\\"\", \"\\\"\"));\n\t\trest = rest.slice(match[0].length);\n\t\tif (rest.startsWith(\".\")) rest = rest.slice(1);\n\t\telse if (rest !== \"\") return void 0;\n\t}\n\treturn segments.length === 1 || segments.length === 2 ? segments : void 0;\n}\nfunction columnTypeUnreadable(type, where, reason) {\n\tthrow postgresError(\"MIGRATION.COLUMN_TYPE_UNREADABLE\", `${where}: ${reason}`, {\n\t\twhy: \"A column type change checks afterwards that the column has the new type, and finds the type through the data types the configured stack registers.\",\n\t\tfix: \"Write the type as a migration writes it, for example int4 or varchar(20), or an enum by its quoted name, such as \\\"Mood\\\". If the type comes from an extension, add that extension to the configuration.\",\n\t\tmeta: {\n\t\t\ttype,\n\t\t\twhere\n\t\t}\n\t});\n}\n/** How a postcheck's description names the type it checks: catalog text in double quotes, and an enum by its quoted name, which carries its own quotes. */\nfunction columnTypeCheckText(check) {\n\treturn check.kind === \"catalog-text\" ? `\"${check.text}\"` : `${check.typeName}${check.many ? \"[]\" : \"\"}`;\n}\nfunction rawTypeCheckText(type, where) {\n\tconst trimmed = type.trim();\n\tconst array = ARRAY_SUFFIX.exec(trimmed);\n\tconst base = array?.[1] ?? trimmed;\n\tconst suffix = array === null ? \"\" : \"[]\";\n\tconst refused = checkRawTypeText(base);\n\treturn refused === void 0 ? `${base}${suffix}` : columnTypeUnreadable(type, where, `the raw type \"${type}\" is refused: ${refused}`);\n}\n/**\n* The postcheck for a column altered to `type`, written as a migration writes it: for a raw type, which the call marks with `raw` (ADR 273), the text as written, compared with the catalog text; otherwise read through the one data type of `dataTypes` that reads it. The planner and the `alterColumnType` facade both check the alter with it, so re-running a migration reproduces its operations. `where` names the call in the error a type no data type reads raises.\n*/\nfunction alterTypeCheck(type, dataTypes, where, raw = false) {\n\tif (raw) return {\n\t\tkind: \"catalog-text\",\n\t\ttext: rawTypeCheckText(type, where)\n\t};\n\tconst read = readColumnTypeCheck(type, dataTypes);\n\treturn read.ok ? read.check : columnTypeUnreadable(type, where, read.reason);\n}\n/** The postcheck for a column of `type`, read as {@link alterTypeCheck} reads it, or `undefined` when the stack's data types do not read `type`, as for a raw column. */\nfunction columnTypeCheckIfReadable(type, dataTypes) {\n\tconst read = readColumnTypeCheck(type, dataTypes);\n\treturn read.ok ? read.check : void 0;\n}\n/**\n* The column type a migration's `type` names, as {@link alterTypeCheck} reads it: the one data type of `dataTypes` that reads it, or for an enum named by its quoted name, the type that claims enums, with the name as introspection would report it. `undefined` when no data type, or more than one, reads it.\n*/\nfunction writtenColumnType(type, dataTypes) {\n\tconst read = readWrittenType(type, dataTypes);\n\treturn read.ok ? {\n\t\tstoredType: read.type,\n\t\tstoredTypeParams: read.typeParams,\n\t\tmany: read.many\n\t} : void 0;\n}\nfunction readWrittenType(type, dataTypes) {\n\tconst trimmed = autoincrementWidthOfPseudoType(type)?.sequenceType ?? type.trim();\n\tconst array = ARRAY_SUFFIX.exec(trimmed);\n\tconst base = array?.[1] ?? trimmed;\n\tconst sqlTypes = dataTypes.filter(isSqlDataType);\n\tconst byText = resolveWrittenSqlTypes(base, sqlTypes);\n\tif (byText.length > 1) return {\n\t\tok: false,\n\t\treason: `more than one data type of the configured stack reads the type \"${type}\", as ${byText.map((resolved) => resolved.dataType.id).join(\" and \")}`\n\t};\n\tconst resolved = byText[0] ?? resolvedByKind(base, sqlTypes);\n\tif (resolved === void 0) return {\n\t\tok: false,\n\t\treason: `no data type of the configured stack reads the type \"${type}\"`\n\t};\n\treturn {\n\t\tok: true,\n\t\ttype: resolved.dataType,\n\t\ttypeParams: resolved.typeParams,\n\t\tmany: array !== null\n\t};\n}\nfunction readColumnTypeCheck(type, dataTypes) {\n\tconst read = readWrittenType(type, dataTypes);\n\tif (!read.ok) return read;\n\tif (read.type.sql.claimsKind !== void 0) return {\n\t\tok: true,\n\t\tcheck: {\n\t\t\tkind: \"identity\",\n\t\t\ttypeName: renderSqlTypeName(read.type, read.typeParams),\n\t\t\tmany: read.many\n\t\t}\n\t};\n\treturn {\n\t\tok: true,\n\t\tcheck: {\n\t\t\tkind: \"catalog-text\",\n\t\t\ttext: `${renderSqlCatalogText(read.type, read.typeParams)}${read.many ? \"[]\" : \"\"}`\n\t\t}\n\t};\n}\n/** The type a quoted name names, read as the one data type that claims a kind reads a reported type of that kind. */\nfunction resolvedByKind(base, dataTypes) {\n\tconst name = quotedName(base);\n\tconst kinds = dataTypes.flatMap(({ sql }) => sql.claimsKind ?? []);\n\tconst [kind] = kinds;\n\tif (name === void 0 || kind === void 0 || kinds.length > 1) return void 0;\n\tconst [schema, typeName] = name.length === 2 ? name : [void 0, name[0]];\n\treturn resolveReportedSqlType({\n\t\ttext: base,\n\t\tkind,\n\t\tschema,\n\t\tname: typeName\n\t}, dataTypes);\n}\n//#endregion\nexport { stackDataTypes as a, qualifyTableName as i, columnTypeCheckIfReadable as n, writtenColumnType as o, columnTypeCheckText as r, alterTypeCheck as t };\n\n//# sourceMappingURL=planner-sql-checks-Dhx-R5GJ.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,iBAAiB,QAAQ,OAAO;CACxC,OAAO,wBAAwB;EAC9B,IAAI;EACJ,SAAS,EAAE,OAAO,CAAC,EAAE;CACtB,CAAC,CAAC,C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rB,IAAI,KAAK,KAAK,IAAI,eAAe,KAAK,GAAG,OAAO;EAC/C,IAAI;EACJ,OAAO;GACN,MAAM;GACN,UAAU,kBAAkB,KAAK,MAAM,KAAK,UAAU;GACtD,MAAM,KAAK;EACZ;CACD;CACA,OAAO;EACN,IAAI;EACJ,OAAO;GACN,MAAM;GACN,MAAM,GAAG,qBAAqB,KAAK,MAAM,KAAK,UAAU,IAAI,KAAK,OAAO,OAAO;EAChF;CACD;AACD;;AAEA,SAAS,eAAe,MAAM,WAAW;CACxC,MAAM,OAAO,WAAW,IAAI;CAC5B,MAAM,QAAQ,UAAU,SAAS,EAAE,UAAU,IAAI,cAAc,CAAC,CAAC;CACjE,MAAM,CAAC,QAAQ;CACf,IAAI,SAAS,KAAK,KAAK,SAAS,KAAK,KAAK,MAAM,SAAS,GAAG,OAAO,KAAK;CACxE,MAAM,CAAC,QAAQ,YAAY,KAAK,WAAW,IAAI,OAAO,CAAC,KAAK,GAAG,KAAK,EAAE;CACtE,OAAO,uBAAuB;EAC7B,MAAM;EACN;EACA;EACA,MAAM;CACP,GAAG,SAAS;AACb"}
1
+ {"version":3,"file":"planner-sql-checks-DOGD6v7y-BWkRMsXt.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-sql-checks-DOGD6v7y.mjs"],"sourcesContent":["import { l as postgresError } from \"./errors-DG6xgXgr.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-CEGf780E.mjs\";\nimport { r as autoincrementWidthOfPseudoType } from \"./autoincrement-widths-DkD24r-C.mjs\";\nimport { assembleDataTypes } from \"@internal/framework-components/codec\";\nimport { checkRawTypeText, isSqlDataType, renderSqlCatalogText, renderSqlTypeName, resolveReportedSqlType, resolveWrittenSqlTypes } from \"@internal/sql-contract/data-type\";\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/** The data types the components of a stack register. */\nfunction stackDataTypes(frameworkComponents) {\n\treturn assembleDataTypes(frameworkComponents).declared.map(({ type }) => type);\n}\nconst ARRAY_SUFFIX = /^(.*?)(?:\\s*\\[\\s*\\])+$/s;\nconst QUOTED_SEGMENT = /^\"((?:[^\"]|\"\")+)\"/;\n/** The segments of a name written as one or two double-quoted identifiers, `\"Mood\"` or `\"app\".\"status\"`. */\nfunction quotedName(text) {\n\tconst segments = [];\n\tlet rest = text;\n\twhile (rest !== \"\") {\n\t\tconst match = QUOTED_SEGMENT.exec(rest);\n\t\tif (match === null) return void 0;\n\t\tsegments.push((match[1] ?? \"\").replaceAll(\"\\\"\\\"\", \"\\\"\"));\n\t\trest = rest.slice(match[0].length);\n\t\tif (rest.startsWith(\".\")) rest = rest.slice(1);\n\t\telse if (rest !== \"\") return void 0;\n\t}\n\treturn segments.length === 1 || segments.length === 2 ? segments : void 0;\n}\nfunction columnTypeUnreadable(type, where, reason) {\n\tthrow postgresError(\"MIGRATION.COLUMN_TYPE_UNREADABLE\", `${where}: ${reason}`, {\n\t\twhy: \"A column type change checks afterwards that the column has the new type, and finds the type through the data types the configured stack registers.\",\n\t\tfix: \"Write the type as a migration writes it, for example int4 or varchar(20), or an enum by its quoted name, such as \\\"Mood\\\". If the type comes from an extension, add that extension to the configuration.\",\n\t\tmeta: {\n\t\t\ttype,\n\t\t\twhere\n\t\t}\n\t});\n}\n/** How a postcheck's description names the type it checks: catalog text in double quotes, and an enum by its quoted name, which carries its own quotes. */\nfunction columnTypeCheckText(check) {\n\treturn check.kind === \"catalog-text\" ? `\"${check.text}\"` : `${check.typeName}${check.many ? \"[]\" : \"\"}`;\n}\nfunction rawTypeCheckText(type, where) {\n\tconst trimmed = type.trim();\n\tconst array = ARRAY_SUFFIX.exec(trimmed);\n\tconst base = array?.[1] ?? trimmed;\n\tconst suffix = array === null ? \"\" : \"[]\";\n\tconst refused = checkRawTypeText(base);\n\treturn refused === void 0 ? `${base}${suffix}` : columnTypeUnreadable(type, where, `the raw type \"${type}\" is refused: ${refused}`);\n}\n/**\n* The postcheck for a column altered to `type`, written as a migration writes it: for a raw type, which the call marks with `raw` (ADR 273), the text as written, compared with the catalog text; otherwise read through the one data type of `dataTypes` that reads it. The planner and the `alterColumnType` facade both check the alter with it, so re-running a migration reproduces its operations. `where` names the call in the error a type no data type reads raises.\n*/\nfunction alterTypeCheck(type, dataTypes, where, raw = false) {\n\tif (raw) return {\n\t\tkind: \"catalog-text\",\n\t\ttext: rawTypeCheckText(type, where)\n\t};\n\tconst read = readColumnTypeCheck(type, dataTypes);\n\treturn read.ok ? read.check : columnTypeUnreadable(type, where, read.reason);\n}\n/** The postcheck for a column of `type`, read as {@link alterTypeCheck} reads it, or `undefined` when the stack's data types do not read `type`, as for a raw column. */\nfunction columnTypeCheckIfReadable(type, dataTypes) {\n\tconst read = readColumnTypeCheck(type, dataTypes);\n\treturn read.ok ? read.check : void 0;\n}\n/**\n* The column type a migration's `type` names, as {@link alterTypeCheck} reads it: the one data type of `dataTypes` that reads it, or for an enum named by its quoted name, the type that claims enums, with the name as introspection would report it. `undefined` when no data type, or more than one, reads it.\n*/\nfunction writtenColumnType(type, dataTypes) {\n\tconst read = readWrittenType(type, dataTypes);\n\treturn read.ok ? {\n\t\tstoredType: read.type,\n\t\tstoredTypeParams: read.typeParams,\n\t\tmany: read.many\n\t} : void 0;\n}\nfunction readWrittenType(type, dataTypes) {\n\tconst trimmed = autoincrementWidthOfPseudoType(type)?.sequenceType ?? type.trim();\n\tconst array = ARRAY_SUFFIX.exec(trimmed);\n\tconst base = array?.[1] ?? trimmed;\n\tconst sqlTypes = dataTypes.filter(isSqlDataType);\n\tconst byText = resolveWrittenSqlTypes(base, sqlTypes);\n\tif (byText.length > 1) return {\n\t\tok: false,\n\t\treason: `more than one data type of the configured stack reads the type \"${type}\", as ${byText.map((resolved) => resolved.dataType.id).join(\" and \")}`\n\t};\n\tconst [written] = byText;\n\tif (written !== void 0) return {\n\t\tok: true,\n\t\ttype: written.dataType,\n\t\ttypeParams: written.typeParams,\n\t\twrittenTypeParams: written.writtenTypeParams,\n\t\tmany: array !== null\n\t};\n\tconst byKind = resolvedByKind(base, sqlTypes);\n\tif (byKind === void 0) return {\n\t\tok: false,\n\t\treason: `no data type of the configured stack reads the type \"${type}\"`\n\t};\n\treturn {\n\t\tok: true,\n\t\ttype: byKind.dataType,\n\t\ttypeParams: byKind.typeParams,\n\t\twrittenTypeParams: byKind.typeParams,\n\t\tmany: array !== null\n\t};\n}\nfunction readColumnTypeCheck(type, dataTypes) {\n\tconst read = readWrittenType(type, dataTypes);\n\tif (!read.ok) return read;\n\tif (read.type.sql.claimsKind !== void 0) return {\n\t\tok: true,\n\t\tcheck: {\n\t\t\tkind: \"identity\",\n\t\t\ttypeName: renderSqlTypeName(read.type, read.typeParams),\n\t\t\tmany: read.many\n\t\t}\n\t};\n\treturn {\n\t\tok: true,\n\t\tcheck: {\n\t\t\tkind: \"catalog-text\",\n\t\t\ttext: `${renderSqlCatalogText(read.type, read.writtenTypeParams)}${read.many ? \"[]\" : \"\"}`\n\t\t}\n\t};\n}\n/** The type a quoted name names, read as the one data type that claims a kind reads a reported type of that kind. */\nfunction resolvedByKind(base, dataTypes) {\n\tconst name = quotedName(base);\n\tconst kinds = dataTypes.flatMap(({ sql }) => sql.claimsKind ?? []);\n\tconst [kind] = kinds;\n\tif (name === void 0 || kind === void 0 || kinds.length > 1) return void 0;\n\tconst [schema, typeName] = name.length === 2 ? name : [void 0, name[0]];\n\treturn resolveReportedSqlType({\n\t\ttext: base,\n\t\tkind,\n\t\tschema,\n\t\tname: typeName\n\t}, dataTypes);\n}\n//#endregion\nexport { stackDataTypes as a, qualifyTableName as i, columnTypeCheckIfReadable as n, writtenColumnType as o, columnTypeCheckText as r, alterTypeCheck as t };\n\n//# sourceMappingURL=planner-sql-checks-DOGD6v7y.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,iBAAiB,QAAQ,OAAO;CACxC,OAAO,wBAAwB;EAC9B,IAAI;EACJ,SAAS,EAAE,OAAO,CAAC,EAAE;CACtB,CAAC,CAAC,CAAC,aAAa,KAAK;AACtB;;AAEA,SAAS,eAAe,qBAAqB;CAC5C,OAAO,kBAAkB,mBAAmB,CAAC,CAAC,SAAS,KAAK,EAAE,WAAW,IAAI;AAC9E;AACA,MAAM,eAAe;AACrB,MAAM,iBAAiB;;AAEvB,SAAS,WAAW,MAAM;CACzB,MAAM,WAAW,CAAC;CAClB,IAAI,OAAO;CACX,OAAO,SAAS,IAAI;EACnB,MAAM,QAAQ,eAAe,KAAK,IAAI;EACtC,IAAI,UAAU,MAAM,OAAO,KAAK;EAChC,SAAS,MAAM,MAAM,MAAM,GAAA,CAAI,WAAW,QAAQ,IAAI,CAAC;EACvD,OAAO,KAAK,MAAM,MAAM,EAAE,CAAC,MAAM;EACjC,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,MAAM,CAAC;OACxC,IAAI,SAAS,IAAI,OAAO,KAAK;CACnC;CACA,OAAO,SAAS,WAAW,KAAK,SAAS,WAAW,IAAI,WAAW,KAAK;AACzE;AACA,SAAS,qBAAqB,MAAM,OAAO,QAAQ;CAClD,MAAM,cAAc,oCAAoC,GAAG,MAAM,IAAI,UAAU;EAC9E,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;AACF;;AAEA,SAAS,oBAAoB,OAAO;CACnC,OAAO,MAAM,SAAS,iBAAiB,IAAI,MAAM,KAAK,KAAK,GAAG,MAAM,WAAW,MAAM,OAAO,OAAO;AACpG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