@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.
- package/dist/control.mjs +1 -1
- package/dist/migration.mjs +2 -2
- package/dist/{op-factory-call-D_eYsHTp.mjs → op-factory-call-Do03QgD9.mjs} +4 -5
- package/dist/op-factory-call-Do03QgD9.mjs.map +1 -0
- package/dist/op-factory-call.mjs +1 -1
- package/dist/{planner-DhvFrgPT.mjs → planner-BD1QRojv.mjs} +25 -31
- package/dist/planner-BD1QRojv.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-DyRmcteq.mjs → planner-produced-sqlite-migration-DEkfABc8.mjs} +2 -2
- package/dist/{planner-produced-sqlite-migration-DyRmcteq.mjs.map → planner-produced-sqlite-migration-DEkfABc8.mjs.map} +1 -1
- package/dist/planner-produced-sqlite-migration.mjs +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{sqlite-migration-D93wCdSD.mjs → sqlite-migration-C68ZaNwH.mjs} +2 -2
- package/dist/{sqlite-migration-D93wCdSD.mjs.map → sqlite-migration-C68ZaNwH.mjs.map} +1 -1
- package/package.json +18 -18
- package/src/core/migrations/diff-database-schema.ts +23 -33
- package/src/core/migrations/issue-planner.ts +10 -8
- package/src/core/migrations/operations/tables.ts +3 -4
- package/dist/op-factory-call-D_eYsHTp.mjs.map +0 -1
- package/dist/planner-DhvFrgPT.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-DhvFrgPT.mjs","names":["exhaustive","#lowerer"],"sources":["../src/core/migrations/diff-database-schema.ts","../src/core/migrations/column-ddl-rendering.ts","../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts","../src/core/migrations/planner.ts"],"sourcesContent":["import type { ColumnDefault, Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { NativeTypeExpander, SqlSchemaDiffResult } from '@prisma-next/family-sql/control';\nimport { buildNativeTypeExpander, contractToSchemaIR } from '@prisma-next/family-sql/control';\nimport {\n neutralizeFlatExpectedFkSchemas,\n normalizeFlatActualForDiff,\n verifySqlSchemaByDiff,\n} from '@prisma-next/family-sql/diff';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n SchemaDiffIssue,\n VerifyDatabaseSchemaResult,\n} from '@prisma-next/framework-components/control';\nimport { diffSchemas } from '@prisma-next/framework-components/control';\nimport { entityAt } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage, StorageColumn, StorageTable } from '@prisma-next/sql-contract/types';\nimport type {\n SqlColumnIRInput,\n SqlSchemaIRInput,\n SqlSchemaIRNode,\n SqlTableIRInput,\n} from '@prisma-next/sql-schema-ir/types';\nimport { relationalNodeGranularity, SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { renderDefaultLiteral } from './planner-ddl-builders';\n\ninterface SqliteDiffDatabaseSchemaInput {\n readonly contract: Contract<SqlStorage>;\n readonly actualSchema: SqlSchemaIRNode;\n readonly strict: boolean;\n readonly typeMetadataRegistry: ReadonlyMap<string, { readonly nativeType?: string }>;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n/** Renders a column default for the SQLite dialect. */\nexport function sqliteRenderDefault(def: ColumnDefault, _column: StorageColumn): string {\n if (def.kind === 'function') {\n if (def.expression === 'now()') {\n return \"datetime('now')\";\n }\n return def.expression;\n }\n return renderDefaultLiteral(def.value);\n}\n\n/**\n * The SQLite expected-side projection: contract → flat relational schema IR.\n *\n * `extras` thread the plan-time derivation input: the native-type expander,\n * so the expected side carries resolved native types (like the verify\n * side). Every expected column also carries its `codecRef` unconditionally\n * (Decision 5) — the planner's op-builders resolve DDL rendering from it at\n * plan time, so no separate render stamper is threaded here.\n */\nexport function sqliteContractToSchema(\n contract: Contract<SqlStorage> | null,\n extras?: {\n readonly expandNativeType?: NativeTypeExpander;\n },\n): SqlSchemaIR {\n return contractToSchemaIR(contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n ...ifDefined('expandNativeType', extras?.expandNativeType),\n });\n}\n\n/**\n * The SQLite schema verify: the full-tree node-diff verdict wrapped in the\n * issue-based result envelope. Used by the runner's post-apply check; the\n * family `verifySchema` runs the same composition via the descriptor hook.\n */\nexport function verifySqliteDatabaseSchema(\n input: SqliteDiffDatabaseSchemaInput,\n): VerifyDatabaseSchemaResult {\n return verifySqlSchemaByDiff({\n contract: input.contract,\n schema: input.actualSchema,\n strict: input.strict,\n frameworkComponents: input.frameworkComponents,\n diffSchema: diffSqliteSchema,\n granularityOf: relationalNodeGranularity,\n });\n}\n\n/**\n * Resolves a verdict-diff issue's subject table's declared control policy\n * directly from the contract. SQLite's expected tree is flat, so the issue\n * path carries no namespace segment — `path[1]` is the table name (`path[0]`\n * is the tree root's own id); every contract namespace is searched for that\n * table name (table names are globally unique in the flat tree — duplicates\n * across namespaces are rejected earlier, at `contractToSchemaIR`).\n */\nfunction resolveControlPolicy(\n issue: SchemaDiffIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicy | undefined {\n const tableName = issue.path[1];\n if (tableName === undefined) return undefined;\n for (const namespaceId of Object.keys(contract.storage.namespaces)) {\n const table = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: tableName,\n });\n if (table !== undefined) return table.control;\n }\n return undefined;\n}\n\n/**\n * The SQLite full-tree node diff for the family verify verdict: derive the\n * expected flat tree with resolved leaf values (expander threaded so\n * parameterized types compare expanded), neutralize the FK schema segment\n * (single-schema target — introspection stamps none), normalize the actual\n * tree for semantic satisfaction, and run the generic differ. Flat targets\n * need no ownership scoping. The codec `verifyType` hooks run once per\n * contract namespace with tables, each against the sole flat actual root —\n * exactly the legacy per-namespace pairing.\n */\nexport function diffSqliteSchema(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): SqlSchemaDiffResult {\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const expected = neutralizeFlatExpectedFkSchemas(\n contractToSchemaIR(input.contract, {\n annotationNamespace: 'sqlite',\n renderDefault: sqliteRenderDefault,\n ...ifDefined('expandNativeType', expandNativeType),\n }),\n );\n const actual =\n input.schema instanceof SqlSchemaIR\n ? input.schema\n : blindCast<\n SqlSchemaIR,\n 'the SQLite introspection adapter always produces a flat SqlSchemaIR root'\n >(input.schema);\n const normalizedActual = normalizeFlatActualForDiff(expected, actual);\n const issues = diffSchemas(expected, normalizedActual);\n const namespacesWithTables = Object.values(input.contract.storage.namespaces).filter(\n (ns) => Object.keys(ns.entries.table ?? {}).length > 0,\n );\n return {\n issues,\n resolveControlPolicy: (issue) => resolveControlPolicy(issue, input.contract),\n namespacePairs: namespacesWithTables.map(() => ({ actual })),\n };\n}\n\nexport interface SqlitePlanDiff {\n /** The desired (\"end\") tree — resolved leaf values, incl. `codecRef`, on every column. */\n readonly expected: SqlSchemaIR;\n /** The live (\"start\") tree, normalized for semantic satisfaction against `expected`. */\n readonly actual: SqlSchemaIR;\n readonly issues: readonly SchemaDiffIssue[];\n}\n\n/**\n * The SQLite planner's diff input: the same tree-building\n * `diffSqliteSchema` uses (expander threaded, FK schema segment\n * neutralized, actual tree normalized for semantic satisfaction). One differ\n * drives both verify and plan; this is the plan-side derivation — column DDL\n * resolves from each expected column's `codecRef` at plan time\n * (`column-ddl-rendering.ts`), so no separate render stamping happens here.\n */\nexport function buildSqlitePlanDiff(input: {\n readonly contract: Contract<SqlStorage>;\n readonly actualSchema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): SqlitePlanDiff {\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const expected = neutralizeFlatExpectedFkSchemas(\n sqliteContractToSchema(input.contract, {\n ...ifDefined('expandNativeType', expandNativeType),\n }),\n );\n // The differ dispatches polymorphically (`.isEqualTo()` / `.children()`), so\n // the actual tree must be genuine `SqlSchemaIR`/`SqlTableIR`/`SqlColumnIR`\n // instances, not plain data shaped like them. `new SqlSchemaIR(...)`\n // normalizes either input uniformly (an already-real tree passes through\n // untouched — its nested values are already instances) and is a no-op\n // rebuild in the common (real-instance) case, so this is always safe to run.\n const actualRaw = new SqlSchemaIR(withRecordKeyNames(input.actualSchema));\n const actual = normalizeFlatActualForDiff(expected, actualRaw);\n const issues = diffSchemas(expected, actual);\n return { expected, actual, issues };\n}\n\n/**\n * Every schema-tree builder in this codebase derives a table's / column's\n * `name` from the record key it's stored under (`contractToSchemaIR`,\n * the SQLite introspection adapter) rather than trusting a redundant\n * embedded field — the record key IS the identity. Mirrors that discipline\n * for the actual/live tree before construction, so `SqlTableIR.id` /\n * `SqlColumnIR.id` (both derived from `.name`) are always correct without\n * requiring every caller to duplicate the key onto the value. A no-op for a\n * tree that already carries matching names (the real introspection adapter\n * always does).\n */\nfunction withRecordKeyNames(actualSchema: SqlSchemaIRNode): SqlSchemaIRInput {\n const raw = blindCast<\n { readonly tables?: Readonly<Record<string, unknown>> },\n 'the SQLite introspection adapter always produces a flat, tables-keyed root'\n >(actualSchema);\n const tables: Record<string, SqlTableIRInput> = {};\n for (const [tableName, table] of Object.entries(raw.tables ?? {})) {\n const rawTable = blindCast<\n Omit<SqlTableIRInput, 'name' | 'columns'>,\n 'every table value in a tables record is SqlTableIR(Input)-shaped'\n >(table);\n const columns: Record<string, SqlColumnIRInput> = {};\n for (const [columnName, column] of Object.entries(\n blindCast<\n { readonly columns?: Readonly<Record<string, unknown>> },\n 'every SqlTableIR(Input) carries a columns record keyed by column name'\n >(table).columns ?? {},\n )) {\n columns[columnName] = {\n ...blindCast<\n SqlColumnIRInput,\n 'every column value in a columns record is SqlColumnIR(Input)-shaped'\n >(column),\n name: columnName,\n };\n }\n tables[tableName] = {\n ...rawTable,\n name: tableName,\n columns,\n foreignKeys: rawTable.foreignKeys ?? [],\n uniques: rawTable.uniques ?? [],\n indexes: rawTable.indexes ?? [],\n };\n }\n return { tables };\n}\n","import type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport {\n DdlColumn,\n type DdlTableConstraint,\n ForeignKeyConstraint,\n FunctionColumnDefault,\n LiteralColumnDefault,\n PrimaryKeyConstraint,\n UniqueConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { SqlColumnIR, SqlTableIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { SqliteColumnSpec } from './operations/shared';\nimport { buildColumnDefaultSql, buildColumnTypeSql } from './planner-ddl-builders';\n\n/**\n * Reconstructs the `StorageColumn`-shaped fields `buildColumnTypeSql` /\n * `buildColumnDefaultSql` expect, from a column node's own stamped codec\n * identity (`codecRef` / `codecBaseNativeType`, Decision 5) — never the\n * contract. SQLite's type renderer only uppercases the resolved base type\n * (no parameterized expansion, no named-type quoting), so `typeRef` is\n * deliberately left unset here: setting it would send `buildColumnTypeSql`\n * back through a live `storageTypes` lookup the node's fields have already\n * resolved past, which throws for an unrecognized reference (unlike\n * Postgres's lenient fallback).\n */\nfunction columnLike(\n column: SqlColumnIR,\n): Pick<StorageColumn, 'nativeType' | 'codecId' | 'nullable' | 'many' | 'typeParams' | 'default'> {\n if (column.codecRef === undefined || column.codecBaseNativeType === undefined) {\n throw new Error(\n `columnLike: expected column \"${column.name}\" carries no codec identity — the expected tree must be derived via contractToSchemaIR for planning`,\n );\n }\n return {\n nativeType: column.codecBaseNativeType,\n codecId: column.codecRef.codecId,\n nullable: column.nullable,\n // `column.many` is unset on contract-derived columns (array-ness rides\n // on the `nativeType` `[]` suffix there instead) — `codecRef.many`\n // carries it. Hand-built/introspected columns set `column.many` directly.\n ...((column.many ?? column.codecRef.many) !== undefined\n ? { many: column.many ?? column.codecRef.many }\n : {}),\n ...(column.codecRef.typeParams !== undefined\n ? {\n typeParams: blindCast<\n Record<string, unknown>,\n 'CodecRef.typeParams is JsonValue-shaped; the DDL builders only ever read it as the Record the contract column originally carried'\n >(column.codecRef.typeParams),\n }\n : {}),\n ...(column.resolvedDefault !== undefined ? { default: column.resolvedDefault } : {}),\n };\n}\n\nfunction sqliteDefaultToDdlColumnDefault(\n columnDefault: StorageColumn['default'],\n): DdlColumn['default'] {\n if (!columnDefault) return undefined;\n switch (columnDefault.kind) {\n case 'literal':\n return new LiteralColumnDefault(columnDefault.value);\n case 'function':\n // `autoincrement()` is not a DEFAULT clause — SQLite encodes it as\n // `INTEGER PRIMARY KEY AUTOINCREMENT` inline on the column. Skip it\n // here; the renderer also has a defensive guard for the same case.\n if (columnDefault.expression === 'autoincrement()') return undefined;\n return new FunctionColumnDefault(columnDefault.expression);\n default: {\n const exhaustive: never = columnDefault;\n throw new Error(\n `sqliteDefaultToDdlColumnDefault: unhandled kind \"${blindCast<{ kind: string }, 'exhaustiveness: surface the unhandled default kind'>(exhaustive).kind}\"`,\n );\n }\n }\n}\n\n/**\n * True when the column is rendered inline as `INTEGER PRIMARY KEY\n * AUTOINCREMENT` — the sole member of the table's primary key with an\n * `autoincrement()` default. Node-based sibling of the retired\n * `isInlineAutoincrementPrimaryKey` (which read the raw `StorageTable`);\n * reads the table/column nodes instead.\n */\nexport function isInlineAutoincrementPrimaryKeyNode(\n table: SqlTableIR,\n column: SqlColumnIR,\n): boolean {\n if (table.primaryKey?.columns.length !== 1) return false;\n if (table.primaryKey.columns[0] !== column.name) return false;\n return (\n column.resolvedDefault?.kind === 'function' &&\n column.resolvedDefault.expression === 'autoincrement()'\n );\n}\n\n/**\n * Builds the flat `SqliteColumnSpec` `AddColumnCall` / `RecreateTableCall`\n * need, resolved from the column node's codec identity — the same builders\n * the pre-`plan(start, end)` op-path called, so the output is\n * byte-identical.\n */\nexport function columnSpecFromNode(column: SqlColumnIR, inline: boolean): SqliteColumnSpec {\n const like = columnLike(column);\n const typeSql = buildColumnTypeSql(like, {});\n const defaultSql = buildColumnDefaultSql(like.default);\n return {\n name: column.name,\n typeSql,\n defaultSql,\n nullable: column.nullable,\n ...(inline ? { inlineAutoincrementPrimaryKey: true } : {}),\n };\n}\n\n/**\n * Builds the `DdlColumn` the `CreateTableCall` path needs, resolved from the\n * column node's codec identity.\n */\nexport function ddlColumnFromNode(column: SqlColumnIR, inline: boolean): DdlColumn {\n const like = columnLike(column);\n const typeSql = buildColumnTypeSql(like, {});\n if (inline) {\n // `DdlColumn` has no SQLite-specific autoincrement flag, so the full\n // `PRIMARY KEY AUTOINCREMENT` clause is embedded in the `type` string.\n // The DDL renderer (`ddl-renderer.ts`) substring-detects `AUTOINCREMENT`\n // to suppress the normal NOT NULL / PRIMARY KEY / DEFAULT clause rendering\n // and emit the entire type string verbatim. Both sites must stay in sync.\n // The structural fix (a SQLite-specific column option) is tracked in TML-2866.\n return new DdlColumn({ name: column.name, type: `${typeSql} PRIMARY KEY AUTOINCREMENT` });\n }\n const colDefault = sqliteDefaultToDdlColumnDefault(like.default);\n return new DdlColumn({\n name: column.name,\n type: typeSql,\n ...(!column.nullable ? { notNull: true } : {}),\n ...(colDefault !== undefined ? { default: colDefault } : {}),\n ...(column.codecRef !== undefined ? { codecRef: column.codecRef } : {}),\n });\n}\n\n/**\n * Builds the table-level constraints (PK / unique / FK) for a `CreateTable`\n * path from the table node — the node-sourced sibling of the retired\n * contract-based `tableToDdlParts`'s constraint half.\n */\nexport function tableConstraintsFromNode(\n table: SqlTableIR,\n hasInlinePk: boolean,\n): DdlTableConstraint[] {\n const constraints: DdlTableConstraint[] = [];\n if (table.primaryKey && !hasInlinePk) {\n constraints.push(new PrimaryKeyConstraint({ columns: table.primaryKey.columns }));\n }\n for (const u of table.uniques) {\n constraints.push(\n new UniqueConstraint({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }),\n );\n }\n for (const fk of table.foreignKeys) {\n constraints.push(\n new ForeignKeyConstraint({\n columns: fk.columns,\n refTable: fk.referencedTable,\n refColumns: fk.referencedColumns,\n ...(fk.name !== undefined ? { name: fk.name } : {}),\n ...(fk.onDelete !== undefined ? { onDelete: fk.onDelete } : {}),\n ...(fk.onUpdate !== undefined ? { onUpdate: fk.onUpdate } : {}),\n }),\n );\n }\n return constraints;\n}\n","/**\n * SQLite migration strategies.\n *\n * Each strategy examines the node-typed issue list, consumes issues it\n * handles, and returns the `SqliteOpFactoryCall[]` to address them. The issue\n * planner runs each strategy in order and routes whatever's left through\n * `mapNodeIssueToCall`.\n *\n * SQLite has no enums, no data-safe backfill, and no component-declared\n * database dependencies. The only recipe that needs strategy-level\n * multi-issue consumption is `recreateTable`, which absorbs\n * type/nullability/default/constraint mismatches for a given table into a\n * single recreate operation.\n */\n\nimport type {\n MigrationOperationClass,\n MigrationOperationPolicy,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport {\n RelationalSchemaNodeKind,\n type SqlColumnIR,\n type SqlSchemaIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { columnTypeChanged, tableSpecFromNode } from './issue-planner';\nimport { DataTransformCall, RecreateTableCall, type SqliteOpFactoryCall } from './op-factory-call';\nimport type { SqliteIndexSpec } from './operations/shared';\nimport { buildRecreatePostchecks, buildRecreateSummary } from './operations/tables';\n\nexport interface StrategyContext {\n /** The desired (\"end\") tree — resolved leaf values, incl. `codecRef`. */\n readonly expected: SqlSchemaIR;\n /** The live (\"start\") tree. */\n readonly actual: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaDiffIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaDiffIssue[];\n calls: readonly SqliteOpFactoryCall[];\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\n// ============================================================================\n// Recreate-table strategy\n// ============================================================================\n\n/**\n * Classifies a node issue into the operation class a recreate absorbing it\n * would need, or `null` when the strategy doesn't handle this node/reason at\n * all (table/column not-found-or-not-expected, and index issues — those are\n * standalone ops, never folded into a recreate).\n *\n * Column drift is a single `not-equal` issue now (type AND nullability\n * compared together by `SqlColumnIR.isEqualTo`), so this reads both fields\n * off the node pair directly rather than trusting a separate issue kind per\n * attribute: a type change is always destructive; a pure nullability change\n * is destructive when tightening (NOT NULL required) and widening when\n * relaxing.\n */\nfunction classifyNodeIssue(issue: SchemaDiffIssue): 'widening' | 'destructive' | null {\n const node = issue.expected ?? issue.actual;\n if (node === undefined) return null;\n const nodeKind = blindCast<\n { readonly nodeKind: string },\n 'every diff-tree node declares nodeKind'\n >(node).nodeKind;\n switch (nodeKind) {\n case RelationalSchemaNodeKind.column: {\n if (issue.reason !== 'not-equal') return null;\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 (columnTypeChanged(expected, actual)) return 'destructive';\n // Type is unchanged, so `not-equal` here means only nullability\n // differs: relaxing (NOT NULL → nullable) is safe; tightening is not.\n return expected.nullable ? 'widening' : 'destructive';\n }\n case RelationalSchemaNodeKind.columnDefault:\n return issue.reason === 'not-expected' ? 'destructive' : 'widening';\n case RelationalSchemaNodeKind.primaryKey:\n case RelationalSchemaNodeKind.foreignKey:\n case RelationalSchemaNodeKind.unique:\n return 'destructive';\n default:\n return null;\n }\n}\n\n/**\n * Groups recreate-eligible issues by table, decides per-table operation class\n * (destructive wins over widening), and emits one `RecreateTableCall` per\n * table. Returns unchanged-or-smaller issue list — issues the strategy\n * consumed are removed so `mapNodeIssueToCall` doesn't double-handle them.\n *\n * The full desired/live table shapes come from `ctx.expected`/`ctx.actual`\n * directly (keyed by table name — SQLite is a flat, single-namespace target)\n * rather than from any individual issue, since a single drifted attribute's\n * issue only carries that attribute's own node, never the whole table.\n */\nexport const recreateTableStrategy: CallMigrationStrategy = (issues, ctx) => {\n const byTable = new Map<string, { issues: SchemaDiffIssue[]; hasDestructive: boolean }>();\n const consumed = new Set<SchemaDiffIssue>();\n\n for (const issue of issues) {\n const cls = classifyNodeIssue(issue);\n if (!cls) continue;\n const tableName = issue.path[1];\n if (tableName === undefined) continue;\n const entry = byTable.get(tableName);\n if (entry) {\n entry.issues.push(issue);\n if (cls === 'destructive') entry.hasDestructive = true;\n } else {\n byTable.set(tableName, { issues: [issue], hasDestructive: cls === 'destructive' });\n }\n consumed.add(issue);\n }\n\n if (byTable.size === 0) return { kind: 'no_match' };\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const [tableName, entry] of byTable) {\n const expectedTable = ctx.expected.tables[tableName];\n const actualTable = ctx.actual.tables[tableName];\n if (!expectedTable || !actualTable) continue;\n const operationClass: MigrationOperationClass = entry.hasDestructive\n ? 'destructive'\n : 'widening';\n\n // Flatten the expected table node to a self-contained spec — the Call\n // holds pre-rendered SQL fragments only, no schema-IR node.\n const tableSpec = tableSpecFromNode(expectedTable);\n\n // Indexes (declared + FK-backing) are already merged and deduped by\n // column-set at derivation (`contractToSchemaIR`'s `convertTable`).\n const indexes: SqliteIndexSpec[] = expectedTable.indexes.map((idx) => ({\n name: idx.name ?? defaultIndexName(tableName, idx.columns),\n columns: idx.columns,\n }));\n\n calls.push(\n new RecreateTableCall({\n tableName,\n contractTable: tableSpec,\n schemaColumnNames: Object.keys(actualTable.columns),\n indexes,\n summary: buildRecreateSummary(tableName, entry.issues),\n postchecks: buildRecreatePostchecks(tableName, entry.issues, tableSpec),\n operationClass,\n }),\n );\n }\n\n return {\n kind: 'match',\n issues: issues.filter((i) => !consumed.has(i)),\n calls,\n recipe: true,\n };\n};\n\n// ============================================================================\n// Nullability-tightening backfill strategy\n// ============================================================================\n\n/**\n * When the policy allows `'data'` and the expected tree tightens one or more\n * columns from nullable to NOT NULL, emit a `DataTransformCall` stub per\n * tightened column. The user fills the backfill `UPDATE` in the rendered\n * `migration.ts` before the subsequent `RecreateTableCall` copies data into\n * the tightened schema (whose `INSERT INTO temp SELECT … FROM old` would\n * otherwise fail at runtime if any `NULL`s remain).\n *\n * Does NOT consume the tightening issue — `recreateTableStrategy` still\n * needs it to produce the actual recreate that enforces the NOT NULL at\n * the schema level. The backfill op and the recreate op end up in the\n * recipe slot in strategy order (backfill first, recreate second), which\n * matches the required execution order.\n *\n * Mirrors Postgres's `nullableTighteningCallStrategy` / `'data'`-class\n * gating. When `'data'` is not in the policy (the default `db update` /\n * `db init` path), the strategy short-circuits and the recreate alone\n * runs with its current destructive-class gating — preserving today's\n * behavior where a tightening blows up at runtime if NULLs are present.\n */\nexport const nullabilityTighteningBackfillStrategy: CallMigrationStrategy = (issues, ctx) => {\n if (!ctx.policy.allowedOperationClasses.includes('data')) {\n return { kind: 'no_match' };\n }\n\n const calls: SqliteOpFactoryCall[] = [];\n for (const issue of issues) {\n if (\n issue.reason !== 'not-equal' ||\n issue.expected === undefined ||\n issue.actual === undefined\n ) {\n continue;\n }\n const expected = blindCast<\n { readonly nodeKind: string },\n 'every diff-tree node declares nodeKind'\n >(issue.expected).nodeKind;\n if (expected !== RelationalSchemaNodeKind.column) continue;\n\n const expectedColumn = blindCast<\n SqlColumnIR,\n 'a not-equal column issue carries the expected node'\n >(issue.expected);\n const actualColumn = blindCast<SqlColumnIR, 'a not-equal column issue carries the actual node'>(\n issue.actual,\n );\n if (expectedColumn.nullable === actualColumn.nullable) continue; // not a nullability change\n if (expectedColumn.nullable) continue; // relaxing — no backfill needed\n\n const tableName = issue.path[1];\n if (tableName === undefined) continue;\n\n calls.push(\n new DataTransformCall(\n `data_migration.backfill-${tableName}-${expectedColumn.name}`,\n `Backfill NULLs in \"${tableName}\".\"${expectedColumn.name}\" before NOT NULL tightening`,\n tableName,\n expectedColumn.name,\n ),\n );\n }\n\n if (calls.length === 0) return { kind: 'no_match' };\n\n return {\n kind: 'match',\n issues,\n calls,\n recipe: true,\n };\n};\n\nexport const sqlitePlannerStrategies: readonly CallMigrationStrategy[] = [\n nullabilityTighteningBackfillStrategy,\n recreateTableStrategy,\n];\n","/**\n * SQLite migration issue planner.\n *\n * Takes node-typed schema-diff issues (from the one differ — see\n * `buildSqlitePlanDiff` in `diff-database-schema.ts`) and emits migration IR\n * (`SqliteOpFactoryCall[]`). Strategies consume issues they recognize and\n * produce specialized call sequences (e.g. `recreateTableStrategy` absorbs\n * type/nullability/default/constraint mismatches into a single recreate op);\n * remaining issues flow through `mapNodeIssueToCall` for the default case.\n *\n * Every branch reads the diff node the issue carries (`issue.expected` /\n * `issue.actual`) — never the contract, never `storageTypes`, never codec\n * hooks. Column DDL resolves from the column node's `codecRef`\n * (`column-ddl-rendering.ts`), never a recomputation against the contract.\n */\n\nimport type {\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport {\n RelationalSchemaNodeKind,\n type SqlColumnIR,\n type SqlIndexIR,\n SqlSchemaIR,\n type SqlSchemaIRNode,\n type SqlTableIR,\n} from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { CONTROL_TABLE_NAMES } from '../control-tables';\nimport {\n columnSpecFromNode,\n ddlColumnFromNode,\n isInlineAutoincrementPrimaryKeyNode,\n tableConstraintsFromNode,\n} from './column-ddl-rendering';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n type SqliteOpFactoryCall,\n} from './op-factory-call';\nimport type {\n SqliteColumnSpec,\n SqliteForeignKeySpec,\n SqliteTableSpec,\n SqliteUniqueSpec,\n} from './operations/shared';\nimport {\n type CallMigrationStrategy,\n type StrategyContext,\n sqlitePlannerStrategies,\n} from './planner-strategies';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n// ============================================================================\n// Node-keyed issue ordering (dependency order)\n// ============================================================================\n\n/**\n * Re-keys the legacy `ISSUE_KIND_ORDER` (kind string → priority number) on\n * `(nodeKind, reason)`. Numbers are preserved from the legacy table so the\n * dependency intent stays legible; the final emission order is actually\n * fixed downstream by category bucketing (create-table → add-column →\n * create-index → recreate → drop-column → drop-index → drop-table), so this\n * only breaks ties within a single bucket.\n */\nexport function nodeIssueOrder(issue: SchemaDiffIssue): number {\n const node = issueNode(issue);\n if (node === undefined) return 99;\n switch (node.nodeKind) {\n case RelationalSchemaNodeKind.foreignKey:\n return issue.reason === 'not-expected' ? 10 : 60;\n case RelationalSchemaNodeKind.unique:\n return issue.reason === 'not-expected' ? 11 : 51;\n case RelationalSchemaNodeKind.primaryKey:\n return issue.reason === 'not-expected' ? 12 : 50;\n case RelationalSchemaNodeKind.index:\n return issue.reason === 'not-expected' ? 13 : 52;\n case RelationalSchemaNodeKind.columnDefault:\n if (issue.reason === 'not-expected') return 14;\n return issue.reason === 'not-found' ? 42 : 43;\n case RelationalSchemaNodeKind.column:\n if (issue.reason === 'not-expected') return 15;\n return issue.reason === 'not-found' ? 30 : 40;\n case RelationalSchemaNodeKind.table:\n return issue.reason === 'not-expected' ? 16 : 20;\n case RelationalSchemaNodeKind.check:\n if (issue.reason === 'not-found') return 53;\n return issue.reason === 'not-expected' ? 54 : 55;\n default:\n return 99;\n }\n}\n\n/** Deterministic tiebreak within an order bucket: the diff path itself already encodes table → child → grandchild. */\nexport function nodeIssueKey(issue: SchemaDiffIssue): string {\n return issue.path.join(' ');\n}\n\n// ============================================================================\n// Subtree coalescing — the planner's responsibility per the differ's contract\n// ============================================================================\n\n/**\n * The generic differ is total: a missing/extra table (or column) emits an\n * issue for itself AND for every node in its subtree (columns, defaults,\n * constraints, indexes). `CreateTableCall`/`DropTableCall` and\n * `AddColumnCall`/`DropColumnCall` already account for the whole subtree\n * (reading it directly off the table/column node), so the nested issues are\n * redundant — coalescing them is \"the planner's responsibility\" the differ's\n * own contract assigns (`schema-diff.ts`). Drops any issue whose path is a\n * strict descendant of a `not-found`/`not-expected` issue's path.\n */\nexport function coalesceSubtreeIssues(\n issues: readonly SchemaDiffIssue[],\n): readonly SchemaDiffIssue[] {\n const collapsingPaths = issues\n .filter((issue) => issue.reason === 'not-found' || issue.reason === 'not-expected')\n .map((issue) => issue.path);\n if (collapsingPaths.length === 0) return issues;\n return issues.filter(\n (issue) => !collapsingPaths.some((ancestor) => isStrictDescendantPath(issue.path, ancestor)),\n );\n}\n\nfunction isStrictDescendantPath(path: readonly string[], ancestor: readonly string[]): boolean {\n if (path.length <= ancestor.length) return false;\n for (let i = 0; i < ancestor.length; i += 1) {\n if (path[i] !== ancestor[i]) return false;\n }\n return true;\n}\n\n// ============================================================================\n// Node helpers\n// ============================================================================\n\nexport function issueNode(issue: SchemaDiffIssue): SqlSchemaIRNode | undefined {\n const node = issue.expected ?? issue.actual;\n if (node === undefined) return undefined;\n return blindCast<\n SqlSchemaIRNode,\n 'every node in a SQL schema diff tree is a SqlSchemaIRNode; nodeKind is its required discriminant'\n >(node);\n}\n\n/** Whether the expected/actual native type (resolved, or raw+many fallback) differs — mirrors `SqlColumnIR.isEqualTo`'s type comparison. */\nexport function 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 * Builds the flat `SqliteTableSpec` `RecreateTableCall` needs from the\n * expected table node — the node-sourced equivalent of the retired\n * `toTableSpec` (which read a raw contract `StorageTable`). Every column's\n * spec is resolved from its `codecRef` via `columnSpecFromNode`.\n */\nexport function tableSpecFromNode(table: SqlTableIR): SqliteTableSpec {\n const columns: SqliteColumnSpec[] = Object.values(table.columns).map((c) =>\n columnSpecFromNode(c, isInlineAutoincrementPrimaryKeyNode(table, c)),\n );\n const uniques: SqliteUniqueSpec[] = table.uniques.map((u) => ({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }));\n // Every FK node on the expected tree is constraint-bearing by construction\n // (contractToSchemaIR filters `constraint: false` FKs out before they ever\n // become nodes — those only ever contribute an index, never an FK node).\n const foreignKeys: SqliteForeignKeySpec[] = table.foreignKeys.map((fk) => ({\n columns: fk.columns,\n references: { table: fk.referencedTable, columns: fk.referencedColumns },\n constraint: true,\n ...(fk.name !== undefined ? { name: fk.name } : {}),\n ...(fk.onDelete !== undefined ? { onDelete: fk.onDelete } : {}),\n ...(fk.onUpdate !== undefined ? { onUpdate: fk.onUpdate } : {}),\n }));\n return {\n columns,\n ...(table.primaryKey ? { primaryKey: { columns: table.primaryKey.columns } } : {}),\n uniques,\n foreignKeys,\n };\n}\n\n// ============================================================================\n// Conflict helpers\n// ============================================================================\n\nfunction issueConflict(\n kind: SqlPlannerConflict['kind'],\n summary: string,\n location?: SqlPlannerConflict['location'],\n): SqlPlannerConflict {\n return {\n kind,\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction issueLocation(tableName: string, columnName?: string): SqlPlannerConflictLocation {\n return columnName !== undefined ? { table: tableName, column: columnName } : { table: tableName };\n}\n\n/**\n * Conflict kind for a node kind that `recreateTableStrategy` absorbs for\n * every reachable production issue. Reaching `mapNodeIssueToCall` for one of\n * these means the recreate strategy didn't run — mirrors the legacy\n * `conflictKindForIssue` per-kind categorization.\n */\nfunction absorbedConflictKind(nodeKind: string): SqlPlannerConflict['kind'] {\n switch (nodeKind) {\n case RelationalSchemaNodeKind.primaryKey:\n case RelationalSchemaNodeKind.unique:\n return 'indexIncompatible';\n case RelationalSchemaNodeKind.foreignKey:\n return 'foreignKeyConflict';\n default:\n return 'missingButNonAdditive';\n }\n}\n\n// ============================================================================\n// StorageTable / StorageColumn → flat SqliteTableSpec / DdlColumn helpers\n// ============================================================================\n\n/**\n * Builds the `CreateTableCall` + per-index `CreateIndexCall`s for a\n * newly-expected table. Reads only the table node's own children — indexes\n * (declared + FK-backing, deduped) are already merged and ordered at\n * derivation (`contractToSchemaIR`'s `convertTable`).\n */\nfunction buildCreateTableCalls(table: SqlTableIR): SqliteOpFactoryCall[] {\n const columns = Object.values(table.columns).map((c) =>\n ddlColumnFromNode(c, isInlineAutoincrementPrimaryKeyNode(table, c)),\n );\n const hasInlinePk = Object.values(table.columns).some((c) =>\n isInlineAutoincrementPrimaryKeyNode(table, c),\n );\n const constraints = tableConstraintsFromNode(table, hasInlinePk);\n const calls: SqliteOpFactoryCall[] = [\n new CreateTableCall(table.name, columns, constraints.length > 0 ? constraints : undefined),\n ];\n for (const index of table.indexes) {\n const indexName = index.name ?? defaultIndexName(table.name, index.columns);\n calls.push(new CreateIndexCall(table.name, indexName, index.columns));\n }\n return calls;\n}\n\n// ============================================================================\n// Issue → Call mapping (per-issue default path)\n// ============================================================================\n\nfunction mapTableIssue(\n issue: SchemaDiffIssue,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n if (issue.reason === 'not-found') {\n const table = blindCast<\n SqlTableIR,\n 'a not-found table issue always carries the expected table node'\n >(issue.expected);\n return ok(buildCreateTableCalls(table));\n }\n if (issue.reason === 'not-expected') {\n const table = blindCast<\n SqlTableIR,\n 'a not-expected table issue always carries the actual table node'\n >(issue.actual);\n // Runner-owned control tables must never be dropped.\n if (CONTROL_TABLE_NAMES.has(table.name)) return ok([]);\n return ok([new DropTableCall(table.name)]);\n }\n // Unreachable: SqlTableIR.isEqualTo is identity, so a paired table can\n // never mismatch — kept for exhaustiveness against a future node change.\n return notOk(issueConflict('unsupportedOperation', `Unexpected table drift: ${issue.message}`));\n}\n\nfunction mapColumnIssue(\n issue: SchemaDiffIssue,\n ctx: StrategyContext,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n const tableName = issue.path[1];\n if (tableName === undefined) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column issue has no table in its path: ${issue.message}`,\n ),\n );\n }\n if (issue.reason === 'not-found') {\n const column = blindCast<\n SqlColumnIR,\n 'a not-found column issue always carries the expected column node'\n >(issue.expected);\n // A sole-autoincrement-PK column is always part of the table's own\n // CREATE (never a bare ADD COLUMN — PK changes go through\n // `recreateTableStrategy`), but the check is cheap and keeps this path\n // honest against the table node rather than assuming it.\n const table = ctx.expected.tables[tableName];\n const inline = table !== undefined && isInlineAutoincrementPrimaryKeyNode(table, column);\n return ok([new AddColumnCall(tableName, columnSpecFromNode(column, inline))]);\n }\n if (issue.reason === 'not-expected') {\n const column = blindCast<\n SqlColumnIR,\n 'a not-expected column issue always carries the actual column node'\n >(issue.actual);\n return ok([new DropColumnCall(tableName, column.name)]);\n }\n // not-equal: absorbed by recreateTableStrategy for every reachable\n // production issue (SQLite can't ALTER a column type/nullability in\n // place). Reaching here means the strategy didn't run — conflict.\n const expected = blindCast<\n SqlColumnIR,\n 'a not-equal column issue always carries the expected column node'\n >(issue.expected);\n const actual = blindCast<\n SqlColumnIR,\n 'a not-equal column issue always carries the actual column node'\n >(issue.actual);\n const kind = columnTypeChanged(expected, actual) ? 'typeMismatch' : 'nullabilityConflict';\n return notOk(issueConflict(kind, issue.message, issueLocation(tableName, expected.name)));\n}\n\nfunction mapIndexIssue(\n issue: SchemaDiffIssue,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n const tableName = issue.path[1];\n if (tableName === undefined) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Index issue has no table in its path: ${issue.message}`,\n ),\n );\n }\n if (issue.reason === 'not-found') {\n const index = blindCast<\n SqlIndexIR,\n 'a not-found index issue always carries the expected index node'\n >(issue.expected);\n const indexName = index.name ?? defaultIndexName(tableName, index.columns);\n return ok([new CreateIndexCall(tableName, indexName, index.columns)]);\n }\n if (issue.reason === 'not-expected') {\n const index = blindCast<\n SqlIndexIR,\n 'a not-expected index issue always carries the actual index node'\n >(issue.actual);\n const indexName = index.name ?? defaultIndexName(tableName, index.columns);\n return ok([new DropIndexCall(tableName, indexName)]);\n }\n // not-equal: index type/options/uniqueness drift. SQLite can't ALTER an\n // index in place and the legacy planner never absorbed this into a\n // recreate either — surfaces as a conflict, matching `index_mismatch`.\n return notOk(issueConflict('indexIncompatible', issue.message, issueLocation(tableName)));\n}\n\nexport function mapNodeIssueToCall(\n issue: SchemaDiffIssue,\n ctx: StrategyContext,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n const node = issueNode(issue);\n if (node === undefined) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Issue carries neither an expected nor an actual node: ${issue.message}`,\n ),\n );\n }\n switch (node.nodeKind) {\n case RelationalSchemaNodeKind.table:\n return mapTableIssue(issue);\n case RelationalSchemaNodeKind.column:\n return mapColumnIssue(issue, ctx);\n case RelationalSchemaNodeKind.index:\n return mapIndexIssue(issue);\n case RelationalSchemaNodeKind.columnDefault:\n case RelationalSchemaNodeKind.primaryKey:\n case RelationalSchemaNodeKind.foreignKey:\n case RelationalSchemaNodeKind.unique:\n return notOk(issueConflict(absorbedConflictKind(node.nodeKind), issue.message));\n case RelationalSchemaNodeKind.check:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `SQLite does not support CHECK constraint DDL: ${issue.message}`,\n ),\n );\n default:\n return notOk(issueConflict('unsupportedOperation', `Unhandled node kind: ${node.nodeKind}`));\n }\n}\n\n// ============================================================================\n// Call categorization for final emission order\n// ============================================================================\n\ntype CallCategory =\n | 'drop-column'\n | 'drop-index'\n | 'drop-table'\n | 'create-table'\n | 'add-column'\n | 'create-index';\n\nfunction classifyCall(call: SqliteOpFactoryCall): CallCategory | null {\n switch (call.factoryName) {\n case 'createTable':\n return 'create-table';\n case 'addColumn':\n return 'add-column';\n case 'createIndex':\n return 'create-index';\n case 'dropColumn':\n return 'drop-column';\n case 'dropIndex':\n return 'drop-index';\n case 'dropTable':\n return 'drop-table';\n // recreateTable goes into the recipe slot; return null for bucketable.\n case 'recreateTable':\n return null;\n default:\n return null;\n }\n}\n\n// ============================================================================\n// Top-level planIssues\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaDiffIssue[];\n /** The desired (\"end\") tree — resolved leaf values, incl. `codecRef`. */\n readonly expected?: SqlSchemaIR;\n /** The live (\"start\") tree. */\n readonly actual?: SqlSchemaIR;\n readonly policy?: MigrationOperationPolicy;\n readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n readonly strategies?: readonly CallMigrationStrategy[];\n}\n\nexport interface IssuePlannerValue {\n readonly calls: readonly SqliteOpFactoryCall[];\n}\n\nconst DEFAULT_POLICY: MigrationOperationPolicy = {\n allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'],\n};\n\nexport function planIssues(\n options: IssuePlannerOptions,\n): Result<IssuePlannerValue, readonly SqlPlannerConflict[]> {\n const policyProvided = options.policy !== undefined;\n const policy = options.policy ?? DEFAULT_POLICY;\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n expected: options.expected ?? emptySchemaIR(),\n actual: options.actual ?? emptySchemaIR(),\n policy,\n frameworkComponents,\n };\n\n const strategies = options.strategies ?? sqlitePlannerStrategies;\n\n let remaining = options.issues;\n const recipeCalls: SqliteOpFactoryCall[] = [];\n const bucketableCalls: SqliteOpFactoryCall[] = [];\n\n for (const strategy of strategies) {\n const result = strategy(remaining, context);\n if (result.kind === 'match') {\n remaining = result.issues;\n if (result.recipe) {\n recipeCalls.push(...result.calls);\n } else {\n bucketableCalls.push(...result.calls);\n }\n }\n }\n\n const sorted = [...remaining].sort((a, b) => {\n const kindDelta = nodeIssueOrder(a) - nodeIssueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = nodeIssueKey(a);\n const keyB = nodeIssueKey(b);\n return keyA < keyB ? -1 : keyA > keyB ? 1 : 0;\n });\n\n const defaultCalls: SqliteOpFactoryCall[] = [];\n const conflicts: SqlPlannerConflict[] = [];\n\n for (const issue of sorted) {\n const result = mapNodeIssueToCall(issue, context);\n if (result.ok) {\n defaultCalls.push(...result.value);\n } else {\n conflicts.push(result.failure);\n }\n }\n\n // Policy gating for recipe + bucketable. Default-mapped calls for disallowed\n // classes never get here (they're surfaced as per-issue conflicts above).\n const allowed = policy.allowedOperationClasses;\n let gatedRecipe = recipeCalls;\n let gatedBucketable = bucketableCalls;\n let gatedDefault = defaultCalls;\n if (policyProvided) {\n const sink = (acc: SqliteOpFactoryCall[]) => (call: SqliteOpFactoryCall) => {\n if (allowed.includes(call.operationClass)) {\n acc.push(call);\n return;\n }\n conflicts.push(conflictForDisallowedCall(call, allowed));\n };\n const gatedRecipeBucket: SqliteOpFactoryCall[] = [];\n const gatedBucketableBucket: SqliteOpFactoryCall[] = [];\n const gatedDefaultBucket: SqliteOpFactoryCall[] = [];\n recipeCalls.forEach(sink(gatedRecipeBucket));\n bucketableCalls.forEach(sink(gatedBucketableBucket));\n defaultCalls.forEach(sink(gatedDefaultBucket));\n gatedRecipe = gatedRecipeBucket;\n gatedBucketable = gatedBucketableBucket;\n gatedDefault = gatedDefaultBucket;\n }\n\n if (conflicts.length > 0) {\n return notOk(conflicts);\n }\n\n // Final emission order matches the current monolithic planner:\n // create-table → add-column → create-index → recreate → drop-column → drop-index → drop-table\n const combined = [...gatedDefault, ...gatedBucketable];\n const byCategory = (cat: CallCategory) => combined.filter((c) => classifyCall(c) === cat);\n\n const calls: SqliteOpFactoryCall[] = [\n ...byCategory('create-table'),\n ...byCategory('add-column'),\n ...byCategory('create-index'),\n ...gatedRecipe,\n ...byCategory('drop-column'),\n ...byCategory('drop-index'),\n ...byCategory('drop-table'),\n ];\n\n return ok({ calls });\n}\n\nfunction emptySchemaIR(): SqlSchemaIR {\n return new SqlSchemaIR({ tables: {} });\n}\n\nfunction conflictForDisallowedCall(\n call: SqliteOpFactoryCall,\n allowed: readonly string[],\n): SqlPlannerConflict {\n const summary = `Operation \"${call.label}\" requires class \"${call.operationClass}\", but policy allows only: ${allowed.join(', ')}`;\n const location = locationForCall(call);\n return {\n kind: conflictKindForCall(call),\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction conflictKindForCall(call: SqliteOpFactoryCall): SqlPlannerConflict['kind'] {\n switch (call.factoryName) {\n case 'createIndex':\n case 'dropIndex':\n return 'indexIncompatible';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction locationForCall(call: SqliteOpFactoryCall): SqlPlannerConflictLocation | undefined {\n const location: { table?: string; column?: string; index?: string } = {};\n if ('tableName' in call) location.table = call.tableName;\n if ('columnName' in call) location.column = call.columnName;\n if ('indexName' in call) location.index = call.indexName;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlanner,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationScaffoldContext,\n SchemaDiffIssue,\n SchemaOwnership,\n} from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { RelationalSchemaNodeKind, type SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { buildSqlitePlanDiff } from './diff-database-schema';\nimport { coalesceSubtreeIssues, issueNode, planIssues } from './issue-planner';\nimport {\n type SqliteMigrationDestinationInfo,\n TypeScriptRenderableSqliteMigration,\n} from './planner-produced-sqlite-migration';\nimport { sqlitePlannerStrategies } from './planner-strategies';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\nexport function createSqliteMigrationPlanner(\n lowerer: ExecuteRequestLowerer,\n): SqliteMigrationPlanner {\n return new SqliteMigrationPlanner(lowerer);\n}\n\nexport type SqlitePlanResult =\n | { readonly kind: 'success'; readonly plan: TypeScriptRenderableSqliteMigration }\n | SqlPlannerFailureResult;\n\n/**\n * SQLite migration planner — a thin wrapper over `planIssues`.\n *\n * `plan()` diffs the live schema against the target contract via the one\n * differ (`buildSqlitePlanDiff`, producing node-typed `SchemaDiffIssue[]`)\n * and delegates to `planIssues` with the registered strategies. Strategies\n * absorb groups of related issues into composite recipes (e.g. recreating a\n * table to apply type/nullability/default/constraint changes at once);\n * anything not absorbed by a strategy flows through `mapNodeIssueToCall` in\n * the issue planner as a one-off call.\n *\n * FK-backing indexes are already merged into the expected table node's\n * `indexes` at derivation (`contractToSchemaIR`'s `convertTable`), so\n * `mapNodeIssueToCall` handles them uniformly alongside user-declared\n * indexes — no separate expansion step in the planner.\n */\nexport class SqliteMigrationPlanner\n implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'>\n{\n readonly #lowerer: ExecuteRequestLowerer;\n\n constructor(lowerer: ExecuteRequestLowerer) {\n this.#lowerer = lowerer;\n }\n\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n /**\n * The \"from\" contract (state the planner assumes the database starts at),\n * or `null` for reconciliation flows.\n *\n * Typed as the framework `Contract | null` to satisfy the\n * `MigrationPlanner` interface contract; `planSql` narrows to the SQL\n * shape via `SqlMigrationPlannerPlanOptions`. Used to populate\n * `describe().from` on the produced plan as\n * `fromContract?.storage.storageHash ?? null`.\n */\n readonly fromContract: Contract | null;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderableSqliteMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n /**\n * Ownership oracle over the contract-space composition — see\n * {@link SqlMigrationPlannerPlanOptions.ownership}.\n */\n readonly ownership?: SchemaOwnership;\n }): SqlitePlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): TypeScriptRenderableSqliteMigration {\n return new TypeScriptRenderableSqliteMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n undefined,\n this.#lowerer,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): SqlitePlanResult {\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) return policyResult;\n\n const { expected, actual, issues } = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n\n const result = planIssues({\n issues,\n expected,\n actual,\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: sqlitePlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n // Codec lifecycle hook (T2.2): inline `onFieldEvent`-emitted ops after\n // structural DDL. Sub-spec § 5 fixes the ordering as\n // `structural → added → dropped → altered`, with within-group sorting by\n // `(tableName, fieldName)` deterministic for byte-stable re-emits.\n // Hook fires only at the application emitter — extension-space planning\n // (M2 R2) never reaches this helper.\n const fieldEventOps = planFieldEventOperations({\n priorContract: options.fromContract,\n newContract: options.contract,\n codecHooks,\n });\n // Codec-emitted calls already conform to `OpFactoryCall` — render +\n // toOp + importRequirements ride directly through the same emit path\n // as structural ops, no `RawSqlCall` wrap.\n const calls = [...result.value.calls, ...fieldEventOps];\n\n const destination: SqliteMigrationDestinationInfo = {\n storageHash: options.contract.storage.storageHash,\n ...(options.contract.profileHash !== undefined\n ? { profileHash: options.contract.profileHash }\n : {}),\n };\n\n return {\n kind: 'success' as const,\n plan: new TypeScriptRenderableSqliteMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n destination,\n this.#lowerer,\n ),\n };\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy): SqlPlannerFailureResult | null {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n\n /**\n * Diffs the target contract against the live schema via the one differ\n * (the same tree-building `diffSqliteSchema` uses, plus the\n * op-render stamper) and prepares the issue list `planIssues` consumes.\n *\n * Three passes, in order:\n * 1. Subtree coalescing — the differ is total (a missing/extra table also\n * emits an issue for every column/constraint under it); those nested\n * issues are redundant once the table-level `CreateTable`/`DropTable`\n * call already accounts for the whole subtree. Runs FIRST, over the\n * complete diff: a sibling-owned extra table's column issues must\n * collapse into its one table-level issue before the ownership pass,\n * because a bare column node carries no table reference — if coalescing\n * ran after ownership dropped the table-level issue, the orphaned column\n * issues would survive and the planner would emit drops against a\n * sibling space's table.\n * 2. Ownership — a live extra is only this plan's to drop when no contract\n * space owns it. The differ ran against THIS space's contract, so a\n * table a sibling owns surfaces here as `not-expected`; the planner asks\n * the ownership oracle (the passive aggregate) whether any space declares\n * it and, if so, leaves it alone. A table no space owns stays a genuine\n * extra. Ownership lives in the aggregate; the planner only asks. No\n * oracle (single-space) keeps every extra.\n * 3. Strict-mode extras gating — `not-expected` (extra table/column/\n * constraint) issues are dropped entirely outside strict mode, mirroring\n * the retired coordinate walk's `if (strict) { ...extra_* } }` guards:\n * an additive-only plan must never even consider dropping an unclaimed\n * object, not just refuse to emit the drop.\n */\n private collectSchemaIssues(options: SqlMigrationPlannerPlanOptions): {\n readonly expected: SqlSchemaIR;\n readonly actual: SqlSchemaIR;\n readonly issues: readonly SchemaDiffIssue[];\n } {\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const {\n expected,\n actual,\n issues: rawIssues,\n } = buildSqlitePlanDiff({\n contract: options.contract,\n actualSchema: options.schema,\n frameworkComponents: options.frameworkComponents,\n });\n const coalesced = coalesceSubtreeIssues(rawIssues);\n const owned = retainUnownedExtras(coalesced, options.ownership);\n const issues = strict ? owned : owned.filter((issue) => issue.reason !== 'not-expected');\n return { expected, actual, issues };\n }\n}\n\n/**\n * Drops a `not-expected` issue when it is a whole extra TABLE that some\n * contract space owns, asking the ownership oracle per node.\n *\n * The consultation applies ONLY to table-level extras — a live table this\n * space's contract lacks — identified by asking the issue's own node\n * (`nodeKind === table`), never by counting path segments. SQLite is a\n * single-namespace target, so every coordinate is qualified with the shared\n * `UNBOUND_NAMESPACE_ID` sentinel (the same one the aggregate's declared\n * entities carry for this target). `entityKind` is the literal `'table'`:\n * this function only ever asks about a node already confirmed to be\n * `RelationalSchemaNodeKind.table` (checked just above), and that's a\n * diff-tree `nodeKind` spelling (`'sql-table'`) distinct from the storage\n * `entries` vocabulary `elementCoordinates` walks (`'table'`) — the literal\n * is that storage-entries spelling. `declaresEntity` answers over the whole\n * composition (self included), so a positive answer on such a table means\n * another space owns it (a table this space owned would be in its expected\n * tree, never an extra): leave it. A negative answer means no space owns\n * it — a genuine orphan to drop.\n *\n * A DEEPER extra (an extra column/constraint on a table this space DOES own —\n * only the child drifted, so the table is in the expected tree) is this\n * space's own drift and is always kept for dropping; asking the oracle there\n * would wrongly suppress it, because the owned table answers `true`. No oracle\n * ⇒ every extra is kept (single-space plan).\n */\nfunction retainUnownedExtras(\n issues: readonly SchemaDiffIssue[],\n ownership: SchemaOwnership | undefined,\n): readonly SchemaDiffIssue[] {\n if (ownership === undefined) return issues;\n return issues.filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n const node = issueNode(issue);\n if (node === undefined || node.nodeKind !== RelationalSchemaNodeKind.table) return true;\n const tableName = issue.path[1];\n return (\n tableName === undefined ||\n !ownership.declaresEntity({\n namespaceId: UNBOUND_NAMESPACE_ID,\n entityKind: 'table',\n entityName: tableName,\n })\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,SAAgB,oBAAoB,KAAoB,SAAgC;CACtF,IAAI,IAAI,SAAS,YAAY;EAC3B,IAAI,IAAI,eAAe,SACrB,OAAO;EAET,OAAO,IAAI;CACb;CACA,OAAO,qBAAqB,IAAI,KAAK;AACvC;;;;;;;;;;AAWA,SAAgB,uBACd,UACA,QAGa;CACb,OAAO,mBAAmB,UAAU;EAClC,qBAAqB;EACrB,eAAe;EACf,GAAG,UAAU,oBAAoB,QAAQ,gBAAgB;CAC3D,CAAC;AACH;;;;;;AAOA,SAAgB,2BACd,OAC4B;CAC5B,OAAO,sBAAsB;EAC3B,UAAU,MAAM;EAChB,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,qBAAqB,MAAM;EAC3B,YAAY;EACZ,eAAe;CACjB,CAAC;AACH;;;;;;;;;AAUA,SAAS,qBACP,OACA,UAC2B;CAC3B,MAAM,YAAY,MAAM,KAAK;CAC7B,IAAI,cAAc,KAAA,GAAW,OAAO,KAAA;CACpC,KAAK,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,GAAG;EAClE,MAAM,QAAQ,SAAuB,SAAS,SAAS;GACrD;GACA,YAAY;GACZ,YAAY;EACd,CAAC;EACD,IAAI,UAAU,KAAA,GAAW,OAAO,MAAM;CACxC;AAEF;;;;;;;;;;;AAYA,SAAgB,iBAAiB,OAIT;CACtB,MAAM,mBAAmB,wBAAwB,MAAM,mBAAmB;CAC1E,MAAM,WAAW,gCACf,mBAAmB,MAAM,UAAU;EACjC,qBAAqB;EACrB,eAAe;EACf,GAAG,UAAU,oBAAoB,gBAAgB;CACnD,CAAC,CACH;CACA,MAAM,SACJ,MAAM,kBAAkB,cACpB,MAAM,SACN,UAGE,MAAM,MAAM;CAMpB,OAAO;E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