@prisma-next/target-postgres 0.12.0-dev.7 → 0.12.0-dev.70

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 (200) hide show
  1. package/dist/{codec-ids-DliyCWPY.d.mts → codec-ids-B1vOchLE.d.mts} +3 -2
  2. package/dist/codec-ids-B1vOchLE.d.mts.map +1 -0
  3. package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-CTikp1if.mjs} +3 -2
  4. package/dist/codec-ids-CTikp1if.mjs.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -2
  6. package/dist/codec-ids.mjs +2 -2
  7. package/dist/{codec-types-BF1DXTPs.d.mts → codec-types-CnFiNML4.d.mts} +8 -9
  8. package/dist/codec-types-CnFiNML4.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -2
  10. package/dist/{codecs-DuP3d9Au.d.mts → codecs-CBpEv4s5.d.mts} +33 -35
  11. package/dist/codecs-CBpEv4s5.d.mts.map +1 -0
  12. package/dist/codecs.d.mts +1 -1
  13. package/dist/codecs.mjs +37 -2
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.d.mts +80 -0
  16. package/dist/contract-free.d.mts.map +1 -0
  17. package/dist/contract-free.mjs +117 -0
  18. package/dist/contract-free.mjs.map +1 -0
  19. package/dist/control.d.mts +1 -1
  20. package/dist/control.d.mts.map +1 -1
  21. package/dist/control.mjs +66 -40
  22. package/dist/control.mjs.map +1 -1
  23. package/dist/{data-transform-CRkv2T_U.mjs → data-transform-D25tLeYU.mjs} +1 -1
  24. package/dist/{data-transform-CRkv2T_U.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
  25. package/dist/{data-transform-CAPmAdxS.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
  26. package/dist/{data-transform-CAPmAdxS.d.mts.map → data-transform-DGOqcLrf.d.mts.map} +1 -1
  27. package/dist/data-transform.d.mts +1 -1
  28. package/dist/data-transform.mjs +1 -1
  29. package/dist/ddl-77SyXgFt.mjs +30 -0
  30. package/dist/ddl-77SyXgFt.mjs.map +1 -0
  31. package/dist/ddl.d.mts +2 -0
  32. package/dist/ddl.mjs +2 -0
  33. package/dist/{default-normalizer-DaAhmzBV.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
  34. package/dist/{default-normalizer-DaAhmzBV.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
  35. package/dist/default-normalizer.mjs +1 -1
  36. package/dist/{descriptor-meta-Uu8QaClr.mjs → descriptor-meta-DKmj-IMN.mjs} +3 -2
  37. package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
  38. package/dist/{descriptor-meta-runtime-DMRX39kp.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +2 -2
  39. package/dist/{descriptor-meta-runtime-DMRX39kp.mjs.map → descriptor-meta-runtime-My8_s4cs.mjs.map} +1 -1
  40. package/dist/{enum-planning-DRA9LaMU.mjs → enum-planning-BCyvlFHk.mjs} +0 -0
  41. package/dist/{enum-planning-DRA9LaMU.mjs.map → enum-planning-BCyvlFHk.mjs.map} +1 -1
  42. package/dist/enum-planning.d.mts +1 -1
  43. package/dist/enum-planning.mjs +1 -1
  44. package/dist/{errors-BbnITmAD.mjs → errors-CUk87ByX.mjs} +1 -1
  45. package/dist/{errors-BbnITmAD.mjs.map → errors-CUk87ByX.mjs.map} +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs +1 -1
  48. package/dist/{issue-planner-BtaL6OfW.mjs → issue-planner-SHnDHfoQ.mjs} +130 -28
  49. package/dist/issue-planner-SHnDHfoQ.mjs.map +1 -0
  50. package/dist/issue-planner.d.mts +1 -1
  51. package/dist/issue-planner.d.mts.map +1 -1
  52. package/dist/issue-planner.mjs +1 -1
  53. package/dist/migration.d.mts +7 -8
  54. package/dist/migration.d.mts.map +1 -1
  55. package/dist/migration.mjs +5 -4
  56. package/dist/migration.mjs.map +1 -1
  57. package/dist/{native-type-normalizer-BNEQ9VDs.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
  58. package/dist/{native-type-normalizer-BNEQ9VDs.mjs.map → native-type-normalizer-Bc9XJzWC.mjs.map} +1 -1
  59. package/dist/native-type-normalizer.mjs +1 -1
  60. package/dist/nodes-779hmCfL.d.mts +40 -0
  61. package/dist/nodes-779hmCfL.d.mts.map +1 -0
  62. package/dist/nodes-DZk2JZG3.mjs +47 -0
  63. package/dist/nodes-DZk2JZG3.mjs.map +1 -0
  64. package/dist/op-factory-call-D2aAUhmS.mjs +1307 -0
  65. package/dist/op-factory-call-D2aAUhmS.mjs.map +1 -0
  66. package/dist/{op-factory-call-CDlImOF_.d.mts → op-factory-call-DMA86_2D.d.mts} +39 -14
  67. package/dist/op-factory-call-DMA86_2D.d.mts.map +1 -0
  68. package/dist/op-factory-call.d.mts +2 -2
  69. package/dist/op-factory-call.mjs +2 -2
  70. package/dist/pack.d.mts +5 -6
  71. package/dist/pack.d.mts.map +1 -1
  72. package/dist/pack.mjs +1 -1
  73. package/dist/planner-Bv5LV2A-.mjs +344 -0
  74. package/dist/planner-Bv5LV2A-.mjs.map +1 -0
  75. package/dist/{planner-ddl-builders-BNMfSE9r.mjs → planner-ddl-builders-DDyptTt5.mjs} +4 -28
  76. package/dist/planner-ddl-builders-DDyptTt5.mjs.map +1 -0
  77. package/dist/planner-ddl-builders.d.mts +6 -7
  78. package/dist/planner-ddl-builders.d.mts.map +1 -1
  79. package/dist/planner-ddl-builders.mjs +2 -2
  80. package/dist/{planner-identity-values-nhVj0hp-.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
  81. package/dist/{planner-identity-values-nhVj0hp-.mjs.map → planner-identity-values-BIpa5p2I.mjs.map} +1 -1
  82. package/dist/planner-identity-values.mjs +1 -1
  83. package/dist/{planner-produced-postgres-migration-D02NOhVQ.d.mts → planner-produced-postgres-migration-B4EDvLdz.d.mts} +5 -4
  84. package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +1 -0
  85. package/dist/{planner-produced-postgres-migration-D_nsXbhl.mjs → planner-produced-postgres-migration-NSEhWL0L.mjs} +8 -6
  86. package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +1 -0
  87. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  88. package/dist/planner-produced-postgres-migration.mjs +1 -1
  89. package/dist/{planner-schema-lookup-CGxxYfnD.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
  90. package/dist/{planner-schema-lookup-CGxxYfnD.mjs.map → planner-schema-lookup-CiVaAQP-.mjs.map} +1 -1
  91. package/dist/planner-schema-lookup.mjs +1 -1
  92. package/dist/{planner-sql-checks-CfEiTXoQ.mjs → planner-sql-checks-DAdhnI2c.mjs} +41 -30
  93. package/dist/planner-sql-checks-DAdhnI2c.mjs.map +1 -0
  94. package/dist/planner-sql-checks.d.mts.map +1 -1
  95. package/dist/planner-sql-checks.mjs +1 -1
  96. package/dist/{planner-target-details-a_wuOiYf.d.mts → planner-target-details-CIY6tLeo.d.mts} +2 -2
  97. package/dist/planner-target-details-CIY6tLeo.d.mts.map +1 -0
  98. package/dist/planner-target-details.d.mts +2 -2
  99. package/dist/planner-type-resolution-836DExFN.mjs +20 -0
  100. package/dist/planner-type-resolution-836DExFN.mjs.map +1 -0
  101. package/dist/planner.d.mts +7 -3
  102. package/dist/planner.d.mts.map +1 -1
  103. package/dist/planner.mjs +1 -1
  104. package/dist/{postgres-contract-serializer-BnOboPWs.mjs → postgres-contract-serializer-DYTyXjPf.mjs} +33 -24
  105. package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +1 -0
  106. package/dist/{postgres-enum-type-CSzsvXrO.d.mts → postgres-enum-type-BVn63a89.d.mts} +1 -1
  107. package/dist/{postgres-enum-type-CSzsvXrO.d.mts.map → postgres-enum-type-BVn63a89.d.mts.map} +1 -1
  108. package/dist/{postgres-enum-type-BMgyxNyy.mjs → postgres-enum-type-DPKqCBem.mjs} +1 -1
  109. package/dist/{postgres-enum-type-BMgyxNyy.mjs.map → postgres-enum-type-DPKqCBem.mjs.map} +1 -1
  110. package/dist/{postgres-migration-BatbEvU6.mjs → postgres-migration-COore9Mz.mjs} +23 -3
  111. package/dist/postgres-migration-COore9Mz.mjs.map +1 -0
  112. package/dist/{postgres-migration-DRY8V-bQ.d.mts → postgres-migration-DZ_gLUOW.d.mts} +25 -3
  113. package/dist/postgres-migration-DZ_gLUOW.d.mts.map +1 -0
  114. package/dist/{postgres-schema-BxAuNFX0.mjs → postgres-schema-BuxCxbvB.mjs} +29 -14
  115. package/dist/postgres-schema-BuxCxbvB.mjs.map +1 -0
  116. package/dist/{render-ops-XhICjX_P.mjs → render-ops-BpjstrKQ.mjs} +4 -3
  117. package/dist/{render-ops-XhICjX_P.mjs.map → render-ops-BpjstrKQ.mjs.map} +1 -1
  118. package/dist/render-ops.d.mts +3 -2
  119. package/dist/render-ops.d.mts.map +1 -1
  120. package/dist/render-ops.mjs +1 -1
  121. package/dist/{render-typescript-K125n-RZ.mjs → render-typescript-KMgosran.mjs} +5 -2
  122. package/dist/render-typescript-KMgosran.mjs.map +1 -0
  123. package/dist/render-typescript.mjs +1 -1
  124. package/dist/runtime.d.mts.map +1 -1
  125. package/dist/runtime.mjs +2 -2
  126. package/dist/{shared-Do_a5ymU.d.mts → shared-DarONYBZ.d.mts} +5 -5
  127. package/dist/{shared-Do_a5ymU.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
  128. package/dist/{sql-utils-CggjWNij.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
  129. package/dist/{sql-utils-CggjWNij.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
  130. package/dist/sql-utils.mjs +1 -1
  131. package/dist/{types-O40IcFV9.d.mts → types-BDKkx8MA.d.mts} +1 -1
  132. package/dist/types-BDKkx8MA.d.mts.map +1 -0
  133. package/dist/types.d.mts +16 -11
  134. package/dist/types.d.mts.map +1 -1
  135. package/dist/types.mjs +2 -2
  136. package/package.json +21 -20
  137. package/src/contract-free/columns.ts +49 -0
  138. package/src/contract-free/control-bootstrap.ts +55 -0
  139. package/src/contract-free/ddl.ts +37 -0
  140. package/src/core/ast/table-source.ts +23 -0
  141. package/src/core/codec-ids.ts +1 -0
  142. package/src/core/codecs.ts +44 -0
  143. package/src/core/ddl/nodes.ts +72 -0
  144. package/src/core/descriptor-meta.ts +1 -0
  145. package/src/core/migrations/control-policy.ts +234 -0
  146. package/src/core/migrations/issue-planner.ts +81 -13
  147. package/src/core/migrations/op-factory-call.ts +289 -46
  148. package/src/core/migrations/operations/constraints.ts +79 -10
  149. package/src/core/migrations/operations/dependencies.ts +0 -17
  150. package/src/core/migrations/operations/shared.ts +3 -3
  151. package/src/core/migrations/operations/tables.ts +1 -39
  152. package/src/core/migrations/planner-ddl-builders.ts +4 -46
  153. package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
  154. package/src/core/migrations/planner-sql-checks.ts +9 -9
  155. package/src/core/migrations/planner-strategies.ts +149 -11
  156. package/src/core/migrations/planner-target-details.ts +2 -1
  157. package/src/core/migrations/planner.ts +66 -8
  158. package/src/core/migrations/postgres-migration.ts +41 -0
  159. package/src/core/migrations/render-ops.ts +7 -2
  160. package/src/core/migrations/render-typescript.ts +5 -1
  161. package/src/core/migrations/runner.ts +78 -50
  162. package/src/core/postgres-contract-serializer.ts +52 -46
  163. package/src/core/postgres-schema.ts +43 -25
  164. package/src/exports/contract-free.ts +7 -0
  165. package/src/exports/control.ts +6 -8
  166. package/src/exports/ddl.ts +7 -0
  167. package/src/exports/migration.ts +11 -2
  168. package/src/exports/op-factory-call.ts +2 -0
  169. package/src/exports/planner-ddl-builders.ts +0 -1
  170. package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
  171. package/dist/codec-ids-DliyCWPY.d.mts.map +0 -1
  172. package/dist/codec-types-BF1DXTPs.d.mts.map +0 -1
  173. package/dist/codecs-DuP3d9Au.d.mts.map +0 -1
  174. package/dist/descriptor-meta-Uu8QaClr.mjs.map +0 -1
  175. package/dist/issue-planner-BtaL6OfW.mjs.map +0 -1
  176. package/dist/op-factory-call-CDlImOF_.d.mts.map +0 -1
  177. package/dist/op-factory-call-ewOd5q6L.mjs +0 -625
  178. package/dist/op-factory-call-ewOd5q6L.mjs.map +0 -1
  179. package/dist/planner-Bjz5pnLa.mjs +0 -177
  180. package/dist/planner-Bjz5pnLa.mjs.map +0 -1
  181. package/dist/planner-ddl-builders-BNMfSE9r.mjs.map +0 -1
  182. package/dist/planner-produced-postgres-migration-D02NOhVQ.d.mts.map +0 -1
  183. package/dist/planner-produced-postgres-migration-D_nsXbhl.mjs.map +0 -1
  184. package/dist/planner-sql-checks-CfEiTXoQ.mjs.map +0 -1
  185. package/dist/planner-target-details-a_wuOiYf.d.mts.map +0 -1
  186. package/dist/postgres-contract-serializer-BnOboPWs.mjs.map +0 -1
  187. package/dist/postgres-migration-BatbEvU6.mjs.map +0 -1
  188. package/dist/postgres-migration-DRY8V-bQ.d.mts.map +0 -1
  189. package/dist/postgres-schema-BxAuNFX0.mjs.map +0 -1
  190. package/dist/render-typescript-K125n-RZ.mjs.map +0 -1
  191. package/dist/statement-builders-DVI5IVAa.mjs +0 -131
  192. package/dist/statement-builders-DVI5IVAa.mjs.map +0 -1
  193. package/dist/statement-builders.d.mts +0 -51
  194. package/dist/statement-builders.d.mts.map +0 -1
  195. package/dist/statement-builders.mjs +0 -2
  196. package/dist/tables-DoA39Yqo.mjs +0 -516
  197. package/dist/tables-DoA39Yqo.mjs.map +0 -1
  198. package/dist/types-O40IcFV9.d.mts.map +0 -1
  199. package/src/core/migrations/statement-builders.ts +0 -183
  200. package/src/exports/statement-builders.ts +0 -8
@@ -1,19 +1,21 @@
1
- import { t as PostgresMigration } from "./postgres-migration-BatbEvU6.mjs";
2
- import { t as renderOps } from "./render-ops-XhICjX_P.mjs";
3
- import { t as renderCallsToTypeScript } from "./render-typescript-K125n-RZ.mjs";
1
+ import { t as PostgresMigration } from "./postgres-migration-COore9Mz.mjs";
2
+ import { t as renderOps } from "./render-ops-BpjstrKQ.mjs";
3
+ import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.mjs";
4
4
  //#region src/core/migrations/planner-produced-postgres-migration.ts
5
5
  var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
6
6
  #calls;
7
7
  #meta;
8
8
  #spaceId;
9
- constructor(calls, meta, spaceId) {
9
+ #lowerer;
10
+ constructor(calls, meta, spaceId, lowerer) {
10
11
  super();
11
12
  this.#calls = calls;
12
13
  this.#meta = meta;
13
14
  this.#spaceId = spaceId;
15
+ this.#lowerer = lowerer;
14
16
  }
15
17
  get operations() {
16
- return renderOps(this.#calls);
18
+ return renderOps(this.#calls, this.#lowerer);
17
19
  }
18
20
  describe() {
19
21
  return this.#meta;
@@ -36,4 +38,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
36
38
  //#endregion
37
39
  export { TypeScriptRenderablePostgresMigration as t };
38
40
 
39
- //# sourceMappingURL=planner-produced-postgres-migration-D_nsXbhl.mjs.map
41
+ //# sourceMappingURL=planner-produced-postgres-migration-NSEhWL0L.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-produced-postgres-migration-NSEhWL0L.mjs","names":["#calls","#meta","#spaceId","#lowerer"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `PN-MIG-2001` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { Lowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n readonly #lowerer: Lowerer | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n lowerer?: Lowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls, this.#lowerer);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, { from: this.#meta.from, to: this.#meta.to });\n }\n}\n"],"mappings":";;;;AAuCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CACA;CAEA,YACE,OACA,MACA,SACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,WAAW;CAClB;CAEA,IAAa,aAA4B;EACvC,OAAO,UAAU,KAAKH,QAAQ,KAAKG,QAAQ;CAC7C;CAEA,WAAmC;EACjC,OAAO,KAAKF;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAAE,MAAM,KAAKC,MAAM;GAAM,IAAI,KAAKA,MAAM;EAAG,CAAC;CAC1F;AACF"}
@@ -1,2 +1,2 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-D02NOhVQ.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-B4EDvLdz.mjs";
2
2
  export { TypeScriptRenderablePostgresMigration };
@@ -1,2 +1,2 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-D_nsXbhl.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-NSEhWL0L.mjs";
2
2
  export { TypeScriptRenderablePostgresMigration };
@@ -54,4 +54,4 @@ function hasForeignKey(lookup, fk) {
54
54
  //#endregion
55
55
  export { hasUniqueConstraint as i, hasForeignKey as n, hasIndex as r, buildSchemaLookupMap as t };
56
56
 
57
- //# sourceMappingURL=planner-schema-lookup-CGxxYfnD.mjs.map
57
+ //# sourceMappingURL=planner-schema-lookup-CiVaAQP-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-schema-lookup-CGxxYfnD.mjs","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { ForeignKey } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Pre-computed lookup sets for a schema table's constraints.\n * Converts O(n*m) linear scans to O(1) Set lookups per constraint check.\n */\nexport interface SchemaTableLookup {\n readonly uniqueKeys: Set<string>;\n readonly indexKeys: Set<string>;\n readonly uniqueIndexKeys: Set<string>;\n readonly fkKeys: Set<string>;\n}\n\nexport function buildSchemaLookupMap(schema: SqlSchemaIR): ReadonlyMap<string, SchemaTableLookup> {\n const map = new Map<string, SchemaTableLookup>();\n for (const [tableName, table] of Object.entries(schema.tables)) {\n map.set(tableName, buildSchemaTableLookup(table));\n }\n return map;\n}\n\nfunction buildSchemaTableLookup(table: SqlSchemaIR['tables'][string]): SchemaTableLookup {\n const uniqueKeys = new Set(table.uniques.map((u) => u.columns.join(',')));\n const indexKeys = new Set(table.indexes.map((i) => i.columns.join(',')));\n const uniqueIndexKeys = new Set(\n table.indexes.filter((i) => i.unique).map((i) => i.columns.join(',')),\n );\n const fkKeys = new Set<string>();\n for (const fk of table.foreignKeys) {\n // Keys are JSON-encoded tuples so identifiers containing any character\n // (including the column-list comma or pipe characters) cannot collide\n // across structurally-distinct FKs. Unqualified keys are 3-tuples\n // (cols, table, refCols); qualified keys are 4-tuples\n // (cols, schema, table, refCols) — the arity difference makes the two\n // key shapes fundamentally non-collidable.\n fkKeys.add(JSON.stringify([fk.columns, fk.referencedTable, fk.referencedColumns]));\n if (fk.referencedSchema !== undefined) {\n fkKeys.add(\n JSON.stringify([fk.columns, fk.referencedSchema, fk.referencedTable, fk.referencedColumns]),\n );\n }\n }\n return { uniqueKeys, indexKeys, uniqueIndexKeys, fkKeys };\n}\n\nexport function hasUniqueConstraint(\n lookup: SchemaTableLookup,\n columns: readonly string[],\n): boolean {\n const key = columns.join(',');\n return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);\n}\n\nexport function hasIndex(lookup: SchemaTableLookup, columns: readonly string[]): boolean {\n const key = columns.join(',');\n return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);\n}\n\nexport function hasForeignKey(lookup: SchemaTableLookup, fk: ForeignKey): boolean {\n // Mirror the encoding produced by buildSchemaTableLookup exactly:\n // unqualified 3-tuple for unbound-namespace FKs, qualified 4-tuple for\n // bound-namespace FKs.\n if (fk.target.namespaceId === UNBOUND_NAMESPACE_ID) {\n return lookup.fkKeys.has(\n JSON.stringify([fk.source.columns, fk.target.tableName, fk.target.columns]),\n );\n }\n return lookup.fkKeys.has(\n JSON.stringify([\n fk.source.columns,\n fk.target.namespaceId,\n fk.target.tableName,\n fk.target.columns,\n ]),\n );\n}\n"],"mappings":";;AAeA,SAAgB,qBAAqB,QAA6D;CAChG,MAAM,sBAAM,IAAI,IAA+B;CAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,OAAO,MAAM,GAC3D,IAAI,IAAI,WAAW,uBAAuB,KAAK,CAAC;CAElD,OAAO;AACT;AAEA,SAAS,uBAAuB,OAAyD;CACvF,MAAM,aAAa,IAAI,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC;CACxE,MAAM,YAAY,IAAI,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC;CACvE,MAAM,kBAAkB,IAAI,IAC1B,MAAM,QAAQ,QAAQ,MAAM,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,QAAQ,KAAK,GAAG,CAAC,CACtE;CACA,MAAM,yBAAS,IAAI,IAAY;CAC/B,KAAK,MAAM,MAAM,MAAM,aAAa;EAOlC,OAAO,IAAI,KAAK,UAAU;GAAC,GAAG;GAAS,GAAG;GAAiB,GAAG;EAAiB,CAAC,CAAC;EACjF,IAAI,GAAG,qBAAqB,KAAA,GAC1B,OAAO,IACL,KAAK,UAAU;GAAC,GAAG;GAAS,GAAG;GAAkB,GAAG;GAAiB,GAAG;EAAiB,CAAC,CAC5F;CAEJ;CACA,OAAO;EAAE;EAAY;EAAW;EAAiB;CAAO;AAC1D;AAEA,SAAgB,oBACd,QACA,SACS;CACT,MAAM,MAAM,QAAQ,KAAK,GAAG;CAC5B,OAAO,OAAO,WAAW,IAAI,GAAG,KAAK,OAAO,gBAAgB,IAAI,GAAG;AACrE;AAEA,SAAgB,SAAS,QAA2B,SAAqC;CACvF,MAAM,MAAM,QAAQ,KAAK,GAAG;CAC5B,OAAO,OAAO,UAAU,IAAI,GAAG,KAAK,OAAO,WAAW,IAAI,GAAG;AAC/D;AAEA,SAAgB,cAAc,QAA2B,IAAyB;CAIhF,IAAI,GAAG,OAAO,gBAAgB,sBAC5B,OAAO,OAAO,OAAO,IACnB,KAAK,UAAU;EAAC,GAAG,OAAO;EAAS,GAAG,OAAO;EAAW,GAAG,OAAO;CAAO,CAAC,CAC5E;CAEF,OAAO,OAAO,OAAO,IACnB,KAAK,UAAU;EACb,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;CACZ,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"planner-schema-lookup-CiVaAQP-.mjs","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { ForeignKey } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Pre-computed lookup sets for a schema table's constraints.\n * Converts O(n*m) linear scans to O(1) Set lookups per constraint check.\n */\nexport interface SchemaTableLookup {\n readonly uniqueKeys: Set<string>;\n readonly indexKeys: Set<string>;\n readonly uniqueIndexKeys: Set<string>;\n readonly fkKeys: Set<string>;\n}\n\nexport function buildSchemaLookupMap(schema: SqlSchemaIR): ReadonlyMap<string, SchemaTableLookup> {\n const map = new Map<string, SchemaTableLookup>();\n for (const [tableName, table] of Object.entries(schema.tables)) {\n map.set(tableName, buildSchemaTableLookup(table));\n }\n return map;\n}\n\nfunction buildSchemaTableLookup(table: SqlSchemaIR['tables'][string]): SchemaTableLookup {\n const uniqueKeys = new Set(table.uniques.map((u) => u.columns.join(',')));\n const indexKeys = new Set(table.indexes.map((i) => i.columns.join(',')));\n const uniqueIndexKeys = new Set(\n table.indexes.filter((i) => i.unique).map((i) => i.columns.join(',')),\n );\n const fkKeys = new Set<string>();\n for (const fk of table.foreignKeys) {\n // Keys are JSON-encoded tuples so identifiers containing any character\n // (including the column-list comma or pipe characters) cannot collide\n // across structurally-distinct FKs. Unqualified keys are 3-tuples\n // (cols, table, refCols); qualified keys are 4-tuples\n // (cols, schema, table, refCols) — the arity difference makes the two\n // key shapes fundamentally non-collidable.\n fkKeys.add(JSON.stringify([fk.columns, fk.referencedTable, fk.referencedColumns]));\n if (fk.referencedSchema !== undefined) {\n fkKeys.add(\n JSON.stringify([fk.columns, fk.referencedSchema, fk.referencedTable, fk.referencedColumns]),\n );\n }\n }\n return { uniqueKeys, indexKeys, uniqueIndexKeys, fkKeys };\n}\n\nexport function hasUniqueConstraint(\n lookup: SchemaTableLookup,\n columns: readonly string[],\n): boolean {\n const key = columns.join(',');\n return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);\n}\n\nexport function hasIndex(lookup: SchemaTableLookup, columns: readonly string[]): boolean {\n const key = columns.join(',');\n return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);\n}\n\nexport function hasForeignKey(lookup: SchemaTableLookup, fk: ForeignKey): boolean {\n // Mirror the encoding produced by buildSchemaTableLookup exactly:\n // unqualified 3-tuple for unbound-namespace FKs, qualified 4-tuple for\n // bound-namespace FKs.\n if (fk.target.namespaceId === UNBOUND_NAMESPACE_ID) {\n return lookup.fkKeys.has(\n JSON.stringify([fk.source.columns, fk.target.tableName, fk.target.columns]),\n );\n }\n return lookup.fkKeys.has(\n JSON.stringify([\n fk.source.columns,\n fk.target.namespaceId,\n fk.target.tableName,\n fk.target.columns,\n ]),\n );\n}\n"],"mappings":";;AAeA,SAAgB,qBAAqB,QAA6D;CAChG,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AK,UAAU;EAAC,GAAG,OAAO;EAAS,GAAG,OAAO;EAAW,GAAG,OAAO;CAAO,CAAC,CAC5E;CAEF,OAAO,OAAO,OAAO,IACnB,KAAK,UAAU;EACb,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;CACZ,CAAC,CACH;AACF"}
@@ -1,2 +1,2 @@
1
- import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-CGxxYfnD.mjs";
1
+ import { i as hasUniqueConstraint, n as hasForeignKey, r as hasIndex, t as buildSchemaLookupMap } from "./planner-schema-lookup-CiVaAQP-.mjs";
2
2
  export { buildSchemaLookupMap, hasForeignKey, hasIndex, hasUniqueConstraint };
@@ -1,22 +1,6 @@
1
- import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-CggjWNij.mjs";
2
- import { i as postgresCreateNamespace } from "./postgres-schema-BxAuNFX0.mjs";
3
- import { isPostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
4
- //#region src/core/migrations/planner-type-resolution.ts
5
- function resolveColumnTypeMetadata(column, storageTypes) {
6
- if (!column.typeRef) return column;
7
- const referencedType = storageTypes[column.typeRef];
8
- if (!referencedType) return column;
9
- if (isPostgresEnumStorageEntry(referencedType)) return {
10
- codecId: referencedType.codecId,
11
- nativeType: referencedType.nativeType
12
- };
13
- return {
14
- codecId: referencedType.codecId,
15
- nativeType: referencedType.nativeType,
16
- typeParams: referencedType.typeParams
17
- };
18
- }
19
- //#endregion
1
+ import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
2
+ import { i as postgresCreateNamespace } from "./postgres-schema-BuxCxbvB.mjs";
3
+ import { t as resolveColumnTypeMetadata } from "./planner-type-resolution-836DExFN.mjs";
20
4
  //#region src/core/migrations/planner-sql-checks.ts
21
5
  /**
22
6
  * String-keyed entry points the migration ops use to render
@@ -30,10 +14,16 @@ function resolveColumnTypeMetadata(column, storageTypes) {
30
14
  * site.
31
15
  */
32
16
  function qualifyTableName(schema, table) {
33
- return postgresCreateNamespace({ id: schema }).qualifyTable(table);
17
+ return postgresCreateNamespace({
18
+ id: schema,
19
+ entries: { table: {} }
20
+ }).qualifyTable(table);
34
21
  }
35
22
  function toRegclassLiteral(schema, name) {
36
- return postgresCreateNamespace({ id: schema }).regclassLiteral(name);
23
+ return postgresCreateNamespace({
24
+ id: schema,
25
+ entries: { table: {} }
26
+ }).regclassLiteral(name);
37
27
  }
38
28
  /**
39
29
  * When `table` is omitted the check matches by name + schema across all tables.
@@ -41,7 +31,10 @@ function toRegclassLiteral(schema, name) {
41
31
  * identically-named constraints in different tables).
42
32
  */
43
33
  function constraintExistsCheck({ constraintName, schema, table, exists = true }) {
44
- const namespace = postgresCreateNamespace({ id: schema });
34
+ const namespace = postgresCreateNamespace({
35
+ id: schema,
36
+ entries: { table: {} }
37
+ });
45
38
  const existsClause = exists ? "EXISTS" : "NOT EXISTS";
46
39
  const tableFilter = table ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})` : "";
47
40
  return `SELECT ${existsClause} (
@@ -53,7 +46,10 @@ function constraintExistsCheck({ constraintName, schema, table, exists = true })
53
46
  )`;
54
47
  }
55
48
  function columnExistsCheck({ schema, table, column, exists = true }) {
56
- const namespace = postgresCreateNamespace({ id: schema });
49
+ const namespace = postgresCreateNamespace({
50
+ id: schema,
51
+ entries: { table: {} }
52
+ });
57
53
  return `SELECT ${exists ? "" : "NOT "}EXISTS (
58
54
  SELECT 1
59
55
  FROM information_schema.columns
@@ -63,7 +59,10 @@ function columnExistsCheck({ schema, table, column, exists = true }) {
63
59
  )`;
64
60
  }
65
61
  function columnNullabilityCheck({ schema, table, column, nullable }) {
66
- const namespace = postgresCreateNamespace({ id: schema });
62
+ const namespace = postgresCreateNamespace({
63
+ id: schema,
64
+ entries: { table: {} }
65
+ });
67
66
  const expected = nullable ? "YES" : "NO";
68
67
  return `SELECT EXISTS (
69
68
  SELECT 1
@@ -81,7 +80,10 @@ function columnHasNoDefaultCheck(opts) {
81
80
  return `SELECT NOT EXISTS (
82
81
  SELECT 1
83
82
  FROM information_schema.columns
84
- WHERE table_schema = ${postgresCreateNamespace({ id: opts.schema }).schemaSqlExpression()}
83
+ WHERE table_schema = ${postgresCreateNamespace({
84
+ id: opts.schema,
85
+ entries: { table: {} }
86
+ }).schemaSqlExpression()}
85
87
  AND table_name = '${escapeLiteral(opts.table)}'
86
88
  AND column_name = '${escapeLiteral(opts.column)}'
87
89
  AND column_default IS NOT NULL
@@ -220,7 +222,10 @@ function columnTypeCheck({ schema, table, column, expectedType }) {
220
222
  FROM pg_attribute a
221
223
  JOIN pg_class c ON c.oid = a.attrelid
222
224
  JOIN pg_namespace n ON n.oid = c.relnamespace
223
- WHERE n.nspname = ${postgresCreateNamespace({ id: schema }).schemaSqlExpression()}
225
+ WHERE n.nspname = ${postgresCreateNamespace({
226
+ id: schema,
227
+ entries: { table: {} }
228
+ }).schemaSqlExpression()}
224
229
  AND c.relname = '${escapeLiteral(table)}'
225
230
  AND a.attname = '${escapeLiteral(column)}'
226
231
  AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'
@@ -228,7 +233,10 @@ function columnTypeCheck({ schema, table, column, expectedType }) {
228
233
  )`;
229
234
  }
230
235
  function columnDefaultExistsCheck({ schema, table, column, exists = true }) {
231
- const namespace = postgresCreateNamespace({ id: schema });
236
+ const namespace = postgresCreateNamespace({
237
+ id: schema,
238
+ entries: { table: {} }
239
+ });
232
240
  const nullCheck = exists ? "IS NOT NULL" : "IS NULL";
233
241
  return `SELECT EXISTS (
234
242
  SELECT 1
@@ -240,7 +248,10 @@ function columnDefaultExistsCheck({ schema, table, column, exists = true }) {
240
248
  )`;
241
249
  }
242
250
  function tableHasPrimaryKeyCheck(schema, table, exists, constraintName) {
243
- const namespace = postgresCreateNamespace({ id: schema });
251
+ const namespace = postgresCreateNamespace({
252
+ id: schema,
253
+ entries: { table: {} }
254
+ });
244
255
  const comparison = exists ? "" : "NOT ";
245
256
  const constraintFilter = constraintName ? `AND c2.relname = '${escapeLiteral(constraintName)}'` : "";
246
257
  return `SELECT ${comparison}EXISTS (
@@ -256,6 +267,6 @@ function tableHasPrimaryKeyCheck(schema, table, exists, constraintName) {
256
267
  )`;
257
268
  }
258
269
  //#endregion
259
- export { columnNullabilityCheck as a, qualifyTableName as c, toRegclassLiteral as d, resolveColumnTypeMetadata as f, columnHasNoDefaultCheck as i, tableHasPrimaryKeyCheck as l, columnDefaultExistsCheck as n, columnTypeCheck as o, columnExistsCheck as r, constraintExistsCheck as s, buildExpectedFormatType as t, tableIsEmptyCheck as u };
270
+ export { columnNullabilityCheck as a, qualifyTableName as c, toRegclassLiteral as d, columnHasNoDefaultCheck as i, tableHasPrimaryKeyCheck as l, columnDefaultExistsCheck as n, columnTypeCheck as o, columnExistsCheck as r, constraintExistsCheck as s, buildExpectedFormatType as t, tableIsEmptyCheck as u };
260
271
 
261
- //# sourceMappingURL=planner-sql-checks-CfEiTXoQ.mjs.map
272
+ //# sourceMappingURL=planner-sql-checks-DAdhnI2c.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-sql-checks-DAdhnI2c.mjs","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { postgresCreateNamespace } from '../postgres-schema';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\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 */\nexport function qualifyTableName(schema: string, table: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(table);\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).regclassLiteral(name);\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = ${namespace.schemaSqlExpression()}\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: opts.schema, entries: { table: {} } });\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance | PostgresEnumStorageEntry> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAAa,KAAK;AAC3F;AAEA,SAAgB,kBAAkB,QAAgB,MAAsB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAA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,IAAI;CAC/D,CAAC,QAAQ,UAAU;CACnB,CAAC,QAAQ,SAAS;CAClB,CAAC,QAAQ,QAAQ;CACjB,CAAC,UAAU,MAAM;CACjB,CAAC,UAAU,kBAAkB;CAC7B,CAAC,QAAQ,SAAS;CAClB,CAAC,aAAa,6BAA6B;CAC3C,CAAC,eAAe,0BAA0B;CAC1C,CAAC,QAAQ,wBAAwB;CACjC,CAAC,UAAU,qBAAqB;AAClC,CAAC;AAED,MAAM,uCAAuC;AAE7C,MAAM,qCAAqC,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,YAA4B;CAC7D,IACE,qCAAqC,KAAK,UAAU,KACpD,CAAC,mCAAmC,IAAI,UAAU,GAElD,OAAO;CAGT,OAAO,gBAAgB,UAAU;AACnC;AAEA,SAAgB,wBACd,QACA,YACA,eAA+E,CAAC,GACxE;CACR,MAAM,WAAW,0BAA0B,QAAQ,YAAY;CAE/D,IAAI,SAAS,cAAc,SAAS,SAAS;EAC3C,MAAM,QAAQ,WAAW,IAAI,SAAS,OAAO;EAC7C,IAAI,OAAO,kBACT,OAAO,MAAM,iBAAiB;GAC5B,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,YAAY,SAAS;EACvB,CAAC;CAEL;CA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A;EACA,MAAA;EACA,KAAA;EACA;AAAA;EAEA,cAAA;EACA,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAgBc,iBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;AAAA;AAAA,iBAac,sBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,QAAA;AAAA;AAAA,iBAcc,iBAAA,CAAkB,kBAA0B;AAAA,iBAI5C,uBAAA,CAAwB,IAAA;EACtC,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAyIc,uBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,YAAA,GAAc,MAAA,SAAe,mBAAA,GAAsB,wBAAA;AAAA,iBAsErC,uBAAA,CACd,MAAA,UACA,KAAA,UACA,MAAA,WACA,cAAA"}
1
+ {"version":3,"file":"planner-sql-checks.d.mts","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"mappings":";;;;;;AAqBA;;;;AAA8D;AAI9D;;;;iBAJgB,gBAAA,CAAiB,MAAA,UAAgB,KAAa;AAAA,iBAI9C,iBAAA,CAAkB,MAAA,UAAgB,IAAY;;;;;;iBAS9C,qBAAA;EACd,cAAA;EACA,MAAA;EACA,KAAA;EACA;AAAA;EAEA,cAAA;EACA,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAgBc,iBAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;AAAA;AAAA,iBAac,sBAAA;EACd,MAAA;EACA,KAAA;EACA,MAAA;EACA;AAAA;EAEA,MAAA;EACA,KAAA;EACA,MAAA;EACA,QAAA;AAAA;AAAA,iBAcc,iBAAA,CAAkB,kBAA0B;AAAA,iBAI5C,uBAAA,CAAwB,IAAA;EACtC,MAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,iBAyIc,uBAAA,CACd,MAAA,EAAQ,aAAA,EACR,UAAA,EAAY,GAAA,SAAY,iBAAA,GACxB,YAAA,GAAc,MAAA,SAAe,mBAAA,GAAsB,wBAAA;AAAA,iBAsErC,uBAAA,CACd,MAAA,UACA,KAAA,UACA,MAAA,WACA,cAAA"}
@@ -1,2 +1,2 @@
1
- import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-CfEiTXoQ.mjs";
1
+ import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, i as columnHasNoDefaultCheck, l as tableHasPrimaryKeyCheck, r as columnExistsCheck, s as constraintExistsCheck, t as buildExpectedFormatType, u as tableIsEmptyCheck } from "./planner-sql-checks-DAdhnI2c.mjs";
2
2
  export { buildExpectedFormatType, columnExistsCheck, columnHasNoDefaultCheck, columnNullabilityCheck, constraintExistsCheck, qualifyTableName, tableHasPrimaryKeyCheck, tableIsEmptyCheck, toRegclassLiteral };
@@ -1,5 +1,5 @@
1
1
  //#region src/core/migrations/planner-target-details.d.ts
2
- type OperationClass = 'dependency' | 'type' | 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey';
2
+ type OperationClass = 'dependency' | 'type' | 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey' | 'checkConstraint';
3
3
  interface PostgresPlanTargetDetails {
4
4
  readonly schema: string;
5
5
  readonly objectType: OperationClass;
@@ -8,4 +8,4 @@ interface PostgresPlanTargetDetails {
8
8
  }
9
9
  //#endregion
10
10
  export { PostgresPlanTargetDetails as t };
11
- //# sourceMappingURL=planner-target-details-a_wuOiYf.d.mts.map
11
+ //# sourceMappingURL=planner-target-details-CIY6tLeo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-target-details-CIY6tLeo.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAWK,yBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAc;EAAA,SAC1B,IAAA;EAAA,SACA,KAAA;AAAA"}
@@ -1,2 +1,2 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-a_wuOiYf.mjs";
2
- export { type PostgresPlanTargetDetails };
1
+ import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
+ export type { PostgresPlanTargetDetails };
@@ -0,0 +1,20 @@
1
+ import { isPostgresEnumStorageEntry } from "@prisma-next/sql-contract/types";
2
+ //#region src/core/migrations/planner-type-resolution.ts
3
+ function resolveColumnTypeMetadata(column, storageTypes) {
4
+ if (!column.typeRef) return column;
5
+ const referencedType = storageTypes[column.typeRef];
6
+ if (!referencedType) return column;
7
+ if (isPostgresEnumStorageEntry(referencedType)) return {
8
+ codecId: referencedType.codecId,
9
+ nativeType: referencedType.nativeType
10
+ };
11
+ return {
12
+ codecId: referencedType.codecId,
13
+ nativeType: referencedType.nativeType,
14
+ typeParams: referencedType.typeParams
15
+ };
16
+ }
17
+ //#endregion
18
+ export { resolveColumnTypeMetadata as t };
19
+
20
+ //# sourceMappingURL=planner-type-resolution-836DExFN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-type-resolution-836DExFN.mjs","names":[],"sources":["../src/core/migrations/planner-type-resolution.ts"],"sourcesContent":["import {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n type StorageColumn,\n type StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n if (isPostgresEnumStorageEntry(referencedType)) {\n // Enum types are referenced by name (`quoteIdentifier(nativeType)`),\n // not via parameterised codec expansion. The structural shape\n // carries `codecId` as an enumerable property (mirroring the\n // codec-typed view); `typeParams` is intentionally omitted here so\n // `expandParameterizedTypeSql` does not try to look up a\n // (deliberately absent) `expandNativeType` hook for `pg/enum@*`.\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n };\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n"],"mappings":";;AAYA,SAAgB,0BACd,QACA,cAC4B;CAC5B,IAAI,CAAC,OAAO,SACV,OAAO;CAGT,MAAM,iBAAiB,aAAa,OAAO;CAC3C,IAAI,CAAC,gBACH,OAAO;CAGT,IAAI,2BAA2B,cAAc,GAO3C,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;CAC7B;CAGF,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;EAC3B,YAAY,eAAe;CAC7B;AACF"}
@@ -1,11 +1,12 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-D02NOhVQ.mjs";
2
- import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-B4EDvLdz.mjs";
2
+ import { MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
3
3
  import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
4
4
  import { Contract } from "@prisma-next/contract/types";
5
+ import { Lowerer } from "@prisma-next/family-sql/control-adapter";
5
6
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
6
7
 
7
8
  //#region src/core/migrations/planner.d.ts
8
- declare function createPostgresMigrationPlanner(): PostgresMigrationPlanner;
9
+ declare function createPostgresMigrationPlanner(lowerer: Lowerer): PostgresMigrationPlanner;
9
10
  /**
10
11
  * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose
11
12
  * success variant carries a `TypeScriptRenderablePostgresMigration` — a
@@ -16,6 +17,7 @@ declare function createPostgresMigrationPlanner(): PostgresMigrationPlanner;
16
17
  type PostgresPlanResult = {
17
18
  readonly kind: 'success';
18
19
  readonly plan: TypeScriptRenderablePostgresMigration;
20
+ readonly warnings?: readonly SqlPlannerConflict[];
19
21
  } | SqlPlannerFailureResult;
20
22
  /**
21
23
  * Postgres migration planner — a thin wrapper over `planIssues`.
@@ -34,6 +36,8 @@ type PostgresPlanResult = {
34
36
  * authoring surface.
35
37
  */
36
38
  declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {
39
+ #private;
40
+ constructor(lowerer?: Lowerer);
37
41
  plan(options: {
38
42
  readonly contract: unknown;
39
43
  readonly schema: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;iBA0CgB,8BAAA,CAAA,GAAkC,wBAAwB;;AAA1E;;;;AAA0E;AAW1E;KAAY,kBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,qCAAA;AAAA,IAC3C,uBAAuB;;;;;AAAA;AAkB3B;;;;;;;;;;;cAAa,wBAAA,YAAoC,gBAAA;EAC/C,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IADR;;;;;;;;;;;;;;IAAA,SAgBA,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAyBtC;;;;AA6EmB;IA7EnB,SAnBG,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAWK,OAAA;EAAA,QAgEA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
1
+ {"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBAsDgB,8BAAA,CAA+B,OAAA,EAAS,OAAA,GAAU,wBAAwB;;AAA1F;;;;;;KAWY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;;;;;;;;;AAAuB;AAkB3B;;cAAa,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,OAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA6BR;;;;;;;;;;;;;;IAAA,SAdA,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IADnC;;;;;IAAA,SAOA,OAAA;EAAA,IACP,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAAA,QAmGA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
package/dist/planner.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPostgresMigrationPlanner } from "./planner-Bjz5pnLa.mjs";
1
+ import { t as createPostgresMigrationPlanner } from "./planner-Bv5LV2A-.mjs";
2
2
  export { createPostgresMigrationPlanner };
@@ -1,6 +1,7 @@
1
- import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-DMRX39kp.mjs";
2
- import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-BxAuNFX0.mjs";
1
+ import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-runtime-My8_s4cs.mjs";
2
+ import { r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-BuxCxbvB.mjs";
3
3
  import { NamespaceBase, UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
4
+ import { blindCast } from "@prisma-next/utils/casts";
4
5
  import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
5
6
  import { isAuthoringEntityTypeDescriptor } from "@prisma-next/framework-components/authoring";
6
7
  //#region src/core/postgres-contract-serializer.ts
@@ -45,30 +46,36 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
45
46
  }
46
47
  hydrateSqlNamespaceEntry(nsId, raw) {
47
48
  if (raw instanceof NamespaceBase) return raw;
48
- const { id, tables, enum: hydratedNsEnums } = super.hydrateSqlNamespaceEntry(nsId, raw);
49
- const emptyTables = Object.keys(tables).length === 0;
50
- const emptyEnums = !hydratedNsEnums || Object.keys(hydratedNsEnums).length === 0;
51
- if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyEnums) return PostgresSchema.unbound;
49
+ const { id, entries } = blindCast(super.hydrateSqlNamespaceEntry(nsId, raw));
50
+ const rawEntries = raw["entries"];
51
+ let typeSlot;
52
+ if (rawEntries !== null && typeof rawEntries === "object" && !Array.isArray(rawEntries)) {
53
+ const rawTypeSlot = rawEntries["type"];
54
+ if (rawTypeSlot !== null && typeof rawTypeSlot === "object" && !Array.isArray(rawTypeSlot)) {
55
+ const enumFactory = this.entityTypeRegistry.get("postgres-enum");
56
+ typeSlot = Object.fromEntries(Object.entries(rawTypeSlot).map(([name, entry]) => [name, blindCast(enumFactory !== void 0 ? enumFactory(entry) : entry)]));
57
+ }
58
+ }
59
+ const emptyTables = Object.keys(entries.table).length === 0;
60
+ const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;
61
+ if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) return PostgresSchema.unbound;
52
62
  return new PostgresSchema({
53
63
  id,
54
- tables,
55
- ...hydratedNsEnums !== void 0 ? { enum: hydratedNsEnums } : {}
64
+ entries: {
65
+ table: entries.table,
66
+ type: typeSlot ?? {}
67
+ }
56
68
  });
57
69
  }
58
70
  serializeContract(contract) {
59
71
  const { storage, ...rest } = contract;
60
72
  const namespacesJson = {};
61
73
  for (const [nsId, ns] of Object.entries(storage.namespaces)) if (isPostgresSchema(ns)) namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);
62
- else {
63
- const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;
64
- const nsEnums = ns.enum ?? {};
65
- namespacesJson[nsId] = {
66
- id: nsId,
67
- kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
68
- tables: Object.fromEntries(Object.entries(ns.tables).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])),
69
- enum: Object.fromEntries(Object.entries(nsEnums).map(([typeName, entry]) => [typeName, this.serializeJsonValue(entry)]))
70
- };
71
- }
74
+ else namespacesJson[nsId] = {
75
+ id: nsId,
76
+ kind: nsId === UNBOUND_NAMESPACE_ID ? "postgres-unbound-schema" : "postgres-schema",
77
+ entries: { table: Object.fromEntries(Object.entries(ns.entries.table).map(([tableName, table]) => [tableName, this.serializeJsonValue(table)])) }
78
+ };
72
79
  const storageOut = {
73
80
  storageHash: String(storage.storageHash),
74
81
  namespaces: namespacesJson
@@ -85,14 +92,16 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
85
92
  }
86
93
  serializePostgresNamespace(ns, isUnboundSlot) {
87
94
  const tablesOut = {};
88
- for (const [tableName, table] of Object.entries(ns.tables)) tablesOut[tableName] = this.serializeJsonValue(table);
89
- const enumOut = {};
90
- for (const [typeName, ty] of Object.entries(ns.enum)) enumOut[typeName] = this.serializeJsonValue(ty);
95
+ for (const [tableName, table] of Object.entries(ns.entries.table)) tablesOut[tableName] = this.serializeJsonValue(table);
96
+ const typeOut = {};
97
+ for (const [typeName, ty] of Object.entries(ns.entries.type)) typeOut[typeName] = this.serializeJsonValue(ty);
91
98
  return {
92
99
  id: ns.id,
93
100
  kind: isUnboundSlot ? "postgres-unbound-schema" : "postgres-schema",
94
- tables: tablesOut,
95
- enum: enumOut
101
+ entries: {
102
+ table: tablesOut,
103
+ type: typeOut
104
+ }
96
105
  };
97
106
  }
98
107
  serializeJsonValue(value) {
@@ -102,4 +111,4 @@ var PostgresContractSerializer = class extends SqlContractSerializerBase {
102
111
  //#endregion
103
112
  export { PostgresContractSerializer as t };
104
113
 
105
- //# sourceMappingURL=postgres-contract-serializer-BnOboPWs.mjs.map
114
+ //# sourceMappingURL=postgres-contract-serializer-DYTyXjPf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-contract-serializer-DYTyXjPf.mjs","names":["rawRecord"],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport type { Type } from 'arktype';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport type { PostgresEnumType } from './postgres-enum-type';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n typeof (output as AuthoringEntityTypeFactoryOutput).factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits the maps the\n * family base consumes — hydrators and validator-schema fragments, both\n * keyed by the descriptor's `discriminator`.\n */\nfunction collectEntityRegistryContributions(namespace: AuthoringEntityTypeNamespace): {\n readonly entityTypeRegistry: ReadonlyMap<string, SqlEntityHydrationFactory>;\n readonly validatorFragments: ReadonlyMap<string, Type<unknown>>;\n} {\n const entityTypeRegistry = new Map<string, SqlEntityHydrationFactory>();\n const validatorFragments = new Map<string, Type<unknown>>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n entityTypeRegistry.set(value.discriminator, (raw) =>\n factory(raw, POSTGRES_AUTHORING_CTX),\n );\n }\n if (value.validatorSchema !== undefined) {\n validatorFragments.set(value.discriminator, value.validatorSchema);\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return { entityTypeRegistry, validatorFragments };\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n const { entityTypeRegistry, validatorFragments } = collectEntityRegistryContributions(\n postgresAuthoringEntityTypes,\n );\n super(entityTypeRegistry, validatorFragments);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns the tables form when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n // Extract the postgres-specific `type` slot directly from raw input.\n // The family base handles the `table` slot; the postgres target owns `type`.\n const rawRecord = raw as Record<string, unknown>;\n const rawEntries = rawRecord['entries'];\n let typeSlot: Record<string, PostgresEnumType> | undefined;\n if (rawEntries !== null && typeof rawEntries === 'object' && !Array.isArray(rawEntries)) {\n const rawTypeSlot = (rawEntries as Record<string, unknown>)['type'];\n if (rawTypeSlot !== null && typeof rawTypeSlot === 'object' && !Array.isArray(rawTypeSlot)) {\n const enumFactory = this.entityTypeRegistry.get('postgres-enum');\n typeSlot = Object.fromEntries(\n Object.entries(rawTypeSlot as Record<string, unknown>).map(([name, entry]) => [\n name,\n blindCast<PostgresEnumType, 'postgres-enum factory returns PostgresEnumType'>(\n enumFactory !== undefined ? enumFactory(entry) : entry,\n ),\n ]),\n );\n }\n }\n\n const emptyTables = Object.keys(entries.table).length === 0;\n const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;\n if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) {\n return PostgresSchema.unbound;\n }\n return new PostgresSchema({\n id,\n entries: {\n table: entries.table,\n type: typeSlot ?? {},\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table).map(([tableName, table]) => [\n tableName,\n this.serializeJsonValue(table) as JsonObject,\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonValue(entry) as JsonObject;\n }\n storageOut['types'] = typesOut;\n }\n return {\n ...rest,\n storage: storageOut,\n } as unknown as JsonObject;\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.entries.table)) {\n tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;\n }\n const typeOut: Record<string, JsonObject> = {};\n for (const [typeName, ty] of Object.entries(ns.entries.type)) {\n typeOut[typeName] = this.serializeJsonValue(ty) as JsonObject;\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n type: typeOut,\n },\n };\n }\n\n private serializeJsonValue(value: unknown): unknown {\n return JSON.parse(JSON.stringify(value)) as unknown;\n }\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA4C,YAAY;AAEpE;;;;;;AAOA,SAAS,mCAAmC,WAG1C;CACA,MAAM,qCAAqB,IAAI,IAAuC;CACtE,MAAM,qCAAqB,IAAI,IAA2B;CAC1D,MAAM,QAAQ,SAA6C;EACzD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG;GACvC,IAAI,gCAAgC,KAAK,GAAG;IAC1C,IAAI,mCAAmC,MAAM,MAAM,GAAG;KACpD,MAAM,EAAE,YAAY,MAAM;KAC1B,mBAAmB,IAAI,MAAM,gBAAgB,QAC3C,QAAQ,KAAK,sBAAsB,CACrC;IACF;IACA,IAAI,MAAM,oBAAoB,KAAA,GAC5B,mBAAmB,IAAI,MAAM,eAAe,MAAM,eAAe;IAEnE;GACF;GACA,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,KAAK;EAEd;CACF;CACA,KAAK,SAAS;CACd,OAAO;EAAE;EAAoB;CAAmB;AAClD;AAEA,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,cAAc;EACZ,M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,OAAO,OAAO,YACZ,OAAO,QAAQ,GAAG,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,WAAW,CAC3D,WACA,KAAK,mBAAmB,KAAK,CAC/B,CAAC,CACH,EACF;EACF;EAGJ,MAAM,aAAsC;GAC1C,aAAa,OAAO,QAAQ,WAAW;GACvC,YAAY;EACd;EACA,IAAI,QAAQ,UAAU,KAAA,GAAW;GAC/B,MAAM,WAAuC,CAAC;GAC9C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,KAAK,GACtD,SAAS,QAAQ,KAAK,mBAAmB,KAAK;GAEhD,WAAW,WAAW;EACxB;EACA,OAAO;GACL,GAAG;GACH,SAAS;EACX;CACF;CAEA,2BAAmC,IAAoB,eAAoC;EACzF,MAAM,YAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,GAAG,QAAQ,KAAK,GAC9D,UAAU,aAAa,KAAK,mBAAmB,KAAK;EAEtD,MAAM,UAAsC,CAAC;EAC7C,KAAK,MAAM,CAAC,UAAU,OAAO,OAAO,QAAQ,GAAG,QAAQ,IAAI,GACzD,QAAQ,YAAY,KAAK,mBAAmB,EAAE;EAEhD,OAAO;GACL,IAAI,GAAG;GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,MAAM;GACR;EACF;CACF;CAEA,mBAA2B,OAAyB;EAClD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACzC;AACF"}
@@ -69,4 +69,4 @@ declare class PostgresEnumType<TName extends string = string, TValues extends re
69
69
  }
70
70
  //#endregion
71
71
  export { PostgresEnumTypeInput as n, PostgresEnumType as t };
72
- //# sourceMappingURL=postgres-enum-type-CSzsvXrO.d.mts.map
72
+ //# sourceMappingURL=postgres-enum-type-BVn63a89.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-enum-type-CSzsvXrO.d.mts","names":[],"sources":["../src/core/postgres-enum-type.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AAQ,OAAA;IAAA;EAAA;AAAA"}
@@ -59,4 +59,4 @@ var PostgresEnumType = class extends SqlNode {
59
59
  //#endregion
60
60
  export { PostgresEnumType as t };
61
61
 
62
- //# sourceMappingURL=postgres-enum-type-BMgyxNyy.mjs.map
62
+ //# sourceMappingURL=postgres-enum-type-DPKqCBem.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-enum-type-BMgyxNyy.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
1
+ {"version":3,"file":"postgres-enum-type-DPKqCBem.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
@@ -1,5 +1,7 @@
1
- import { t as errorPostgresMigrationStackMissing } from "./errors-BbnITmAD.mjs";
2
- import { t as dataTransform } from "./data-transform-CRkv2T_U.mjs";
1
+ import { d as CreateSchemaCall, f as CreateTableCall } from "./op-factory-call-D2aAUhmS.mjs";
2
+ import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
+ import { t as dataTransform } from "./data-transform-D25tLeYU.mjs";
4
+ import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
3
5
  import { Migration } from "@prisma-next/family-sql/migration";
4
6
  //#region src/core/migrations/postgres-migration.ts
5
7
  /**
@@ -44,8 +46,26 @@ var PostgresMigration = class extends Migration {
44
46
  if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
45
47
  return dataTransform(contract, name, options, this.controlAdapter);
46
48
  }
49
+ /**
50
+ * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
51
+ * the supplied options and lowers it through the stored control adapter.
52
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
53
+ */
54
+ createTable(options) {
55
+ if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
56
+ return new CreateTableCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.columns, options.constraints).toOp(this.controlAdapter);
57
+ }
58
+ /**
59
+ * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
60
+ * the supplied options and lowers it through the stored control adapter.
61
+ * Throws if no adapter is present (i.e. migration instantiated without a stack).
62
+ */
63
+ createSchema(options) {
64
+ if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
65
+ return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);
66
+ }
47
67
  };
48
68
  //#endregion
49
69
  export { PostgresMigration as t };
50
70
 
51
- //# sourceMappingURL=postgres-migration-BatbEvU6.mjs.map
71
+ //# sourceMappingURL=postgres-migration-COore9Mz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgres-migration-COore9Mz.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { CreateSchemaCall, CreateTableCall } from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\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 `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/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 */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema?: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAMmC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAGkC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;AACF"}