@prisma-next/target-postgres 0.5.0-dev.3 → 0.5.0-dev.30

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 (61) hide show
  1. package/dist/codec-types.d.mts +1 -1
  2. package/dist/codec-types.mjs +1 -1
  3. package/dist/{codecs-D-F2KJqt.d.mts → codecs-CE5EUsNM.d.mts} +54 -30
  4. package/dist/codecs-CE5EUsNM.d.mts.map +1 -0
  5. package/dist/{codecs-BoahtY_Q.mjs → codecs-OkTYeJQb.mjs} +7 -21
  6. package/dist/codecs-OkTYeJQb.mjs.map +1 -0
  7. package/dist/codecs.d.mts +1 -1
  8. package/dist/codecs.mjs +1 -1
  9. package/dist/control.mjs +7 -6
  10. package/dist/control.mjs.map +1 -1
  11. package/dist/{data-transform-VfEGzXWt.mjs → data-transform-C83dy0vk.mjs} +3 -1
  12. package/dist/data-transform-C83dy0vk.mjs.map +1 -0
  13. package/dist/{data-transform-CxFRBIUp.d.mts → data-transform-D8x5m1YV.d.mts} +7 -1
  14. package/dist/data-transform-D8x5m1YV.d.mts.map +1 -0
  15. package/dist/data-transform.d.mts +1 -1
  16. package/dist/data-transform.mjs +1 -1
  17. package/dist/migration.d.mts +2 -2
  18. package/dist/migration.mjs +2 -2
  19. package/dist/op-factory-call-C3bWXKSP.d.mts.map +1 -1
  20. package/dist/pack.d.mts +1 -1
  21. package/dist/{planner-CLUvVhUN.mjs → planner-BGMG70Ns.mjs} +3 -3
  22. package/dist/planner-BGMG70Ns.mjs.map +1 -0
  23. package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs → planner-produced-postgres-migration-C0GNhHGw.mjs} +3 -4
  24. package/dist/{planner-produced-postgres-migration-DSSPq8QS.mjs.map → planner-produced-postgres-migration-C0GNhHGw.mjs.map} +1 -1
  25. package/dist/{planner-produced-postgres-migration-CRRTno6Z.d.mts → planner-produced-postgres-migration-Dw_mPMKt.d.mts} +2 -2
  26. package/dist/planner-produced-postgres-migration-Dw_mPMKt.d.mts.map +1 -0
  27. package/dist/planner-produced-postgres-migration.d.mts +2 -2
  28. package/dist/planner-produced-postgres-migration.mjs +1 -1
  29. package/dist/planner.d.mts +3 -3
  30. package/dist/planner.mjs +1 -1
  31. package/dist/{postgres-migration-BjA3Zmts.d.mts → postgres-migration-DcfWGqhe.d.mts} +2 -2
  32. package/dist/{postgres-migration-BjA3Zmts.d.mts.map → postgres-migration-DcfWGqhe.d.mts.map} +1 -1
  33. package/dist/{postgres-migration-qtmtbONe.mjs → postgres-migration-EGSlO4jO.mjs} +2 -2
  34. package/dist/{postgres-migration-qtmtbONe.mjs.map → postgres-migration-EGSlO4jO.mjs.map} +1 -1
  35. package/dist/{render-typescript-1rF_SB4g.mjs → render-typescript-Co3Emwgz.mjs} +1 -2
  36. package/dist/render-typescript-Co3Emwgz.mjs.map +1 -0
  37. package/dist/render-typescript.d.mts +1 -2
  38. package/dist/render-typescript.d.mts.map +1 -1
  39. package/dist/render-typescript.mjs +1 -1
  40. package/dist/{statement-builders-BPnmt6wx.mjs → statement-builders-CHqCtSfe.mjs} +13 -8
  41. package/dist/statement-builders-CHqCtSfe.mjs.map +1 -0
  42. package/dist/statement-builders.d.mts +10 -3
  43. package/dist/statement-builders.d.mts.map +1 -1
  44. package/dist/statement-builders.mjs +2 -2
  45. package/package.json +17 -14
  46. package/src/core/codecs.ts +10 -24
  47. package/src/core/migrations/operations/data-transform.ts +8 -0
  48. package/src/core/migrations/planner-produced-postgres-migration.ts +0 -1
  49. package/src/core/migrations/planner.ts +6 -3
  50. package/src/core/migrations/render-typescript.ts +1 -5
  51. package/src/core/migrations/runner.ts +7 -4
  52. package/src/core/migrations/statement-builders.ts +22 -6
  53. package/src/exports/statement-builders.ts +1 -1
  54. package/dist/codecs-BoahtY_Q.mjs.map +0 -1
  55. package/dist/codecs-D-F2KJqt.d.mts.map +0 -1
  56. package/dist/data-transform-CxFRBIUp.d.mts.map +0 -1
  57. package/dist/data-transform-VfEGzXWt.mjs.map +0 -1
  58. package/dist/planner-CLUvVhUN.mjs.map +0 -1
  59. package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +0 -1
  60. package/dist/render-typescript-1rF_SB4g.mjs.map +0 -1
  61. package/dist/statement-builders-BPnmt6wx.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { _ as dropColumn, a as addEnumValues, b as setDefault, c as renameType, d as addForeignKey, f as addPrimaryKey, g as alterColumnType, h as addColumn, i as dropIndex, l as createExtension, m as dropConstraint, n as dropTable, o as createEnumType, p as addUnique, r as createIndex, s as dropEnumType, t as createTable, u as createSchema, v as dropDefault, x as setNotNull, y as dropNotNull } from "./tables-BmdW_FWO.mjs";
2
- import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-qtmtbONe.mjs";
2
+ import { t as dataTransform } from "./data-transform-C83dy0vk.mjs";
3
+ import { t as PostgresMigration } from "./postgres-migration-EGSlO4jO.mjs";
4
4
  import { placeholder } from "@prisma-next/errors/migration";
5
5
  import { MigrationCLI } from "@prisma-next/cli/migration-cli";
6
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"op-factory-call-C3bWXKSP.d.mts","names":[],"sources":["../src/core/migrations/op-factory-call.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA8CK,EAAA,GAAK,yBAmGS,CAnGiB,yBAmGjB,CAAA;uBA/FJ,yBAAA,SAAkC,YAAA,YAAwB,aAkGZ,CAAA;EASnD,kBAAA,WAAA,EAAA,MAAA;EAjByB,kBAAA,cAAA,EAxFC,uBAwFD;EAAyB,kBAAA,KAAA,EAAA,MAAA;EA0B/C,SAAA,IAAA,CAAA,CAAA,EAhHM,EAgHS;EA0BX,kBAAA,CAAA,CAAA,EAAA,SAxIgB,iBAwIM,EAAA;EAO1B,UAAA,MAAA,CAAA,CAAA,EAAA,IAAoB;;AAapB,UA/II,qBAAA,CA+IJ;EAWH,SAAA,OAAA,EAAA,SAAA,MAAA,EAA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;;;;;;;;UAiB3B;;;cAaG,iBAAA,SAA0B,yBAAA;;;;;;;;;UAwB7B;;;cASG,aAAA,SAAsB,yBAAA;;;;;;;;;UAwBzB;;;cASG,iBAAA,SAA0B,yBAAA;;;;;eAKxB;;yDAG0C;UAS/C;;;cASG,kBAAA,SAA2B,yBAAA;;;;;;;;;UAwB9B;;;cAqBG,eAAA,SAAwB,yBAAA;;;;;;;;;UAwB3B;;;cASG,aAAA,SAAsB,yBAAA;;;;;;;;UAiBzB;;;cAaG,kBAAA,SAA2B,yBAAA;;;;;;;;UAiB9B;;;cASG,iBAAA,SAA0B,yBAAA;;;;;;;;;UAmB7B;;;cASG,gBAAA,SAAyB,yBAAA;;;;;;;UAe5B;;;cASG,cAAA,SAAuB,yBAAA;;;;;;;;UAiB1B;;;;;;;;;;;;;;;;;cA2BG,UAAA,SAAmB,yBAAA;;2BAEL;;eAEZ;kBAEG;UAQR;;;cAaG,mBAAA,SAA4B,yBAAA;;;;;;UAa/B;;;cASG,gBAAA,SAAyB,yBAAA;;;;;;UAa5B;;;;;;;;;;cAoBG,iBAAA,SAA0B,yBAAA;;2BAEZ;;;;kFASP;UAUV;;iCAagC;;KAa9B,qBAAA,GACR,kBACA,gBACA,gBACA,iBACA,sBACA,iBACA,kBACA,iBACA,kBACA,oBACA,oBACA,gBACA,kBACA,gBACA,qBACA,qBACA,oBACA,mBACA,iBACA,aACA,sBACA,mBACA"}
1
+ {"version":3,"file":"op-factory-call-C3bWXKSP.d.mts","names":[],"sources":["../src/core/migrations/op-factory-call.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA8CK,EAAA,GAAK,yBAmGS,CAnGiB,yBAmGjB,CAAA;uBA/FJ,yBAAA,SAAkC,YAAA,YAAwB,aAkGZ,CAAA;EASnD,kBAAA,WAAA,EAAA,MAAA;EAjByB,kBAAA,cAAA,EAxFC,uBAwFD;EAAyB,kBAAA,KAAA,EAAA,MAAA;EA0B/C,SAAA,IAAA,CAAA,CAAA,EAhHM,EAg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AAA;;cA9lBR,cAAA,SAAuB,yBAAA;;;;;;;;UAiB1B;;;cASG,eAAA,SAAwB,yBAAA;;;;;;;;UAiB3B;;;cASG,cAAA,SAAuB,yBAAA;;;;;;;;;UA0B1B;;;cAwBG,eAAA,SAAwB,yBAAA;;;;;;;;UAiB3B;;;cAaG,iBAAA,SAA0B,yBAAA;;;;;;;;;UAwB7B;;;cASG,aAAA,SAAsB,yBAAA;;;;;;;;;UAwBzB;;;cASG,iBAAA,SAA0B,yBAAA;;;;;eAKxB;;yDAG0C;UAS/C;;;cASG,kBAAA,SAA2B,yBAAA;;;;;;;;;UAwB9B;;;cAqBG,eAAA,SAAwB,yBAAA;;;;;;;;;UAwB3B;;;cASG,aAAA,SAAsB,yBAAA;;;;;;;;UAiBzB;;;cAaG,kBAAA,SAA2B,yBAAA;;;;;;;;UAiB9B;;;cASG,iBAAA,SAA0B,yBAAA;;;;;;;;;UAmB7B;;;cASG,gBAAA,SAAyB,yBAAA;;;;;;;UAe5B;;;cASG,cAAA,SAAuB,yBAAA;;;;;;;;UAiB1B;;;;;;;;;;;;;;;;;cA2BG,UAAA,SAAmB,yBAAA;;2BAEL;;eAEZ;kBAEG;UAQR;;;cAaG,mBAAA,SAA4B,yBAAA;;;;;;UAa/B;;;cASG,gBAAA,SAAyB,yBAAA;;;;;;UAa5B;;;;;;;;;;cAoBG,iBAAA,SAA0B,yBAAA;;2BAEZ;;;;kFASP;UAUV;;iCAagC;;KAa9B,qBAAA,GACR,kBACA,gBACA,gBACA,iBACA,sBACA,iBACA,kBACA,iBACA,kBACA,oBACA,oBACA,gBACA,kBACA,gBACA,qBACA,qBACA,oBACA,mBACA,iBACA,aACA,sBACA,mBACA"}
package/dist/pack.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as CodecTypes } from "./codecs-D-F2KJqt.mjs";
1
+ import { t as CodecTypes } from "./codecs-CE5EUsNM.mjs";
2
2
 
3
3
  //#region src/core/descriptor-meta.d.ts
4
4
  declare const postgresTargetDescriptorMetaBase: {
@@ -1,7 +1,7 @@
1
1
  import { t as parsePostgresDefault } from "./default-normalizer-DNOpRoOF.mjs";
2
2
  import { t as normalizeSchemaNativeType } from "./native-type-normalizer-CInai_oY.mjs";
3
3
  import { n as postgresPlannerStrategies, t as planIssues } from "./issue-planner-CFjB0_oO.mjs";
4
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-DSSPq8QS.mjs";
4
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-C0GNhHGw.mjs";
5
5
  import { extractCodecControlHooks, plannerFailure } from "@prisma-next/family-sql/control";
6
6
  import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
7
7
 
@@ -34,7 +34,7 @@ var PostgresMigrationPlanner = class {
34
34
  this.config = config;
35
35
  }
36
36
  plan(options) {
37
- return this.planSql(options, options.fromHash ?? "");
37
+ return this.planSql(options, options.fromHash ?? null);
38
38
  }
39
39
  emptyMigration(context) {
40
40
  return new TypeScriptRenderablePostgresMigration([], {
@@ -95,4 +95,4 @@ var PostgresMigrationPlanner = class {
95
95
 
96
96
  //#endregion
97
97
  export { createPostgresMigrationPlanner as t };
98
- //# sourceMappingURL=planner-CLUvVhUN.mjs.map
98
+ //# sourceMappingURL=planner-BGMG70Ns.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-BGMG70Ns.mjs","names":["DEFAULT_PLANNER_CONFIG: PlannerConfig","config: PlannerConfig"],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":["import type {\n MigrationOperationPolicy,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport { extractCodecControlHooks, plannerFailure } from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport { planIssues } from './issue-planner';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\n\ntype PlannerFrameworkComponents = SqlMigrationPlannerPlanOptions extends {\n readonly frameworkComponents: infer T;\n}\n ? T\n : ReadonlyArray<unknown>;\n\ntype PlannerOptionsWithComponents = SqlMigrationPlannerPlanOptions & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\ntype VerifySqlSchemaOptionsWithComponents = Parameters<typeof verifySqlSchema>[0] & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\ninterface PlannerConfig {\n readonly defaultSchema: string;\n}\n\nconst DEFAULT_PLANNER_CONFIG: PlannerConfig = {\n defaultSchema: 'public',\n};\n\nexport function createPostgresMigrationPlanner(\n config: Partial<PlannerConfig> = {},\n): PostgresMigrationPlanner {\n return new PostgresMigrationPlanner({\n ...DEFAULT_PLANNER_CONFIG,\n ...config,\n });\n}\n\n/**\n * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose\n * success variant carries a `TypeScriptRenderablePostgresMigration` — a\n * migration object that both the CLI (via `renderTypeScript()`) and the\n * SQL-typed callers (via `operations`, `describe()`, etc.) consume\n * uniformly.\n */\nexport type PostgresPlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderablePostgresMigration }\n | SqlPlannerFailureResult;\n\n/**\n * Postgres migration planner — a thin wrapper over `planIssues`.\n *\n * `plan()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the unified\n * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,\n * type-change, nullable-tightening, codec-hook storage types,\n * component-declared dependency installs, and shared-temp-default /\n * empty-table-guarded NOT-NULL add-column. The same strategy list runs for\n * `migration plan`, `db update`, and `db init`; behavior diverges purely on\n * `policy.allowedOperationClasses` (the data-safe strategies short-circuit\n * when `'data'` is excluded). The issue planner applies operation-class\n * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both\n * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`\n * authoring surface.\n */\nexport class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {\n constructor(private readonly config: PlannerConfig) {}\n\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n readonly fromHash?: string | null;\n /**\n * The \"from\" contract (state the planner assumes the database starts\n * at). Only `migration plan` supplies this; `db update` / `db init`\n * reconcile against the live schema with no old contract. When present\n * alongside the `'data'` operation class, strategies that need from/to\n * column shape comparisons (unsafe type change, nullability tightening)\n * activate.\n */\n readonly fromContract?: unknown;\n readonly schemaName?: string;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions, options.fromHash ?? null);\n }\n\n emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration([], {\n from: context.fromHash,\n to: context.toHash,\n });\n }\n\n private planSql(\n options: SqlMigrationPlannerPlanOptions,\n fromHash: string | null,\n ): PostgresPlanResult {\n const schemaName = options.schemaName ?? this.config.defaultSchema;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n\n const result = planIssues({\n issues: schemaIssues,\n toContract: options.contract,\n // `fromContract` is only supplied by `migration plan`. It is `null` for\n // `db update` / `db init`, which means data-safety strategies needing\n // from/to comparisons (unsafe type change, nullable tightening) are\n // inapplicable there — reconciliation falls through to\n // `mapIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract ?? null,\n schemaName,\n codecHooks,\n storageTypes,\n schema: options.schema,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: postgresPlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(result.value.calls, {\n from: fromHash,\n to: options.contract.storage.storageHash,\n }),\n });\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy) {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n\n private collectSchemaIssues(options: PlannerOptionsWithComponents): readonly SchemaIssue[] {\n // `db init` uses additive-only policy and intentionally ignores extra\n // schema objects. Any reconciliation-capable policy (widening or\n // destructive) must inspect extras to reconcile strict equality.\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyOptions: VerifySqlSchemaOptionsWithComponents = {\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parsePostgresDefault,\n normalizeNativeType: normalizeSchemaNativeType,\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;;AAsCA,MAAMA,yBAAwC,EAC5C,eAAe,UAChB;AAED,SAAgB,+BACd,SAAiC,EAAE,EACT;AAC1B,QAAO,IAAI,yBAAyB;EAClC,GAAG;EACH,GAAG;EACJ,CAAC;;;;;;;;;;;;;;;;;;AA8BJ,IAAa,2BAAb,MAAqF;CACnF,YAAY,AAAiBC,QAAuB;EAAvB;;CAE7B,KAAK,SAgBkB;AACrB,SAAO,KAAK,QAAQ,SAA2C,QAAQ,YAAY,KAAK;;CAG1F,eAAe,SAAsE;AACnF,SAAO,IAAI,sCAAsC,EAAE,EAAE;GACnD,MAAM,QAAQ;GACd,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igration } from "./postgres-migration-EGSlO4jO.mjs";
2
2
  import { t as renderOps } from "./render-ops-D6_DHdOK.mjs";
3
- import { t as renderCallsToTypeScript } from "./render-typescript-1rF_SB4g.mjs";
3
+ import { t as renderCallsToTypeScript } from "./render-typescript-Co3Emwgz.mjs";
4
4
  import { ifDefined } from "@prisma-next/utils/defined";
5
5
 
6
6
  //#region src/core/migrations/planner-produced-postgres-migration.ts
@@ -22,7 +22,6 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
22
22
  return renderCallsToTypeScript(this.#calls, {
23
23
  from: this.#meta.from,
24
24
  to: this.#meta.to,
25
- ...ifDefined("kind", this.#meta.kind),
26
25
  ...ifDefined("labels", this.#meta.labels)
27
26
  });
28
27
  }
@@ -30,4 +29,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
30
29
 
31
30
  //#endregion
32
31
  export { TypeScriptRenderablePostgresMigration as t };
33
- //# sourceMappingURL=planner-produced-postgres-migration-DSSPq8QS.mjs.map
32
+ //# sourceMappingURL=planner-produced-postgres-migration-C0GNhHGw.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-produced-postgres-migration-DSSPq8QS.mjs","names":["#calls","#meta"],"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 { MigrationPlanWithAuthoringSurface } from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\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 PostgresOpFactoryCall[];\n readonly #meta: MigrationMeta;\n\n constructor(calls: readonly PostgresOpFactoryCall[], meta: MigrationMeta) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, {\n from: this.#meta.from,\n to: this.#meta.to,\n ...ifDefined('kind', this.#meta.kind),\n ...ifDefined('labels', this.#meta.labels),\n });\n }\n}\n"],"mappings":";;;;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE,CAASA;CACT,CAASC;CAET,YAAY,OAAyC,MAAqB;AACxE,SAAO;AACP,QAAKD,QAAS;AACd,QAAKC,OAAQ;;CAGf,IAAa,aAA4B;AACvC,SAAO,UAAU,MAAKD,MAAO;;CAG/B,AAAS,WAA0B;AACjC,SAAO,MAAKC;;CAGd,mBAA2B;AACzB,SAAO,wBAAwB,MAAKD,OAAQ;GAC1C,MAAM,MAAKC,KAAM;GACjB,IAAI,MAAKA,KAAM;GACf,GAAG,UAAU,QAAQ,MAAKA,KAAM,KAAK;GACrC,GAAG,UAAU,UAAU,MAAKA,KAAM,OAAO;GAC1C,CAAC"}
1
+ {"version":3,"file":"planner-produced-postgres-migration-C0GNhHGw.mjs","names":["#calls","#meta"],"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 { MigrationPlanWithAuthoringSurface } from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\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 PostgresOpFactoryCall[];\n readonly #meta: MigrationMeta;\n\n constructor(calls: readonly PostgresOpFactoryCall[], meta: MigrationMeta) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, {\n from: this.#meta.from,\n to: this.#meta.to,\n ...ifDefined('labels', this.#meta.labels),\n });\n }\n}\n"],"mappings":";;;;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE,CAASA;CACT,CAASC;CAET,YAAY,OAAyC,MAAqB;AACxE,SAAO;AACP,QAAKD,QAAS;AACd,QAAKC,OAAQ;;CAGf,IAAa,aAA4B;AACvC,SAAO,UAAU,MAAKD,MAAO;;CAG/B,AAAS,WAA0B;AACjC,SAAO,MAAKC;;CAGd,mBAA2B;AACzB,SAAO,wBAAwB,MAAKD,OAAQ;GAC1C,MAAM,MAAKC,KAAM;GACjB,IAAI,MAAKA,KAAM;GACf,GAAG,UAAU,UAAU,MAAKA,KAAM,OAAO;GAC1C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
2
  import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
3
- import { t as PostgresMigration } from "./postgres-migration-BjA3Zmts.mjs";
3
+ import { t as PostgresMigration } from "./postgres-migration-DcfWGqhe.mjs";
4
4
  import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
5
5
  import { MigrationPlanWithAuthoringSurface } from "@prisma-next/framework-components/control";
6
6
  import { MigrationMeta } from "@prisma-next/migration-tools/migration";
@@ -17,4 +17,4 @@ declare class TypeScriptRenderablePostgresMigration extends PostgresMigration im
17
17
  }
18
18
  //#endregion
19
19
  export { TypeScriptRenderablePostgresMigration as t };
20
- //# sourceMappingURL=planner-produced-postgres-migration-CRRTno6Z.d.mts.map
20
+ //# sourceMappingURL=planner-produced-postgres-migration-Dw_mPMKt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-produced-postgres-migration-Dw_mPMKt.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAmCK,EAAA,GAAK,0BAA0B;cAEvB,qCAAA,SACH,iBAAA,YACG;;8BAKiB,+BAA+B;6BAMvB;cAIf"}
@@ -1,5 +1,5 @@
1
1
  import "./shared-Bxkt8pNO.mjs";
2
2
  import "./op-factory-call-C3bWXKSP.mjs";
3
- import "./postgres-migration-BjA3Zmts.mjs";
4
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CRRTno6Z.mjs";
3
+ import "./postgres-migration-DcfWGqhe.mjs";
4
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Dw_mPMKt.mjs";
5
5
  export { TypeScriptRenderablePostgresMigration };
@@ -1,3 +1,3 @@
1
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-DSSPq8QS.mjs";
1
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-C0GNhHGw.mjs";
2
2
 
3
3
  export { TypeScriptRenderablePostgresMigration };
@@ -1,7 +1,7 @@
1
1
  import "./shared-Bxkt8pNO.mjs";
2
2
  import "./op-factory-call-C3bWXKSP.mjs";
3
- import "./postgres-migration-BjA3Zmts.mjs";
4
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-CRRTno6Z.mjs";
3
+ import "./postgres-migration-DcfWGqhe.mjs";
4
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Dw_mPMKt.mjs";
5
5
  import { MigrationOperationPolicy, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
6
6
  import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
7
7
  import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
@@ -45,7 +45,7 @@ declare class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postg
45
45
  readonly contract: unknown;
46
46
  readonly schema: unknown;
47
47
  readonly policy: MigrationOperationPolicy;
48
- readonly fromHash?: string;
48
+ readonly fromHash?: string | null;
49
49
  /**
50
50
  * The "from" contract (state the planner assumes the database starts
51
51
  * at). Only `migration plan` supplies this; `db update` / `db init`
package/dist/planner.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./issue-planner-CFjB0_oO.mjs";
2
- import { t as createPostgresMigrationPlanner } from "./planner-CLUvVhUN.mjs";
2
+ import { t as createPostgresMigrationPlanner } from "./planner-BGMG70Ns.mjs";
3
3
 
4
4
  export { createPostgresMigrationPlanner };
@@ -1,5 +1,5 @@
1
1
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-DH-azLu-.mjs";
2
- import { n as DataTransformOptions, r as PostgresDataTransformOperation } from "./data-transform-CxFRBIUp.mjs";
2
+ import { n as DataTransformOptions, r as PostgresDataTransformOperation } from "./data-transform-D8x5m1YV.mjs";
3
3
  import { Migration } from "@prisma-next/family-sql/migration";
4
4
  import { Contract } from "@prisma-next/contract/types";
5
5
  import { SqlStorage } from "@prisma-next/sql-contract/types";
@@ -47,4 +47,4 @@ declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDet
47
47
  }
48
48
  //#endregion
49
49
  export { PostgresMigration as t };
50
- //# sourceMappingURL=postgres-migration-BjA3Zmts.d.mts.map
50
+ //# sourceMappingURL=postgres-migration-DcfWGqhe.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-BjA3Zmts.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,UAC9C;;;;;;;;qCAWmC;sBAEf;;;;;;4CAesB,SAAS,uBACvC,kCAED,uBACR"}
1
+ {"version":3,"file":"postgres-migration-DcfWGqhe.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,UAC9C;;;;;;;;qCAWmC;sBAEf;;;;;;4CAesB,SAAS,uBACvC,kCAED,uBACR"}
@@ -1,5 +1,5 @@
1
1
  import { t as errorPostgresMigrationStackMissing } from "./errors-AFvEPZ1R.mjs";
2
- import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
2
+ import { t as dataTransform } from "./data-transform-C83dy0vk.mjs";
3
3
  import { Migration } from "@prisma-next/family-sql/migration";
4
4
 
5
5
  //#region src/core/migrations/postgres-migration.ts
@@ -49,4 +49,4 @@ var PostgresMigration = class extends Migration {
49
49
 
50
50
  //#endregion
51
51
  export { PostgresMigration as t };
52
- //# sourceMappingURL=postgres-migration-qtmtbONe.mjs.map
52
+ //# sourceMappingURL=postgres-migration-EGSlO4jO.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-qtmtbONe.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\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 type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n type DataTransformOptions,\n dataTransform,\n type PostgresDataTransformOperation,\n} 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 target-specific re-export of this\n * class from `@prisma-next/target-postgres/migration`, keeping the\n * authoring surface 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 ): PostgresDataTransformOperation {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,AAAS,WAAW;;;;;;;CAQpB,AAAmB;CAEnB,YAAY,OAAyC;AACnD,QAAM,MAAM;AAIZ,OAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B;;;;;;;CAQN,AAAU,cACR,UACA,MACA,SACgC;AAChC,MAAI,CAAC,KAAK,eACR,OAAM,oCAAoC;AAE5C,SAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
1
+ {"version":3,"file":"postgres-migration-EGSlO4jO.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\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 type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport {\n type DataTransformOptions,\n dataTransform,\n type PostgresDataTransformOperation,\n} 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 target-specific re-export of this\n * class from `@prisma-next/target-postgres/migration`, keeping the\n * authoring surface 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 ): PostgresDataTransformOperation {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,AAAS,WAAW;;;;;;;CAQpB,AAAmB;CAEnB,YAAY,OAAyC;AACnD,QAAM,MAAM;AAIZ,OAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,MAAM,GAC5B;;;;;;;CAQN,AAAU,cACR,UACA,MACA,SACgC;AAChC,MAAI,CAAC,KAAK,eACR,OAAM,oCAAoC;AAE5C,SAAO,cAAc,UAAU,MAAM,SAAS,KAAK,eAAe"}
@@ -68,7 +68,6 @@ function buildDescribeMethod(meta) {
68
68
  lines.push(" return {");
69
69
  lines.push(` from: ${JSON.stringify(meta.from)},`);
70
70
  lines.push(` to: ${JSON.stringify(meta.to)},`);
71
- if (meta.kind) lines.push(` kind: ${JSON.stringify(meta.kind)},`);
72
71
  if (meta.labels && meta.labels.length > 0) lines.push(` labels: ${jsonToTsSource(meta.labels)},`);
73
72
  lines.push(" };");
74
73
  lines.push(" }");
@@ -82,4 +81,4 @@ function indent(text, spaces) {
82
81
 
83
82
  //#endregion
84
83
  export { renderCallsToTypeScript as t };
85
- //# sourceMappingURL=render-typescript-1rF_SB4g.mjs.map
84
+ //# sourceMappingURL=render-typescript-Co3Emwgz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-typescript-Co3Emwgz.mjs","names":["BASE_IMPORTS: readonly ImportRequirement[]","requirements: ImportRequirement[]","lines: string[]"],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the Postgres migration IR.\n *\n * Each `PostgresOpFactoryCall` renders itself via `renderTypeScript()` and\n * declares its own `importRequirements()`; this file just composes the module\n * source around those contributions. The design mirrors the Mongo target's\n * `render-typescript.ts` deliberately — byte-for-byte alignment isn't required\n * (different factory module specifiers, different base-class name) but the\n * shape is, so future consolidation to a framework-level helper is mechanical.\n */\n\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/target-postgres/migration` so an authored Postgres\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint:\n *\n * - `Migration` — the target-owned re-export fixes the `SqlMigration`\n * generic to `PostgresPlanTargetDetails` and the abstract `targetId`\n * to `'postgres'`, so user-authored migrations don't need to thread\n * target-details or redeclare `targetId`.\n * - `MigrationCLI` — the migration-file CLI entrypoint, re-exported from\n * `@prisma-next/cli/migration-cli`. Loads `prisma-next.config.ts`,\n * assembles a `ControlStack`, and instantiates the migration class.\n * The migration file owns this dependency directly: pulling CLI\n * machinery in at script run time is acceptable because the script's\n * whole purpose is to be invoked from the project that owns the\n * config.\n */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/target-postgres/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-postgres/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<PostgresOpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<PostgresOpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n"],"mappings":";;;;;;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@ -4,9 +4,8 @@ import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
4
4
  //#region src/core/migrations/render-typescript.d.ts
5
5
 
6
6
  interface RenderMigrationMeta {
7
- readonly from: string;
7
+ readonly from: string | null;
8
8
  readonly to: string;
9
- readonly kind?: string;
10
9
  readonly labels?: readonly string[];
11
10
  }
12
11
  declare function renderCallsToTypeScript(calls: ReadonlyArray<PostgresOpFactoryCall>, meta: RenderMigrationMeta): string;
@@ -1 +1 @@
1
- {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA;;;;;;iBA8BD,uBAAA,QACP,cAAc,8BACf"}
1
+ {"version":3,"file":"render-typescript.d.mts","names":[],"sources":["../src/core/migrations/render-typescript.ts"],"sourcesContent":[],"mappings":";;;;;UAeiB,mBAAA;;;;;iBA6BD,uBAAA,QACP,cAAc,8BACf"}
@@ -1,3 +1,3 @@
1
- import { t as renderCallsToTypeScript } from "./render-typescript-1rF_SB4g.mjs";
1
+ import { t as renderCallsToTypeScript } from "./render-typescript-Co3Emwgz.mjs";
2
2
 
3
3
  export { renderCallsToTypeScript };
@@ -12,7 +12,8 @@ const ensureMarkerTableStatement = {
12
12
  canonical_version int,
13
13
  updated_at timestamptz not null default now(),
14
14
  app_tag text,
15
- meta jsonb not null default '{}'
15
+ meta jsonb not null default '{}',
16
+ invariants text[] not null default '{}'
16
17
  )`,
17
18
  params: []
18
19
  };
@@ -30,7 +31,7 @@ const ensureLedgerTableStatement = {
30
31
  )`,
31
32
  params: []
32
33
  };
33
- function buildWriteMarkerStatements(input) {
34
+ function buildMergeMarkerStatements(input) {
34
35
  const params = [
35
36
  1,
36
37
  input.storageHash,
@@ -38,7 +39,8 @@ function buildWriteMarkerStatements(input) {
38
39
  jsonParam(input.contractJson),
39
40
  input.canonicalVersion ?? null,
40
41
  input.appTag ?? null,
41
- jsonParam(input.meta ?? {})
42
+ jsonParam(input.meta ?? {}),
43
+ input.invariants
42
44
  ];
43
45
  return {
44
46
  insert: {
@@ -50,7 +52,8 @@ function buildWriteMarkerStatements(input) {
50
52
  canonical_version,
51
53
  updated_at,
52
54
  app_tag,
53
- meta
55
+ meta,
56
+ invariants
54
57
  ) values (
55
58
  $1,
56
59
  $2,
@@ -59,7 +62,8 @@ function buildWriteMarkerStatements(input) {
59
62
  $5,
60
63
  now(),
61
64
  $6,
62
- $7::jsonb
65
+ $7::jsonb,
66
+ $8::text[]
63
67
  )`,
64
68
  params
65
69
  },
@@ -71,7 +75,8 @@ function buildWriteMarkerStatements(input) {
71
75
  canonical_version = $5,
72
76
  updated_at = now(),
73
77
  app_tag = $6,
74
- meta = $7::jsonb
78
+ meta = $7::jsonb,
79
+ invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)
75
80
  where id = $1`,
76
81
  params
77
82
  }
@@ -112,5 +117,5 @@ function jsonParam(value) {
112
117
  }
113
118
 
114
119
  //#endregion
115
- export { ensurePrismaContractSchemaStatement as a, ensureMarkerTableStatement as i, buildWriteMarkerStatements as n, ensureLedgerTableStatement as r, buildLedgerInsertStatement as t };
116
- //# sourceMappingURL=statement-builders-BPnmt6wx.mjs.map
120
+ export { ensurePrismaContractSchemaStatement as a, ensureMarkerTableStatement as i, buildMergeMarkerStatements as n, ensureLedgerTableStatement as r, buildLedgerInsertStatement as t };
121
+ //# sourceMappingURL=statement-builders-CHqCtSfe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement-builders-CHqCtSfe.mjs","names":["ensurePrismaContractSchemaStatement: SqlStatement","ensureMarkerTableStatement: SqlStatement","ensureLedgerTableStatement: SqlStatement","params: readonly unknown[]"],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":["export interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport const ensurePrismaContractSchemaStatement: SqlStatement = {\n sql: 'create schema if not exists prisma_contract',\n params: [],\n};\n\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.marker (\n id smallint primary key default 1,\n core_hash text not null,\n profile_hash text not null,\n contract_json jsonb,\n canonical_version int,\n updated_at timestamptz not null default now(),\n app_tag text,\n meta jsonb not null default '{}',\n invariants text[] not null default '{}'\n )`,\n params: [],\n};\n\nexport const ensureLedgerTableStatement: SqlStatement = {\n sql: `create table if not exists prisma_contract.ledger (\n id bigserial primary key,\n created_at timestamptz not null default now(),\n origin_core_hash text,\n origin_profile_hash text,\n destination_core_hash text not null,\n destination_profile_hash text,\n contract_json_before jsonb,\n contract_json_after jsonb,\n operations jsonb not null\n )`,\n params: [],\n};\n\nexport interface MergeMarkerInput {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number | null;\n readonly appTag?: string | null;\n readonly meta?: Record<string, unknown>;\n /**\n * Invariants to merge into `marker.invariants`. INSERT writes them as\n * the initial value (callers are expected to pass a sorted, deduped\n * array). UPDATE merges them with the existing column server-side via\n * a single atomic SQL expression.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildMergeMarkerStatements(input: MergeMarkerInput): {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n} {\n const params: readonly unknown[] = [\n 1,\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n input.invariants,\n ];\n\n return {\n insert: {\n sql: `insert into prisma_contract.marker (\n id,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n ) values (\n $1,\n $2,\n $3,\n $4::jsonb,\n $5,\n now(),\n $6,\n $7::jsonb,\n $8::text[]\n )`,\n params,\n },\n update: {\n // `invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)`\n // reads the current column value under the UPDATE's row lock, unions\n // with the incoming array, dedupes, and sorts ascending — single\n // statement, atomic, no read-then-write window.\n sql: `update prisma_contract.marker set\n core_hash = $2,\n profile_hash = $3,\n contract_json = $4::jsonb,\n canonical_version = $5,\n updated_at = now(),\n app_tag = $6,\n meta = $7::jsonb,\n invariants = array(select distinct unnest(invariants || $8::text[]) order by 1)\n where id = $1`,\n params,\n },\n };\n}\n\nexport interface LedgerInsertInput {\n readonly originStorageHash?: string | null;\n readonly originProfileHash?: string | null;\n readonly destinationStorageHash: string;\n readonly destinationProfileHash?: string | null;\n readonly contractJsonBefore?: unknown;\n readonly contractJsonAfter?: unknown;\n readonly operations: unknown;\n}\n\nexport function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {\n return {\n sql: `insert into prisma_contract.ledger (\n origin_core_hash,\n origin_profile_hash,\n destination_core_hash,\n destination_profile_hash,\n contract_json_before,\n contract_json_after,\n operations\n ) values (\n $1,\n $2,\n $3,\n $4,\n $5::jsonb,\n $6::jsonb,\n $7::jsonb\n )`,\n params: [\n input.originStorageHash ?? null,\n input.originProfileHash ?? null,\n input.destinationStorageHash,\n input.destinationProfileHash ?? null,\n jsonParam(input.contractJsonBefore),\n jsonParam(input.contractJsonAfter),\n jsonParam(input.operations),\n ],\n };\n}\n\nfunction jsonParam(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";AAKA,MAAaA,sCAAoD;CAC/D,KAAK;CACL,QAAQ,EAAE;CACX;AAED,MAAaC,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AAED,MAAaC,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AAkBD,SAAgB,2BAA2B,OAGzC;CACA,MAAMC,SAA6B;EACjC;EACA,MAAM;EACN,MAAM;EACN,UAAU,MAAM,aAAa;EAC7B,MAAM,oBAAoB;EAC1B,MAAM,UAAU;EAChB,UAAU,MAAM,QAAQ,EAAE,CAAC;EAC3B,MAAM;EACP;AAED,QAAO;EACL,QAAQ;GACN,KAAK;;;;;;;;;;;;;;;;;;;;;GAqBL;GACD;EACD,QAAQ;GAKN,KAAK;;;;;;;;;;GAUL;GACD;EACF;;AAaH,SAAgB,2BAA2B,OAAwC;AACjF,QAAO;EACL,KAAK;;;;;;;;;;;;;;;;;EAiBL,QAAQ;GACN,MAAM,qBAAqB;GAC3B,MAAM,qBAAqB;GAC3B,MAAM;GACN,MAAM,0BAA0B;GAChC,UAAU,MAAM,mBAAmB;GACnC,UAAU,MAAM,kBAAkB;GAClC,UAAU,MAAM,WAAW;GAC5B;EACF;;AAGH,SAAS,UAAU,OAAwB;AACzC,QAAO,KAAK,UAAU,SAAS,KAAK"}
@@ -6,18 +6,25 @@ interface SqlStatement {
6
6
  declare const ensurePrismaContractSchemaStatement: SqlStatement;
7
7
  declare const ensureMarkerTableStatement: SqlStatement;
8
8
  declare const ensureLedgerTableStatement: SqlStatement;
9
- interface WriteMarkerInput {
9
+ interface MergeMarkerInput {
10
10
  readonly storageHash: string;
11
11
  readonly profileHash: string;
12
12
  readonly contractJson?: unknown;
13
13
  readonly canonicalVersion?: number | null;
14
14
  readonly appTag?: string | null;
15
15
  readonly meta?: Record<string, unknown>;
16
+ /**
17
+ * Invariants to merge into `marker.invariants`. INSERT writes them as
18
+ * the initial value (callers are expected to pass a sorted, deduped
19
+ * array). UPDATE merges them with the existing column server-side via
20
+ * a single atomic SQL expression.
21
+ */
22
+ readonly invariants: readonly string[];
16
23
  }
17
- declare function buildWriteMarkerStatements(input: WriteMarkerInput): {
24
+ declare function buildMergeMarkerStatements(input: MergeMarkerInput): {
18
25
  readonly insert: SqlStatement;
19
26
  readonly update: SqlStatement;
20
27
  };
21
28
  //#endregion
22
- export { type SqlStatement, buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
29
+ export { type SqlStatement, buildMergeMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
23
30
  //# sourceMappingURL=statement-builders.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"statement-builders.d.mts","names":[],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":[],"mappings":";UAAiB,YAAA;EAAA,SAAA,GAAA,EAAA,MAAY;EAKhB,SAAA,MAAA,EAAA,SAAA,OAAA,EAAA;AAKb;AAca,cAnBA,mCAmB4B,EAnBS,YAgCjD;AAEgB,cA7BJ,0BAmCW,EAnCiB,YAmCjB;AAGR,cAxBH,0BAwB6B,EAxBD,YAwBC;AAAQ,UATjC,gBAAA,CASiC;EAC/B,SAAA,WAAA,EAAA,MAAA;EACA,SAAA,WAAA,EAAA,MAAA;EAAY,SAAA,YAAA,CAAA,EAAA,OAAA;;;kBALb;;iBAGF,0BAAA,QAAkC;mBAC/B;mBACA"}
1
+ {"version":3,"file":"statement-builders.d.mts","names":[],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":[],"mappings":";UAAiB,YAAA;EAAA,SAAA,GAAA,EAAA,MAAY;EAKhB,SAAA,MAAA,EAAA,SAAA,OAAA,EAAA;AAKb;AAea,cApBA,mCAoB4B,EApBS,YAiCjD;AAEgB,cA9BJ,0BAoCW,EApCiB,YAoCjB;AAUR,cA/BH,0BA+B6B,EA/BD,YA+BC;AAAQ,UAhBjC,gBAAA,CAgBiC;EAC/B,SAAA,WAAA,EAAA,MAAA;EACA,SAAA,WAAA,EAAA,MAAA;EAAY,SAAA,YAAA,CAAA,EAAA,OAAA;;;kBAZb;;;;;;;;;iBAUF,0BAAA,QAAkC;mBAC/B;mBACA"}
@@ -1,3 +1,3 @@
1
- import { a as ensurePrismaContractSchemaStatement, i as ensureMarkerTableStatement, n as buildWriteMarkerStatements, r as ensureLedgerTableStatement } from "./statement-builders-BPnmt6wx.mjs";
1
+ import { a as ensurePrismaContractSchemaStatement, i as ensureMarkerTableStatement, n as buildMergeMarkerStatements, r as ensureLedgerTableStatement } from "./statement-builders-CHqCtSfe.mjs";
2
2
 
3
- export { buildWriteMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
3
+ export { buildMergeMarkerStatements, ensureLedgerTableStatement, ensureMarkerTableStatement, ensurePrismaContractSchemaStatement };
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@prisma-next/target-postgres",
3
- "version": "0.5.0-dev.3",
3
+ "version": "0.5.0-dev.30",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Postgres target pack for Prisma Next",
7
7
  "dependencies": {
8
8
  "arktype": "^2.0.0",
9
9
  "pathe": "^2.0.3",
10
- "@prisma-next/contract": "0.5.0-dev.3",
11
- "@prisma-next/cli": "0.5.0-dev.3",
12
- "@prisma-next/errors": "0.5.0-dev.3",
13
- "@prisma-next/family-sql": "0.5.0-dev.3",
14
- "@prisma-next/framework-components": "0.5.0-dev.3",
15
- "@prisma-next/sql-errors": "0.5.0-dev.3",
16
- "@prisma-next/ts-render": "0.5.0-dev.3",
17
- "@prisma-next/sql-relational-core": "0.5.0-dev.3",
18
- "@prisma-next/migration-tools": "0.5.0-dev.3",
19
- "@prisma-next/sql-contract": "0.5.0-dev.3",
20
- "@prisma-next/sql-operations": "0.5.0-dev.3",
21
- "@prisma-next/sql-schema-ir": "0.5.0-dev.3",
22
- "@prisma-next/utils": "0.5.0-dev.3"
10
+ "@prisma-next/cli": "0.5.0-dev.30",
11
+ "@prisma-next/errors": "0.5.0-dev.30",
12
+ "@prisma-next/migration-tools": "0.5.0-dev.30",
13
+ "@prisma-next/family-sql": "0.5.0-dev.30",
14
+ "@prisma-next/framework-components": "0.5.0-dev.30",
15
+ "@prisma-next/contract": "0.5.0-dev.30",
16
+ "@prisma-next/ts-render": "0.5.0-dev.30",
17
+ "@prisma-next/sql-operations": "0.5.0-dev.30",
18
+ "@prisma-next/sql-contract": "0.5.0-dev.30",
19
+ "@prisma-next/sql-errors": "0.5.0-dev.30",
20
+ "@prisma-next/sql-relational-core": "0.5.0-dev.30",
21
+ "@prisma-next/sql-schema-ir": "0.5.0-dev.30",
22
+ "@prisma-next/utils": "0.5.0-dev.30"
23
23
  },
24
24
  "devDependencies": {
25
25
  "tsdown": "0.18.4",
@@ -67,6 +67,9 @@
67
67
  "url": "https://github.com/prisma/prisma-next.git",
68
68
  "directory": "packages/3-targets/3-targets/postgres"
69
69
  },
70
+ "prismaNext": {
71
+ "minServerVersion": "14"
72
+ },
70
73
  "scripts": {
71
74
  "build": "tsdown",
72
75
  "test": "vitest run --passWithNoTests",
@@ -339,22 +339,15 @@ const pgFloat8Codec = codec({
339
339
  const pgTimestampCodec = codec<
340
340
  typeof PG_TIMESTAMP_CODEC_ID,
341
341
  readonly ['equality', 'order'],
342
- string | Date,
343
- string | Date
342
+ Date,
343
+ Date
344
344
  >({
345
345
  typeId: PG_TIMESTAMP_CODEC_ID,
346
346
  targetTypes: ['timestamp'],
347
347
  traits: ['equality', 'order'],
348
- encode: (value: string | Date): string => {
349
- if (value instanceof Date) return value.toISOString();
350
- if (typeof value === 'string') return value;
351
- return String(value);
352
- },
353
- decode: (wire: string | Date): string => {
354
- if (wire instanceof Date) return wire.toISOString();
355
- return wire;
356
- },
357
- encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),
348
+ encode: (value: Date): Date => value,
349
+ decode: (wire: Date): Date => wire,
350
+ encodeJson: (value: Date) => value.toISOString(),
358
351
  decodeJson: (json) => {
359
352
  if (typeof json !== 'string') {
360
353
  throw new Error(`Expected ISO date string for pg/timestamp@1, got ${typeof json}`);
@@ -381,22 +374,15 @@ const pgTimestampCodec = codec<
381
374
  const pgTimestamptzCodec = codec<
382
375
  typeof PG_TIMESTAMPTZ_CODEC_ID,
383
376
  readonly ['equality', 'order'],
384
- string | Date,
385
- string | Date
377
+ Date,
378
+ Date
386
379
  >({
387
380
  typeId: PG_TIMESTAMPTZ_CODEC_ID,
388
381
  targetTypes: ['timestamptz'],
389
382
  traits: ['equality', 'order'],
390
- encode: (value: string | Date): string => {
391
- if (value instanceof Date) return value.toISOString();
392
- if (typeof value === 'string') return value;
393
- return String(value);
394
- },
395
- decode: (wire: string | Date): string => {
396
- if (wire instanceof Date) return wire.toISOString();
397
- return wire;
398
- },
399
- encodeJson: (value: string | Date) => (value instanceof Date ? value.toISOString() : value),
383
+ encode: (value: Date): Date => value,
384
+ decode: (wire: Date): Date => wire,
385
+ encodeJson: (value: Date) => value.toISOString(),
400
386
  decodeJson: (json) => {
401
387
  if (typeof json !== 'string') {
402
388
  throw new Error(`Expected ISO date string for pg/timestamptz@1, got ${typeof json}`);
@@ -37,6 +37,7 @@ import type {
37
37
  } from '@prisma-next/framework-components/control';
38
38
  import type { SqlStorage } from '@prisma-next/sql-contract/types';
39
39
  import type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';
40
+ import { ifDefined } from '@prisma-next/utils/defined';
40
41
 
41
42
  interface Buildable<R = unknown> {
42
43
  build(): SqlQueryPlan<R>;
@@ -49,6 +50,12 @@ interface Buildable<R = unknown> {
49
50
  export type DataTransformClosure = () => SqlQueryPlan | Buildable;
50
51
 
51
52
  export interface DataTransformOptions {
53
+ /**
54
+ * Optional opt-in routing identity. Presence opts the transform into
55
+ * invariant-aware routing; absence means it is path-dependent and
56
+ * not referenceable from refs.
57
+ */
58
+ readonly invariantId?: string;
52
59
  /** Optional pre-flight query. `undefined` means "no check". */
53
60
  readonly check?: DataTransformClosure;
54
61
  /** One or more mutation queries to execute. */
@@ -76,6 +83,7 @@ export function dataTransform<TContract extends Contract<SqlStorage>>(
76
83
  label: `Data transform: ${name}`,
77
84
  operationClass: 'data',
78
85
  name,
86
+ ...ifDefined('invariantId', options.invariantId),
79
87
  source: 'migration.ts',
80
88
  check: options.check ? invokeAndLower(options.check, contract, adapter, name) : null,
81
89
  run: runClosures.map((closure) => invokeAndLower(closure, contract, adapter, name)),
@@ -60,7 +60,6 @@ export class TypeScriptRenderablePostgresMigration
60
60
  return renderCallsToTypeScript(this.#calls, {
61
61
  from: this.#meta.from,
62
62
  to: this.#meta.to,
63
- ...ifDefined('kind', this.#meta.kind),
64
63
  ...ifDefined('labels', this.#meta.labels),
65
64
  });
66
65
  }
@@ -83,7 +83,7 @@ export class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgr
83
83
  readonly contract: unknown;
84
84
  readonly schema: unknown;
85
85
  readonly policy: MigrationOperationPolicy;
86
- readonly fromHash?: string;
86
+ readonly fromHash?: string | null;
87
87
  /**
88
88
  * The "from" contract (state the planner assumes the database starts
89
89
  * at). Only `migration plan` supplies this; `db update` / `db init`
@@ -96,7 +96,7 @@ export class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgr
96
96
  readonly schemaName?: string;
97
97
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
98
98
  }): PostgresPlanResult {
99
- return this.planSql(options as SqlMigrationPlannerPlanOptions, options.fromHash ?? '');
99
+ return this.planSql(options as SqlMigrationPlannerPlanOptions, options.fromHash ?? null);
100
100
  }
101
101
 
102
102
  emptyMigration(context: MigrationScaffoldContext): MigrationPlanWithAuthoringSurface {
@@ -106,7 +106,10 @@ export class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgr
106
106
  });
107
107
  }
108
108
 
109
- private planSql(options: SqlMigrationPlannerPlanOptions, fromHash: string): PostgresPlanResult {
109
+ private planSql(
110
+ options: SqlMigrationPlannerPlanOptions,
111
+ fromHash: string | null,
112
+ ): PostgresPlanResult {
110
113
  const schemaName = options.schemaName ?? this.config.defaultSchema;
111
114
  const policyResult = this.ensureAdditivePolicy(options.policy);
112
115
  if (policyResult) {