@prisma-next/target-sqlite 0.14.0-dev.57 → 0.14.0-dev.59

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.
@@ -1 +1 @@
1
- {"version":3,"file":"planner-produced-sqlite-migration-DyRmcteq.mjs","names":["#calls","#meta","#destination","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/render-typescript.ts","../src/core/migrations/planner-produced-sqlite-migration.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the\n * Postgres `render-typescript.ts` — different base-class + factory module\n * specifier, same overall shape.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/sqlite/migration` so an authored SQLite\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to\n * `'sqlite'`.\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 */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls, meta);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n const hasStart = meta.from !== null;\n const startField = hasStart ? [' override readonly startContractJson = startContract;'] : [];\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n `export default class M extends Migration<${hasStart ? 'Start' : 'never'}, End> {`,\n ...startField,\n ' override readonly endContractJson = endContract;',\n '',\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<OpFactoryCall>, meta: RenderMigrationMeta): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS, ...contractImports(meta)];\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\n/**\n * The committed contract-JSON imports the scaffold reads its from/to identity\n * from. `end-contract.json` is always present; `start-contract.json` is added\n * only for a non-baseline migration (`meta.from !== null`). The matching\n * `Contract` type imports (aliased `Start`/`End`) feed the\n * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with\n * no start imports — `never` is the honest \"no prior contract\" Start.\n */\nfunction contractImports(meta: RenderMigrationMeta): readonly ImportRequirement[] {\n const reqs: ImportRequirement[] = [\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n { moduleSpecifier: './end-contract', symbol: 'Contract', alias: 'End', typeOnly: true },\n ];\n if (meta.from !== null) {\n reqs.push({\n moduleSpecifier: './start-contract.json',\n symbol: 'startContract',\n kind: 'default',\n attributes: { type: 'json' },\n });\n reqs.push({\n moduleSpecifier: './start-contract',\n symbol: 'Contract',\n alias: 'Start',\n typeOnly: true,\n });\n }\n return reqs;\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","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } 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 { SqlitePlanTargetDetails } from './planner-target-details';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\nimport { SqliteMigration } from './sqlite-migration';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport interface SqliteMigrationDestinationInfo {\n readonly storageHash: string;\n readonly profileHash?: string;\n}\n\nexport class TypeScriptRenderableSqliteMigration\n extends SqliteMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache: readonly (Op | Promise<Op>)[] | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (Op | Promise<Op>)[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n override get destination(): SqliteMigrationDestinationInfo {\n return this.#destination;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner\n * keys the marker row by 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, {\n from: this.#meta.from,\n to: this.#meta.to,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,eAA6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AAM;CAC7B,OAAO,KACJ,MAAM,IAAI,CAAC,CACX,KAAK,SAAU,KAAK,KAAK,IAAI,GAAG,MAAM,SAAS,IAAK,CAAC,CACrD,KAAK,IAAI;AACd;;;AC9FA,IAAa,sCAAb,cACU,gBAEV;CACE;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,OACA,MACA,SACA,aACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKE,WAAW;EAChB,KAAKD,eAAe,eAAe,EAAE,aAAa,KAAK,GAAG;EAC1D,KAAKE,WAAW;CAClB;CAEA,IAAa,aAA4C;EACvD,KAAKC,qBAAqB,UAAU,KAAKL,QAAQ,KAAKI,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKJ;CACd;CAEA,IAAa,cAA8C;EACzD,OAAO,KAAKC;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKH,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;EACjB,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"planner-produced-sqlite-migration-DEkfABc8.mjs","names":["#calls","#meta","#destination","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/render-typescript.ts","../src/core/migrations/planner-produced-sqlite-migration.ts"],"sourcesContent":["/**\n * Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the\n * Postgres `render-typescript.ts` — different base-class + factory module\n * specifier, same overall shape.\n */\n\nimport type { OpFactoryCall } from '@prisma-next/framework-components/control';\nimport { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, renderImports } from '@prisma-next/ts-render';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/sqlite/migration` so an authored SQLite\n * `migration.ts` only needs a single dependency for its base class and\n * its CLI entrypoint. Mirrors Postgres's `BASE_IMPORTS`.\n *\n * - `Migration` — the facade re-export fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to\n * `'sqlite'`.\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 */\nconst BASE_IMPORTS: readonly ImportRequirement[] = [\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<OpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls, meta);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n const hasStart = meta.from !== null;\n const startField = hasStart ? [' override readonly startContractJson = startContract;'] : [];\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n `export default class M extends Migration<${hasStart ? 'Start' : 'never'}, End> {`,\n ...startField,\n ' override readonly endContractJson = endContract;',\n '',\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<OpFactoryCall>, meta: RenderMigrationMeta): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS, ...contractImports(meta)];\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\n/**\n * The committed contract-JSON imports the scaffold reads its from/to identity\n * from. `end-contract.json` is always present; `start-contract.json` is added\n * only for a non-baseline migration (`meta.from !== null`). The matching\n * `Contract` type imports (aliased `Start`/`End`) feed the\n * `Migration<Start, End>` generics. Baseline emits `Migration<never, End>` with\n * no start imports — `never` is the honest \"no prior contract\" Start.\n */\nfunction contractImports(meta: RenderMigrationMeta): readonly ImportRequirement[] {\n const reqs: ImportRequirement[] = [\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n { moduleSpecifier: './end-contract', symbol: 'Contract', alias: 'End', typeOnly: true },\n ];\n if (meta.from !== null) {\n reqs.push({\n moduleSpecifier: './start-contract.json',\n symbol: 'startContract',\n kind: 'default',\n attributes: { type: 'json' },\n });\n reqs.push({\n moduleSpecifier: './start-contract',\n symbol: 'Contract',\n alias: 'Start',\n typeOnly: true,\n });\n }\n return reqs;\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","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } 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 { SqlitePlanTargetDetails } from './planner-target-details';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\nimport { SqliteMigration } from './sqlite-migration';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport interface SqliteMigrationDestinationInfo {\n readonly storageHash: string;\n readonly profileHash?: string;\n}\n\nexport class TypeScriptRenderableSqliteMigration\n extends SqliteMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache: readonly (Op | Promise<Op>)[] | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (Op | Promise<Op>)[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n override get destination(): SqliteMigrationDestinationInfo {\n return this.#destination;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from {@link SqlMigrationPlannerPlanOptions.spaceId} so the runner\n * keys the marker row by 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, {\n from: this.#meta.from,\n to: this.#meta.to,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,eAA6C,CACjD;CAAE,iBAAiB;CAAiC,QAAQ;AAAY,GACxE;CAAE,iBAAiB;CAAiC,QAAQ;AAAe,CAC7E;AAEA,SAAgB,wBACd,OACA,MACQ;CACR,MAAM,UAAU,aAAa,OAAO,IAAI;CACxC,MAAM,iBAAiB,MAAM,KAAK,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,KAAK;CACxE,MAAM,WAAW,KAAK,SAAS;CAC/B,MAAM,aAAa,WAAW,CAAC,wDAAwD,IAAI,CAAC;CAE5F,OAAO;EACL,eAAe,sBAAsB,CAAC;EACtC;EACA;EACA,4CAA4C,WAAW,UAAU,QAAQ;EACzE,GAAG;EACH;EACA;EACA;EACA;EACA,OAAO,gBAAgB,CAAC;EACxB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAS,aAAa,OAAqC,MAAmC;CAC5F,MAAM,eAAoC,CAAC,GAAG,cAAc,GAAG,gBAAgB,IAAI,CAAC;CACpF,KAAK,MAAM,QAAQ,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AAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;EACjB,CAAC;CACH;AACF"}
@@ -1,2 +1,2 @@
1
- import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-DyRmcteq.mjs";
1
+ import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-DEkfABc8.mjs";
2
2
  export { TypeScriptRenderableSqliteMigration };
package/dist/planner.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-DhvFrgPT.mjs";
1
+ import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-BD1QRojv.mjs";
2
2
  export { SqliteMigrationPlanner, createSqliteMigrationPlanner };
@@ -1,4 +1,4 @@
1
- import { a as DropColumnCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-D_eYsHTp.mjs";
1
+ import { a as DropColumnCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-Do03QgD9.mjs";
2
2
  import { t as SqliteContractView } from "./sqlite-contract-view-BEwi0mUC.mjs";
3
3
  import { blindCast } from "@prisma-next/utils/casts";
4
4
  import { Migration } from "@prisma-next/family-sql/migration";
@@ -116,4 +116,4 @@ var SqliteMigration = class extends Migration {
116
116
  //#endregion
117
117
  export { SqliteMigration as t };
118
118
 
119
- //# sourceMappingURL=sqlite-migration-D93wCdSD.mjs.map
119
+ //# sourceMappingURL=sqlite-migration-C68ZaNwH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-migration-D93wCdSD.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/errors.ts","../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { CliStructuredError } from '@prisma-next/errors/control';\n\n/**\n * A `SqliteMigration` instance method that needs the materialized control\n * adapter (currently only `this.createTable(...)`) was invoked, but the\n * migration was constructed without a `ControlStack`. Concrete authoring\n * usage always goes through the migration CLI entrypoint, which assembles\n * a stack from the loaded `prisma-next.config.ts`; reaching this error\n * means a test fixture or ad-hoc consumer instantiated `SqliteMigration`\n * with the no-arg form (legal for `operations` / `describe` introspection\n * only).\n *\n * Distinct from `PN-MIG-2001` (placeholder not filled) because the missing\n * input is the stack itself, not the per-operation contract.\n *\n * Lives in `@prisma-next/target-sqlite/errors` rather than the shared\n * framework migration errors module because the failure is target-specific:\n * the contract it talks about (`SqliteMigration`, the SQLite control\n * adapter, the SQLite-target stack) only exists in this package.\n */\nexport function errorSqliteMigrationStackMissing(): CliStructuredError {\n return new CliStructuredError('2008', 'SqliteMigration.createTable requires a control adapter', {\n domain: 'MIG',\n why: 'SqliteMigration.createTable was invoked on an instance constructed without a ControlStack. The stored controlAdapter is undefined, so createTable cannot lower its DDL node.',\n fix: 'Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma-next.config.ts), or pass a ControlStack containing a SQLite adapter to the migration constructor in test fixtures.',\n meta: {},\n });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} 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 { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its `start-contract.json` / `end-contract.json` imports gets\n * fully-typed view accessors: `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite 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); the operation methods\n * throw in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropTableCall(options.table).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new AddColumnCall(options.table, options.column).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropColumnCall(options.table, options.column).toOp(this.controlAdapter);\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropIndexCall(options.table, options.index).toOp(this.controlAdapter);\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new RecreateTableCall(options).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mCAAuD;CACrE,OAAO,IAAI,mBAAmB,QAAQ,0DAA0D;EAC9F,QAAQ;EACR,KAAK;EACL,KAAK;EACL,MAAM,CAAC;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;ACsBA,IAAsB,kBAAtB,cAGUA,UAA4D;CACpE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBAAgD,MAAM,oBAAoB,SACvF,mBAAmB,SAAc,IAAI,CACvC;CACA,aAAa,IAAI,uBACf,MACA,oBACC,SAAS,mBAAmB,SAAgB,IAAI,CACnD;CAEA,YAAY,OAAuC;EACjD,MAAM,KAAK;EACX,KAAK,iBAAiB,OAAO,UACzB,UAGE,MAAM,QAAQ,OAAO,KAAK,CAAC,IAC7B,KAAA;CACN;;;;;;CAOA,IAAI,cAAuC;EACzC,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAkD;EACpD,OAAO,KAAKC,WAAW;CACzB;CAEA,YAAsB,SAKN;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,SAAS,QAAQ,WAAW,CAAC,CAAC,KAC9E,KAAK,cACP;CACF;CAEA,UAAoB,SAAkD;EACpE,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,cAAc;CAClE;CAEA,UAAoB,SAGJ;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CAClF;CAEA,WAAqB,SAA2E;EAC9F,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,eAAe,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACnF;CAEA,YAAsB,SAIN;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,UAAoB,SAA0E;EAC5F,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,cAAc;CACjF;CAEA,cAAwB,SAQR;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,kBAAkB,OAAO,CAAC,CAAC,KAAK,KAAK,cAAc;CAChE;AACF"}
1
+ {"version":3,"file":"sqlite-migration-C68ZaNwH.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/errors.ts","../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { CliStructuredError } from '@prisma-next/errors/control';\n\n/**\n * A `SqliteMigration` instance method that needs the materialized control\n * adapter (currently only `this.createTable(...)`) was invoked, but the\n * migration was constructed without a `ControlStack`. Concrete authoring\n * usage always goes through the migration CLI entrypoint, which assembles\n * a stack from the loaded `prisma-next.config.ts`; reaching this error\n * means a test fixture or ad-hoc consumer instantiated `SqliteMigration`\n * with the no-arg form (legal for `operations` / `describe` introspection\n * only).\n *\n * Distinct from `PN-MIG-2001` (placeholder not filled) because the missing\n * input is the stack itself, not the per-operation contract.\n *\n * Lives in `@prisma-next/target-sqlite/errors` rather than the shared\n * framework migration errors module because the failure is target-specific:\n * the contract it talks about (`SqliteMigration`, the SQLite control\n * adapter, the SQLite-target stack) only exists in this package.\n */\nexport function errorSqliteMigrationStackMissing(): CliStructuredError {\n return new CliStructuredError('2008', 'SqliteMigration.createTable requires a control adapter', {\n domain: 'MIG',\n why: 'SqliteMigration.createTable was invoked on an instance constructed without a ControlStack. The stored controlAdapter is undefined, so createTable cannot lower its DDL node.',\n fix: 'Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma-next.config.ts), or pass a ControlStack containing a SQLite adapter to the migration constructor in test fixtures.',\n meta: {},\n });\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} 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 { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its `start-contract.json` / `end-contract.json` imports gets\n * fully-typed view accessors: `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite 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); the operation methods\n * throw in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropTableCall(options.table).toOp(this.controlAdapter);\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new AddColumnCall(options.table, options.column).toOp(this.controlAdapter);\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropColumnCall(options.table, options.column).toOp(this.controlAdapter);\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapter,\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new DropIndexCall(options.table, options.index).toOp(this.controlAdapter);\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing();\n }\n return new RecreateTableCall(options).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mCAAuD;CACrE,OAAO,IAAI,mBAAmB,QAAQ,0DAA0D;EAC9F,QAAQ;EACR,KAAK;EACL,KAAK;EACL,MAAM,CAAC;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;ACsBA,IAAsB,kBAAtB,cAGUA,UAA4D;CACpE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBAAgD,MAAM,oBAAoB,SACvF,mBAAmB,SAAc,IAAI,CACvC;CACA,aAAa,IAAI,uBACf,MACA,oBACC,SAAS,mBAAmB,SAAgB,IAAI,CACnD;CAEA,YAAY,OAAuC;EACjD,MAAM,KAAK;EACX,KAAK,iBAAiB,OAAO,UACzB,UAGE,MAAM,QAAQ,OAAO,KAAK,CAAC,IAC7B,KAAA;CACN;;;;;;CAOA,IAAI,cAAuC;EACzC,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAkD;EACpD,OAAO,KAAKC,WAAW;CACzB;CAEA,YAAsB,SAKN;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,SAAS,QAAQ,WAAW,CAAC,CAAC,KAC9E,KAAK,cACP;CACF;CAEA,UAAoB,SAAkD;EACpE,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,cAAc;CAClE;CAEA,UAAoB,SAGJ;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CAClF;CAEA,WAAqB,SAA2E;EAC9F,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,eAAe,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACnF;CAEA,YAAsB,SAIN;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,gBAAgB,QAAQ,OAAO,QAAQ,OAAO,QAAQ,OAAO,CAAC,CAAC,KACxE,KAAK,cACP;CACF;CAEA,UAAoB,SAA0E;EAC5F,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,cAAc,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,cAAc;CACjF;CAEA,cAAwB,SAQR;EACd,IAAI,CAAC,KAAK,gBACR,MAAM,iCAAiC;EAEzC,OAAO,IAAI,kBAAkB,OAAO,CAAC,CAAC,KAAK,KAAK,cAAc;CAChE;AACF"}
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "@prisma-next/target-sqlite",
3
- "version": "0.14.0-dev.57",
3
+ "version": "0.14.0-dev.59",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
- "@prisma-next/cli": "0.14.0-dev.57",
9
- "@prisma-next/contract": "0.14.0-dev.57",
10
- "@prisma-next/errors": "0.14.0-dev.57",
11
- "@prisma-next/family-sql": "0.14.0-dev.57",
12
- "@prisma-next/framework-components": "0.14.0-dev.57",
13
- "@prisma-next/migration-tools": "0.14.0-dev.57",
14
- "@prisma-next/sql-contract": "0.14.0-dev.57",
15
- "@prisma-next/sql-errors": "0.14.0-dev.57",
16
- "@prisma-next/sql-relational-core": "0.14.0-dev.57",
17
- "@prisma-next/sql-runtime": "0.14.0-dev.57",
18
- "@prisma-next/sql-schema-ir": "0.14.0-dev.57",
19
- "@prisma-next/ts-render": "0.14.0-dev.57",
20
- "@prisma-next/utils": "0.14.0-dev.57",
8
+ "@prisma-next/cli": "0.14.0-dev.59",
9
+ "@prisma-next/contract": "0.14.0-dev.59",
10
+ "@prisma-next/errors": "0.14.0-dev.59",
11
+ "@prisma-next/family-sql": "0.14.0-dev.59",
12
+ "@prisma-next/framework-components": "0.14.0-dev.59",
13
+ "@prisma-next/migration-tools": "0.14.0-dev.59",
14
+ "@prisma-next/sql-contract": "0.14.0-dev.59",
15
+ "@prisma-next/sql-errors": "0.14.0-dev.59",
16
+ "@prisma-next/sql-relational-core": "0.14.0-dev.59",
17
+ "@prisma-next/sql-runtime": "0.14.0-dev.59",
18
+ "@prisma-next/sql-schema-ir": "0.14.0-dev.59",
19
+ "@prisma-next/ts-render": "0.14.0-dev.59",
20
+ "@prisma-next/utils": "0.14.0-dev.59",
21
21
  "@standard-schema/spec": "1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@prisma-next/driver-sqlite": "0.14.0-dev.57",
25
- "@prisma-next/test-utils": "0.14.0-dev.57",
26
- "@prisma-next/tsconfig": "0.14.0-dev.57",
27
- "@prisma-next/tsdown": "0.14.0-dev.57",
24
+ "@prisma-next/driver-sqlite": "0.14.0-dev.59",
25
+ "@prisma-next/test-utils": "0.14.0-dev.59",
26
+ "@prisma-next/tsconfig": "0.14.0-dev.59",
27
+ "@prisma-next/tsdown": "0.14.0-dev.59",
28
28
  "tsdown": "0.22.1",
29
29
  "typescript": "5.9.3",
30
30
  "vitest": "4.1.8"
@@ -1,11 +1,7 @@
1
1
  import type { ColumnDefault, Contract, ControlPolicy } from '@prisma-next/contract/types';
2
2
  import type { NativeTypeExpander, SqlSchemaDiffResult } from '@prisma-next/family-sql/control';
3
3
  import { buildNativeTypeExpander, contractToSchemaIR } from '@prisma-next/family-sql/control';
4
- import {
5
- neutralizeFlatExpectedFkSchemas,
6
- normalizeFlatActualForDiff,
7
- verifySqlSchemaByDiff,
8
- } from '@prisma-next/family-sql/diff';
4
+ import { verifySqlSchemaByDiff } from '@prisma-next/family-sql/diff';
9
5
  import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';
10
6
  import type {
11
7
  SchemaDiffIssue,
@@ -59,6 +55,10 @@ export function sqliteContractToSchema(
59
55
  readonly expandNativeType?: NativeTypeExpander;
60
56
  },
61
57
  ): SqlSchemaIR {
58
+ // SQLite is single-schema: every contract FK targets the unbound namespace
59
+ // node, so derivation stamps no referenced namespace — the same absence
60
+ // flat introspection produces — and the derived expected FK pairs with its
61
+ // introspected counterpart by construction. No pre-diff pass, no flag.
62
62
  return contractToSchemaIR(contract, {
63
63
  annotationNamespace: 'sqlite',
64
64
  renderDefault: sqliteRenderDefault,
@@ -112,12 +112,11 @@ function resolveControlPolicy(
112
112
  /**
113
113
  * The SQLite full-tree node diff for the family verify verdict: derive the
114
114
  * expected flat tree with resolved leaf values (expander threaded so
115
- * parameterized types compare expanded), neutralize the FK schema segment
116
- * (single-schema target introspection stamps none), normalize the actual
117
- * tree for semantic satisfaction, and run the generic differ. Flat targets
118
- * need no ownership scoping. The codec `verifyType` hooks run once per
119
- * contract namespace with tables, each against the sole flat actual root —
120
- * exactly the legacy per-namespace pairing.
115
+ * parameterized types compare expanded; FK nodes born with the flat empty
116
+ * `resolvedReferencedNamespace`), and run the generic differ over the trees
117
+ * as derived. Flat targets need no ownership scoping. The codec `verifyType`
118
+ * hooks run once per contract namespace with tables, each against the sole
119
+ * flat actual root exactly the legacy per-namespace pairing.
121
120
  */
122
121
  export function diffSqliteSchema(input: {
123
122
  readonly contract: Contract<SqlStorage>;
@@ -125,13 +124,9 @@ export function diffSqliteSchema(input: {
125
124
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
126
125
  }): SqlSchemaDiffResult {
127
126
  const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);
128
- const expected = neutralizeFlatExpectedFkSchemas(
129
- contractToSchemaIR(input.contract, {
130
- annotationNamespace: 'sqlite',
131
- renderDefault: sqliteRenderDefault,
132
- ...ifDefined('expandNativeType', expandNativeType),
133
- }),
134
- );
127
+ const expected = sqliteContractToSchema(input.contract, {
128
+ ...ifDefined('expandNativeType', expandNativeType),
129
+ });
135
130
  const actual =
136
131
  input.schema instanceof SqlSchemaIR
137
132
  ? input.schema
@@ -139,8 +134,7 @@ export function diffSqliteSchema(input: {
139
134
  SqlSchemaIR,
140
135
  'the SQLite introspection adapter always produces a flat SqlSchemaIR root'
141
136
  >(input.schema);
142
- const normalizedActual = normalizeFlatActualForDiff(expected, actual);
143
- const issues = diffSchemas(expected, normalizedActual);
137
+ const issues = diffSchemas(expected, actual);
144
138
  const namespacesWithTables = Object.values(input.contract.storage.namespaces).filter(
145
139
  (ns) => Object.keys(ns.entries.table ?? {}).length > 0,
146
140
  );
@@ -154,18 +148,17 @@ export function diffSqliteSchema(input: {
154
148
  export interface SqlitePlanDiff {
155
149
  /** The desired ("end") tree — resolved leaf values, incl. `codecRef`, on every column. */
156
150
  readonly expected: SqlSchemaIR;
157
- /** The live ("start") tree, normalized for semantic satisfaction against `expected`. */
151
+ /** The live ("start") tree. */
158
152
  readonly actual: SqlSchemaIR;
159
153
  readonly issues: readonly SchemaDiffIssue[];
160
154
  }
161
155
 
162
156
  /**
163
157
  * The SQLite planner's diff input: the same tree-building
164
- * `diffSqliteSchema` uses (expander threaded, FK schema segment
165
- * neutralized, actual tree normalized for semantic satisfaction). One differ
166
- * drives both verify and plan; this is the plan-side derivation — column DDL
167
- * resolves from each expected column's `codecRef` at plan time
168
- * (`column-ddl-rendering.ts`), so no separate render stamping happens here.
158
+ * `diffSqliteSchema` uses (expander threaded, FK nodes born flat). One differ
159
+ * drives both verify and plan over the trees as derived; this is the plan-side
160
+ * derivation column DDL resolves from each expected column's `codecRef` at
161
+ * plan time (`column-ddl-rendering.ts`), so no separate render stamping happens here.
169
162
  */
170
163
  export function buildSqlitePlanDiff(input: {
171
164
  readonly contract: Contract<SqlStorage>;
@@ -173,19 +166,16 @@ export function buildSqlitePlanDiff(input: {
173
166
  readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
174
167
  }): SqlitePlanDiff {
175
168
  const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);
176
- const expected = neutralizeFlatExpectedFkSchemas(
177
- sqliteContractToSchema(input.contract, {
178
- ...ifDefined('expandNativeType', expandNativeType),
179
- }),
180
- );
169
+ const expected = sqliteContractToSchema(input.contract, {
170
+ ...ifDefined('expandNativeType', expandNativeType),
171
+ });
181
172
  // The differ dispatches polymorphically (`.isEqualTo()` / `.children()`), so
182
173
  // the actual tree must be genuine `SqlSchemaIR`/`SqlTableIR`/`SqlColumnIR`
183
174
  // instances, not plain data shaped like them. `new SqlSchemaIR(...)`
184
175
  // normalizes either input uniformly (an already-real tree passes through
185
176
  // untouched — its nested values are already instances) and is a no-op
186
177
  // rebuild in the common (real-instance) case, so this is always safe to run.
187
- const actualRaw = new SqlSchemaIR(withRecordKeyNames(input.actualSchema));
188
- const actual = normalizeFlatActualForDiff(expected, actualRaw);
178
+ const actual = new SqlSchemaIR(withRecordKeyNames(input.actualSchema));
189
179
  const issues = diffSchemas(expected, actual);
190
180
  return { expected, actual, issues };
191
181
  }
@@ -290,7 +290,9 @@ function mapTableIssue(
290
290
  }
291
291
  // Unreachable: SqlTableIR.isEqualTo is identity, so a paired table can
292
292
  // never mismatch — kept for exhaustiveness against a future node change.
293
- return notOk(issueConflict('unsupportedOperation', `Unexpected table drift: ${issue.message}`));
293
+ return notOk(
294
+ issueConflict('unsupportedOperation', `Unexpected table drift: ${issue.path.join('/')}`),
295
+ );
294
296
  }
295
297
 
296
298
  function mapColumnIssue(
@@ -302,7 +304,7 @@ function mapColumnIssue(
302
304
  return notOk(
303
305
  issueConflict(
304
306
  'unsupportedOperation',
305
- `Column issue has no table in its path: ${issue.message}`,
307
+ `Column issue has no table in its path: ${issue.path.join('/')}`,
306
308
  ),
307
309
  );
308
310
  }
@@ -338,7 +340,7 @@ function mapColumnIssue(
338
340
  'a not-equal column issue always carries the actual column node'
339
341
  >(issue.actual);
340
342
  const kind = columnTypeChanged(expected, actual) ? 'typeMismatch' : 'nullabilityConflict';
341
- return notOk(issueConflict(kind, issue.message, issueLocation(tableName, expected.name)));
343
+ return notOk(issueConflict(kind, issue.path.join('/'), issueLocation(tableName, expected.name)));
342
344
  }
343
345
 
344
346
  function mapIndexIssue(
@@ -349,7 +351,7 @@ function mapIndexIssue(
349
351
  return notOk(
350
352
  issueConflict(
351
353
  'unsupportedOperation',
352
- `Index issue has no table in its path: ${issue.message}`,
354
+ `Index issue has no table in its path: ${issue.path.join('/')}`,
353
355
  ),
354
356
  );
355
357
  }
@@ -372,7 +374,7 @@ function mapIndexIssue(
372
374
  // not-equal: index type/options/uniqueness drift. SQLite can't ALTER an
373
375
  // index in place and the legacy planner never absorbed this into a
374
376
  // recreate either — surfaces as a conflict, matching `index_mismatch`.
375
- return notOk(issueConflict('indexIncompatible', issue.message, issueLocation(tableName)));
377
+ return notOk(issueConflict('indexIncompatible', issue.path.join('/'), issueLocation(tableName)));
376
378
  }
377
379
 
378
380
  export function mapNodeIssueToCall(
@@ -384,7 +386,7 @@ export function mapNodeIssueToCall(
384
386
  return notOk(
385
387
  issueConflict(
386
388
  'unsupportedOperation',
387
- `Issue carries neither an expected nor an actual node: ${issue.message}`,
389
+ `Issue carries neither an expected nor an actual node: ${issue.path.join('/')}`,
388
390
  ),
389
391
  );
390
392
  }
@@ -399,12 +401,12 @@ export function mapNodeIssueToCall(
399
401
  case RelationalSchemaNodeKind.primaryKey:
400
402
  case RelationalSchemaNodeKind.foreignKey:
401
403
  case RelationalSchemaNodeKind.unique:
402
- return notOk(issueConflict(absorbedConflictKind(node.nodeKind), issue.message));
404
+ return notOk(issueConflict(absorbedConflictKind(node.nodeKind), issue.path.join('/')));
403
405
  case RelationalSchemaNodeKind.check:
404
406
  return notOk(
405
407
  issueConflict(
406
408
  'unsupportedOperation',
407
- `SQLite does not support CHECK constraint DDL: ${issue.message}`,
409
+ `SQLite does not support CHECK constraint DDL: ${issue.path.join('/')}`,
408
410
  ),
409
411
  );
410
412
  default:
@@ -201,15 +201,14 @@ export async function recreateTable(
201
201
  * issues that triggered it. Lives next to `recreateTable` so the planner
202
202
  * (which has the issues) can produce the same description the factory
203
203
  * used to build inline. Keeping the formatting target-side keeps
204
- * `RecreateTableCall` issue-free at the IR layer. Each `SchemaDiffIssue`
205
- * already carries a differ-generated `message`, so this is a plain join
206
- * rather than a per-kind message builder.
204
+ * `RecreateTableCall` issue-free at the IR layer. `SchemaDiffIssue` carries
205
+ * no rendered message, so this renders one from each issue's path.
207
206
  */
208
207
  export function buildRecreateSummary(
209
208
  tableName: string,
210
209
  issues: readonly SchemaDiffIssue[],
211
210
  ): string {
212
- const messages = issues.map((i) => i.message).join('; ');
211
+ const messages = issues.map((i) => i.path.join('/')).join('; ');
213
212
  return `Recreates table ${tableName} to apply schema changes: ${messages}`;
214
213
  }
215
214
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"op-factory-call-D_eYsHTp.mjs","names":["contractFreeDdl.createTable"],"sources":["../src/core/migrations/planner-ddl-builders.ts","../src/core/migrations/operations/shared.ts","../src/core/migrations/operations/columns.ts","../src/core/migrations/operations/tables.ts","../src/core/migrations/op-factory-call.ts"],"sourcesContent":["/**\n * Low-level DDL fragment builders for SQLite migrations.\n *\n * These helpers consume `StorageColumn` (the contract shape, possibly with\n * `typeRef`) and produce string fragments. They are called once per column\n * at the call-construction boundary in `issue-planner.ts` / strategies to\n * build flat `SqliteColumnSpec`s; the operation factories themselves never\n * see `StorageColumn` or `storageTypes`.\n */\n\nimport type {\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\n\ntype SqliteColumnDefault = StorageColumn['default'];\n\nconst SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*$/;\n\nfunction assertSafeNativeType(nativeType: string): void {\n if (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) {\n throw new Error(\n `Unsafe native type name in contract: \"${nativeType}\". ` +\n 'Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*$/',\n );\n }\n}\n\nfunction assertSafeDefaultExpression(expression: string): void {\n if (expression.includes(';') || /--|\\/\\*|\\bSELECT\\b/i.test(expression)) {\n throw new Error(\n `Unsafe default expression in contract: \"${expression}\". ` +\n 'Default expressions must not contain semicolons, SQL comment tokens, or subqueries.',\n );\n }\n}\n\n/**\n * Renders the column's DDL type token (e.g. `\"INTEGER\"`, `\"TEXT\"`).\n * Resolves `typeRef` against `storageTypes` and validates the resulting\n * native type against a safe-identifier pattern.\n */\nexport function buildColumnTypeSql(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n assertSafeNativeType(resolved.nativeType);\n return resolved.nativeType.toUpperCase();\n}\n\n/**\n * Renders the column's `DEFAULT …` clause. Returns the empty string when\n * there is no default, and also when the default is `autoincrement()` —\n * SQLite encodes that as `INTEGER PRIMARY KEY AUTOINCREMENT` inline on the\n * column definition, not as a separate DEFAULT.\n */\nexport function buildColumnDefaultSql(columnDefault: SqliteColumnDefault | undefined): string {\n if (!columnDefault) return '';\n\n switch (columnDefault.kind) {\n case 'literal':\n return `DEFAULT ${renderDefaultLiteral(columnDefault.value)}`;\n case 'function': {\n if (columnDefault.expression === 'autoincrement()') return '';\n if (columnDefault.expression === 'now()') return \"DEFAULT (datetime('now'))\";\n assertSafeDefaultExpression(columnDefault.expression);\n return `DEFAULT (${columnDefault.expression})`;\n }\n }\n}\n\nexport function renderDefaultLiteral(value: unknown): string {\n if (value instanceof Date) {\n return `'${escapeLiteral(value.toISOString())}'`;\n }\n if (typeof value === 'string') {\n return `'${escapeLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'bigint') {\n return String(value);\n }\n if (typeof value === 'boolean') {\n return value ? '1' : '0';\n }\n if (value === null) {\n return 'NULL';\n }\n return `'${escapeLiteral(JSON.stringify(value))}'`;\n}\n\nexport function buildCreateIndexSql(\n tableName: string,\n indexName: string,\n columns: readonly string[],\n unique = false,\n): string {\n const uniqueKeyword = unique ? 'UNIQUE ' : '';\n return `CREATE ${uniqueKeyword}INDEX ${quoteIdentifier(indexName)} ON ${quoteIdentifier(tableName)} (${columns.map(quoteIdentifier).join(', ')})`;\n}\n\nexport function buildDropIndexSql(indexName: string): string {\n return `DROP INDEX IF EXISTS ${quoteIdentifier(indexName)}`;\n}\n\n/**\n * True when the column is rendered inline as `INTEGER PRIMARY KEY\n * AUTOINCREMENT`. Requires the column's default to be `autoincrement()` and\n * the column to be the sole member of the table's primary key — anything\n * else falls back to a separate PRIMARY KEY constraint with a default\n * AUTOINCREMENT semantics expressed elsewhere.\n */\nexport function isInlineAutoincrementPrimaryKey(table: StorageTable, columnName: string): boolean {\n if (table.primaryKey?.columns.length !== 1) return false;\n if (table.primaryKey.columns[0] !== columnName) return false;\n const column = table.columns[columnName];\n return column?.default?.kind === 'function' && column.default.expression === 'autoincrement()';\n}\n\ntype ResolvedColumnTypeMetadata = Pick<StorageColumn, 'nativeType' | 'codecId' | 'typeParams'>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n throw new Error(\n `Storage type \"${column.typeRef}\" referenced by column is not defined in storage.types.`,\n );\n }\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import type {\n SqlMigrationPlanOperation,\n SqlMigrationPlanOperationStep,\n} from '@prisma-next/family-sql/control';\nimport { REFERENTIAL_ACTION_SQL } from '@prisma-next/sql-contract/referential-action-sql';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { quoteIdentifier } from '../../sql-utils';\nimport type { SqlitePlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport function step(\n description: string,\n sql: string,\n params?: readonly unknown[],\n): SqlMigrationPlanOperationStep {\n return { description, sql, ...ifDefined('params', params) };\n}\n\n/**\n * Flat, fully-resolved column shape consumed by `createTable`, `addColumn`,\n * and `recreateTable`. Codec / `typeRef` / default expansion happens at the\n * call-construction site (in the issue-planner / strategies) so the\n * operation factories deal only in pre-rendered SQL fragments — mirrors the\n * Postgres `ColumnSpec` pattern.\n *\n * - `typeSql` is the column's DDL type token (e.g. `\"INTEGER\"`, `\"TEXT\"`).\n * - `defaultSql` is the full `DEFAULT …` clause (or empty when there is no\n * default and when the column is rendered as `INTEGER PRIMARY KEY\n * AUTOINCREMENT`, since SQLite forbids a default on an autoincrement PK).\n * - `inlineAutoincrementPrimaryKey` directs the renderer to emit\n * `INTEGER PRIMARY KEY AUTOINCREMENT` inline and to skip the table-level\n * primary-key constraint for this column. SQLite-specific: the column\n * becomes an alias for `rowid` only when this exact form is used.\n */\nexport interface SqliteColumnSpec {\n readonly name: string;\n readonly typeSql: string;\n readonly defaultSql: string;\n readonly nullable: boolean;\n readonly inlineAutoincrementPrimaryKey?: boolean;\n}\n\nexport interface SqlitePrimaryKeySpec {\n readonly columns: readonly string[];\n}\n\nexport interface SqliteUniqueSpec {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\nexport interface SqliteForeignKeySpec {\n readonly columns: readonly string[];\n readonly references: {\n readonly table: string;\n readonly columns: readonly string[];\n };\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n readonly constraint: boolean;\n}\n\n/**\n * Flat shape of a contract table for DDL emission. Used by both\n * `createTable` (additive) and `recreateTable` (widening/destructive).\n */\nexport interface SqliteTableSpec {\n readonly columns: readonly SqliteColumnSpec[];\n readonly primaryKey?: SqlitePrimaryKeySpec;\n readonly uniques?: readonly SqliteUniqueSpec[];\n readonly foreignKeys?: readonly SqliteForeignKeySpec[];\n}\n\n/**\n * Index recreation spec for `recreateTable`. Both declared indexes and\n * FK-backing indexes flatten to the same shape; the planner dedupes by\n * column-set before constructing the call.\n */\nexport interface SqliteIndexSpec {\n readonly name: string;\n readonly columns: readonly string[];\n}\n\n/**\n * Renders a single column's inline DDL fragment within a `CREATE TABLE`\n * statement. Honours the `inlineAutoincrementPrimaryKey` flag — SQLite\n * treats `INTEGER PRIMARY KEY AUTOINCREMENT` as a special form that aliases\n * `rowid`, and the column must not carry a `DEFAULT` or repeat `NOT NULL`.\n */\nexport function renderColumnDefinition(column: SqliteColumnSpec): string {\n const parts: string[] = [quoteIdentifier(column.name), column.typeSql];\n if (column.inlineAutoincrementPrimaryKey) {\n parts.push('PRIMARY KEY AUTOINCREMENT');\n } else {\n if (column.defaultSql) parts.push(column.defaultSql);\n if (!column.nullable) parts.push('NOT NULL');\n }\n return parts.join(' ');\n}\n\n/**\n * Renders an inline FOREIGN KEY constraint clause for a `CREATE TABLE`\n * body. Returns the empty string when `constraint` is false (the FK is\n * tracked at the contract level for index-creation purposes only and must\n * not produce DDL).\n */\nexport function renderForeignKeyClause(fk: SqliteForeignKeySpec): string {\n if (!fk.constraint) return '';\n const name = fk.name ? `CONSTRAINT ${quoteIdentifier(fk.name)} ` : '';\n let sql = `${name}FOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')}) REFERENCES ${quoteIdentifier(fk.references.table)} (${fk.references.columns.map(quoteIdentifier).join(', ')})`;\n if (fk.onDelete !== undefined) {\n sql += ` ON DELETE ${REFERENTIAL_ACTION_SQL[fk.onDelete]}`;\n }\n if (fk.onUpdate !== undefined) {\n sql += ` ON UPDATE ${REFERENTIAL_ACTION_SQL[fk.onUpdate]}`;\n }\n return sql;\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { columnExistsAst } from '../../../contract-free/checks';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { buildTargetDetails } from '../planner-target-details';\nimport { type Op, type SqliteColumnSpec, step } from './shared';\n\nexport function addColumnExecuteSql(tableName: string, column: SqliteColumnSpec): string {\n const parts = [\n `ALTER TABLE ${quoteIdentifier(tableName)}`,\n `ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n}\n\nexport function dropColumnExecuteSql(tableName: string, columnName: string): string {\n return `ALTER TABLE ${quoteIdentifier(tableName)} DROP COLUMN ${quoteIdentifier(columnName)}`;\n}\n\nexport async function addColumn(\n tableName: string,\n column: SqliteColumnSpec,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const checks = columnExistsAst(tableName, column.name);\n const absent = await lowerer.lowerToExecuteRequest(checks.columnAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.columnPresent());\n return {\n id: `column.${tableName}.${column.name}`,\n label: `Add column ${column.name} on ${tableName}`,\n summary: `Adds column ${column.name} on ${tableName}`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('column', column.name, tableName) },\n precheck: [step(`ensure column \"${column.name}\" is missing`, absent.sql, absent.params)],\n execute: [step(`add column \"${column.name}\"`, addColumnExecuteSql(tableName, column))],\n postcheck: [step(`verify column \"${column.name}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropColumn(\n tableName: string,\n columnName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const checks = columnExistsAst(tableName, columnName);\n const present = await lowerer.lowerToExecuteRequest(checks.columnPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.columnAbsent());\n return {\n id: `dropColumn.${tableName}.${columnName}`,\n label: `Drop column ${columnName} on ${tableName}`,\n summary: `Drops column ${columnName} on ${tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('column', columnName, tableName) },\n precheck: [\n step(`ensure column \"${columnName}\" exists on \"${tableName}\"`, present.sql, present.params),\n ],\n execute: [\n step(\n `drop column \"${columnName}\" from \"${tableName}\"`,\n dropColumnExecuteSql(tableName, columnName),\n ),\n ],\n postcheck: [\n step(`verify column \"${columnName}\" is gone from \"${tableName}\"`, absent.sql, absent.params),\n ],\n };\n}\n","import type { MigrationOperationClass } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { RelationalSchemaNodeKind, type SqlColumnIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { tableExistsAst } from '../../../contract-free/checks';\nimport { stripOuterParens } from '../../default-normalizer';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { buildCreateIndexSql } from '../planner-ddl-builders';\nimport { buildTargetDetails } from '../planner-target-details';\nimport {\n type Op,\n renderColumnDefinition,\n renderForeignKeyClause,\n type SqliteIndexSpec,\n type SqliteTableSpec,\n step,\n} from './shared';\n\ntype CheckStep = { sql: string; params?: readonly unknown[] };\n\nasync function tableExistsSteps(\n lowerer: ExecuteRequestLowerer,\n tableName: string,\n): Promise<{ present: CheckStep; absent: CheckStep }> {\n const checks = tableExistsAst(tableName);\n const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());\n return { present, absent };\n}\n\n/**\n * Renders the body of a `CREATE TABLE <name> ( … )` statement from a flat\n * `SqliteTableSpec`. SQLite's `INTEGER PRIMARY KEY AUTOINCREMENT` form is\n * inline on the column; the table-level PRIMARY KEY clause is emitted only\n * when no column carries `inlineAutoincrementPrimaryKey`.\n */\nfunction renderCreateTableSql(tableName: string, spec: SqliteTableSpec): string {\n const columnDefs = spec.columns.map(renderColumnDefinition);\n\n const constraintDefs: string[] = [];\n const hasInlinePk = spec.columns.some((c) => c.inlineAutoincrementPrimaryKey);\n if (spec.primaryKey && !hasInlinePk) {\n constraintDefs.push(`PRIMARY KEY (${spec.primaryKey.columns.map(quoteIdentifier).join(', ')})`);\n }\n\n for (const u of spec.uniques ?? []) {\n const name = u.name ? `CONSTRAINT ${quoteIdentifier(u.name)} ` : '';\n constraintDefs.push(`${name}UNIQUE (${u.columns.map(quoteIdentifier).join(', ')})`);\n }\n\n for (const fk of spec.foreignKeys ?? []) {\n const clause = renderForeignKeyClause(fk);\n if (clause) constraintDefs.push(clause);\n }\n\n const allDefs = [...columnDefs, ...constraintDefs];\n return `CREATE TABLE ${quoteIdentifier(tableName)} (\\n ${allDefs.join(',\\n ')}\\n)`;\n}\n\nexport async function createTable(\n tableName: string,\n spec: SqliteTableSpec,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { present, absent } = await tableExistsSteps(lowerer, tableName);\n return {\n id: `table.${tableName}`,\n label: `Create table ${tableName}`,\n summary: `Creates table ${tableName} with required columns`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [step(`ensure table \"${tableName}\" does not exist`, absent.sql, absent.params)],\n execute: [step(`create table \"${tableName}\"`, renderCreateTableSql(tableName, spec))],\n postcheck: [step(`verify table \"${tableName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropTable(tableName: string, lowerer: ExecuteRequestLowerer): Promise<Op> {\n const { present, absent } = await tableExistsSteps(lowerer, tableName);\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table ${tableName}`,\n summary: `Drops table ${tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [step(`ensure table \"${tableName}\" exists`, present.sql, present.params)],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${quoteIdentifier(tableName)}`)],\n postcheck: [step(`verify table \"${tableName}\" is gone`, absent.sql, absent.params)],\n };\n}\n\nexport interface RecreateTableArgs {\n readonly tableName: string;\n /** New (post-recreate) shape of the table. Same flat spec as `createTable`. */\n readonly contractTable: SqliteTableSpec;\n /**\n * Names of columns that exist in the live (pre-recreate) schema. Used to\n * compute the `INSERT INTO temp ... SELECT ... FROM old` column list — only\n * shared columns are copied, so dropped columns are left behind and added\n * columns come from defaults.\n */\n readonly schemaColumnNames: readonly string[];\n /**\n * Indexes (declared + FK-backing, deduped by column-set) to recreate after\n * the table has been replaced. The planner pre-merges these.\n */\n readonly indexes: readonly SqliteIndexSpec[];\n /** Human-readable summary of the change, built by the planner from issues. */\n readonly summary: string;\n /**\n * Per-issue postcheck steps appended after the structural postchecks. The\n * planner pre-builds these via `buildRecreatePostchecks` so the call IR\n * carries flat, serializable data only — no `SchemaDiffIssue` references.\n */\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n}\n\nexport async function recreateTable(\n args: RecreateTableArgs,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const {\n tableName,\n contractTable,\n schemaColumnNames,\n indexes,\n summary,\n postchecks,\n operationClass,\n } = args;\n const tempName = `_prisma_new_${tableName}`;\n const liveSet = new Set(schemaColumnNames);\n const sharedColumns = contractTable.columns.filter((c) => liveSet.has(c.name)).map((c) => c.name);\n const columnList = sharedColumns.map(quoteIdentifier).join(', ');\n\n const indexStatements = indexes.map((idx) => ({\n description: `recreate index \"${idx.name}\" on \"${tableName}\"`,\n sql: buildCreateIndexSql(tableName, idx.name, idx.columns),\n }));\n\n // If the contract retains no columns from the live table, an `INSERT INTO\n // tmp () SELECT FROM old` is invalid SQL — and would also be a no-op since\n // there's nothing to copy. Skip the copy step in that case; the new\n // (empty) table replaces the old one directly.\n const copyStep =\n sharedColumns.length > 0\n ? [\n step(\n `copy data from \"${tableName}\" to \"${tempName}\"`,\n `INSERT INTO ${quoteIdentifier(tempName)} (${columnList}) SELECT ${columnList} FROM ${quoteIdentifier(tableName)}`,\n ),\n ]\n : [];\n\n const tableSteps = await tableExistsSteps(lowerer, tableName);\n const tempSteps = await tableExistsSteps(lowerer, tempName);\n\n return {\n id: `recreateTable.${tableName}`,\n label: `Recreate table ${tableName}`,\n summary,\n operationClass,\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [\n step(`ensure table \"${tableName}\" exists`, tableSteps.present.sql, tableSteps.present.params),\n step(\n `ensure temp table \"${tempName}\" does not exist`,\n tempSteps.absent.sql,\n tempSteps.absent.params,\n ),\n ],\n execute: [\n step(\n `create new table \"${tempName}\" with desired schema`,\n renderCreateTableSql(tempName, contractTable),\n ),\n ...copyStep,\n step(`drop old table \"${tableName}\"`, `DROP TABLE ${quoteIdentifier(tableName)}`),\n step(\n `rename \"${tempName}\" to \"${tableName}\"`,\n `ALTER TABLE ${quoteIdentifier(tempName)} RENAME TO ${quoteIdentifier(tableName)}`,\n ),\n ...indexStatements,\n ],\n postcheck: [\n step(`verify table \"${tableName}\" exists`, tableSteps.present.sql, tableSteps.present.params),\n step(\n `verify temp table \"${tempName}\" is gone`,\n tempSteps.absent.sql,\n tempSteps.absent.params,\n ),\n ...postchecks,\n ],\n };\n}\n\n/**\n * Build a one-line summary of a recreate-table operation from the schema-diff\n * issues that triggered it. Lives next to `recreateTable` so the planner\n * (which has the issues) can produce the same description the factory\n * used to build inline. Keeping the formatting target-side keeps\n * `RecreateTableCall` issue-free at the IR layer. Each `SchemaDiffIssue`\n * already carries a differ-generated `message`, so this is a plain join\n * rather than a per-kind message builder.\n */\nexport function buildRecreateSummary(\n tableName: string,\n issues: readonly SchemaDiffIssue[],\n): string {\n const messages = issues.map((i) => i.message).join('; ');\n return `Recreates table ${tableName} to apply schema changes: ${messages}`;\n}\n\nfunction nodeKindOf(issue: SchemaDiffIssue): string | undefined {\n const node = issue.expected ?? issue.actual;\n if (node === undefined) return undefined;\n return blindCast<{ readonly nodeKind: string }, 'every diff-tree node declares nodeKind'>(node)\n .nodeKind;\n}\n\n/** Mirrors `SqlColumnIR.isEqualTo`'s type comparison, isolated so a `not-equal` column issue's postcheck can target type drift and nullability drift independently. */\nfunction columnTypeChanged(expected: SqlColumnIR, actual: SqlColumnIR): boolean {\n if (expected.resolvedNativeType !== undefined && actual.resolvedNativeType !== undefined) {\n return expected.resolvedNativeType !== actual.resolvedNativeType;\n }\n return (\n expected.nativeType !== actual.nativeType || Boolean(expected.many) !== Boolean(actual.many)\n );\n}\n\n/**\n * Returns the columns the contract expects as the table's primary key. Picks\n * up SQLite's inline `INTEGER PRIMARY KEY AUTOINCREMENT` form when no\n * explicit `primaryKey` clause is set on the spec.\n */\nfunction expectedPrimaryKeyColumns(spec: SqliteTableSpec): readonly string[] {\n if (spec.primaryKey) return spec.primaryKey.columns;\n const inlinePk = spec.columns.find((c) => c.inlineAutoincrementPrimaryKey);\n return inlinePk ? [inlinePk.name] : [];\n}\n\nfunction quoteSqlList(values: readonly string[]): string {\n return values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n}\n\nfunction columnNameFromNode(issue: SchemaDiffIssue): string | undefined {\n const node = issue.expected ?? issue.actual;\n if (node === undefined) return undefined;\n return blindCast<\n { readonly name: string },\n 'a column or column-default issue node carries name (default nodes read the owning column name off the diff path instead)'\n >(node).name;\n}\n\n/**\n * A column-default issue's own node has no back-reference to its owning\n * column — it's a transient child built by `SqlColumnIR.children()`. The\n * column's id (`column:<name>`) is always the diff path's second-to-last\n * segment for a default issue (`[..., tableId, columnId, 'default']`), so\n * the name is recovered from the path rather than the node.\n */\nfunction columnNameFromDefaultIssuePath(issue: SchemaDiffIssue): string | undefined {\n const columnId = issue.path[issue.path.length - 2];\n if (columnId === undefined) return undefined;\n const prefix = 'column:';\n return columnId.startsWith(prefix) ? columnId.slice(prefix.length) : columnId;\n}\n\n/**\n * Per-issue postchecks verifying the recreated table's shape against the\n * expected spec. Column-level issues (`sql-column` `not-equal`,\n * `sql-column-default` any reason) emit one targeted check each;\n * constraint-level issues (`sql-primary-key`, `sql-unique`, `sql-foreign-key`,\n * any reason) emit one `pragma_*`-driven check per declared constraint in the\n * expected spec, so a recreated table with the right columns but the wrong\n * PK / unique / FK shape fails the postcheck instead of passing silently.\n * Exported so the planner can pre-build the list at construction time and\n * `RecreateTableCall` doesn't have to carry `SchemaDiffIssue` objects through\n * to render time.\n */\nexport function buildRecreatePostchecks(\n tableName: string,\n issues: readonly SchemaDiffIssue[],\n spec: SqliteTableSpec,\n): Array<{ description: string; sql: string }> {\n const checks: Array<{ description: string; sql: string }> = [];\n const t = escapeLiteral(tableName);\n const byName = new Map(spec.columns.map((c) => [c.name, c]));\n\n let hasPkIssue = false;\n let hasUniqueIssue = false;\n let hasFkIssue = false;\n\n for (const issue of issues) {\n const nodeKind = nodeKindOf(issue);\n if (nodeKind === RelationalSchemaNodeKind.column && issue.reason === 'not-equal') {\n const columnName = columnNameFromNode(issue);\n if (columnName === undefined) continue;\n const c = escapeLiteral(columnName);\n const expected = blindCast<SqlColumnIR, 'a not-equal column issue carries the expected node'>(\n issue.expected,\n );\n const actual = blindCast<SqlColumnIR, 'a not-equal column issue carries the actual node'>(\n issue.actual,\n );\n if (expected.nullable !== actual.nullable) {\n checks.push({\n description: `verify \"${columnName}\" nullability on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND \"notnull\" = ${expected.nullable ? 0 : 1}`,\n });\n }\n if (columnTypeChanged(expected, actual)) {\n const colSpec = byName.get(columnName);\n if (colSpec) {\n checks.push({\n description: `verify \"${columnName}\" type on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND LOWER(type) = '${escapeLiteral(colSpec.typeSql.toLowerCase())}'`,\n });\n }\n }\n continue;\n }\n if (nodeKind === RelationalSchemaNodeKind.columnDefault) {\n const columnName = columnNameFromDefaultIssuePath(issue);\n if (columnName === undefined) continue;\n const c = escapeLiteral(columnName);\n if (issue.reason === 'not-expected') {\n checks.push({\n description: `verify \"${columnName}\" has no default on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value IS NULL`,\n });\n continue;\n }\n // not-found (missing) or not-equal (drift) — both want the expected\n // default SQL present on the live column.\n const colSpec = byName.get(columnName);\n const expectedRaw = colSpec?.defaultSql.startsWith('DEFAULT ')\n ? // SQLite's pragma_table_info.dflt_value strips outer parens for\n // expression defaults (per the SQLite docs), so `(datetime('now'))`\n // is stored as `datetime('now')`. Strip them here so the postcheck\n // matches.\n stripOuterParens(colSpec.defaultSql.slice('DEFAULT '.length))\n : null;\n if (expectedRaw) {\n checks.push({\n description: `verify \"${columnName}\" default on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value = '${escapeLiteral(expectedRaw)}'`,\n });\n }\n continue;\n }\n if (nodeKind === RelationalSchemaNodeKind.primaryKey) hasPkIssue = true;\n if (nodeKind === RelationalSchemaNodeKind.unique) hasUniqueIssue = true;\n if (nodeKind === RelationalSchemaNodeKind.foreignKey) hasFkIssue = true;\n }\n\n // Constraint-level issues — emit one postcheck per declared constraint in\n // the expected spec when *any* issue of that kind fires, since recreate\n // rebuilds the entire table at once.\n\n if (hasPkIssue) {\n const pkColumns = expectedPrimaryKeyColumns(spec);\n // Verify pragma_table_info reports exactly these columns as PK members\n // (count + named membership); zero columns expected ⇒ no PK at all.\n const colCount = pkColumns.length;\n if (colCount === 0) {\n checks.push({\n description: `verify \"${tableName}\" has no primary key`,\n sql: `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = 0`,\n });\n } else {\n checks.push({\n description: `verify primary key on \"${tableName}\"`,\n sql:\n `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = ${colCount}` +\n ` AND (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0 AND name IN (${quoteSqlList(pkColumns)})) = ${colCount}`,\n });\n }\n }\n\n if (hasUniqueIssue) {\n for (const u of spec.uniques ?? []) {\n const colCount = u.columns.length;\n const description = u.name\n ? `verify unique constraint \"${u.name}\" on \"${tableName}\"`\n : `verify unique constraint (${u.columns.join(', ')}) on \"${tableName}\"`;\n // Match any unique index whose covered columns are exactly the expected\n // set. Order is intentionally not checked — SQLite's unique-index\n // identity is column-set, not column-sequence.\n checks.push({\n description,\n sql:\n `SELECT EXISTS (SELECT 1 FROM pragma_index_list('${t}') l` +\n ` WHERE l.\"unique\" = 1` +\n ` AND (SELECT COUNT(*) FROM pragma_index_info(l.name)) = ${colCount}` +\n ` AND (SELECT COUNT(*) FROM pragma_index_info(l.name) WHERE name IN (${quoteSqlList(u.columns)})) = ${colCount})`,\n });\n }\n }\n\n if (hasFkIssue) {\n for (const fk of spec.foreignKeys ?? []) {\n const refTable = escapeLiteral(fk.references.table);\n const colCount = fk.columns.length;\n // Build a `SUM(CASE WHEN (\"from\",\"to\") IN ((…)) …)` so the check works\n // for both single- and multi-column FKs without depending on FK row\n // ordering inside `pragma_foreign_key_list`.\n const tuples = fk.columns\n .map((from, i) => {\n const to = fk.references.columns[i] ?? from;\n return `('${escapeLiteral(from)}', '${escapeLiteral(to)}')`;\n })\n .join(', ');\n const description = `verify foreign key (${fk.columns.join(', ')}) → ${fk.references.table}(${fk.references.columns.join(', ')}) on \"${tableName}\"`;\n checks.push({\n description,\n sql:\n `SELECT EXISTS (SELECT 1 FROM pragma_foreign_key_list('${t}') f` +\n ` WHERE f.\"table\" = '${refTable}'` +\n ' GROUP BY f.id' +\n ` HAVING COUNT(*) = ${colCount}` +\n ` AND SUM(CASE WHEN (f.\"from\", f.\"to\") IN (${tuples}) THEN 1 ELSE 0 END) = ${colCount})`,\n });\n }\n }\n\n return checks;\n}\n","/**\n * SQLite migration IR: one concrete `*Call` class per pure factory under\n * `operations/`, plus a shared `SqliteOpFactoryCallNode` abstract base.\n *\n * Each call class carries fully-resolved literal arguments. `CreateTableCall`\n * holds structured `DdlColumn[]` + `DdlTableConstraint[]` and lowers via the\n * adapter's DDL path; other call classes carry flat SQL fragments. Codec /\n * `typeRef` / default expansion happens upstream in the issue-planner /\n * strategies, mirroring the Postgres `ColumnSpec` pattern.\n */\n\nimport { errorUnfilledPlaceholder } from '@prisma-next/errors/migration';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer, Lowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { OpFactoryCall as FrameworkOpFactoryCall } from '@prisma-next/framework-components/control';\nimport type {\n AnyDdlColumnDefault,\n DdlColumn,\n DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport { type ImportRequirement, jsonToTsSource, TsExpression } from '@prisma-next/ts-render';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { columnExistsAst, indexExistsAst, tableExistsAst } from '../../contract-free/checks';\nimport * as contractFreeDdl from '../../contract-free/ddl';\nimport { quoteIdentifier } from '../sql-utils';\nimport { addColumnExecuteSql, dropColumnExecuteSql } from './operations/columns';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport { step } from './operations/shared';\nimport { recreateTable } from './operations/tables';\nimport { buildCreateIndexSql, buildDropIndexSql } from './planner-ddl-builders';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\nimport { buildTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nconst TARGET_MIGRATION_MODULE = '@prisma-next/sqlite/migration';\n\nabstract class SqliteOpFactoryCallNode extends TsExpression implements FrameworkOpFactoryCall {\n abstract readonly factoryName: string;\n abstract readonly operationClass: MigrationOperationClass;\n abstract readonly label: string;\n abstract toOp(lowerer?: Lowerer): Op | Promise<Op>;\n\n importRequirements(): readonly ImportRequirement[] {\n return [{ moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: this.factoryName }];\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\n// ============================================================================\n// Table\n// ============================================================================\n\n// ---------------------------------------------------------------------------\n// TypeScript rendering helpers for DdlColumn / DdlTableConstraint\n// ---------------------------------------------------------------------------\n\nfunction renderDdlColumnDefault(def: AnyDdlColumnDefault | undefined): string {\n if (!def) return '';\n if (def.kind === 'literal') {\n return `lit(${jsonToTsSource(def.value)})`;\n }\n return `fn(${jsonToTsSource(def.expression)})`;\n}\n\nfunction renderDdlColumnAsTsCall(column: DdlColumn): string {\n const opts: string[] = [];\n if (column.notNull) opts.push('notNull: true');\n if (column.primaryKey) opts.push('primaryKey: true');\n if (column.default) opts.push(`default: ${renderDdlColumnDefault(column.default)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `col(${jsonToTsSource(column.name)}, ${jsonToTsSource(column.type)}${optsStr})`;\n}\n\nfunction renderDdlConstraintAsTsCall(constraint: DdlTableConstraint): string {\n switch (constraint.kind) {\n case 'primary-key': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `primaryKey(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n case 'foreign-key': {\n const opts: string[] = [];\n if (constraint.name) opts.push(`name: ${jsonToTsSource(constraint.name)}`);\n if (constraint.onDelete) opts.push(`onDelete: ${jsonToTsSource(constraint.onDelete)}`);\n if (constraint.onUpdate) opts.push(`onUpdate: ${jsonToTsSource(constraint.onUpdate)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `foreignKey(${jsonToTsSource(constraint.columns)}, ${jsonToTsSource(constraint.refTable)}, ${jsonToTsSource(constraint.refColumns)}${optsStr})`;\n }\n case 'unique': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n case 'check-expression':\n throw new Error(\n `SQLite does not support expression CHECK constraints (constraint \"${constraint.name}\"). ` +\n 'Scalar-array columns and their element-non-null checks are Postgres-only.',\n );\n }\n}\n\nfunction constraintImportSymbols(constraints: readonly DdlTableConstraint[] | undefined): string[] {\n if (!constraints || constraints.length === 0) return [];\n const symbols = new Set<string>();\n for (const c of constraints) {\n if (c.kind === 'primary-key') symbols.add('primaryKey');\n else if (c.kind === 'foreign-key') symbols.add('foreignKey');\n else if (c.kind === 'unique') symbols.add('unique');\n }\n return [...symbols];\n}\n\nfunction defaultImportSymbols(columns: readonly DdlColumn[]): string[] {\n const symbols = new Set<string>();\n for (const col of columns) {\n if (col.default?.kind === 'literal') symbols.add('lit');\n else if (col.default?.kind === 'function') symbols.add('fn');\n }\n return [...symbols];\n}\n\nexport class CreateTableCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'createTable' as const;\n readonly operationClass = 'additive' as const;\n readonly tableName: string;\n readonly columns: readonly DdlColumn[];\n readonly constraints: readonly DdlTableConstraint[] | undefined;\n readonly label: string;\n\n constructor(\n tableName: string,\n columns: readonly DdlColumn[],\n constraints?: readonly DdlTableConstraint[],\n ) {\n super();\n this.tableName = tableName;\n this.columns = Object.freeze([...columns]);\n this.constraints = constraints ? Object.freeze([...constraints]) : undefined;\n this.label = `Create table ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateTableCall.toOp: a DDL lowerer is required on the SQLite planner path (table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.createTable({\n table: this.tableName,\n columns: this.columns,\n ...ifDefined('constraints', this.constraints),\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const tableName = this.tableName;\n const tableChecks = tableExistsAst(tableName);\n const absent = await lowerer.lowerToExecuteRequest(tableChecks.tableAbsent());\n const present = await lowerer.lowerToExecuteRequest(tableChecks.tablePresent());\n return {\n id: `table.${tableName}`,\n label: `Create table ${tableName}`,\n summary: `Creates table ${tableName} with required columns`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [step(`ensure table \"${tableName}\" does not exist`, absent.sql, absent.params)],\n execute: [\n {\n description: `create table \"${tableName}\"`,\n sql: statement.sql,\n params: statement.params ?? [],\n },\n ],\n postcheck: [step(`verify table \"${tableName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n const columnsList = this.columns.map(renderDdlColumnAsTsCall).join(', ');\n const constraintsList = this.constraints\n ? this.constraints.map(renderDdlConstraintAsTsCall).join(', ')\n : undefined;\n\n const opts: string[] = [];\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`columns: [${columnsList}]`);\n if (constraintsList) opts.push(`constraints: [${constraintsList}]`);\n\n return `this.createTable({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n const req: ImportRequirement[] = [];\n if (this.columns.length > 0) {\n req.push({ moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: 'col' });\n for (const sym of defaultImportSymbols(this.columns)) {\n req.push({ moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: sym });\n }\n }\n for (const sym of constraintImportSymbols(this.constraints)) {\n req.push({ moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: sym });\n }\n return req;\n }\n}\n\nexport class DropTableCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'dropTable' as const;\n readonly operationClass = 'destructive' as const;\n readonly tableName: string;\n readonly label: string;\n\n constructor(tableName: string) {\n super();\n this.tableName = tableName;\n this.label = `Drop table ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropTableCall.toOp: a lowerer is required on the SQLite planner path (table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const checks = tableExistsAst(this.tableName);\n const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());\n return {\n id: `dropTable.${this.tableName}`,\n label: `Drop table ${this.tableName}`,\n summary: `Drops table ${this.tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('table', this.tableName) },\n precheck: [step(`ensure table \"${this.tableName}\" exists`, present.sql, present.params)],\n execute: [\n step(`drop table \"${this.tableName}\"`, `DROP TABLE ${quoteIdentifier(this.tableName)}`),\n ],\n postcheck: [step(`verify table \"${this.tableName}\" is gone`, absent.sql, absent.params)],\n };\n }\n\n renderTypeScript(): string {\n return `this.dropTable({ table: ${jsonToTsSource(this.tableName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class RecreateTableCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'recreateTable' as const;\n readonly operationClass: MigrationOperationClass;\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly label: string;\n\n constructor(args: {\n tableName: string;\n contractTable: SqliteTableSpec;\n schemaColumnNames: readonly string[];\n indexes: readonly SqliteIndexSpec[];\n summary: string;\n postchecks: readonly { readonly description: string; readonly sql: string }[];\n operationClass: MigrationOperationClass;\n }) {\n super();\n this.tableName = args.tableName;\n this.contractTable = args.contractTable;\n this.schemaColumnNames = args.schemaColumnNames;\n this.indexes = args.indexes;\n this.summary = args.summary;\n this.postchecks = args.postchecks;\n this.operationClass = args.operationClass;\n this.label = `Recreate table ${args.tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `RecreateTableCall.toOp: a lowerer is required on the SQLite planner path (table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n return recreateTable(\n {\n tableName: this.tableName,\n contractTable: this.contractTable,\n schemaColumnNames: this.schemaColumnNames,\n indexes: this.indexes,\n summary: this.summary,\n postchecks: this.postchecks,\n operationClass: this.operationClass,\n },\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n const args = {\n tableName: this.tableName,\n contractTable: this.contractTable,\n schemaColumnNames: this.schemaColumnNames,\n indexes: this.indexes,\n summary: this.summary,\n postchecks: this.postchecks,\n operationClass: this.operationClass,\n };\n return `this.recreateTable(${jsonToTsSource(args)})`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Column\n// ============================================================================\n\nexport class AddColumnCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'addColumn' as const;\n readonly operationClass = 'additive' as const;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: SqliteColumnSpec;\n readonly label: string;\n\n constructor(tableName: string, column: SqliteColumnSpec) {\n super();\n this.tableName = tableName;\n this.columnName = column.name;\n this.column = column;\n this.label = `Add column ${column.name} on ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddColumnCall.toOp: a lowerer is required on the SQLite planner path (column \"${this.column.name}\" on table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const checks = columnExistsAst(this.tableName, this.column.name);\n const absent = await lowerer.lowerToExecuteRequest(checks.columnAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.columnPresent());\n return {\n id: `column.${this.tableName}.${this.column.name}`,\n label: `Add column ${this.column.name} on ${this.tableName}`,\n summary: `Adds column ${this.column.name} on ${this.tableName}`,\n operationClass: 'additive',\n target: {\n id: 'sqlite',\n details: buildTargetDetails('column', this.column.name, this.tableName),\n },\n precheck: [step(`ensure column \"${this.column.name}\" is missing`, absent.sql, absent.params)],\n execute: [\n step(`add column \"${this.column.name}\"`, addColumnExecuteSql(this.tableName, this.column)),\n ],\n postcheck: [step(`verify column \"${this.column.name}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n return `this.addColumn({ table: ${jsonToTsSource(this.tableName)}, column: ${jsonToTsSource(this.column)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropColumnCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'dropColumn' as const;\n readonly operationClass = 'destructive' as const;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(tableName: string, columnName: string) {\n super();\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop column ${columnName} on ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropColumnCall.toOp: a lowerer is required on the SQLite planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const checks = columnExistsAst(this.tableName, this.columnName);\n const present = await lowerer.lowerToExecuteRequest(checks.columnPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.columnAbsent());\n return {\n id: `dropColumn.${this.tableName}.${this.columnName}`,\n label: `Drop column ${this.columnName} on ${this.tableName}`,\n summary: `Drops column ${this.columnName} on ${this.tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: {\n id: 'sqlite',\n details: buildTargetDetails('column', this.columnName, this.tableName),\n },\n precheck: [\n step(\n `ensure column \"${this.columnName}\" exists on \"${this.tableName}\"`,\n present.sql,\n present.params,\n ),\n ],\n execute: [\n step(\n `drop column \"${this.columnName}\" from \"${this.tableName}\"`,\n dropColumnExecuteSql(this.tableName, this.columnName),\n ),\n ],\n postcheck: [\n step(\n `verify column \"${this.columnName}\" is gone from \"${this.tableName}\"`,\n absent.sql,\n absent.params,\n ),\n ],\n };\n }\n\n renderTypeScript(): string {\n return `this.dropColumn({ table: ${jsonToTsSource(this.tableName)}, column: ${jsonToTsSource(this.columnName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Index\n// ============================================================================\n\nexport class CreateIndexCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'createIndex' as const;\n readonly operationClass = 'additive' as const;\n readonly tableName: string;\n readonly indexName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(tableName: string, indexName: string, columns: readonly string[]) {\n super();\n this.tableName = tableName;\n this.indexName = indexName;\n this.columns = columns;\n this.label = `Create index ${indexName} on ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateIndexCall.toOp: a lowerer is required on the SQLite planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const checks = indexExistsAst(this.indexName);\n const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());\n return {\n id: `index.${this.tableName}.${this.indexName}`,\n label: `Create index ${this.indexName} on ${this.tableName}`,\n summary: `Creates index ${this.indexName} on ${this.tableName}`,\n operationClass: 'additive',\n target: {\n id: 'sqlite',\n details: buildTargetDetails('index', this.indexName, this.tableName),\n },\n precheck: [step(`ensure index \"${this.indexName}\" is missing`, absent.sql, absent.params)],\n execute: [\n step(\n `create index \"${this.indexName}\"`,\n buildCreateIndexSql(this.tableName, this.indexName, this.columns),\n ),\n ],\n postcheck: [step(`verify index \"${this.indexName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n return `this.createIndex({ table: ${jsonToTsSource(this.tableName)}, index: ${jsonToTsSource(this.indexName)}, columns: ${jsonToTsSource(this.columns)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropIndexCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'dropIndex' as const;\n readonly operationClass = 'destructive' as const;\n readonly tableName: string;\n readonly indexName: string;\n readonly label: string;\n\n constructor(tableName: string, indexName: string) {\n super();\n this.tableName = tableName;\n this.indexName = indexName;\n this.label = `Drop index ${indexName} on ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropIndexCall.toOp: a lowerer is required on the SQLite planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createSqliteMigrationPlanner.`,\n );\n }\n const checks = indexExistsAst(this.indexName);\n const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());\n return {\n id: `dropIndex.${this.tableName}.${this.indexName}`,\n label: `Drop index ${this.indexName} on ${this.tableName}`,\n summary: `Drops index ${this.indexName} on ${this.tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: {\n id: 'sqlite',\n details: buildTargetDetails('index', this.indexName, this.tableName),\n },\n precheck: [step(`ensure index \"${this.indexName}\" exists`, present.sql, present.params)],\n execute: [step(`drop index \"${this.indexName}\"`, buildDropIndexSql(this.indexName))],\n postcheck: [step(`verify index \"${this.indexName}\" is gone`, absent.sql, absent.params)],\n };\n }\n\n renderTypeScript(): string {\n return `this.dropIndex({ table: ${jsonToTsSource(this.tableName)}, index: ${jsonToTsSource(this.indexName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Data transform\n// ============================================================================\n\n/**\n * A planner-generated data-transform stub. The current default strategy\n * (`nullabilityTighteningBackfillStrategy`) emits one of these with a\n * backfill-flavored `id`/`label` when the policy allows `'data'` and the\n * contract tightens a column's nullability, but the op itself is generic —\n * any future strategy that needs a placeholder data step can construct one\n * with its own id/label.\n *\n * `toOp()` always throws `PN-MIG-2001`: the planner cannot lower a stubbed\n * transform to a runtime op — the user must edit the rendered\n * `migration.ts` and re-emit.\n */\nexport class DataTransformCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'dataTransform' as const;\n readonly operationClass = 'data' as const;\n readonly id: string;\n readonly label: string;\n readonly tableName: string;\n readonly columnName: string;\n\n constructor(id: string, label: string, tableName: string, columnName: string) {\n super();\n this.id = id;\n this.label = label;\n this.tableName = tableName;\n this.columnName = columnName;\n this.freeze();\n }\n\n toOp(_lowerer?: Lowerer): Op {\n throw errorUnfilledPlaceholder(this.label);\n }\n\n renderTypeScript(): string {\n const slot = `${this.tableName}-${this.columnName}-backfill-sql`;\n return [\n 'dataTransform({',\n ` id: ${jsonToTsSource(this.id)},`,\n ` label: ${jsonToTsSource(this.label)},`,\n ` table: ${jsonToTsSource(this.tableName)},`,\n ` description: ${jsonToTsSource(`Backfill NULL ${this.columnName} values in ${this.tableName}`)},`,\n ` run: () => placeholder(${jsonToTsSource(slot)}),`,\n '})',\n ].join('\\n');\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [\n { moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: this.factoryName },\n { moduleSpecifier: TARGET_MIGRATION_MODULE, symbol: 'placeholder' },\n ];\n }\n}\n\n// ============================================================================\n// Raw SQL\n// ============================================================================\n\n/**\n * Laundered pre-built operation. Mirrors Postgres's `RawSqlCall`: wraps an\n * already-materialized `SqlMigrationPlanOperation` (typically produced by a\n * SQL-family helper or a codec lifecycle hook) so the planner can carry it\n * alongside structured call IR. `toOp()` returns the stored op unchanged;\n * `renderTypeScript()` emits `rawSql({...})` with the op serialized as a\n * JSON literal — round-tripping requires every field on the op to be\n * JSON-serializable (no closures).\n */\nexport class RawSqlCall extends SqliteOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly op: Op;\n\n constructor(op: Op) {\n super();\n this.op = op;\n this.label = op.label;\n this.operationClass = op.operationClass;\n this.freeze();\n }\n\n toOp(_lowerer?: Lowerer): Op {\n return this.op;\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource(this.op)})`;\n }\n}\n\n// ============================================================================\n// Union\n// ============================================================================\n\nexport type SqliteOpFactoryCall =\n | CreateTableCall\n | DropTableCall\n | RecreateTableCall\n | AddColumnCall\n | DropColumn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