@prisma/orm-target-postgres 8.0.0-rc.21-dev.13 → 8.0.0-rc.21-dev.14

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 (160) hide show
  1. package/dist/{adapter-t3IEEEbY-BKJyNGtz.mjs → adapter-DJoHcCZV-CWdrs4yI.mjs} +3 -3
  2. package/dist/{adapter-t3IEEEbY-BKJyNGtz.mjs.map → adapter-DJoHcCZV-CWdrs4yI.mjs.map} +1 -1
  3. package/dist/{adapter-BdL6nOY0.d.mts → adapter-Dz86ldS1.d.mts} +14 -14
  4. package/dist/{adapter-BdL6nOY0.d.mts.map → adapter-Dz86ldS1.d.mts.map} +1 -1
  5. package/dist/adapter.d.mts +7 -7
  6. package/dist/adapter.mjs +2 -2
  7. package/dist/adapter__adapter.d.mts +1 -1
  8. package/dist/adapter__adapter.mjs +2 -2
  9. package/dist/adapter__control.d.mts +1 -1
  10. package/dist/adapter__control.mjs +2 -2
  11. package/dist/adapter__control.mjs.map +1 -1
  12. package/dist/adapter__runtime.d.mts +1 -1
  13. package/dist/adapter__runtime.mjs +2 -2
  14. package/dist/adapter__runtime.mjs.map +1 -1
  15. package/dist/adapter__sql-renderer.d.mts +1 -1
  16. package/dist/adapter__types.d.mts +3 -3
  17. package/dist/{aggregates-CCEULCRK.d.mts → aggregates-CJGvlOCM.d.mts} +12 -12
  18. package/dist/{aggregates-CCEULCRK.d.mts.map → aggregates-CJGvlOCM.d.mts.map} +1 -1
  19. package/dist/{authoring-D7EAP1iG-DlpkOeVt.mjs → authoring-BFb5LVsK-CkHmM-aP.mjs} +50 -3
  20. package/dist/authoring-BFb5LVsK-CkHmM-aP.mjs.map +1 -0
  21. package/dist/{authoring-DWd5pnnV-BBX7P1wT.d.mts → authoring-BRqyCnBa-CAzlQNHw.d.mts} +5 -4
  22. package/dist/{authoring-DWd5pnnV-BBX7P1wT.d.mts.map → authoring-BRqyCnBa-CAzlQNHw.d.mts.map} +1 -1
  23. package/dist/{contract-contributions-CbLCF8jV-BOZHg83r.mjs → contract-contributions-DS1YZqxl-CipEzWQj.mjs} +17 -5
  24. package/dist/contract-contributions-DS1YZqxl-CipEzWQj.mjs.map +1 -0
  25. package/dist/{contract-free-B6-wuc6M.d.mts → contract-free-DcaYH2c5.d.mts} +6 -2
  26. package/dist/contract-free-DcaYH2c5.d.mts.map +1 -0
  27. package/dist/{contract-free-DtJ1gJxN.mjs → contract-free-DmNEp1_Y.mjs} +3 -3
  28. package/dist/contract-free-DmNEp1_Y.mjs.map +1 -0
  29. package/dist/{control-DKpIWFg_.d.mts → control-2DHRXqEz.d.mts} +5 -3
  30. package/dist/{control-DKpIWFg_.d.mts.map → control-2DHRXqEz.d.mts.map} +1 -1
  31. package/dist/{control-policy-DZzwyc3L-_Bf4iEaW.mjs → control-policy-DYDR6FhY-CPBeYqu5.mjs} +45 -10
  32. package/dist/control-policy-DYDR6FhY-CPBeYqu5.mjs.map +1 -0
  33. package/dist/{ddl-URS0VlHr--s2jpN6c.mjs → ddl-qu-IzeH4-CFpSpY0X.mjs} +11 -4
  34. package/dist/ddl-qu-IzeH4-CFpSpY0X.mjs.map +1 -0
  35. package/dist/{descriptor-meta-BPjw5dIw-DSlWgzbV.mjs → descriptor-meta-5gncreHF-BD1kpxJu.mjs} +3 -3
  36. package/dist/{descriptor-meta-BPjw5dIw-DSlWgzbV.mjs.map → descriptor-meta-5gncreHF-BD1kpxJu.mjs.map} +1 -1
  37. package/dist/{descriptor-meta-DokyxrzY-D2S-BLI0.mjs → descriptor-meta-CszCf4Hs-DVGeuxNv.mjs} +4 -4
  38. package/dist/{descriptor-meta-DokyxrzY-D2S-BLI0.mjs.map → descriptor-meta-CszCf4Hs-DVGeuxNv.mjs.map} +1 -1
  39. package/dist/{diff-database-schema-BxzhZaVN.d.mts → diff-database-schema-COp7SqEI.d.mts} +5 -3
  40. package/dist/{diff-database-schema-BxzhZaVN.d.mts.map → diff-database-schema-COp7SqEI.d.mts.map} +1 -1
  41. package/dist/{diff-database-schema-DrOE5ahI-BfrNtMDu.mjs → diff-database-schema-DyoCp8VS-BKtXp-eB.mjs} +30 -8
  42. package/dist/diff-database-schema-DyoCp8VS-BKtXp-eB.mjs.map +1 -0
  43. package/dist/{infer-psl-contract-Du026CJo-sRmqBsId.mjs → infer-psl-contract-BP2DgxTx-BqV8gUu4.mjs} +45 -6
  44. package/dist/infer-psl-contract-BP2DgxTx-BqV8gUu4.mjs.map +1 -0
  45. package/dist/{issue-planner-BLiMn8iP.d.mts → issue-planner-BUo9S9Ge.d.mts} +3 -3
  46. package/dist/{issue-planner-BLiMn8iP.d.mts.map → issue-planner-BUo9S9Ge.d.mts.map} +1 -1
  47. package/dist/migration-Be_iuIpn.mjs.map +1 -1
  48. package/dist/{migration-cnT6b-9x.d.mts → migration-Drs_EeiM.d.mts} +10 -3
  49. package/dist/migration-Drs_EeiM.d.mts.map +1 -0
  50. package/dist/op-factory-call-D2HXLJQJ.d.mts +1 -0
  51. package/dist/{op-factory-call-DsQATX-o-BHcqPXrs.mjs → op-factory-call-DyQO1ZdB-CnbOJIf8.mjs} +115 -20
  52. package/dist/op-factory-call-DyQO1ZdB-CnbOJIf8.mjs.map +1 -0
  53. package/dist/{op-factory-call-DeaoFqMW-XAP00c7U.d.mts → op-factory-call-L1gqYhhk-DMnspvjf.d.mts} +30 -6
  54. package/dist/{op-factory-call-DeaoFqMW-XAP00c7U.d.mts.map → op-factory-call-L1gqYhhk-DMnspvjf.d.mts.map} +1 -1
  55. package/dist/{pack-CjVhjxir.d.mts → pack-CLpRLkRQ.d.mts} +27 -4
  56. package/dist/{pack-CjVhjxir.d.mts.map → pack-CLpRLkRQ.d.mts.map} +1 -1
  57. package/dist/{planner-RW8za3Vm.d.mts → planner-Bl3kIyMG.d.mts} +4 -4
  58. package/dist/{planner-RW8za3Vm.d.mts.map → planner-Bl3kIyMG.d.mts.map} +1 -1
  59. package/dist/{planner-CNoNH9bo-3g7WX476.mjs → planner-D1mzh6Cb-B1Z2YTiQ.mjs} +19 -13
  60. package/dist/planner-D1mzh6Cb-B1Z2YTiQ.mjs.map +1 -0
  61. package/dist/{planner-produced-postgres-migration-DnAk6KxF-Vj31eyEf.mjs → planner-produced-postgres-migration-Cw8gbwED-tyj9TLlB.mjs} +4 -4
  62. package/dist/{planner-produced-postgres-migration-DnAk6KxF-Vj31eyEf.mjs.map → planner-produced-postgres-migration-Cw8gbwED-tyj9TLlB.mjs.map} +1 -1
  63. package/dist/{planner-produced-postgres-migration-DtjZyo7p-CQxcHWwC.d.mts → planner-produced-postgres-migration-Cx9bERx3-DRNnR16E.d.mts} +3 -3
  64. package/dist/planner-produced-postgres-migration-Cx9bERx3-DRNnR16E.d.mts.map +1 -0
  65. package/dist/planner-produced-postgres-migration-DRPVY4iL.d.mts +1 -0
  66. package/dist/{planner-sql-checks-CvI80tt0-B5bKCucD.mjs → planner-sql-checks-FU4T7wgu-C-tIJOH-.mjs} +3 -3
  67. package/dist/{planner-sql-checks-CvI80tt0-B5bKCucD.mjs.map → planner-sql-checks-FU4T7wgu-C-tIJOH-.mjs.map} +1 -1
  68. package/dist/{postgres-contract-view-CRy_3BMc-60fosJRZ.mjs → postgres-contract-view-iwNgaXQw-QzVSakJT.mjs} +30 -4
  69. package/dist/postgres-contract-view-iwNgaXQw-QzVSakJT.mjs.map +1 -0
  70. package/dist/{postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts → postgres-database-schema-node-BjmJ6_Cs-LyZ0n9oj.d.mts} +33 -5
  71. package/dist/postgres-database-schema-node-BjmJ6_Cs-LyZ0n9oj.d.mts.map +1 -0
  72. package/dist/{postgres-migration-CSU_fUlQ-C5TNpgq4.mjs → postgres-migration-BhijSOgq-CP_oflub.mjs} +29 -11
  73. package/dist/postgres-migration-BhijSOgq-CP_oflub.mjs.map +1 -0
  74. package/dist/{postgres-migration-CDPlleMc-B4JQjDcN.d.mts → postgres-migration-DNnmFBsR-BJU9865a.d.mts} +19 -2
  75. package/dist/{postgres-migration-CDPlleMc-B4JQjDcN.d.mts.map → postgres-migration-DNnmFBsR-BJU9865a.d.mts.map} +1 -1
  76. package/dist/{postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs → postgres-role-schema-node-DuljIQWp-D6Q5JyEs.mjs} +12 -5
  77. package/dist/postgres-role-schema-node-DuljIQWp-D6Q5JyEs.mjs.map +1 -0
  78. package/dist/{postgres-schema-osNZNX0D-BpKJDg4M.mjs → postgres-schema-BBWgs4fX-DWdYxNi8.mjs} +35 -4
  79. package/dist/postgres-schema-BBWgs4fX-DWdYxNi8.mjs.map +1 -0
  80. package/dist/{postgres-schema-Xsjt3RKO-bis-SVSB.d.mts → postgres-schema-CJvUnBU9-Bvn7zbr1.d.mts} +21 -3
  81. package/dist/postgres-schema-CJvUnBU9-Bvn7zbr1.d.mts.map +1 -0
  82. package/dist/{postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs → postgres-table-schema-node-nY6II-Uv-Bj-lgmSi.mjs} +50 -6
  83. package/dist/postgres-table-schema-node-nY6II-Uv-Bj-lgmSi.mjs.map +1 -0
  84. package/dist/{prisma7-binding-DiHnmsNq.d.mts → prisma7-binding-BFypqPE0.d.mts} +48 -4
  85. package/dist/{prisma7-binding-DiHnmsNq.d.mts.map → prisma7-binding-BFypqPE0.d.mts.map} +1 -1
  86. package/dist/{prisma7-binding-CPcA6N3v.mjs → prisma7-binding-DWW3L3C4.mjs} +26 -5
  87. package/dist/{prisma7-binding-CPcA6N3v.mjs.map → prisma7-binding-DWW3L3C4.mjs.map} +1 -1
  88. package/dist/{render-ops-Cj7mog0v-DPzODjA0.mjs → render-ops-5VMQY7FM-Cdil7oOP.mjs} +3 -3
  89. package/dist/{render-ops-Cj7mog0v-DPzODjA0.mjs.map → render-ops-5VMQY7FM-Cdil7oOP.mjs.map} +1 -1
  90. package/dist/{resolve-ddl-schema-uDXEVepU-COWNfVPC.mjs → resolve-ddl-schema-BZzteXH1-C57Iavtu.mjs} +3 -3
  91. package/dist/{resolve-ddl-schema-uDXEVepU-COWNfVPC.mjs.map → resolve-ddl-schema-BZzteXH1-C57Iavtu.mjs.map} +1 -1
  92. package/dist/{runtime-DMle_B4T.d.mts → runtime-BJetnmVm.d.mts} +2 -1
  93. package/dist/runtime-BJetnmVm.d.mts.map +1 -0
  94. package/dist/{runtime-R_BCXCp_.d.mts → runtime-K2strEv6.d.mts} +3 -3
  95. package/dist/{runtime-R_BCXCp_.d.mts.map → runtime-K2strEv6.d.mts.map} +1 -1
  96. package/dist/{schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts → schema-node-kinds-Baf4tcly-CI3SyVG4.d.mts} +3 -2
  97. package/dist/schema-node-kinds-Baf4tcly-CI3SyVG4.d.mts.map +1 -0
  98. package/dist/{sql-renderer-BnO2fkSf.d.mts → sql-renderer-PT6pQ66O.d.mts} +3 -3
  99. package/dist/{sql-renderer-BnO2fkSf.d.mts.map → sql-renderer-PT6pQ66O.d.mts.map} +1 -1
  100. package/dist/target.d.mts +19 -19
  101. package/dist/target.mjs +18 -18
  102. package/dist/target__aggregates.d.mts +1 -1
  103. package/dist/target__contract-free.d.mts +2 -2
  104. package/dist/target__contract-free.mjs +4 -4
  105. package/dist/target__control.mjs +44 -18
  106. package/dist/target__control.mjs.map +1 -1
  107. package/dist/target__diff-database-schema.d.mts +1 -1
  108. package/dist/target__diff-database-schema.mjs +1 -1
  109. package/dist/target__issue-planner.d.mts +1 -1
  110. package/dist/target__issue-planner.mjs +1 -1
  111. package/dist/target__migration.d.mts +2 -2
  112. package/dist/target__migration.mjs +2 -2
  113. package/dist/target__op-factory-call.d.mts +3 -3
  114. package/dist/target__op-factory-call.mjs +2 -2
  115. package/dist/target__pack.d.mts +1 -1
  116. package/dist/target__pack.mjs +1 -1
  117. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  118. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  119. package/dist/target__planner-sql-checks.mjs +1 -1
  120. package/dist/target__planner.d.mts +1 -1
  121. package/dist/target__planner.mjs +2 -2
  122. package/dist/target__prisma7-binding.d.mts +1 -1
  123. package/dist/target__prisma7-binding.mjs +1 -1
  124. package/dist/target__render-ops.mjs +1 -1
  125. package/dist/target__runtime.d.mts +1 -1
  126. package/dist/target__runtime.mjs +1 -1
  127. package/dist/target__runtime.mjs.map +1 -1
  128. package/dist/target__schema-ir-annotations.mjs +1 -1
  129. package/dist/target__types.d.mts +5 -5
  130. package/dist/target__types.mjs +4 -4
  131. package/dist/{types-D6lgKhE5-BrgAgVCq.d.mts → types-D6lgKhE5-DVHMZPbP.d.mts} +2 -2
  132. package/dist/{types-D6lgKhE5-BrgAgVCq.d.mts.map → types-D6lgKhE5-DVHMZPbP.d.mts.map} +1 -1
  133. package/dist/{types-D-U10Lyo.d.mts → types-D6p1198n.d.mts} +4 -4
  134. package/dist/{types-D-U10Lyo.d.mts.map → types-D6p1198n.d.mts.map} +1 -1
  135. package/dist/types-oaZIR8i0.d.mts +2 -0
  136. package/package.json +9 -9
  137. package/dist/authoring-D7EAP1iG-DlpkOeVt.mjs.map +0 -1
  138. package/dist/contract-contributions-CbLCF8jV-BOZHg83r.mjs.map +0 -1
  139. package/dist/contract-free-B6-wuc6M.d.mts.map +0 -1
  140. package/dist/contract-free-DtJ1gJxN.mjs.map +0 -1
  141. package/dist/control-policy-DZzwyc3L-_Bf4iEaW.mjs.map +0 -1
  142. package/dist/ddl-URS0VlHr--s2jpN6c.mjs.map +0 -1
  143. package/dist/diff-database-schema-DrOE5ahI-BfrNtMDu.mjs.map +0 -1
  144. package/dist/infer-psl-contract-Du026CJo-sRmqBsId.mjs.map +0 -1
  145. package/dist/migration-cnT6b-9x.d.mts.map +0 -1
  146. package/dist/op-factory-call-D9O6cXRE.d.mts +0 -1
  147. package/dist/op-factory-call-DsQATX-o-BHcqPXrs.mjs.map +0 -1
  148. package/dist/planner-CNoNH9bo-3g7WX476.mjs.map +0 -1
  149. package/dist/planner-produced-postgres-migration-DtjZyo7p-CQxcHWwC.d.mts.map +0 -1
  150. package/dist/planner-produced-postgres-migration-JI4uclWQ.d.mts +0 -1
  151. package/dist/postgres-contract-view-CRy_3BMc-60fosJRZ.mjs.map +0 -1
  152. package/dist/postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map +0 -1
  153. package/dist/postgres-migration-CSU_fUlQ-C5TNpgq4.mjs.map +0 -1
  154. package/dist/postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs.map +0 -1
  155. package/dist/postgres-schema-Xsjt3RKO-bis-SVSB.d.mts.map +0 -1
  156. package/dist/postgres-schema-osNZNX0D-BpKJDg4M.mjs.map +0 -1
  157. package/dist/postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs.map +0 -1
  158. package/dist/runtime-DMle_B4T.d.mts.map +0 -1
  159. package/dist/schema-node-kinds-C52Bb1ve-DmxQRPPS.d.mts.map +0 -1
  160. package/dist/types-DNbQLBpx.d.mts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"planner-sql-checks-CvI80tt0-B5bKCucD.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-sql-checks-CvI80tt0.mjs"],"sourcesContent":["import { u as postgresError } from \"./errors-DpdPXR_L.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-osNZNX0D.mjs\";\nimport { r as autoincrementWidthOfPseudoType } from \"./autoincrement-widths-Cy5o21bQ.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, writt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d,YAAY,QAAQ;EACpB,mBAAmB,QAAQ;EAC3B,MAAM,UAAU;CACjB;CACA,MAAM,SAAS,eAAe,MAAM,QAAQ;CAC5C,IAAI,WAAW,KAAK,GAAG,OAAO;EAC7B,IAAI;EACJ,QAAQ,wDAAwD,KAAK;CACtE;CACA,OAAO;EACN,IAAI;EACJ,MAAM,OAAO;EACb,YAAY,OAAO;EACnB,mBAAmB,OAAO;EAC1B,MAAM,UAAU;CACjB;AACD;AACA,SAAS,oBAAoB,MAAM,WAAW;CAC7C,MAAM,OAAO,gBAAgB,MAAM,SAAS;CAC5C,IAAI,CAAC,KAAK,IAAI,OAAO;CACrB,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,iBAAiB,IAAI,KAAK,OAAO,OAAO;EACvF;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-FU4T7wgu-C-tIJOH-.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/planner-sql-checks-FU4T7wgu.mjs"],"sourcesContent":["import { u as postgresError } from \"./errors-DpdPXR_L.mjs\";\nimport { i as postgresCreateNamespace } from \"./postgres-schema-BBWgs4fX.mjs\";\nimport { r as autoincrementWidthOfPseudoType } from \"./autoincrement-widths-Cy5o21bQ.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-FU4T7wgu.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,OA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,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,10 +1,11 @@
1
1
  import { T as PG_TEXT_CODEC_ID, v as PG_INT_CODEC_ID } from "./codec-ids-2htdtS66-CJPMZv1t.mjs";
2
+ import { u as postgresError } from "./errors-DpdPXR_L-DailcY-X.mjs";
2
3
  import { i as createPostgresBuiltinDataTypeLookup, rt as postgresTextDataTypes } from "./data-types-DHpMs3mz-BllVpLs5.mjs";
3
4
  import { r as createPostgresBuiltinCodecLookup } from "./codec-registry-D-bD-lFp-BCSmwfrE.mjs";
4
5
  import { a as assertFullTextIndexes } from "./full-text-index-definition-MfjtL-x7-ImaTAFMs.mjs";
5
- import { _ as roleEntityKind, c as PostgresSchema, f as nativeEnumEntityKind, g as rlsEnablementEntityKind, p as policyEntityKind } from "./postgres-schema-osNZNX0D-BpKJDg4M.mjs";
6
+ import { b as roleEntityKind, g as policyEntityKind, h as nativeEnumEntityKind, p as extensionEntityKind, u as PostgresSchema, y as rlsEnablementEntityKind } from "./postgres-schema-BBWgs4fX-DWdYxNi8.mjs";
6
7
  import { t as postgresCodecTraitsOf } from "./postgres-codec-traits-CAzQDLh0-BiKmrtXk.mjs";
7
- import { n as postgresAuthoringEntityTypes } from "./authoring-D7EAP1iG-DlpkOeVt.mjs";
8
+ import { n as postgresAuthoringEntityTypes } from "./authoring-BFb5LVsK-CkHmM-aP.mjs";
8
9
  import { requiredSchemaKeys } from "@prisma/orm-framework/components/codec";
9
10
  import { blindCast } from "@prisma/orm-framework/utils/casts";
10
11
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -14,7 +15,7 @@ import { buildSqlSchemaQualifiedView } from "@prisma/orm-family-sql/contract/con
14
15
  import { createPreserveEmptyPredicate } from "@prisma/orm-framework/contract/hashing-utils";
15
16
  import { SqlContractSerializerBase } from "@prisma/orm-family-sql/family/ir";
16
17
  import { sqlContractCanonicalizationHooks } from "@prisma/orm-family-sql/contract/canonicalization-hooks";
17
- //#region ../../../3-targets/postgres/1-target/dist/postgres-contract-view-CRy_3BMc.mjs
18
+ //#region ../../../3-targets/postgres/1-target/dist/postgres-contract-view-iwNgaXQw.mjs
18
19
  const POSTGRES_CODEC_LOOKUP = createPostgresBuiltinCodecLookup();
19
20
  /** The context entity hydration runs in. Hydration reads stored contract JSON and never a written value, so its data types carry no authoring entries, which keeps the PSL readers out of the runtime. */
20
21
  const POSTGRES_AUTHORING_CTX = {
@@ -92,6 +93,7 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
92
93
  roleEntityKind,
93
94
  rlsEnablementEntityKind,
94
95
  nativeEnumEntityKind,
96
+ extensionEntityKind,
95
97
  ...extraPackEntityKinds
96
98
  ];
97
99
  super(storageTypesHydrators, entityKinds);
@@ -115,6 +117,11 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
115
117
  for (const table of Object.values(schema.table)) assertFullTextIndexes(table, postgresCodecTraitsOf);
116
118
  return schema;
117
119
  }
120
+ hydrateSqlStorage(validated) {
121
+ const hydrated = super.hydrateSqlStorage(validated);
122
+ assertExtensionsInOneNamespace(hydrated.storage);
123
+ return hydrated;
124
+ }
118
125
  serializeContract(contract) {
119
126
  const { storage, ...rest } = contract;
120
127
  const namespacesJson = {};
@@ -141,6 +148,25 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
141
148
  });
142
149
  }
143
150
  };
151
+ function assertExtensionsInOneNamespace(storage) {
152
+ const namespacesByExtension = /* @__PURE__ */ new Map();
153
+ for (const namespace of Object.values(storage.namespaces)) {
154
+ if (!(namespace instanceof PostgresSchema)) continue;
155
+ for (const name of Object.keys(namespace.extension)) namespacesByExtension.set(name, [...namespacesByExtension.get(name) ?? [], namespace.id]);
156
+ }
157
+ for (const [name, namespaceIds] of namespacesByExtension) {
158
+ if (namespaceIds.length < 2) continue;
159
+ const namespaces = [...namespaceIds].sort();
160
+ throw postgresError("CONTRACT.NAME_DUPLICATE", `Extension "${name}" is declared in namespaces ${namespaces.map((id) => `"${id}"`).join(" and ")}. An extension's name is unique in the database, so a contract declares it in one namespace only.`, {
161
+ fix: "Re-emit the contract from its source, which refuses one extension declared in two namespaces.",
162
+ meta: {
163
+ kind: "extension",
164
+ name,
165
+ namespaces
166
+ }
167
+ });
168
+ }
169
+ }
144
170
  const PostgresContractView = {
145
171
  /** Wrap an already-deserialized Postgres contract in a schema-qualified view. */
146
172
  from(contract) {
@@ -154,4 +180,4 @@ const PostgresContractView = {
154
180
  //#endregion
155
181
  export { PostgresContractView as n, PostgresContractSerializer as t };
156
182
 
157
- //# sourceMappingURL=postgres-contract-view-CRy_3BMc-60fosJRZ.mjs.map
183
+ //# sourceMappingURL=postgres-contract-view-iwNgaXQw-QzVSakJT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-contract-view-iwNgaXQw-QzVSakJT.mjs","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/postgres-contract-view-iwNgaXQw.mjs"],"sourcesContent":["import { T as PG_TEXT_CODEC_ID, v as PG_INT_CODEC_ID } from \"./codec-ids-2htdtS66.mjs\";\nimport { u as postgresError } from \"./errors-DpdPXR_L.mjs\";\nimport { K as postgresTextDataTypes, t as createPostgresBuiltinDataTypeLookup } from \"./data-types-DHpMs3mz.mjs\";\nimport { r as createPostgresBuiltinCodecLookup } from \"./codec-registry-D-bD-lFp.mjs\";\nimport { n as assertFullTextIndexes } from \"./full-text-index-definition-MfjtL-x7.mjs\";\nimport { t as postgresCodecTraitsOf } from \"./postgres-codec-traits-CAzQDLh0.mjs\";\nimport { a as extensionEntityKind, c as rlsEnablementEntityKind, l as roleEntityKind, o as nativeEnumEntityKind, s as policyEntityKind, t as PostgresSchema } from \"./postgres-schema-BBWgs4fX.mjs\";\nimport { n as postgresAuthoringEntityTypes } from \"./authoring-BFb5LVsK.mjs\";\nimport { requiredSchemaKeys } from \"@internal/framework-components/codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { isAuthoringEntityTypeDescriptor } from \"@internal/framework-components/authoring\";\nimport { buildSqlSchemaQualifiedView } from \"@internal/sql-contract/contract-view\";\nimport { createPreserveEmptyPredicate } from \"@internal/contract/hashing-utils\";\nimport { SqlContractSerializerBase } from \"@internal/family-sql/ir\";\nimport { sqlContractCanonicalizationHooks } from \"@internal/sql-contract/canonicalization-hooks\";\n//#region src/core/postgres-contract-serializer.ts\nconst POSTGRES_CODEC_LOOKUP = createPostgresBuiltinCodecLookup();\n/** The context entity hydration runs in. Hydration reads stored contract JSON and never a written value, so its data types carry no authoring entries, which keeps the PSL readers out of the runtime. */\nconst POSTGRES_AUTHORING_CTX = {\n\tfamily: \"sql\",\n\ttarget: \"postgres\",\n\tcodecLookup: POSTGRES_CODEC_LOOKUP,\n\tdataTypes: {\n\t\tentries: {},\n\t\tlookup: createPostgresBuiltinDataTypeLookup(),\n\t\tdataTypeOfCodec: (codecId) => POSTGRES_CODEC_LOOKUP.descriptorFor(codecId)?.dataType,\n\t\ttextDataTypes: postgresTextDataTypes\n\t},\n\tenumInferenceCodecs: {\n\t\ttext: PG_TEXT_CODEC_ID,\n\t\tint: PG_INT_CODEC_ID\n\t}\n};\nfunction isAuthoringEntityTypeFactoryOutput(output) {\n\treturn typeof output === \"object\" && output !== null && \"factory\" in output && typeof output.factory === \"function\";\n}\n/**\n* Walks a pack's entity-type namespace tree and emits hydration factories\n* keyed by the descriptor's `discriminator`. Used for `storage.types`\n* (codec-triple hydration). Namespace entries hydration dispatches by\n* entries key, not discriminator — handled by `hydrateNamespaceEntities`.\n*/\nfunction collectStorageTypesHydrators(namespace) {\n\tconst registry = /* @__PURE__ */ new Map();\n\tconst walk = (node) => {\n\t\tfor (const value of Object.values(node)) {\n\t\t\tif (isAuthoringEntityTypeDescriptor(value)) {\n\t\t\t\tif (isAuthoringEntityTypeFactoryOutput(value.output)) {\n\t\t\t\t\tconst { factory } = value.output;\n\t\t\t\t\tregistry.set(value.discriminator, (raw) => factory(raw, POSTGRES_AUTHORING_CTX));\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (typeof value === \"object\" && value !== null) walk(value);\n\t\t}\n\t};\n\twalk(namespace);\n\treturn registry;\n}\n/**\n* The canonicalization walk drops a field whose value equals its type's\n* default, which for a required field of an entity kind means the emitted\n* contract fails that kind's own schema on the next read (a RESTRICTIVE\n* policy's `permissive: false` is the live case). The set of fields that must\n* survive is therefore the required keys of the registered entity kinds —\n* read off the schemas rather than listed by hand, so a kind that gains a\n* required field is covered the day it gains one.\n*/\nfunction requiredEntityFieldsSurviveDefaults(kinds) {\n\treturn createPreserveEmptyPredicate(kinds.flatMap((kind) => requiredKeysOf(kind.schema).map((key) => [\n\t\t\"storage\",\n\t\t\"namespaces\",\n\t\t\"*\",\n\t\t\"entries\",\n\t\tkind.kind,\n\t\t\"*\",\n\t\tkey\n\t])));\n}\nfunction requiredKeysOf(schema) {\n\tconst keys = requiredSchemaKeys(schema);\n\tif (keys === void 0) throw new InternalError(\"entity-kind schema does not expose arktype object props; the required-field preserve set cannot be derived\");\n\treturn keys;\n}\nvar PostgresContractSerializer = class extends SqlContractSerializerBase {\n\tshouldPreserveEmpty;\n\tconstructor(extraPackEntityKinds = []) {\n\t\tconst storageTypesHydrators = collectStorageTypesHydrators(postgresAuthoringEntityTypes);\n\t\tconst entityKinds = [\n\t\t\tpolicyEntityKind,\n\t\t\troleEntityKind,\n\t\t\trlsEnablementEntityKind,\n\t\t\tnativeEnumEntityKind,\n\t\t\textensionEntityKind,\n\t\t\t...extraPackEntityKinds\n\t\t];\n\t\tsuper(storageTypesHydrators, entityKinds);\n\t\tconst preserveRequired = requiredEntityFieldsSurviveDefaults(entityKinds);\n\t\tthis.shouldPreserveEmpty = (path) => preserveRequired(path) || sqlContractCanonicalizationHooks.shouldPreserveEmpty(path);\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\tconst { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));\n\t\tconst allSlotsEmpty = Object.values(entries).every((slot) => slot === void 0 || Object.keys(slot).length === 0);\n\t\tif (id === UNBOUND_NAMESPACE_ID && allSlotsEmpty) return PostgresSchema.unbound;\n\t\tconst valueSetSlot = entries[\"valueSet\"];\n\t\tconst hasValueSets = valueSetSlot !== void 0 && Object.keys(valueSetSlot).length > 0;\n\t\tconst schema = new PostgresSchema({\n\t\t\tid,\n\t\t\tentries: {\n\t\t\t\t...entries,\n\t\t\t\ttable: entries[\"table\"] ?? {},\n\t\t\t\t...hasValueSets ? { valueSet: valueSetSlot } : {}\n\t\t\t}\n\t\t});\n\t\tfor (const table of Object.values(schema.table)) assertFullTextIndexes(table, postgresCodecTraitsOf);\n\t\treturn schema;\n\t}\n\thydrateSqlStorage(validated) {\n\t\tconst hydrated = super.hydrateSqlStorage(validated);\n\t\tassertExtensionsInOneNamespace(hydrated.storage);\n\t\treturn hydrated;\n\t}\n\tserializeContract(contract) {\n\t\tconst { storage, ...rest } = contract;\n\t\tconst namespacesJson = {};\n\t\tfor (const [nsId, ns] of Object.entries(storage.namespaces)) {\n\t\t\tconst isUnboundSlot = ns.id === UNBOUND_NAMESPACE_ID;\n\t\t\tnamespacesJson[nsId] = {\n\t\t\t\tid: ns.id,\n\t\t\t\tkind: isUnboundSlot ? \"postgres-unbound-schema\" : \"postgres-schema\",\n\t\t\t\tentries: this.serializeNamespaceEntries(ns.entries)\n\t\t\t};\n\t\t}\n\t\tconst storageOut = {\n\t\t\tstorageHash: String(storage.storageHash),\n\t\t\tnamespaces: namespacesJson\n\t\t};\n\t\tif (storage.types !== void 0) {\n\t\t\tconst typesOut = {};\n\t\t\tfor (const [name, entry] of Object.entries(storage.types)) typesOut[name] = this.serializeJsonObject(entry);\n\t\t\tstorageOut[\"types\"] = typesOut;\n\t\t}\n\t\treturn blindCast({\n\t\t\t...rest,\n\t\t\tstorage: storageOut\n\t\t});\n\t}\n};\nfunction assertExtensionsInOneNamespace(storage) {\n\tconst namespacesByExtension = /* @__PURE__ */ new Map();\n\tfor (const namespace of Object.values(storage.namespaces)) {\n\t\tif (!(namespace instanceof PostgresSchema)) continue;\n\t\tfor (const name of Object.keys(namespace.extension)) namespacesByExtension.set(name, [...namespacesByExtension.get(name) ?? [], namespace.id]);\n\t}\n\tfor (const [name, namespaceIds] of namespacesByExtension) {\n\t\tif (namespaceIds.length < 2) continue;\n\t\tconst namespaces = [...namespaceIds].sort();\n\t\tthrow postgresError(\"CONTRACT.NAME_DUPLICATE\", `Extension \"${name}\" is declared in namespaces ${namespaces.map((id) => `\"${id}\"`).join(\" and \")}. An extension's name is unique in the database, so a contract declares it in one namespace only.`, {\n\t\t\tfix: \"Re-emit the contract from its source, which refuses one extension declared in two namespaces.\",\n\t\t\tmeta: {\n\t\t\t\tkind: \"extension\",\n\t\t\t\tname,\n\t\t\t\tnamespaces\n\t\t\t}\n\t\t});\n\t}\n}\n//#endregion\n//#region src/core/postgres-contract-view.ts\nconst PostgresContractView = {\n\t/** Wrap an already-deserialized Postgres contract in a schema-qualified view. */\n\tfrom(contract) {\n\t\treturn buildSqlSchemaQualifiedView(contract);\n\t},\n\t/** Deserialize a Postgres contract JSON envelope and wrap it in a view. */\n\tfromJson(json) {\n\t\treturn buildSqlSchemaQualifiedView(new PostgresContractSerializer().deserializeContract(json));\n\t}\n};\n//#endregion\nexport { PostgresContractSerializer as n, PostgresContractView as t };\n\n//# sourceMappingURL=postgres-contract-view-iwN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ef } from "@prisma/orm-framework/components/control";
2
+ import { DiffableNode, MismatchExplanation, SchemaNodeRef } from "@prisma/orm-framework/components/control";
3
3
  import { SqlObjectNaming } from "@prisma/orm-family-sql/schema-ir/naming";
4
4
  import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma/orm-family-sql/schema-ir/types";
5
5
  import { ControlPolicy } from "@prisma/orm-framework/contract/types";
6
- //#region ../../../3-targets/postgres/1-target/dist/postgres-database-schema-node-Cv8usVNX.d.mts
6
+ //#region ../../../3-targets/postgres/1-target/dist/postgres-database-schema-node-BjmJ6_Cs.d.mts
7
+ //#region src/core/schema-ir/postgres-extension-schema-node.d.ts
8
+ interface PostgresExtensionSchemaNodeInput {
9
+ readonly name: string;
10
+ /** The schema that holds the extension's objects (`pg_extension.extnamespace`). */
11
+ readonly schemaName: string;
12
+ /** The contract entity's control policy, on the expected side only. */
13
+ readonly control: ControlPolicy | undefined;
14
+ }
15
+ /**
16
+ * Schema-diff node for an installed Postgres extension. An extension's name is unique in the whole database, so the node sits on the database root and pairs by name alone; the schema holding its objects is compared, so an extension in another schema is one mismatch rather than a missing and an extra extension.
17
+ */
18
+ declare class PostgresExtensionSchemaNode extends SqlSchemaIRNode implements DiffableNode {
19
+ readonly nodeKind: "postgres-extension";
20
+ readonly name: string;
21
+ readonly schemaName: string;
22
+ readonly control?: ControlPolicy;
23
+ constructor(input: PostgresExtensionSchemaNodeInput);
24
+ get id(): string;
25
+ children(): readonly DiffableNode[];
26
+ isEqualTo(other: DiffableNode): boolean;
27
+ explainMismatch(actual: DiffableNode | undefined): MismatchExplanation | undefined;
28
+ static is(node: SqlSchemaIRNode): node is PostgresExtensionSchemaNode;
29
+ static assert(node: SqlSchemaIRNode): asserts node is PostgresExtensionSchemaNode;
30
+ }
31
+ //#endregion
7
32
  //#region src/core/schema-ir/postgres-native-enum-schema-node.d.ts
8
33
  interface PostgresNativeEnumSchemaNodeInput {
9
34
  /** The Postgres type name (`CREATE TYPE <typeName> AS ENUM (…)`). */
@@ -254,6 +279,7 @@ declare class PostgresRoleSchemaNode extends SqlSchemaIRNode implements Diffable
254
279
  interface PostgresDatabaseSchemaNodeInput {
255
280
  readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
256
281
  readonly roles: readonly PostgresRoleSchemaNode[];
282
+ readonly extensions: readonly PostgresExtensionSchemaNode[] | undefined;
257
283
  readonly existingSchemas: readonly string[];
258
284
  readonly pgVersion: string;
259
285
  }
@@ -265,12 +291,14 @@ interface PostgresDatabaseSchemaNodeInput {
265
291
  * (roots always share the `'database'` id). `children()` yields the namespace
266
292
  * nodes followed by the role nodes — both are root-level diff subjects. The
267
293
  * differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may
268
- * share a name without colliding.
294
+ * share a name without colliding. Extensions are root children too: an
295
+ * extension's name is unique in the database.
269
296
  */
270
297
  declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {
271
298
  readonly nodeKind: "postgres-database";
272
299
  readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;
273
300
  readonly roles: readonly PostgresRoleSchemaNode[];
301
+ readonly extensions: readonly PostgresExtensionSchemaNode[];
274
302
  readonly existingSchemas: readonly string[];
275
303
  readonly pgVersion: string;
276
304
  constructor(input: PostgresDatabaseSchemaNodeInput);
@@ -281,5 +309,5 @@ declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements Diff
281
309
  static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode;
282
310
  }
283
311
  //#endregion
284
- export { PostgresNativeEnumSchemaNode as a, PostgresPolicySchemaNodeInput as c, PostgresTableSchemaNode as d, PostgresTableSchemaNodeInput as f, PostgresNamespaceSchemaNodeInput as i, PostgresRoleSchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNativeEnumSchemaNodeInput as o, PostgresNamespaceSchemaNode as r, PostgresPolicySchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresRoleSchemaNodeInput as u };
285
- //# sourceMappingURL=postgres-database-schema-node-Cv8usVNX-BmvGozi4.d.mts.map
312
+ export { PostgresNamespaceSchemaNode as a, PostgresNativeEnumSchemaNodeInput as c, PostgresRoleSchemaNode as d, PostgresRoleSchemaNodeInput as f, PostgresExtensionSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresTableSchemaNodeInput as m, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresTableSchemaNode as p, PostgresExtensionSchemaNode as r, PostgresNativeEnumSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
313
+ //# sourceMappingURL=postgres-database-schema-node-BjmJ6_Cs-LyZ0n9oj.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-database-schema-node-BjmJ6_Cs-LyZ0n9oj.d.mts","names":[],"sources":["../../../../3-targets/postgres/1-target/dist/postgres-database-schema-node-BjmJ6_Cs.d.mts"],"mappings":";;;;;;;UAMU;WACC;;WAEA;;WAEA,SAAS;;;;;cAKN,oCAAoC,2BAA2B;WAClE;WACA;WACA;WACA,UAAU;EACnB,YAAY,OAAO;MACf;EACJ,qBAAqB;EACrB,UAAU,OAAO;EACjB,gBAAgB,QAAQ,2BAA2B;SAC5C,GAAG,MAAM,kBAAkB,QAAQ;SACnC,OAAO,MAAM,0BAA0B,QAAQ;;;;UAI9C;;WAEC;;WAEA;;WAEA;;WAEA,UAAU;;;;;;;;;;;;;;;;;;;;;cAqBP,qCAAqC,2BAA2B;WACnE;WACA;WACA;WACA;WACA,UAAU;EACnB,YAAY,OAAO;MACf;EACJ,qBAAqB;EACrB,UAAU,OAAO;SACV,GAAG,MAAM,kBAAkB,QAAQ;SACnC,OAAO,MAAM,0BAA0B,QAAQ;;;;UAI9C;;WAEC,QAAQ;;WAER;;WAEA;WACA,WAAW;;WAEX;;WAEA;;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WACA;;;;;;;;;;;;;cAaG,mCAAmC,2BAA2B;WACjE;WACA,YAAY,SAAS,eAAe;WACpC,gBAAgB;WAChB,qBAAqB;WACrB;WACA;EACT,YAAY,OAAO;MACf;EACJ,UAAU,OAAO;EACjB,qBAAqB;SACd,GAAG,MAAM,kBAAkB,QAAQ;SACnC,OAAO,MAAM,0BAA0B,QAAQ"}
@@ -1,16 +1,16 @@
1
1
  import { r as errorPostgresMigrationStackMissing, u as postgresError } from "./errors-DpdPXR_L-DailcY-X.mjs";
2
- import { i as PostgresRlsPolicy } from "./postgres-schema-osNZNX0D-BpKJDg4M.mjs";
3
- import { n as PostgresSchemaNodeKind, r as PostgresTableSchemaNode } from "./postgres-table-schema-node-BBkitBQh-Dll8iaZT.mjs";
4
- import { n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--BzOKm4N1.mjs";
2
+ import { o as PostgresRlsPolicy } from "./postgres-schema-BBWgs4fX-DWdYxNi8.mjs";
3
+ import { i as PostgresTableSchemaNode, r as PostgresSchemaNodeKind } from "./postgres-table-schema-node-nY6II-Uv-Bj-lgmSi.mjs";
4
+ import { n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-DuljIQWp-D6Q5JyEs.mjs";
5
5
  import { t as postgresResolveDefault } from "./default-normalizer-BqK6XxdC-2OUb2ybG.mjs";
6
- import { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage, t as ddlSchemaOfCallSchema } from "./resolve-ddl-schema-uDXEVepU-COWNfVPC.mjs";
6
+ import { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage, t as ddlSchemaOfCallSchema } from "./resolve-ddl-schema-BZzteXH1-C57Iavtu.mjs";
7
7
  import { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from "./default-constraint-names-Cz9Yoeim-sUzOGvIm.mjs";
8
8
  import { i as hasAutoincrementDefault } from "./autoincrement-widths-Cy5o21bQ-DKg9UXXV.mjs";
9
- import { a as stackDataTypes, o as writtenColumnType } from "./planner-sql-checks-CvI80tt0-B5bKCucD.mjs";
10
- import { A as RemoveStoredValueCall, B as SetNotNullCall, C as DropNativeEnumTypeCall, D as DropTableCall, E as DropSchemaCall, F as RenameSchemaCall, H as alterColumnTypeCallText, I as RenameTableCall, K as installExtension, L as ReplaceStoredValueCall, M as RenameConstraintCall, N as RenameIndexCall, O as EnableRowLevelSecurityCall, P as RenamePostgresRlsPolicyCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, V as SetTableSchemaCall, Y as renameTableStatement, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddForeignKeyCall, j as RenameColumnCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall, z as SetDefaultCall } from "./op-factory-call-DsQATX-o-BHcqPXrs.mjs";
11
- import { l as resolveNamespaceIdForDdlSchema, r as issueNode } from "./control-policy-DZzwyc3L-_Bf4iEaW.mjs";
12
- import { n as contractToPostgresDatabaseSchemaNode, t as buildPostgresPlanDiff } from "./diff-database-schema-DrOE5ahI-BfrNtMDu.mjs";
13
- import { n as PostgresContractView } from "./postgres-contract-view-CRy_3BMc-60fosJRZ.mjs";
9
+ import { a as stackDataTypes, o as writtenColumnType } from "./planner-sql-checks-FU4T7wgu-C-tIJOH-.mjs";
10
+ import { B as SetDefaultCall, C as DropIndexCall, D as DropSchemaCall, E as DropPostgresRlsPolicyCall, F as RenamePostgresRlsPolicyCall, H as SetNotNullCall, I as RenameSchemaCall, J as installExtension, L as RenameTableCall, M as RenameColumnCall, N as RenameConstraintCall, O as DropTableCall, P as RenameIndexCall, R as ReplaceStoredValueCall, S as DropExtensionCall, T as DropNotNullCall, U as SetTableSchemaCall, V as SetExtensionSchemaCall, W as alterColumnTypeCallText, Z as renameTableStatement, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddForeignKeyCall, j as RemoveStoredValueCall, k as EnableRowLevelSecurityCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreatePostgresRlsPolicyCall, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, u as CreateExtensionCall, v as DropCheckConstraintCall, w as DropNativeEnumTypeCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-DyQO1ZdB-CnbOJIf8.mjs";
11
+ import { l as resolveNamespaceIdForDdlSchema, r as issueNode } from "./control-policy-DYDR6FhY-CPBeYqu5.mjs";
12
+ import { n as contractToPostgresDatabaseSchemaNode, t as buildPostgresPlanDiff } from "./diff-database-schema-DyoCp8VS-BKtXp-eB.mjs";
13
+ import { n as PostgresContractView } from "./postgres-contract-view-iwNgaXQw-QzVSakJT.mjs";
14
14
  import { t as dataTransform } from "./data-transform-h9agBu_c-RlC5A7aY.mjs";
15
15
  import { blindCast } from "@prisma/orm-framework/utils/casts";
16
16
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -25,7 +25,7 @@ import { resolveColumnRenameAgainst, resolveTableRenameAgainst, sqlTypeLookupsOf
25
25
  import { errorMigrationOperationOptionRemoved } from "@prisma/orm-framework/errors/migration";
26
26
  import { Migration } from "@prisma/orm-family-sql/family/migration";
27
27
  import { MigrationContractViews } from "@prisma/orm-toolchain/migration-tools/migration";
28
- //#region ../../../3-targets/postgres/1-target/dist/postgres-migration-CSU_fUlQ.mjs
28
+ //#region ../../../3-targets/postgres/1-target/dist/postgres-migration-BhijSOgq.mjs
29
29
  /**
30
30
  * The Postgres schema tree a contract describes, as the planner's "from" side:
31
31
  * the target descriptor's `migrations.contractToSchema` hook and the trees
@@ -465,6 +465,7 @@ function mapTables(schema, rewrite, editFor) {
465
465
  }))
466
466
  })])),
467
467
  roles: schema.roles,
468
+ extensions: schema.extensions,
468
469
  existingSchemas: schema.existingSchemas,
469
470
  pgVersion: schema.pgVersion
470
471
  });
@@ -567,6 +568,7 @@ function moveTableInPostgresSchema(schema, move) {
567
568
  })
568
569
  },
569
570
  roles: rewritten.roles,
571
+ extensions: rewritten.extensions,
570
572
  existingSchemas: rewritten.existingSchemas,
571
573
  pgVersion: rewritten.pgVersion
572
574
  });
@@ -602,6 +604,7 @@ function renameSchemaInPostgresSchema(schema, rename) {
602
604
  tables: namespace.tables
603
605
  })] : [key, namespace])),
604
606
  roles: rewritten.roles,
607
+ extensions: rewritten.extensions,
605
608
  existingSchemas: rewritten.existingSchemas.map((name) => name === from ? to : name),
606
609
  pgVersion: rewritten.pgVersion
607
610
  });
@@ -611,6 +614,7 @@ function withSchema(schema, schemaName) {
611
614
  return new PostgresDatabaseSchemaNode({
612
615
  namespaces: schema.namespaces,
613
616
  roles: schema.roles,
617
+ extensions: schema.extensions,
614
618
  existingSchemas: [...schema.existingSchemas, schemaName],
615
619
  pgVersion: schema.pgVersion
616
620
  });
@@ -1250,6 +1254,20 @@ var PostgresMigration = class extends Migration {
1250
1254
  dropIndex(options) {
1251
1255
  return new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor("dropIndex"));
1252
1256
  }
1257
+ /**
1258
+ * Emit a `CREATE EXTENSION … WITH SCHEMA …` migration operation, checked to find the extension absent before and present after.
1259
+ */
1260
+ createExtension(options) {
1261
+ return new CreateExtensionCall(options.schema, options.extension).toOp(this.controlAdapterFor("createExtension"));
1262
+ }
1263
+ /** Emit a `DROP EXTENSION` migration operation, without `CASCADE`. */
1264
+ dropExtension(options) {
1265
+ return new DropExtensionCall(options.schema, options.extension).toOp(this.controlAdapterFor("dropExtension"));
1266
+ }
1267
+ /** Emit an `ALTER EXTENSION … SET SCHEMA …` migration operation. */
1268
+ setExtensionSchema(options) {
1269
+ return new SetExtensionSchemaCall(options.extension, options.schema).toOp(this.controlAdapterFor("setExtensionSchema"));
1270
+ }
1253
1271
  installExtension(options) {
1254
1272
  return installExtension(options, this.controlAdapterFor("installExtension"));
1255
1273
  }
@@ -1330,4 +1348,4 @@ function createIndexExtrasOf(extras, index) {
1330
1348
  //#endregion
1331
1349
  export { postgresColumnRenameCall as a, postgresTableRenameByHand as c, renderRenameTableCall as d, pairIndexRenames as i, postgresTableRenameCall as l, createWorkingSchema as n, postgresContractToSchema as o, pairCheckRenames as r, postgresSchemaTables as s, PostgresMigration as t, renameTableByHandStatements as u };
1332
1350
 
1333
- //# sourceMappingURL=postgres-migration-CSU_fUlQ-C5TNpgq4.mjs.map
1351
+ //# sourceMappingURL=postgres-migration-BhijSOgq-CP_oflub.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-BhijSOgq-CP_oflub.mjs","names":["#current","#endView","#startView","#renames"],"sources":["../../../../3-targets/postgres/1-target/dist/postgres-migration-BhijSOgq.mjs"],"sourcesContent":["import { r as errorPostgresMigrationStackMissing, u as postgresError } from \"./errors-DpdPXR_L.mjs\";\nimport { y as PostgresRlsPolicy } from \"./postgres-schema-BBWgs4fX.mjs\";\nimport { t as postgresResolveDefault } from \"./default-normalizer-BqK6XxdC.mjs\";\nimport { i as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-nY6II-Uv.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode } from \"./postgres-role-schema-node-DuljIQWp.mjs\";\nimport { n as emissionSchemaForNamespace, r as resolveDdlSchemaForNamespaceStorage, t as ddlSchemaOfCallSchema } from \"./resolve-ddl-schema-BZzteXH1.mjs\";\nimport { r as contractToPostgresDatabaseSchemaNode, t as buildPostgresPlanDiff } from \"./diff-database-schema-DyoCp8VS.mjs\";\nimport { c as issueNode, n as resolveNamespaceIdForDdlSchema } from \"./control-policy-DYDR6FhY.mjs\";\nimport { n as defaultPrimaryKeyName, r as defaultUniqueName, t as defaultForeignKeyName } from \"./default-constraint-names-Cz9Yoeim.mjs\";\nimport { i as hasAutoincrementDefault } from \"./autoincrement-widths-Cy5o21bQ.mjs\";\nimport { $ as installExtension, B as SetExtensionSchemaCall, C as DropIndexCall, D as DropSchemaCall, E as DropPostgresRlsPolicyCall, F as RenamePostgresRlsPolicyCall, H as SetTableSchemaCall, I as RenameSchemaCall, L as RenameTableCall, M as RenameColumnCall, N as RenameConstraintCall, O as DropTableCall, P as RenameIndexCall, R as ReplaceStoredValueCall, S as DropExtensionCall, T as DropNotNullCall, U as alterColumnTypeCallText, V as SetNotNullCall, _ as DisableRowLevelSecurityCall, a as AddNativeEnumValueCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddForeignKeyCall, j as RemoveStoredValueCall, k as EnableRowLevelSecurityCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreatePostgresRlsPolicyCall, q as renameTableStatement, r as AddColumnWithTemporaryDefaultCall, s as AddRequiredColumnToEmptyTableCall, t as AddCheckConstraintCall, u as CreateExtensionCall, v as DropCheckConstraintCall, w as DropNativeEnumTypeCall, x as DropDefaultCall, y as DropColumnCall, z as SetDefaultCall } from \"./op-factory-call-DyQO1ZdB.mjs\";\nimport { a as stackDataTypes, o as writtenColumnType } from \"./planner-sql-checks-FU4T7wgu.mjs\";\nimport { t as PostgresContractView } from \"./postgres-contract-view-iwNgaXQw.mjs\";\nimport { t as dataTransform } from \"./data-transform-h9agBu_c.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { nameOf, namingOf, namingOfLiveName, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { sqlTextOf } from \"@internal/sql-relational-core/contract-free\";\nimport { resolveColumnRenameAgainst, resolveTableRenameAgainst, sqlTypeLookupsOf, unmatchedColumnRename, unmatchedTableRename } from \"@internal/family-sql/control\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlCheckConstraintIR, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR, sqlColumnTypesEqual } from \"@internal/sql-schema-ir/types\";\nimport { isArrayEqual } from \"@internal/utils/array-equal\";\nimport { errorMigrationOperationOptionRemoved } from \"@internal/errors/migration\";\nimport { Migration } from \"@internal/family-sql/migration\";\nimport { MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/migrations/postgres-contract-to-schema.ts\n/**\n* The Postgres schema tree a contract describes, as the planner's \"from\" side:\n* the target descriptor's `migrations.contractToSchema` hook and the trees\n* `renameTable` compares to find its companion renames both go through here,\n* so they are built with the same type lookups and default resolver.\n*/\nfunction postgresContractToSchema(contract, frameworkComponents) {\n\tconst types = sqlTypeLookupsOf(frameworkComponents);\n\treturn contractToPostgresDatabaseSchemaNode(blindCast(contract), {\n\t\tannotationNamespace: \"pg\",\n\t\tdataTypeLookup: types.dataTypeLookup,\n\t\tcodecLookup: types.codecLookup,\n\t\tresolveDefault: postgresResolveDefault\n\t});\n}\n//#endregion\n//#region src/core/migrations/index-and-check-renames.ts\n/**\n* Rename post-pass for indexes, per `(schema, table)`, widening-only,\n* deterministic by sorted names — the same structure as the policy pass\n* below (which stays untouched: policies pair by hash only).\n*\n* Hash pairing (prefix-only renames): extras whose live names parse as\n* wire names, grouped by `(schema, table, hash)`; missing nodes iterated\n* in sorted-name order consume the sorted-name-first candidate.\n*\n* Content pairing (exact→wire convergence), after hash pairing has\n* consumed its matches: the remaining wire-named-missing nodes\n* (`prefix` defined) against the remaining extras of any name shape,\n* paired iff content-equal (columns ordered-strict both-defined-or-\n* both-undefined, `unique`/`type` strict, `options` loose, bodies\n* byte-equal).\n*\n* Leftovers proceed as create/drop exactly as before; without the\n* widening allowance the pass is skipped and pairing degrades to the\n* additive half, like the policy pass.\n*/\nfunction pairIndexRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlIndexIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst rename = (missingFinding, candidate) => {\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));\n\t};\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\tconst sortedExtras = [...extra].sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tif (consumed.has(missingFinding.issue)) continue;\n\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\tconst candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {\n\t\t\tcolumnPresence: \"matching\",\n\t\t\tbodies: \"verbatim\"\n\t\t}));\n\t\tif (candidate === void 0) continue;\n\t\trename(missingFinding, candidate);\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n/**\n* Check-constraint rename post-pass: a `not-found` and a `not-expected`\n* check on the same table whose wire-name content hashes match but whose\n* prefixes differ is a prefix-only rename, and collapses into one\n* `ALTER TABLE … RENAME CONSTRAINT`.\n*\n* This is the index pass's hash-pairing phase and nothing else. There is\n* deliberately no content-pairing phase: a live check body is whatever\n* Postgres reprinted, so it never byte-matches the authored text, and\n* pairing an exact-named live check by content would bless whatever\n* predicate is actually live. Adoption of an old exact-named check stays\n* drop + add.\n*\n* Runs only when the policy allows `widening` (rename's class). Without it\n* the pass no-ops and the pair degrades to an add and a drop, and the drop,\n* which is `widening` too, is refused as a conflict.\n*/\nfunction pairCheckRenames(options, issues) {\n\tconst consumed = /* @__PURE__ */ new Set();\n\tconst calls = [];\n\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst missing = [];\n\tconst extra = [];\n\tfor (const issue of issues) {\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0 || !SqlCheckConstraintIR.is(node)) continue;\n\t\tconst ddlSchema = issue.path[1];\n\t\tconst tableName = issue.path[2];\n\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\tissue,\n\t\t\tnode,\n\t\t\tddlSchema,\n\t\t\ttableName\n\t\t});\n\t}\n\tif (missing.length === 0 || extra.length === 0) return {\n\t\tcalls,\n\t\tconsumed\n\t};\n\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\tfinding.ddlSchema,\n\t\tfinding.tableName,\n\t\thash\n\t]);\n\tconst sortedMissing = [...missing].sort(byName);\n\tconst extrasByHash = /* @__PURE__ */ new Map();\n\tfor (const finding of extra) {\n\t\tconst parsed = parseWireName(finding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst key = pairingKey(finding, parsed.hash);\n\t\tconst group = extrasByHash.get(key) ?? [];\n\t\tgroup.push(finding);\n\t\textrasByHash.set(key, group);\n\t}\n\tfor (const group of extrasByHash.values()) group.sort(byName);\n\tfor (const missingFinding of sortedMissing) {\n\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\tif (parsed === void 0) continue;\n\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\tif (candidate === void 0) continue;\n\t\tconsumed.add(missingFinding.issue);\n\t\tconsumed.add(candidate.issue);\n\t\tcalls.push(new RenameConstraintCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, \"checkConstraint\", candidate.node.name, missingFinding.node.name));\n\t}\n\treturn {\n\t\tcalls,\n\t\tconsumed\n\t};\n}\n//#endregion\n//#region src/core/migrations/schema-tables.ts\n/**\n* The tables of a Postgres schema, addressed by `contract`'s namespace ids, each mapped to its DDL\n* schema.\n*/\nfunction postgresSchemaTables(schema, contract) {\n\tconst tableIn = (namespaceId, table) => schema.namespaces[resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId)]?.tables[table];\n\tconst hasTable = (namespaceId, table) => tableIn(namespaceId, table) !== void 0;\n\treturn {\n\t\thasTable,\n\t\thasColumn: (namespaceId, table, column) => Object.hasOwn(tableIn(namespaceId, table)?.columns ?? {}, column),\n\t\ttablesNamed: (namespaceId, table) => hasTable(namespaceId, table) ? [table] : [],\n\t\tcolumnsNamed: (namespaceId, table, column) => Object.hasOwn(tableIn(namespaceId, table)?.columns ?? {}, column) ? [column] : [],\n\t\thasNamespace: (namespaceId) => {\n\t\t\tconst schemaName = resolveDdlSchemaForNamespaceStorage(contract.storage, namespaceId);\n\t\t\treturn schema.existingSchemas.includes(schemaName);\n\t\t},\n\t\tnamespacesWithTable: (table) => Object.keys(contract.storage.namespaces).filter((namespaceId) => hasTable(namespaceId, table))\n\t};\n}\n//#endregion\n//#region src/core/migrations/table-rename-constraint-renames.ts\n/**\n* The constraint renames that follow a table rename. Each primary key, unique constraint and\n* foreign key of the renamed table is paired with the destination constraint of the same kind on\n* the same columns, and for a foreign key the same referenced columns. Foreign keys pair first\n* with destination keys to the same referenced table, and the rest then pair with keys to another\n* table, because a later rename in the same plan may change that table and a foreign key's derived\n* name never depends on it. A paired constraint is renamed to the destination's explicit name, or else\n* to the name the planner derives from the new table name, when that differs from its name in the\n* database. Each destination constraint pairs with at most one constraint, in order. An unpaired\n* constraint is being dropped or changed and keeps its name. Indexes and checks are not handled\n* here: their wire names pair by content hash in the index and check rename passes.\n*/\nfunction constraintRenamesForTableRename(input) {\n\treturn pairedConstraintRenames(input, {\n\t\tprimaryKey: true,\n\t\tonColumns: () => true\n\t});\n}\n/**\n* The renames of the constraints in `scope` that pair with a destination constraint of the same\n* kind on the same columns, to the destination's explicit name or else the derived one.\n*/\nfunction pairedConstraintRenames(input, scope) {\n\tconst { schemaName, previous, next } = input;\n\tconst table = next.name;\n\tconst rename = (kind, actualName, target) => {\n\t\tassertDefined(actualName, `the table \"${previous.name}\" has a ${kind} that has no name; the working schema names every primary key, unique and foreign key a rename can change`);\n\t\treturn target === void 0 || target === actualName ? [] : [new RenameConstraintCall(schemaName, table, kind, actualName, target)];\n\t};\n\tconst nextPrimaryKey = next.primaryKey;\n\tconst primaryKey = previous.primaryKey === void 0 || !scope.primaryKey ? [] : rename(\"primaryKey\", previous.primaryKey.name, nextPrimaryKey !== void 0 && isArrayEqual(previous.primaryKey.columns, nextPrimaryKey.columns) ? nextPrimaryKey.name ?? defaultPrimaryKeyName(table) : void 0);\n\tconst pairedUniques = /* @__PURE__ */ new Set();\n\tconst uniques = previous.uniques.filter((unique) => scope.onColumns(unique.columns)).flatMap((unique) => {\n\t\tconst paired = next.uniques.find((candidate) => !pairedUniques.has(candidate) && isArrayEqual(candidate.columns, unique.columns));\n\t\tif (paired !== void 0) pairedUniques.add(paired);\n\t\treturn rename(\"unique\", unique.name, paired === void 0 ? void 0 : paired.name ?? defaultUniqueName(table, paired.columns));\n\t});\n\tconst previousForeignKeys = previous.foreignKeys.filter((fk) => scope.onColumns(fk.columns));\n\tconst pairing = pairForeignKeys(previousForeignKeys, next.foreignKeys);\n\tconst foreignKeys = previousForeignKeys.flatMap((fk) => {\n\t\tconst paired = pairing.get(fk);\n\t\treturn rename(\"foreignKey\", fk.name, paired === void 0 ? void 0 : paired.name ?? defaultForeignKeyName(table, fk.columns));\n\t});\n\treturn [\n\t\t...primaryKey,\n\t\t...uniques,\n\t\t...foreignKeys\n\t];\n}\n/**\n* Pairs old foreign keys with destination keys on the same columns and referenced columns. Every\n* key to the same referenced table pairs first, so an old key with no such match cannot take the\n* destination key another old key keeps; the remaining keys then pair in order.\n*/\nfunction pairForeignKeys(previous, next) {\n\tconst pairs = /* @__PURE__ */ new Map();\n\tconst taken = /* @__PURE__ */ new Set();\n\tconst pass = (accepts) => {\n\t\tfor (const fk of previous) {\n\t\t\tif (pairs.has(fk)) continue;\n\t\t\tconst paired = next.find((candidate) => !taken.has(candidate) && isArrayEqual(candidate.columns, fk.columns) && isArrayEqual(candidate.referencedColumns, fk.referencedColumns) && accepts(fk, candidate));\n\t\t\tif (paired === void 0) continue;\n\t\t\tpairs.set(fk, paired);\n\t\t\ttaken.add(paired);\n\t\t}\n\t};\n\tpass((fk, candidate) => candidate.referencedTable === fk.referencedTable && candidate.resolvedReferencedNamespace === fk.resolvedReferencedNamespace);\n\tpass(() => true);\n\treturn pairs;\n}\n//#endregion\n//#region src/core/migrations/column-rename-constraint-renames.ts\n/**\n* The constraint renames that follow a column rename. Each unique constraint and foreign key on\n* the renamed column is paired with the destination constraint of the same kind on the same\n* columns, and renamed to the destination's explicit name, or else to the name the planner derives\n* from the table and the new column names, when that differs from its name in the database. The\n* primary key's derived name does not depend on its columns, so it is left alone. `previous` is\n* the table after the column rename, its constraint names as they are in the database.\n*/\nfunction constraintRenamesForColumnRename(input) {\n\treturn pairedConstraintRenames(input, {\n\t\tprimaryKey: false,\n\t\tonColumns: (columns) => columns.includes(input.column)\n\t});\n}\n//#endregion\n//#region src/core/migrations/working-schema.ts\nfunction rewriteRefs(refs, rewrite) {\n\treturn refs?.map(rewrite);\n}\n/**\n* Rewrites the step of `kind` and `id` in a ref that runs through the given table, and the table\n* step itself when `kind` is the table kind.\n*/\nfunction stepRewrite(schemaName, tableName, kind, fromId, toId) {\n\treturn (ref) => {\n\t\tconst namespaceStep = ref[1];\n\t\tconst tableStep = ref[2];\n\t\tif (namespaceStep?.nodeKind !== PostgresSchemaNodeKind.namespace || namespaceStep.id !== schemaName || tableStep?.nodeKind !== PostgresSchemaNodeKind.table || tableStep.id !== tableName) return ref;\n\t\treturn ref.map((step, index) => index >= 2 && step.nodeKind === kind && step.id === fromId ? {\n\t\t\tnodeKind: kind,\n\t\t\tid: toId\n\t\t} : step);\n\t};\n}\nfunction withPrimaryKey(primaryKey, name, rewrite, columnName) {\n\treturn new PrimaryKey({\n\t\tcolumns: primaryKey.columns.map(columnName),\n\t\t...ifDefined(\"name\", name),\n\t\t...ifDefined(\"dependsOn\", rewriteRefs(primaryKey.dependsOn, rewrite))\n\t});\n}\nfunction withUnique(unique, name, rewrite, columnName) {\n\treturn new SqlUniqueIR({\n\t\tcolumns: unique.columns.map(columnName),\n\t\t...ifDefined(\"name\", name),\n\t\t...ifDefined(\"annotations\", unique.annotations),\n\t\t...ifDefined(\"dependsOn\", rewriteRefs(unique.dependsOn, rewrite))\n\t});\n}\nfunction withForeignKey(fk, overrides, rewrite, columnName) {\n\treturn new SqlForeignKeyIR({\n\t\tcolumns: fk.columns.map(columnName),\n\t\treferencedTable: overrides.referencedTable,\n\t\treferencedColumns: overrides.referencedColumns ?? fk.referencedColumns,\n\t\t...ifDefined(\"referencedSchema\", overrides.referencedSchema ?? fk.referencedSchema),\n\t\t...ifDefined(\"name\", overrides.name),\n\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t...ifDefined(\"resolvedReferencedNamespace\", overrides.referencedSchema ?? fk.resolvedReferencedNamespace),\n\t\t...ifDefined(\"dependsOn\", rewriteRefs(fk.dependsOn, rewrite))\n\t});\n}\n/**\n* An index whose definition carries SQL text, an expression or a predicate, keeps its columns as\n* they are: a column named inside the text cannot be renamed here, so the diff plans the index.\n*/\nfunction withIndex(index, naming, rewrite, columnName) {\n\tconst columnsFollow = index.expression === void 0 && index.where === void 0;\n\tconst base = {\n\t\tnaming,\n\t\twhere: index.where,\n\t\tunique: index.unique,\n\t\tpartial: index.partial,\n\t\ttype: index.type,\n\t\toptions: index.options,\n\t\tannotations: index.annotations,\n\t\tdependsOn: rewriteRefs(index.dependsOn, rewrite)\n\t};\n\treturn new SqlIndexIR(index.expression !== void 0 ? {\n\t\t...base,\n\t\texpression: index.expression\n\t} : {\n\t\t...base,\n\t\tcolumns: (index.columns ?? []).map(columnsFollow ? columnName : (c) => c)\n\t});\n}\nfunction withCheck(check, naming, rewrite) {\n\treturn new SqlCheckConstraintIR({\n\t\tnaming,\n\t\texpression: check.expression,\n\t\tdependsOn: rewriteRefs(check.dependsOn, rewrite)\n\t});\n}\nfunction withPolicy(policy, overrides, rewrite) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: overrides.naming,\n\t\ttableName: overrides.tableName,\n\t\tnamespaceId: overrides.namespaceId ?? policy.namespaceId,\n\t\toperation: policy.operation,\n\t\troles: policy.roles,\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: rewriteRefs(policy.dependsOn, rewrite)\n\t});\n}\nfunction unchangedEdit(table) {\n\treturn {\n\t\tname: table.name,\n\t\tprimaryKeyName: (primaryKey) => primaryKey.name,\n\t\tuniqueName: (unique) => unique.name,\n\t\tforeignKey: (fk) => ({\n\t\t\tname: fk.name,\n\t\t\treferencedTable: fk.referencedTable\n\t\t}),\n\t\tcolumnName: (column) => column,\n\t\tindexNaming: (index) => namingOf(index.name, index.prefix),\n\t\tcheckNaming: (check) => namingOf(check.name, check.prefix),\n\t\tpolicy: (policy) => ({\n\t\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\t\ttableName: policy.tableName\n\t\t})\n\t};\n}\nfunction rebuildTable(table, edit, rewrite) {\n\tconst { columnName } = edit;\n\treturn new PostgresTableSchemaNode({\n\t\tname: edit.name,\n\t\tcolumns: Object.fromEntries(Object.values(table.columns).map((column) => {\n\t\t\tconst name = columnName(column.name);\n\t\t\treturn [name, name === column.name ? column : column.withName(name)];\n\t\t})),\n\t\t...ifDefined(\"primaryKey\", table.primaryKey === void 0 ? void 0 : withPrimaryKey(table.primaryKey, edit.primaryKeyName(table.primaryKey), rewrite, columnName)),\n\t\tuniques: table.uniques.map((unique) => withUnique(unique, edit.uniqueName(unique), rewrite, columnName)),\n\t\tforeignKeys: table.foreignKeys.map((fk) => withForeignKey(fk, edit.foreignKey(fk), rewrite, columnName)),\n\t\tindexes: table.indexes.map((index) => withIndex(index, edit.indexNaming(index), rewrite, columnName)),\n\t\t...ifDefined(\"checks\", table.checks?.map((check) => withCheck(check, edit.checkNaming(check), rewrite))),\n\t\t...ifDefined(\"annotations\", table.annotations),\n\t\tpolicies: table.policies.map((policy) => withPolicy(policy, edit.policy(policy), rewrite)),\n\t\trlsEnabled: table.rlsEnabled\n\t});\n}\n/**\n* Rebuilds every table of the schema: `editFor` returns the edit for a table, or `undefined` to\n* only rewrite its dependencies.\n*/\nfunction mapTables(schema, rewrite, editFor) {\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces: Object.fromEntries(Object.entries(schema.namespaces).map(([key, namespace]) => [key, new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: namespace.schemaName,\n\t\t\tnativeEnums: namespace.nativeEnums,\n\t\t\ttables: Object.fromEntries(Object.values(namespace.tables).map((table) => {\n\t\t\t\tconst rebuilt = rebuildTable(table, editFor(namespace.schemaName, table) ?? unchangedEdit(table), rewrite);\n\t\t\t\treturn [rebuilt.name, rebuilt];\n\t\t\t}))\n\t\t})])),\n\t\troles: schema.roles,\n\t\textensions: schema.extensions,\n\t\texistingSchemas: schema.existingSchemas,\n\t\tpgVersion: schema.pgVersion\n\t});\n}\n/**\n* The schema with one table under its new name. Foreign keys anywhere that reference the table\n* follow it, its policies and every dependency that names it move with it, and row-level security\n* is carried. Constraint, index, check and policy names do not change: a primary key, unique\n* constraint or foreign key whose name was derived from the old table name gets that name spelled\n* out, since it no longer derives from the table it is on.\n*/\nfunction renameTableInPostgresSchema(schema, rename) {\n\tconst { schemaName, from, to } = rename;\n\tconst rewrite = stepRewrite(schemaName, from, PostgresSchemaNodeKind.table, from, to);\n\tconst referencesRenamed = (ownSchema, fk) => (fk.resolvedReferencedNamespace ?? ownSchema) === schemaName && fk.referencedTable === from;\n\treturn mapTables(schema, rewrite, (tableSchema, table) => {\n\t\tconst unchanged = unchangedEdit(table);\n\t\tconst followReference = (fk) => ({\n\t\t\tname: fk.name,\n\t\t\treferencedTable: referencesRenamed(tableSchema, fk) ? to : fk.referencedTable\n\t\t});\n\t\tif (tableSchema !== schemaName || table.name !== from) return {\n\t\t\t...unchanged,\n\t\t\tforeignKey: followReference\n\t\t};\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tname: to,\n\t\t\tprimaryKeyName: (primaryKey) => primaryKey.name ?? defaultPrimaryKeyName(from),\n\t\t\tuniqueName: (unique) => unique.name ?? defaultUniqueName(from, unique.columns),\n\t\t\tforeignKey: (fk) => ({\n\t\t\t\t...followReference(fk),\n\t\t\t\tname: fk.name ?? defaultForeignKeyName(from, fk.columns)\n\t\t\t}),\n\t\t\tpolicy: (policy) => ({\n\t\t\t\t...unchanged.policy(policy),\n\t\t\t\ttableName: to\n\t\t\t})\n\t\t};\n\t});\n}\n/**\n* The schema with one table moved to another schema, as `ALTER TABLE … SET SCHEMA` moves it: its\n* constraints, indexes and policies move with it, foreign keys anywhere that reference it follow\n* it, and every dependency that names it moves with it. The destination schema is added when the\n* schema has no node for it.\n*/\nfunction moveTableInPostgresSchema(schema, move) {\n\tconst { table: tableName, from, to } = move;\n\tconst rewrite = (ref) => {\n\t\tconst namespaceStep = ref[1];\n\t\tconst tableStep = ref[2];\n\t\tif (namespaceStep?.nodeKind !== PostgresSchemaNodeKind.namespace || namespaceStep.id !== from || tableStep?.nodeKind !== PostgresSchemaNodeKind.table || tableStep.id !== tableName) return ref;\n\t\treturn ref.map((step, index) => index === 1 ? {\n\t\t\tnodeKind: step.nodeKind,\n\t\t\tid: to\n\t\t} : step);\n\t};\n\tconst rewritten = mapTables(schema, rewrite, (tableSchema, table) => {\n\t\tconst unchanged = unchangedEdit(table);\n\t\tconst isMoved = tableSchema === from && table.name === tableName;\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tpolicy: (policy) => isMoved ? {\n\t\t\t\t...unchanged.policy(policy),\n\t\t\t\tnamespaceId: to\n\t\t\t} : unchanged.policy(policy),\n\t\t\tforeignKey: (fk) => {\n\t\t\t\tconst referencedSchema = fk.resolvedReferencedNamespace ?? tableSchema;\n\t\t\t\tif (referencedSchema === from && fk.referencedTable === tableName) return {\n\t\t\t\t\t...unchanged.foreignKey(fk),\n\t\t\t\t\treferencedSchema: to\n\t\t\t\t};\n\t\t\t\treturn isMoved && fk.resolvedReferencedNamespace === void 0 ? {\n\t\t\t\t\t...unchanged.foreignKey(fk),\n\t\t\t\t\treferencedSchema\n\t\t\t\t} : unchanged.foreignKey(fk);\n\t\t\t}\n\t\t};\n\t});\n\tconst source = rewritten.namespaces[from];\n\tconst moved = source?.tables[tableName];\n\tif (source === void 0 || moved === void 0) return rewritten;\n\tconst destination = rewritten.namespaces[to];\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {\n\t\t\t...rewritten.namespaces,\n\t\t\t[from]: new PostgresNamespaceSchemaNode({\n\t\t\t\tschemaName: source.schemaName,\n\t\t\t\tnativeEnums: source.nativeEnums,\n\t\t\t\ttables: Object.fromEntries(Object.entries(source.tables).filter(([name]) => name !== tableName))\n\t\t\t}),\n\t\t\t[to]: new PostgresNamespaceSchemaNode({\n\t\t\t\tschemaName: to,\n\t\t\t\tnativeEnums: destination?.nativeEnums ?? [],\n\t\t\t\ttables: {\n\t\t\t\t\t...destination?.tables,\n\t\t\t\t\t[tableName]: moved\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\troles: rewritten.roles,\n\t\textensions: rewritten.extensions,\n\t\texistingSchemas: rewritten.existingSchemas,\n\t\tpgVersion: rewritten.pgVersion\n\t});\n}\n/**\n* The schema with one schema renamed, as `ALTER SCHEMA … RENAME TO` renames it: its tables and\n* their policies keep their place in it, and foreign keys and dependencies that name it follow.\n*/\nfunction renameSchemaInPostgresSchema(schema, rename) {\n\tconst { from, to } = rename;\n\tconst rewrite = (ref) => ref[1]?.nodeKind === PostgresSchemaNodeKind.namespace && ref[1].id === from ? ref.map((step, index) => index === 1 ? {\n\t\tnodeKind: step.nodeKind,\n\t\tid: to\n\t} : step) : ref;\n\tconst rewritten = mapTables(schema, rewrite, (tableSchema, table) => {\n\t\tconst unchanged = unchangedEdit(table);\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tpolicy: (policy) => tableSchema === from ? {\n\t\t\t\t...unchanged.policy(policy),\n\t\t\t\tnamespaceId: to\n\t\t\t} : unchanged.policy(policy),\n\t\t\tforeignKey: (fk) => (fk.resolvedReferencedNamespace ?? tableSchema) === from ? {\n\t\t\t\t...unchanged.foreignKey(fk),\n\t\t\t\treferencedSchema: to\n\t\t\t} : unchanged.foreignKey(fk)\n\t\t};\n\t});\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces: Object.fromEntries(Object.entries(rewritten.namespaces).filter(([key]) => key !== to).map(([key, namespace]) => key === from ? [to, new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: to,\n\t\t\tnativeEnums: namespace.nativeEnums,\n\t\t\ttables: namespace.tables\n\t\t})] : [key, namespace])),\n\t\troles: rewritten.roles,\n\t\textensions: rewritten.extensions,\n\t\texistingSchemas: rewritten.existingSchemas.map((name) => name === from ? to : name),\n\t\tpgVersion: rewritten.pgVersion\n\t});\n}\nfunction withSchema(schema, schemaName) {\n\tif (schema.existingSchemas.includes(schemaName)) return schema;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces: schema.namespaces,\n\t\troles: schema.roles,\n\t\textensions: schema.extensions,\n\t\texistingSchemas: [...schema.existingSchemas, schemaName],\n\t\tpgVersion: schema.pgVersion\n\t});\n}\n/**\n* The schema with one column under its new name. The table's primary key, unique constraints,\n* foreign keys and plain column indexes name it under the new name, foreign keys anywhere that\n* reference it follow it, and every dependency that names it moves with it. An index with an\n* expression or a predicate, and a check, keep their SQL text. Constraint and index names do not\n* change: a unique constraint or foreign key on the column whose name was derived from the old\n* column name gets that name spelled out.\n*/\nfunction renameColumnInPostgresSchema(schema, rename) {\n\tconst { schemaName, table: tableName, from, to } = rename;\n\tconst rewrite = stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.column, `column:${from}`, `column:${to}`);\n\tconst renamed = (column) => column === from ? to : column;\n\tconst referencesTable = (ownSchema, fk) => (fk.resolvedReferencedNamespace ?? ownSchema) === schemaName && fk.referencedTable === tableName;\n\treturn mapTables(schema, rewrite, (tableSchema, table) => {\n\t\tconst unchanged = unchangedEdit(table);\n\t\tconst followReference = (fk) => ({\n\t\t\tname: fk.name,\n\t\t\treferencedTable: fk.referencedTable,\n\t\t\treferencedColumns: referencesTable(tableSchema, fk) ? fk.referencedColumns.map(renamed) : fk.referencedColumns\n\t\t});\n\t\tif (tableSchema !== schemaName || table.name !== tableName) return {\n\t\t\t...unchanged,\n\t\t\tforeignKey: followReference\n\t\t};\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tcolumnName: renamed,\n\t\t\tuniqueName: (unique) => unique.name ?? (unique.columns.includes(from) ? defaultUniqueName(tableName, unique.columns) : void 0),\n\t\t\tforeignKey: (fk) => ({\n\t\t\t\t...followReference(fk),\n\t\t\t\tname: fk.name ?? (fk.columns.includes(from) ? defaultForeignKeyName(tableName, fk.columns) : void 0)\n\t\t\t})\n\t\t};\n\t});\n}\nfunction renamedNaming(previous, name) {\n\treturn previous.prefix === void 0 ? namingOf(name, void 0) : namingOfLiveName(name);\n}\nfunction renameConstraint(schema, call) {\n\tconst schemaName = ddlSchemaOfCallSchema(call.schemaName);\n\tconst { tableName, oldConstraintName, newConstraintName } = call;\n\tconst renamed = (name, derived) => (name ?? derived) === oldConstraintName ? newConstraintName : name;\n\treturn mapTables(schema, stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.check, `check:${oldConstraintName}`, `check:${newConstraintName}`), (tableSchema, table) => {\n\t\tif (tableSchema !== schemaName || table.name !== tableName) return void 0;\n\t\tconst unchanged = unchangedEdit(table);\n\t\tswitch (call.kind) {\n\t\t\tcase \"primaryKey\": return {\n\t\t\t\t...unchanged,\n\t\t\t\tprimaryKeyName: (primaryKey) => renamed(primaryKey.name, defaultPrimaryKeyName(tableName))\n\t\t\t};\n\t\t\tcase \"unique\": return {\n\t\t\t\t...unchanged,\n\t\t\t\tuniqueName: (unique) => renamed(unique.name, defaultUniqueName(tableName, unique.columns))\n\t\t\t};\n\t\t\tcase \"foreignKey\": return {\n\t\t\t\t...unchanged,\n\t\t\t\tforeignKey: (fk) => ({\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\tname: renamed(fk.name, defaultForeignKeyName(tableName, fk.columns))\n\t\t\t\t})\n\t\t\t};\n\t\t\tcase \"checkConstraint\": return {\n\t\t\t\t...unchanged,\n\t\t\t\tcheckNaming: (check) => check.name === oldConstraintName ? renamedNaming(check, newConstraintName) : unchanged.checkNaming(check)\n\t\t\t};\n\t\t}\n\t});\n}\nfunction renameIndex(schema, call) {\n\tconst schemaName = ddlSchemaOfCallSchema(call.schemaName);\n\tconst { tableName, oldIndexName, newIndexName } = call;\n\treturn mapTables(schema, stepRewrite(schemaName, tableName, RelationalSchemaNodeKind.index, `index:${oldIndexName}`, `index:${newIndexName}`), (tableSchema, table) => {\n\t\tif (tableSchema !== schemaName || table.name !== tableName) return void 0;\n\t\tconst unchanged = unchangedEdit(table);\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tindexNaming: (index) => index.name === oldIndexName ? renamedNaming(index, newIndexName) : unchanged.indexNaming(index)\n\t\t};\n\t});\n}\nfunction renamePolicy(schema, call) {\n\tconst schemaName = ddlSchemaOfCallSchema(call.schemaName);\n\tconst { tableName, oldPolicyName, newPolicyName } = call;\n\treturn mapTables(schema, stepRewrite(schemaName, tableName, PostgresSchemaNodeKind.policy, oldPolicyName, newPolicyName), (tableSchema, table) => {\n\t\tif (tableSchema !== schemaName || table.name !== tableName) return void 0;\n\t\tconst unchanged = unchangedEdit(table);\n\t\treturn {\n\t\t\t...unchanged,\n\t\t\tpolicy: (policy) => policy.name === oldPolicyName ? {\n\t\t\t\tnaming: renamedNaming(policy, newPolicyName),\n\t\t\t\ttableName: policy.tableName\n\t\t\t} : unchanged.policy(policy)\n\t\t};\n\t});\n}\nfunction applied(schema, call) {\n\tif (call instanceof CreateSchemaCall) return withSchema(schema, call.schemaName);\n\tif (call instanceof RenameSchemaCall) return renameSchemaInPostgresSchema(schema, {\n\t\tfrom: call.schemaName,\n\t\tto: call.toSchemaName\n\t});\n\tif (call instanceof SetTableSchemaCall) return moveTableInPostgresSchema(schema, {\n\t\ttable: call.tableName,\n\t\tfrom: ddlSchemaOfCallSchema(call.schemaName),\n\t\tto: call.toSchemaName\n\t});\n\tif (call instanceof RenameTableCall) {\n\t\tconst renamed = renameTableInPostgresSchema(schema, {\n\t\t\tschemaName: ddlSchemaOfCallSchema(call.schemaName),\n\t\t\tfrom: call.oldTableName,\n\t\t\tto: call.tableName\n\t\t});\n\t\treturn call.companions.reduce(applied, renamed);\n\t}\n\tif (call instanceof RenameColumnCall) {\n\t\tconst renamed = renameColumnInPostgresSchema(schema, {\n\t\t\tschemaName: ddlSchemaOfCallSchema(call.schemaName),\n\t\t\ttable: call.tableName,\n\t\t\tfrom: call.oldColumnName,\n\t\t\tto: call.columnName\n\t\t});\n\t\treturn call.companions.reduce(applied, renamed);\n\t}\n\tif (call instanceof RenameConstraintCall) return renameConstraint(schema, call);\n\tif (call instanceof RenameIndexCall) return renameIndex(schema, call);\n\treturn renamePolicy(schema, call);\n}\n/** The working schema of a plan or a migration, starting from `initial`. */\nfunction createWorkingSchema(initial) {\n\treturn new WorkingSchemaImpl(initial);\n}\nvar WorkingSchemaImpl = class {\n\t#current;\n\tconstructor(initial) {\n\t\tthis.#current = initial;\n\t}\n\tget current() {\n\t\treturn this.#current;\n\t}\n\tapply(call) {\n\t\tthis.#current = applied(this.#current, call);\n\t}\n};\n//#endregion\n//#region src/core/migrations/table-rename-calls.ts\nconst RENAME_POLICY = { allowedOperationClasses: [\"widening\"] };\n/**\n* The `renameTable` call a user writes in `migration.ts` for `rename`. `schema` names the namespace\n* the facade resolves the table in, and is left out for the unbound namespace or when not given.\n*/\nfunction renderRenameTableCall(rename) {\n\treturn new RenameTableCall(rename.namespaceId ?? UNBOUND_NAMESPACE_ID, rename.from, rename.to, []).renderTypeScript();\n}\n/** The SQL a user runs against the database to rename the table by hand. */\nfunction renameTableByHandStatements(contract, rename) {\n\treturn [renameTableStatement(emissionSchemaForNamespace(contract, rename.namespaceId), rename.from, rename.to)];\n}\n/** How a user renames a table of `contract` by hand on Postgres. */\nfunction postgresTableRenameByHand(contract) {\n\treturn {\n\t\trenderTableRename: renderRenameTableCall,\n\t\ttableRenameByHand: (rename) => renameTableByHandStatements(contract, rename)\n\t};\n}\nfunction tableNode(schema, ddlSchema, tableName) {\n\tconst table = schema.namespaces[ddlSchema]?.tables[tableName];\n\tassertDefined(table, `a resolved rename names table \"${tableName}\" in schema \"${ddlSchema}\"`);\n\treturn table;\n}\n/**\n* The call that renames a table, carrying as companions the renames of the objects on the table\n* whose names derive from the table name: each primary key, unique constraint and foreign key the\n* destination keeps, named as the destination names it, and each wire-named index and check whose\n* prefix changes. `previous` is the schema before the rename; the renamed copy is diffed against\n* the destination built from `contract`.\n*/\nfunction postgresTableRenameCall(input) {\n\tconst { contract, rename } = input;\n\tconst schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);\n\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);\n\tconst renamed = renameTableInPostgresSchema(input.previous, {\n\t\tschemaName: ddlSchema,\n\t\tfrom: rename.from,\n\t\tto: rename.to\n\t});\n\tconst { expected, issues } = buildPostgresPlanDiff({\n\t\tcontract,\n\t\tactualSchema: renamed,\n\t\tframeworkComponents: input.frameworkComponents\n\t});\n\tconst onRenamedTable = (call) => call.schemaName === schemaName && call.tableName === rename.to;\n\tconst pairing = {\n\t\tcontract,\n\t\tpolicy: RENAME_POLICY\n\t};\n\treturn new RenameTableCall(schemaName, rename.from, rename.to, [\n\t\t...constraintRenamesForTableRename({\n\t\t\tschemaName,\n\t\t\tprevious: tableNode(renamed, ddlSchema, rename.to),\n\t\t\tnext: tableNode(expected, ddlSchema, rename.to)\n\t\t}),\n\t\t...pairIndexRenames(pairing, issues).calls.filter(onRenamedTable),\n\t\t...pairCheckRenames(pairing, issues).calls.filter(onRenamedTable)\n\t]);\n}\n/**\n* The call that renames a column, carrying as companions the renames of the objects on its table\n* whose names derive from the column name: each unique constraint and foreign key on the column\n* the destination keeps, named as the destination names it, and each index on the column renamed\n* to the destination's wire name. `previous` is the schema before the rename; the renamed copy is\n* diffed against the destination built from `contract`. A check on the column keeps its name: its\n* expression names the column, so the diff replaces it.\n*/\nfunction postgresColumnRenameCall(input) {\n\tconst { contract, rename } = input;\n\tconst schemaName = emissionSchemaForNamespace(contract, rename.namespaceId);\n\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, rename.namespaceId);\n\tconst renamed = renameColumnInPostgresSchema(input.previous, {\n\t\tschemaName: ddlSchema,\n\t\ttable: rename.table,\n\t\tfrom: rename.from,\n\t\tto: rename.to\n\t});\n\tconst { expected, issues } = buildPostgresPlanDiff({\n\t\tcontract,\n\t\tactualSchema: renamed,\n\t\tframeworkComponents: input.frameworkComponents\n\t});\n\tconst table = tableNode(renamed, ddlSchema, rename.table);\n\tconst destination = expected.namespaces[ddlSchema]?.tables[rename.table];\n\tconst indexesOnColumn = new Set(table.indexes.filter((index) => index.columns?.includes(rename.to)).map((index) => index.name));\n\tconst indexRenames = pairIndexRenames({\n\t\tcontract,\n\t\tpolicy: RENAME_POLICY\n\t}, issues).calls.filter((call) => call.schemaName === schemaName && call.tableName === rename.table && indexesOnColumn.has(call.oldIndexName));\n\treturn new RenameColumnCall(schemaName, rename.table, rename.from, rename.to, [...destination === void 0 ? [] : constraintRenamesForColumnRename({\n\t\tschemaName,\n\t\tcolumn: rename.to,\n\t\tprevious: table,\n\t\tnext: destination\n\t}), ...indexRenames]);\n}\n//#endregion\n//#region src/core/migrations/postgres-migration.ts\n/**\n* Target-owned base class for Postgres migrations.\n*\n* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n* abstract `targetId` to the Postgres target-id string literal, so both\n* user-authored migrations and renderer-generated scaffolds (the output of\n* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n* redeclaring target-local identity.\n*\n* Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer\n* emits `extends Migration` against a facade re-export of this class\n* from `@internal/postgres/migration`, keeping the authoring surface\n* target-scoped rather than family-scoped.\n*\n* The constructor materializes a single Postgres `SqlControlAdapter` from\n* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n* instance method forwards to the free `dataTransform` factory with that\n* stored adapter, so user migrations can write `this.dataTransform(...)`\n* without threading the adapter through every call.\n*\n* Every method requires an explicit `schema`. Postgres migrations name their\n* schema deliberately — there is no default and no `search_path`-relative\n* option. A migration that left the schema unspecified would resolve against\n* whatever `search_path` the connection happened to carry, and that ambiguity\n* is an antipattern in a migration. (The unbound/unspecified namespace concept\n* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n*/\nvar PostgresMigration = class extends Migration {\n\ttargetId = \"postgres\";\n\t/**\n\t* Materialized Postgres control adapter, created once per migration\n\t* instance from the injected stack. `undefined` only when the migration\n\t* was instantiated without a stack (test fixtures); `controlAdapterFor`\n\t* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n\t*/\n\tcontrolAdapter;\n\t/** The rename calls this read of `operations` has made so far, in order. */\n\t#renames = [];\n\t#endView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\tconstructor(stack) {\n\t\tsuper(stack);\n\t\tthis.controlAdapter = stack?.adapter ? blindCast(stack.adapter.create(stack)) : void 0;\n\t}\n\tframeworkComponents() {\n\t\tconst stack = this.stack;\n\t\tif (stack === void 0) return [];\n\t\treturn [\n\t\t\tstack.target,\n\t\t\t...stack.adapter === void 0 ? [] : [stack.adapter],\n\t\t\t...stack.extensions\n\t\t];\n\t}\n\t/** The codec `codecRef` names, built from the stack's codecs; a codec needs a stack. */\n\tstoredValueCodec(operation, codecRef) {\n\t\tif (codecRef === void 0) return void 0;\n\t\tthis.controlAdapterFor(operation);\n\t\treturn {\n\t\t\tcodecRef,\n\t\t\tcodecs: sqlTypeLookupsOf(this.frameworkComponents()).codecLookup\n\t\t};\n\t}\n\tdataTypes() {\n\t\treturn stackDataTypes(this.frameworkComponents());\n\t}\n\t/**\n\t* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n\t* `operation` when the migration was constructed without a `ControlStack`.\n\t* Single home for the null-check that every DDL/DML method shares.\n\t*/\n\tcontrolAdapterFor(operation) {\n\t\tif (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);\n\t\treturn this.controlAdapter;\n\t}\n\t/**\n\t* The typed, schema-qualified Postgres view over this migration's end-state\n\t* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n\t* if no `endContractJson` was provided.\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed Postgres view over this migration's start-state contract, or\n\t* `null` for a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n\t/**\n\t* Instance-method wrapper around the free `dataTransform` factory that\n\t* supplies the stored control adapter. Authors call this from inside\n\t* `get operations()`; the adapter argument is hidden from the call site.\n\t*/\n\tdataTransform(contract, name, options) {\n\t\treturn dataTransform(contract, name, options, this.controlAdapterFor(\"dataTransform\"));\n\t}\n\t/**\n\t* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateTable(options) {\n\t\treturn new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor(\"createTable\"));\n\t}\n\t/**\n\t* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateSchema(options) {\n\t\treturn new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor(\"createSchema\"));\n\t}\n\t/**\n\t* Emit an `ALTER TABLE … SET SCHEMA` operation that moves `table` from `schema` to the schema\n\t* `to`. Leave out `schema` for a table of the unbound namespace. Indexes, constraints and owned\n\t* sequences move with the table, and foreign keys from other tables keep pointing at it. Later\n\t* rename calls find the table in its new schema.\n\t*/\n\tsetTableSchema(options) {\n\t\tconst call = new SetTableSchemaCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.to);\n\t\tconst op = call.toOp(this.controlAdapterFor(\"setTableSchema\"));\n\t\tthis.#renames.push(call);\n\t\treturn op;\n\t}\n\t/**\n\t* Emit an `ALTER SCHEMA … RENAME TO` operation. Everything in the schema keeps its place in it,\n\t* and later rename calls find its tables under the new name.\n\t*/\n\trenameSchema(options) {\n\t\tconst call = new RenameSchemaCall(options.schema, options.to);\n\t\tconst op = call.toOp(this.controlAdapterFor(\"renameSchema\"));\n\t\tthis.#renames.push(call);\n\t\treturn op;\n\t}\n\t/**\n\t* Emit a `DROP SCHEMA` operation, without `CASCADE`. Drop or move the schema's tables first: the\n\t* operation fails its precheck while the schema still holds anything.\n\t*/\n\tdropSchema(options) {\n\t\treturn new DropSchemaCall(options.schema).toOp(this.controlAdapterFor(\"dropSchema\"));\n\t}\n\t/**\n\t* Emit an `UPDATE` operation that changes the stored value `from` to `to` in `column`, in every row that holds it. With `many`, the column is a list column and the value changes inside every list that holds it. Values are stored values, as the column's codec writes them, and are passed as parameters. Without `codecRef`, pass each value in the form the column stores it, or no row matches. Leave out `schema` for a table of the unbound namespace.\n\t*/\n\treplaceStoredValue(options) {\n\t\treturn new ReplaceStoredValueCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.column, options.from, options.to, options.many === true, this.storedValueCodec(\"replaceStoredValue\", options.codecRef)).toOp();\n\t}\n\t/**\n\t* Emit an `UPDATE` operation that removes the stored value `value` from `column`: it sets the column to NULL in every row that holds it, or, with `many`, takes the value out of every list that holds it. On a scalar column that takes no NULL, its check fails while any row holds the value. The operation is destructive.\n\t*/\n\tremoveStoredValue(options) {\n\t\treturn new RemoveStoredValueCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.column, options.value, options.many === true, this.storedValueCodec(\"removeStoredValue\", options.codecRef), options.enumValue).toOp();\n\t}\n\t/**\n\t* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n\t* native enum. Builds a typed DDL node and lowers it through the stored\n\t* control adapter (members render in declaration order). Throws if no adapter\n\t* is present.\n\t*/\n\tcreateNativeEnumType(options) {\n\t\treturn new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor(\"createNativeEnumType\"));\n\t}\n\t/**\n\t* Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n\t* through the stored control adapter. Throws if no adapter is present.\n\t*/\n\tdropNativeEnumType(options) {\n\t\treturn new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor(\"dropNativeEnumType\"));\n\t}\n\t/**\n\t* Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n\t* member to a managed native enum, lowered through the stored control\n\t* adapter. Throws if no adapter is present. Every appended value is its\n\t* own operation — call this once per value to append more than one.\n\t*/\n\taddNativeEnumValue(options) {\n\t\treturn new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor(\"addNativeEnumValue\"));\n\t}\n\taddColumn(options) {\n\t\tconst adapter = this.controlAdapterFor(\"addColumn\");\n\t\treturn new AddColumnCall(options.schema, options.table, options.column, this.dataTypes()).toOp(adapter);\n\t}\n\t/**\n\t* Adds a required column of `type` to a table that may have rows. Every existing row takes\n\t* `temporaryDefault`, SQL such as `''` or `0`, and the default is dropped once the column is added.\n\t*/\n\taddColumnWithTemporaryDefault(options) {\n\t\tconst adapter = this.controlAdapterFor(\"addColumnWithTemporaryDefault\");\n\t\treturn new AddColumnWithTemporaryDefaultCall(options.schema, options.table, options.column, options.type, sqlTextOf(options.temporaryDefault, `addColumnWithTemporaryDefault ${JSON.stringify(options.table)}.${JSON.stringify(options.column)} temporaryDefault`), this.dataTypes()).toOp(adapter);\n\t}\n\t/** Adds a required column of `type` with no default, checking first that the table is empty. */\n\taddRequiredColumnToEmptyTable(options) {\n\t\tconst adapter = this.controlAdapterFor(\"addRequiredColumnToEmptyTable\");\n\t\treturn new AddRequiredColumnToEmptyTableCall(options.schema, options.table, options.column, options.type, this.dataTypes()).toOp(adapter);\n\t}\n\taddPrimaryKey(options) {\n\t\treturn new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addPrimaryKey\"));\n\t}\n\taddUnique(options) {\n\t\treturn new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addUnique\"));\n\t}\n\taddForeignKey(options) {\n\t\treturn new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor(\"addForeignKey\"));\n\t}\n\taddCheckConstraint(options) {\n\t\treturn new AddCheckConstraintCall(options.schema, options.table, options.constraint, sqlTextOf(options.expression, `addCheckConstraint ${JSON.stringify(options.constraint)} expression`)).toOp(this.controlAdapterFor(\"addCheckConstraint\"));\n\t}\n\trenameCheckConstraint(options) {\n\t\treturn this.renameConstraint({\n\t\t\t...options,\n\t\t\tkind: \"checkConstraint\"\n\t\t});\n\t}\n\trenameConstraint(options) {\n\t\tconst call = new RenameConstraintCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.kind, options.from, options.to);\n\t\tconst adapter = this.controlAdapterFor(\"renameConstraint\");\n\t\tthis.#renames.push(call);\n\t\treturn call.toOp(adapter);\n\t}\n\tdropCheckConstraint(options) {\n\t\treturn new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor(\"dropCheckConstraint\"));\n\t}\n\tdropConstraint(options) {\n\t\treturn new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? \"unique\").toOp(this.controlAdapterFor(\"dropConstraint\"));\n\t}\n\t/**\n\t* Emit the operations that rename a table: the table rename, then a rename of each primary key,\n\t* unique constraint, foreign key, index and check whose name was derived from the old table name.\n\t* The old name is resolved against the schema as this migration's earlier rename calls\n\t* (`renameTable`, `renameIndex`, `renameConstraint`, `renameRlsPolicy`) leave it, and the new\n\t* name against the end contract, so the companions start from names an earlier rename gave.\n\t* Spread the result into `operations`:\n\t* `...this.renameTable({ table: 'userProfile', to: 'UserProfile' })`. `schema` names the table's\n\t* namespace when more than one declares the table. Throws `MIGRATION.TABLE_RENAME_UNMATCHED` when\n\t* the table does not exist at that point of the migration or the end contract lacks the new name.\n\t*/\n\trenameTable(options) {\n\t\tconst adapter = this.controlAdapterFor(\"renameTable\");\n\t\tconst rename = {\n\t\t\tnamespaceId: options.schema,\n\t\t\tfrom: options.table,\n\t\t\tto: options.to\n\t\t};\n\t\tconst startContract = this.startContract;\n\t\tif (startContract === null) throw unmatchedTableRename(rename, \"the migration has no start contract\");\n\t\tconst current = this.schemaAfterRenames(startContract);\n\t\tconst endContract = this.endContract;\n\t\tconst resolved = resolveTableRenameAgainst(postgresSchemaTables(current, startContract), endContract, rename);\n\t\tif (!resolved.ok) throw resolved.failure;\n\t\tconst call = postgresTableRenameCall({\n\t\t\tprevious: current,\n\t\t\tcontract: endContract,\n\t\t\trename: resolved.value,\n\t\t\tframeworkComponents: this.frameworkComponents()\n\t\t});\n\t\tthis.#renames.push(call);\n\t\treturn call.toOps(adapter).map(async (op) => op);\n\t}\n\t/**\n\t* Emit the operations that rename a column: the column rename, then a rename of each unique\n\t* constraint, foreign key and index on the column whose name was derived from the old column\n\t* name, to the name the end contract gives it. The column is resolved against the schema as this\n\t* migration's earlier rename calls leave it, so a column of a table an earlier `renameTable`\n\t* renamed is named on the table's new name. Spread the result into `operations`:\n\t* `...this.renameColumn({ table: 'User', column: 'name', to: 'fullName' })`. `schema` names the\n\t* table's namespace when more than one declares the table. Throws\n\t* `MIGRATION.COLUMN_RENAME_UNMATCHED` when the table or column does not exist at that point of\n\t* the migration, the table already has the new column, or the end contract lacks it.\n\t*/\n\trenameColumn(options) {\n\t\tconst adapter = this.controlAdapterFor(\"renameColumn\");\n\t\tconst rename = {\n\t\t\tnamespaceId: options.schema,\n\t\t\ttable: options.table,\n\t\t\tfrom: options.column,\n\t\t\tto: options.to\n\t\t};\n\t\tconst startContract = this.startContract;\n\t\tif (startContract === null) throw unmatchedColumnRename(rename, \"the migration has no start contract\");\n\t\tconst current = this.schemaAfterRenames(startContract);\n\t\tconst endContract = this.endContract;\n\t\tconst resolved = resolveColumnRenameAgainst(postgresSchemaTables(current, startContract), endContract, rename);\n\t\tif (!resolved.ok) throw resolved.failure;\n\t\tconst call = postgresColumnRenameCall({\n\t\t\tprevious: current,\n\t\t\tcontract: endContract,\n\t\t\trename: resolved.value,\n\t\t\tframeworkComponents: this.frameworkComponents()\n\t\t});\n\t\tthis.#renames.push(call);\n\t\treturn call.toOps(adapter).map(async (op) => op);\n\t}\n\t/**\n\t* The start contract's schema with this read's rename calls applied in order. It is built only\n\t* when a rename or a `setDefault` needs it, so a migration that calls neither never reads its\n\t* start contract.\n\t*/\n\tschemaAfterRenames(startContract) {\n\t\tconst working = createWorkingSchema(postgresContractToSchema(startContract, this.frameworkComponents()));\n\t\tfor (const call of this.#renames) working.apply(call);\n\t\treturn working.current;\n\t}\n\tbeginOperationsRead() {\n\t\tthis.#renames = [];\n\t}\n\tdropTable(options) {\n\t\treturn new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor(\"dropTable\"));\n\t}\n\tdropColumn(options) {\n\t\treturn new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropColumn\"));\n\t}\n\talterColumnType(options) {\n\t\trefuseInvalidAlterColumnTypeOptions(options);\n\t\tconst adapter = this.controlAdapterFor(\"alterColumnType\");\n\t\tconst using = optionalSqlTextOf(options.using, `alterColumnType ${JSON.stringify(options.table)}.${JSON.stringify(options.column)} using`);\n\t\tconst call = new AlterColumnTypeCall({\n\t\t\tschemaName: options.schema,\n\t\t\ttableName: options.table,\n\t\t\tcolumnName: options.column,\n\t\t\ttype: options.type,\n\t\t\t...ifDefined(\"raw\", options.raw),\n\t\t\t...ifDefined(\"using\", using === void 0 ? void 0 : {\n\t\t\t\tkind: \"sql\",\n\t\t\t\tsql: using\n\t\t\t}),\n\t\t\tdataTypes: this.dataTypes(),\n\t\t\t...ifDefined(\"operationClass\", options.operationClass),\n\t\t\townsAutoincrementSequence: this.startColumnHasAutoincrementDefault(options.schema, options.table, options.column)\n\t\t});\n\t\tif (using !== void 0) this.refuseUnchangedTypeConversion(call);\n\t\treturn call.toOp(adapter);\n\t}\n\tstartColumnHasAutoincrementDefault(schema, table, column) {\n\t\tconst startColumn = this.startColumnAfterRenames(schema, table, column);\n\t\treturn startColumn !== void 0 && hasAutoincrementDefault(startColumn);\n\t}\n\t/** The column in the start contract's schema after this migration's earlier renames. */\n\tstartColumnAfterRenames(schema, table, column) {\n\t\tconst startContract = this.startContract;\n\t\tif (startContract === null) return void 0;\n\t\treturn this.schemaAfterRenames(startContract).namespaces[ddlSchemaOfCallSchema(schema)]?.tables[table]?.columns[column];\n\t}\n\t/**\n\t* Refuses an `alterColumnType` with `using` to the type the start contract, after this migration's earlier renames, already gives the column. Its postcheck compares only the type, which already holds, so the runner would skip the conversion. Other earlier operations of the migration, such as an earlier `alterColumnType`, are not applied to the start contract.\n\t*/\n\trefuseUnchangedTypeConversion(call) {\n\t\tconst column = this.startColumnAfterRenames(call.schemaName, call.tableName, call.columnName);\n\t\tif (column === void 0) return;\n\t\tconst written = writtenColumnType(call.type, this.dataTypes());\n\t\tif (written === void 0 || !sqlColumnTypesEqual(column, written)) return;\n\t\tconst where = alterColumnTypeCallText(call.schemaName, call.tableName, call.columnName);\n\t\tthrow postgresError(\"MIGRATION.ALTER_COLUMN_TYPE_USING_WITHOUT_TYPE_CHANGE\", `${where}: the start contract, after the earlier renames in this migration, already gives the column the type ${JSON.stringify(call.type)}, so the conversion in using would never run`, {\n\t\t\twhy: \"The runner skips an operation whose postchecks already hold. alterColumnType checks only that the column has the new type, which holds before it runs, so the values would never be converted.\",\n\t\t\tfix: \"Write the conversion as a dataTransform, which checks the rows themselves, or change the column to another type.\",\n\t\t\tmeta: {\n\t\t\t\twhere,\n\t\t\t\ttype: call.type\n\t\t\t}\n\t\t});\n\t}\n\tsetNotNull(options) {\n\t\treturn new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"setNotNull\"));\n\t}\n\tdropNotNull(options) {\n\t\treturn new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropNotNull\"));\n\t}\n\t/**\n\t* Emit an `ALTER COLUMN … SET DEFAULT` operation. It is widening when this migration's start contract, after the renames made earlier in the migration, gives the column a default, and additive otherwise.\n\t*/\n\tsetDefault(options) {\n\t\trefuseEarlierSetDefaultOptions(options);\n\t\treturn new SetDefaultCall(options.schema, options.table, options.column, this.columnHasDefaultAfterRenames(options.schema, options.table, options.column.name) ? \"widening\" : \"additive\").toOp(this.controlAdapterFor(\"setDefault\"));\n\t}\n\t/**\n\t* Whether the column, found by schema, table and column name in the start contract after this migration's earlier renames, has a default.\n\t*/\n\tcolumnHasDefaultAfterRenames(schema, table, column) {\n\t\treturn this.startColumnAfterRenames(schema, table, column)?.resolvedDefault !== void 0;\n\t}\n\tdropDefault(options) {\n\t\treturn new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropDefault\"));\n\t}\n\tcreateIndex(options) {\n\t\treturn new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: sqlTextOf(options.expression, `createIndex ${JSON.stringify(options.index)} expression`) }, options.extras === void 0 ? void 0 : createIndexExtrasOf(options.extras, options.index)).toOp(this.controlAdapterFor(\"createIndex\"));\n\t}\n\trenameIndex(options) {\n\t\tconst call = new RenameIndexCall(options.schema, options.table, options.from, options.to);\n\t\tconst adapter = this.controlAdapterFor(\"renameIndex\");\n\t\tthis.#renames.push(call);\n\t\treturn call.toOp(adapter);\n\t}\n\tdropIndex(options) {\n\t\treturn new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor(\"dropIndex\"));\n\t}\n\t/**\n\t* Emit a `CREATE EXTENSION … WITH SCHEMA …` migration operation, checked to find the extension absent before and present after.\n\t*/\n\tcreateExtension(options) {\n\t\treturn new CreateExtensionCall(options.schema, options.extension).toOp(this.controlAdapterFor(\"createExtension\"));\n\t}\n\t/** Emit a `DROP EXTENSION` migration operation, without `CASCADE`. */\n\tdropExtension(options) {\n\t\treturn new DropExtensionCall(options.schema, options.extension).toOp(this.controlAdapterFor(\"dropExtension\"));\n\t}\n\t/** Emit an `ALTER EXTENSION … SET SCHEMA …` migration operation. */\n\tsetExtensionSchema(options) {\n\t\treturn new SetExtensionSchemaCall(options.extension, options.schema).toOp(this.controlAdapterFor(\"setExtensionSchema\"));\n\t}\n\tinstallExtension(options) {\n\t\treturn installExtension(options, this.controlAdapterFor(\"installExtension\"));\n\t}\n\tenableRowLevelSecurity(options) {\n\t\treturn new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"enableRowLevelSecurity\"));\n\t}\n\tdisableRowLevelSecurity(options) {\n\t\treturn new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"disableRowLevelSecurity\"));\n\t}\n\tcreateRlsPolicy(options) {\n\t\tconst policyName = JSON.stringify(nameOf(options.policy.naming));\n\t\treturn new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({\n\t\t\t...options.policy,\n\t\t\tusing: optionalSqlTextOf(options.policy.using, `createRlsPolicy ${policyName} using`),\n\t\t\twithCheck: optionalSqlTextOf(options.policy.withCheck, `createRlsPolicy ${policyName} withCheck`)\n\t\t})).toOp(this.controlAdapterFor(\"createRlsPolicy\"));\n\t}\n\tdropRlsPolicy(options) {\n\t\treturn new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor(\"dropRlsPolicy\"));\n\t}\n\trenameRlsPolicy(options) {\n\t\tconst call = new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to);\n\t\tconst adapter = this.controlAdapterFor(\"renameRlsPolicy\");\n\t\tthis.#renames.push(call);\n\t\treturn call.toOp(adapter);\n\t}\n};\n/**\n* `setDefault` options an earlier version wrote carry the column's name in `column` and its default as SQL text in `defaultSql`.\n*/\nfunction refuseEarlierSetDefaultOptions(options) {\n\tconst column = options.column;\n\tconst columnIsName = typeof column === \"string\";\n\tif (!columnIsName && !Object.hasOwn(options, \"defaultSql\")) return;\n\tthrow errorMigrationOperationOptionRemoved({\n\t\toperation: \"setDefault\",\n\t\toption: \"defaultSql\",\n\t\tsubject: `column ${JSON.stringify(columnIsName ? column : options.column.name)} of table ${JSON.stringify(options.table)}`,\n\t\trewrite: \"Pass the column as `col(name, type, { default, codecRef })`, with its default written as `lit(value)` or `fn(expression)`, in place of its name and `defaultSql`.\",\n\t\tupgradeEntry: \"migration-ts-column-defaults\"\n\t});\n}\n/**\n* `alterColumnType` options as a hand-written `migration.ts` may pass them, which `node migration.ts` does not type-check: the\n* `options` object an earlier version wrote, or no `type`.\n*/\nfunction refuseInvalidAlterColumnTypeOptions(options) {\n\tif (Object.hasOwn(options, \"options\")) throw errorMigrationOperationOptionRemoved({\n\t\toperation: \"alterColumnType\",\n\t\toption: \"options\",\n\t\tsubject: `column ${JSON.stringify(options.column)} of table ${JSON.stringify(options.table)}`,\n\t\trewrite: \"Pass `{ schema, table, column, type, using? }`: move `options.qualifiedTargetType` to `type` and `options.using` to `using`, and drop the other options.\",\n\t\tupgradeEntry: \"postgres-alter-column-type-plain-options\"\n\t});\n\tconst type = options.type;\n\tif (typeof type === \"string\") return;\n\tconst where = alterColumnTypeCallText(options.schema, options.table, options.column);\n\tthrow postgresError(\"MIGRATION.COLUMN_TYPE_UNREADABLE\", `${where}: it has no \\`type\\``, {\n\t\twhy: \"A column type change needs the new type, and node migration.ts does not check the types of the options it is given.\",\n\t\tfix: \"Pass `{ schema, table, column, type, using? }`, with `type` written as a migration writes it, such as int4 or varchar(20).\",\n\t\tmeta: {\n\t\t\ttype: String(type),\n\t\t\twhere\n\t\t}\n\t});\n}\nfunction optionalSqlTextOf(value, what) {\n\treturn value === void 0 ? void 0 : sqlTextOf(value, what);\n}\nfunction createIndexExtrasOf(extras, index) {\n\tconst { where, ...rest } = extras;\n\tconst what = `createIndex ${JSON.stringify(index)} where`;\n\treturn {\n\t\t...rest,\n\t\t...ifDefined(\"where\", optionalSqlTextOf(where, what))\n\t};\n}\n//#endregion\nexport { renameTableByHandStatements as a, postgresSchemaTables as c, postgresContractToSchema as d, postgresTableRenameCall as i, pairCheckRenames as l, postgresColumnRenameCall as n, renderRenameTableCall as o, postgresTableRenameByHand as r, createWorkingSchema as s, PostgresMigration as t, pairIndexRenames as u };\n\n//# sourceMappingURL=postgres-migration-BhijSOgq.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,yBAAyB,UAAU,qBAAqB;CAChE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;;;AAIA,SAAS,+BAA+B,SAAS;CAChD,MAAM,SAAS,QAAQ;CACvB,MAAM,eAAe,OAAO,WAAW;CACvC,IAAI,CAAC,gBAAgB,CAAC,OAAO,OAAO,SAAS,YAAY,GAAG;CAC5D,MAAM,qCAAqC;EAC1C,WAAW;EACX,QAAQ;EACR,SAAS,UAAU,KAAK,UAAU,eAAe,SAAS,QAAQ,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU,QAAQ,KAAK;EACvH,SAAS;EACT,cAAc;CACf,CAAC;AACF;;;;;AAKA,SAAS,oCAAoC,SAAS;CACrD,IAAI,OAAO,OAAO,SAAS,SAAS,GAAG,MAAM,qCAAqC;EACjF,WAAW;EACX,QAAQ;EACR,SAAS,UAAU,KAAK,UAAU,QAAQ,MAAM,EAAE,YAAY,KAAK,UAAU,QAAQ,KAAK;EAC1F,SAAS;EACT,cAAc;CACf,CAAC;CACD,MAAM,OAAO,QAAQ;CACrB,IAAI,OAAO,SAAS,UAAU;CAC9B,MAAM,QAAQ,wBAAwB,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM;CACnF,MAAM,cAAc,oCAAoC,GAAG,MAAM,uBAAuB;EACvF,KAAK;EACL,KAAK;EACL,MAAM;GACL,MAAM,OAAO,IAAI;GACjB;EACD;CACD,CAAC;AACF;AACA,SAAS,kBAAkB,OAAO,MAAM;CACvC,OAAO,UAAU,KAAK,IAAI,KAAK,IAAI,UAAU,OAAO,IAAI;AACzD;AACA,SAAS,oBAAoB,QAAQ,OAAO;CAC3C,MAAM,EAAE,OAAO,GAAG,SAAS;CAC3B,MAAM,OAAO,eAAe,KAAK,UAAU,KAAK,EAAE;CAClD,OAAO;EACN,GAAG;EACH,GAAG,UAAU,SAAS,kBAAkB,OAAO,IAAI,CAAC;CACrD;AACD"}
@@ -12,7 +12,7 @@ import { SqlMigrationPlanOperation } from "@prisma/orm-family-sql/family/control
12
12
  import { Migration } from "@prisma/orm-family-sql/family/migration";
13
13
  import { Contract } from "@prisma/orm-framework/contract/types";
14
14
  import { SqlControlAdapter } from "@prisma/orm-family-sql/family/control-adapter";
15
- //#region ../../../3-targets/postgres/1-target/dist/postgres-migration-CDPlleMc.d.mts
15
+ //#region ../../../3-targets/postgres/1-target/dist/postgres-migration-DNnmFBsR.d.mts
16
16
  //#region src/core/migrations/postgres-migration.d.ts
17
17
  /**
18
18
  * Target-owned base class for Postgres migrations.
@@ -372,6 +372,23 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
372
372
  readonly table: string;
373
373
  readonly index: string;
374
374
  }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
375
+ /**
376
+ * Emit a `CREATE EXTENSION … WITH SCHEMA …` migration operation, checked to find the extension absent before and present after.
377
+ */
378
+ protected createExtension(options: {
379
+ readonly schema: string;
380
+ readonly extension: string;
381
+ }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
382
+ /** Emit a `DROP EXTENSION` migration operation, without `CASCADE`. */
383
+ protected dropExtension(options: {
384
+ readonly schema: string;
385
+ readonly extension: string;
386
+ }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
387
+ /** Emit an `ALTER EXTENSION … SET SCHEMA …` migration operation. */
388
+ protected setExtensionSchema(options: {
389
+ readonly extension: string;
390
+ readonly schema: string;
391
+ }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
375
392
  protected installExtension(options: {
376
393
  readonly extensionName: string;
377
394
  readonly invariantId: string;
@@ -412,4 +429,4 @@ type RlsPolicyInput = Omit<RenderedRlsPolicyLiteral, 'using' | 'withCheck'> & {
412
429
  };
413
430
  //#endregion
414
431
  export { PostgresMigration as t };
415
- //# sourceMappingURL=postgres-migration-CDPlleMc-B4JQjDcN.d.mts.map
432
+ //# sourceMappingURL=postgres-migration-DNnmFBsR-BJU9865a.d.mts.map