@prisma-next/target-sqlite 0.5.0-dev.66 → 0.5.0-dev.68
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/{codec-ids-DyLO2Rfx.d.mts → codec-ids-CYwMu3-4.d.mts} +1 -1
- package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
- package/dist/{codec-ids-B1-OiN8Q.mjs → codec-ids-CuUxYcd0.mjs} +2 -3
- package/dist/{codec-ids-B1-OiN8Q.mjs.map → codec-ids-CuUxYcd0.mjs.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/codec-ids.mjs +2 -3
- package/dist/{codec-types-Bbzv7qCW.d.mts → codec-types-DNauB5UT.d.mts} +7 -8
- package/dist/codec-types-DNauB5UT.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -3
- package/dist/codec-types.mjs +2 -3
- package/dist/{codecs-BqDitp2X.d.mts → codecs-BAlEiSeP.d.mts} +18 -19
- package/dist/codecs-BAlEiSeP.d.mts.map +1 -0
- package/dist/{codecs-CDcidsHL.mjs → codecs-DVnHtVWW.mjs} +3 -4
- package/dist/codecs-DVnHtVWW.mjs.map +1 -0
- package/dist/codecs.d.mts +1 -2
- package/dist/codecs.mjs +2 -3
- package/dist/codecs.mjs.map +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +127 -61
- package/dist/control.mjs.map +1 -1
- package/dist/{default-normalizer-R-sQXAYt.mjs → default-normalizer-3Fccw7yw.mjs} +2 -2
- package/dist/{default-normalizer-R-sQXAYt.mjs.map → default-normalizer-3Fccw7yw.mjs.map} +1 -1
- package/dist/default-normalizer.d.mts +0 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +2 -3
- package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
- package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
- package/dist/migration.d.mts +13 -4
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +17 -6
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-BMovohPm.mjs → native-type-normalizer-BlN5XfD-.mjs} +2 -2
- package/dist/{native-type-normalizer-BMovohPm.mjs.map → native-type-normalizer-BlN5XfD-.mjs.map} +1 -1
- package/dist/native-type-normalizer.d.mts.map +1 -1
- package/dist/native-type-normalizer.mjs +2 -3
- package/dist/{op-factory-call-BUVV-W9F.mjs → op-factory-call-DRKKURAO.mjs} +32 -5
- package/dist/{op-factory-call-BUVV-W9F.mjs.map → op-factory-call-DRKKURAO.mjs.map} +1 -1
- package/dist/{op-factory-call-dUIOao68.d.mts → op-factory-call-FrU2vXqw.d.mts} +23 -6
- package/dist/op-factory-call-FrU2vXqw.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -3
- package/dist/op-factory-call.mjs +2 -3
- package/dist/pack.d.mts +1 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/{planner-DmOFOhoq.mjs → planner-C94LJeIM.mjs} +16 -13
- package/dist/planner-C94LJeIM.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-CJr8ATRH.d.mts → planner-produced-sqlite-migration-BblR19lI.d.mts} +4 -4
- package/dist/planner-produced-sqlite-migration-BblR19lI.d.mts.map +1 -0
- package/dist/{planner-produced-sqlite-migration-BANB82Pw.mjs → planner-produced-sqlite-migration-CH7YGZf6.mjs} +4 -6
- package/dist/planner-produced-sqlite-migration-CH7YGZf6.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration.d.mts +1 -4
- package/dist/planner-produced-sqlite-migration.mjs +2 -3
- package/dist/{planner-target-details-BQIWQlBu.mjs → planner-target-details-Bm71XPKb.mjs} +2 -3
- package/dist/{planner-target-details-BQIWQlBu.mjs.map → planner-target-details-Bm71XPKb.mjs.map} +1 -1
- package/dist/{planner-target-details-CtWRvse0.d.mts → planner-target-details-vhvZDWK1.d.mts} +1 -1
- package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner-target-details.mjs +2 -3
- package/dist/planner.d.mts +2 -5
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -3
- package/dist/{render-ops-CXOv7SRC.mjs → render-ops-CSRDT4YL.mjs} +2 -2
- package/dist/{render-ops-CXOv7SRC.mjs.map → render-ops-CSRDT4YL.mjs.map} +1 -1
- package/dist/render-ops.d.mts +2 -3
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +2 -3
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -5
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-D_1fFqLf.d.mts → shared-qLsgTOZs.d.mts} +2 -2
- package/dist/shared-qLsgTOZs.d.mts.map +1 -0
- package/dist/{sql-utils-D3SMPFDD.mjs → sql-utils-DhevMgef.mjs} +4 -2
- package/dist/sql-utils-DhevMgef.mjs.map +1 -0
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -3
- package/dist/{sqlite-migration-CnLhIrJF.mjs → sqlite-migration-BBJktVVw.mjs} +2 -3
- package/dist/{sqlite-migration-CnLhIrJF.mjs.map → sqlite-migration-BBJktVVw.mjs.map} +1 -1
- package/dist/{sqlite-migration-BeR1cikr.d.mts → sqlite-migration-DAb2NEX6.d.mts} +2 -3
- package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
- package/dist/{statement-builders-DobaAWnW.mjs → statement-builders-Dne-LkAV.mjs} +5 -6
- package/dist/statement-builders-Dne-LkAV.mjs.map +1 -0
- package/dist/statement-builders.d.mts.map +1 -1
- package/dist/statement-builders.mjs +2 -3
- package/dist/{tables-sKIg_lWE.mjs → tables-D84zfPZI.mjs} +5 -10
- package/dist/tables-D84zfPZI.mjs.map +1 -0
- package/package.json +19 -19
- package/src/core/migrations/op-factory-call.ts +38 -1
- package/src/core/migrations/operations/raw.ts +12 -0
- package/src/core/migrations/planner.ts +30 -2
- package/src/core/migrations/runner.ts +164 -75
- package/src/exports/migration.ts +1 -0
- package/src/exports/op-factory-call.ts +1 -0
- package/dist/codec-ids-DyLO2Rfx.d.mts.map +0 -1
- package/dist/codec-types-Bbzv7qCW.d.mts.map +0 -1
- package/dist/codecs-BqDitp2X.d.mts.map +0 -1
- package/dist/codecs-CDcidsHL.mjs.map +0 -1
- package/dist/descriptor-meta-BA2YAFQq.mjs +0 -24
- package/dist/descriptor-meta-BA2YAFQq.mjs.map +0 -1
- package/dist/op-factory-call-dUIOao68.d.mts.map +0 -1
- package/dist/planner-DmOFOhoq.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-BANB82Pw.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-CJr8ATRH.d.mts.map +0 -1
- package/dist/planner-target-details-CtWRvse0.d.mts.map +0 -1
- package/dist/shared-D_1fFqLf.d.mts.map +0 -1
- package/dist/sql-utils-D3SMPFDD.mjs.map +0 -1
- package/dist/sqlite-migration-BeR1cikr.d.mts.map +0 -1
- package/dist/statement-builders-DobaAWnW.mjs.map +0 -1
- package/dist/tables-sKIg_lWE.mjs.map +0 -1
package/dist/pack.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import "./codec-
|
|
2
|
-
import "./codecs-BqDitp2X.mjs";
|
|
3
|
-
import { t as CodecTypes } from "./codec-types-Bbzv7qCW.mjs";
|
|
1
|
+
import { t as CodecTypes } from "./codec-types-DNauB5UT.mjs";
|
|
4
2
|
|
|
5
3
|
//#region src/core/descriptor-meta.d.ts
|
|
6
4
|
declare const sqliteTargetDescriptorMetaBase: {
|
package/dist/pack.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"
|
|
1
|
+
{"version":3,"file":"pack.d.mts","names":[],"sources":["../src/core/descriptor-meta.ts"],"mappings":";;;cAGM,8BAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAYO,0BAAA,SAAmC,8BAAA;EAAA,SACrC,YAAA,GAAe,UAAA;AAAA"}
|
package/dist/pack.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-
|
|
2
|
-
|
|
3
|
-
export { sqliteTargetDescriptorMeta as default };
|
|
1
|
+
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-CE2Kbn9b.mjs";
|
|
2
|
+
export { sqliteTargetDescriptorMeta as default };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { t as parseSqliteDefault } from "./default-normalizer-
|
|
2
|
-
import { t as normalizeSqliteNativeType } from "./native-type-normalizer-
|
|
3
|
-
import { c as buildColumnDefaultSql, l as buildColumnTypeSql, n as buildRecreateSummary, t as buildRecreatePostchecks, u as isInlineAutoincrementPrimaryKey } from "./tables-
|
|
4
|
-
import { a as DropColumnCall, c as
|
|
5
|
-
import { n as CONTROL_TABLE_NAMES } from "./statement-builders-
|
|
6
|
-
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
7
|
-
import { extractCodecControlHooks, plannerFailure } from "@prisma-next/family-sql/control";
|
|
1
|
+
import { t as parseSqliteDefault } from "./default-normalizer-3Fccw7yw.mjs";
|
|
2
|
+
import { t as normalizeSqliteNativeType } from "./native-type-normalizer-BlN5XfD-.mjs";
|
|
3
|
+
import { c as buildColumnDefaultSql, l as buildColumnTypeSql, n as buildRecreateSummary, t as buildRecreatePostchecks, u as isInlineAutoincrementPrimaryKey } from "./tables-D84zfPZI.mjs";
|
|
4
|
+
import { a as DropColumnCall, c as RawSqlCall, i as DataTransformCall, l as RecreateTableCall, n as CreateIndexCall, o as DropIndexCall, r as CreateTableCall, s as DropTableCall, t as AddColumnCall } from "./op-factory-call-DRKKURAO.mjs";
|
|
5
|
+
import { n as CONTROL_TABLE_NAMES } from "./statement-builders-Dne-LkAV.mjs";
|
|
6
|
+
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CH7YGZf6.mjs";
|
|
7
|
+
import { extractCodecControlHooks, planFieldEventOperations, plannerFailure } from "@prisma-next/family-sql/control";
|
|
8
8
|
import { verifySqlSchema } from "@prisma-next/family-sql/schema-verify";
|
|
9
9
|
import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
10
10
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
11
|
-
|
|
12
11
|
//#region src/core/migrations/planner-strategies.ts
|
|
13
12
|
const WIDENING_ISSUE_KINDS = new Set(["default_mismatch", "default_missing"]);
|
|
14
13
|
const DESTRUCTIVE_ISSUE_KINDS = new Set([
|
|
@@ -140,7 +139,6 @@ const nullabilityTighteningBackfillStrategy = (issues, ctx) => {
|
|
|
140
139
|
};
|
|
141
140
|
};
|
|
142
141
|
const sqlitePlannerStrategies = [nullabilityTighteningBackfillStrategy, recreateTableStrategy];
|
|
143
|
-
|
|
144
142
|
//#endregion
|
|
145
143
|
//#region src/core/migrations/issue-planner.ts
|
|
146
144
|
const ISSUE_KIND_ORDER = {
|
|
@@ -434,7 +432,6 @@ function planIssues(options) {
|
|
|
434
432
|
...byCategory("drop-table")
|
|
435
433
|
] });
|
|
436
434
|
}
|
|
437
|
-
|
|
438
435
|
//#endregion
|
|
439
436
|
//#region src/core/migrations/planner.ts
|
|
440
437
|
function createSqliteMigrationPlanner() {
|
|
@@ -482,13 +479,19 @@ var SqliteMigrationPlanner = class {
|
|
|
482
479
|
strategies: sqlitePlannerStrategies
|
|
483
480
|
});
|
|
484
481
|
if (!result.ok) return plannerFailure(result.failure);
|
|
482
|
+
const fieldEventOps = planFieldEventOperations({
|
|
483
|
+
priorContract: options.fromContract,
|
|
484
|
+
newContract: options.contract,
|
|
485
|
+
codecHooks
|
|
486
|
+
});
|
|
487
|
+
const calls = [...result.value.calls, ...fieldEventOps.map((op) => new RawSqlCall(op))];
|
|
485
488
|
const destination = {
|
|
486
489
|
storageHash: options.contract.storage.storageHash,
|
|
487
490
|
...options.contract.profileHash !== void 0 ? { profileHash: options.contract.profileHash } : {}
|
|
488
491
|
};
|
|
489
492
|
return {
|
|
490
493
|
kind: "success",
|
|
491
|
-
plan: new TypeScriptRenderableSqliteMigration(
|
|
494
|
+
plan: new TypeScriptRenderableSqliteMigration(calls, {
|
|
492
495
|
from: options.fromContract?.storage.storageHash ?? null,
|
|
493
496
|
to: options.contract.storage.storageHash
|
|
494
497
|
}, options.spaceId, destination)
|
|
@@ -516,7 +519,7 @@ var SqliteMigrationPlanner = class {
|
|
|
516
519
|
}).schema.issues;
|
|
517
520
|
}
|
|
518
521
|
};
|
|
519
|
-
|
|
520
522
|
//#endregion
|
|
521
523
|
export { createSqliteMigrationPlanner as n, SqliteMigrationPlanner as t };
|
|
522
|
-
|
|
524
|
+
|
|
525
|
+
//# sourceMappingURL=planner-C94LJeIM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-C94LJeIM.mjs","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts","../src/core/migrations/planner.ts"],"sourcesContent":["/**\n * SQLite migration strategies.\n *\n * Each strategy examines the issue list, consumes issues it handles, and\n * returns the `SqliteOpFactoryCall[]` to address them. The issue planner\n * runs each strategy in order and routes whatever's left through\n * `mapIssueToCall`.\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` (added in a later phase), which\n * absorbs type/nullability/default/constraint mismatches for a given table\n * into a single recreate operation.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationClass,\n MigrationOperationPolicy,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { toTableSpec } 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 readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaIssue[];\n calls: readonly SqliteOpFactoryCall[];\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\n// ============================================================================\n// Recreate-table strategy\n// ============================================================================\n\nconst WIDENING_ISSUE_KINDS = new Set<SchemaIssue['kind']>(['default_mismatch', 'default_missing']);\n\nconst DESTRUCTIVE_ISSUE_KINDS = new Set<SchemaIssue['kind']>([\n 'extra_default',\n 'type_mismatch',\n 'primary_key_mismatch',\n 'foreign_key_mismatch',\n 'unique_constraint_mismatch',\n 'extra_foreign_key',\n 'extra_unique_constraint',\n 'extra_primary_key',\n]);\n\nfunction classifyIssue(issue: SchemaIssue): 'widening' | 'destructive' | null {\n if (issue.kind === 'enum_values_changed') return null;\n if (!issue.table) return null;\n if (issue.kind === 'nullability_mismatch') {\n // Relaxing (NOT NULL → nullable) is widening; tightening is destructive.\n return issue.expected === 'true' ? 'widening' : 'destructive';\n }\n if (WIDENING_ISSUE_KINDS.has(issue.kind)) return 'widening';\n if (DESTRUCTIVE_ISSUE_KINDS.has(issue.kind)) return 'destructive';\n return null;\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 `mapIssueToCall` doesn't double-handle them.\n */\nexport const recreateTableStrategy: CallMigrationStrategy = (issues, ctx) => {\n const byTable = new Map<string, { issues: SchemaIssue[]; hasDestructive: boolean }>();\n const consumed = new Set<SchemaIssue>();\n\n for (const issue of issues) {\n const cls = classifyIssue(issue);\n if (!cls) continue;\n if (issue.kind === 'enum_values_changed') continue;\n if (!issue.table) continue;\n const table = issue.table;\n const entry = byTable.get(table);\n if (entry) {\n entry.issues.push(issue);\n if (cls === 'destructive') entry.hasDestructive = true;\n } else {\n byTable.set(table, { 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 contractTable = ctx.toContract.storage.tables[tableName];\n const schemaTable = ctx.schema.tables[tableName];\n if (!contractTable || !schemaTable) continue;\n const operationClass: MigrationOperationClass = entry.hasDestructive\n ? 'destructive'\n : 'widening';\n\n // Flatten the contract table to a self-contained spec — the Call holds\n // pre-rendered SQL fragments only, no `StorageColumn` or `storageTypes`.\n const tableSpec = toTableSpec(contractTable, ctx.storageTypes);\n\n const seenIndexColumnKeys = new Set<string>();\n const indexes: SqliteIndexSpec[] = [];\n for (const idx of contractTable.indexes) {\n const key = idx.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: idx.name ?? defaultIndexName(tableName, idx.columns),\n columns: idx.columns,\n });\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n const key = fk.columns.join(',');\n if (seenIndexColumnKeys.has(key)) continue;\n seenIndexColumnKeys.add(key);\n indexes.push({\n name: defaultIndexName(tableName, fk.columns),\n columns: fk.columns,\n });\n }\n\n calls.push(\n new RecreateTableCall({\n tableName,\n contractTable: tableSpec,\n schemaColumnNames: Object.keys(schemaTable.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 contract 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 (issue.kind !== 'nullability_mismatch') continue;\n if (!issue.table || !issue.column) continue;\n // Tightening only: `expected === 'true'` means the contract wants the\n // column nullable (relaxing from NOT NULL → nullable), which is safe and\n // needs no backfill.\n if (issue.expected === 'true') continue;\n\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column || column.nullable === true) continue;\n\n calls.push(\n new DataTransformCall(\n `data_migration.backfill-${issue.table}-${issue.column}`,\n `Backfill NULLs in \"${issue.table}\".\"${issue.column}\" before NOT NULL tightening`,\n issue.table,\n issue.column,\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 schema issues (from `verifySqlSchema`) 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 `mapIssueToCall` for the default case.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\n SqlStorage,\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { defaultIndexName } from '@prisma-next/sql-schema-ir/naming';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\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 buildColumnDefaultSql,\n buildColumnTypeSql,\n isInlineAutoincrementPrimaryKey,\n} from './planner-ddl-builders';\nimport {\n type CallMigrationStrategy,\n type StrategyContext,\n sqlitePlannerStrategies,\n} from './planner-strategies';\nimport { CONTROL_TABLE_NAMES } from './statement-builders';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n// ============================================================================\n// Issue kind ordering (dependency order)\n// ============================================================================\n\nconst ISSUE_KIND_ORDER: Record<string, number> = {\n // Drops (reconciliation — clear the way for creates)\n extra_foreign_key: 10,\n extra_unique_constraint: 11,\n extra_primary_key: 12,\n extra_index: 13,\n extra_default: 14,\n extra_column: 15,\n extra_table: 16,\n\n // Tables before columns\n missing_table: 20,\n\n // Columns before constraints\n missing_column: 30,\n\n // Reconciliation alters (on existing objects)\n type_mismatch: 40,\n nullability_mismatch: 41,\n default_missing: 42,\n default_mismatch: 43,\n\n // Constraints after columns exist\n primary_key_mismatch: 50,\n unique_constraint_mismatch: 51,\n index_mismatch: 52,\n foreign_key_mismatch: 60,\n};\n\nfunction issueOrder(issue: SchemaIssue): number {\n return ISSUE_KIND_ORDER[issue.kind] ?? 99;\n}\n\nfunction issueKey(issue: SchemaIssue): string {\n const table = 'table' in issue && typeof issue.table === 'string' ? issue.table : '';\n const column = 'column' in issue && typeof issue.column === 'string' ? issue.column : '';\n const name =\n 'indexOrConstraint' in issue && typeof issue.indexOrConstraint === 'string'\n ? issue.indexOrConstraint\n : '';\n return `${table}\\u0000${column}\\u0000${name}`;\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 conflictKindForIssue(issue: SchemaIssue): SqlPlannerConflict['kind'] {\n switch (issue.kind) {\n case 'type_mismatch':\n return 'typeMismatch';\n case 'nullability_mismatch':\n return 'nullabilityConflict';\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'index_mismatch':\n case 'extra_primary_key':\n case 'extra_unique_constraint':\n return 'indexIncompatible';\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n return 'foreignKeyConflict';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction issueLocation(issue: SchemaIssue): SqlPlannerConflictLocation | undefined {\n if (issue.kind === 'enum_values_changed') return undefined;\n const location: {\n table?: string;\n column?: string;\n constraint?: string;\n } = {};\n if (issue.table) location.table = issue.table;\n if (issue.column) location.column = issue.column;\n if (issue.indexOrConstraint) location.constraint = issue.indexOrConstraint;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\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\nfunction isMissing(issue: SchemaIssue): boolean {\n if (issue.kind === 'enum_values_changed') return false;\n return issue.actual === undefined;\n}\n\n// ============================================================================\n// StorageTable / StorageColumn → flat SqliteTableSpec\n// ============================================================================\n\n/**\n * Resolves codec / `typeRef` / default rendering into a flat\n * `SqliteColumnSpec`. Mirrors Postgres's `toColumnSpec`. Once a column is\n * flattened, downstream Calls and operation factories never see\n * `StorageColumn` again — they deal in pre-rendered SQL fragments.\n */\nexport function toColumnSpec(\n name: string,\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n inlineAutoincrementPrimaryKey = false,\n): SqliteColumnSpec {\n const typeSql = buildColumnTypeSql(column, storageTypes as Record<string, StorageTypeInstance>);\n const defaultSql = buildColumnDefaultSql(column.default);\n return {\n name,\n typeSql,\n defaultSql,\n nullable: column.nullable,\n ...(inlineAutoincrementPrimaryKey ? { inlineAutoincrementPrimaryKey: true } : {}),\n };\n}\n\n/**\n * Flattens a `StorageTable` into a `SqliteTableSpec` ready for\n * `CreateTableCall` / `RecreateTableCall`. Sole-column AUTOINCREMENT\n * primary keys are detected here and marked on the column spec so the\n * renderer emits `INTEGER PRIMARY KEY AUTOINCREMENT` inline.\n */\nexport function toTableSpec(\n table: StorageTable,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n): SqliteTableSpec {\n const columns: SqliteColumnSpec[] = Object.entries(table.columns).map(([name, column]) =>\n toColumnSpec(name, column, storageTypes, isInlineAutoincrementPrimaryKey(table, name)),\n );\n const uniques: SqliteUniqueSpec[] = table.uniques.map((u) => ({\n columns: u.columns,\n ...(u.name !== undefined ? { name: u.name } : {}),\n }));\n const foreignKeys: SqliteForeignKeySpec[] = table.foreignKeys.map((fk) => ({\n columns: fk.columns,\n references: { table: fk.references.table, columns: fk.references.columns },\n constraint: fk.constraint !== false,\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// Issue planner\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaIssue[];\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema?: 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\nfunction emptySchemaIR(): SqlSchemaIR {\n return { tables: {}, dependencies: [] };\n}\n\n// ============================================================================\n// Issue → Call mapping (per-issue default path)\n// ============================================================================\n\nfunction mapIssueToCall(\n issue: SchemaIssue,\n ctx: StrategyContext,\n): Result<readonly SqliteOpFactoryCall[], SqlPlannerConflict> {\n switch (issue.kind) {\n case 'missing_table': {\n if (!issue.table) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing table issue has no table name'),\n );\n }\n const contractTable = ctx.toContract.storage.tables[issue.table];\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" reported missing but not found in destination contract`,\n ),\n );\n }\n const tableSpec = toTableSpec(contractTable, ctx.storageTypes);\n const calls: SqliteOpFactoryCall[] = [new CreateTableCall(issue.table, tableSpec)];\n const declaredIndexColumnKeys = new Set<string>();\n for (const index of contractTable.indexes) {\n const indexName = index.name ?? defaultIndexName(issue.table, index.columns);\n declaredIndexColumnKeys.add(index.columns.join(','));\n calls.push(new CreateIndexCall(issue.table, indexName, index.columns));\n }\n for (const fk of contractTable.foreignKeys) {\n if (fk.index === false) continue;\n if (declaredIndexColumnKeys.has(fk.columns.join(','))) continue;\n const indexName = defaultIndexName(issue.table, fk.columns);\n calls.push(new CreateIndexCall(issue.table, indexName, fk.columns));\n }\n return ok(calls);\n }\n\n case 'missing_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Missing column issue has no table/column name'),\n );\n }\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n }\n const contractTable = ctx.toContract.storage.tables[issue.table];\n const columnSpec = toColumnSpec(\n issue.column,\n column,\n ctx.storageTypes,\n contractTable ? isInlineAutoincrementPrimaryKey(contractTable, issue.column) : false,\n );\n return ok([new AddColumnCall(issue.table, columnSpec)]);\n }\n\n case 'index_mismatch': {\n if (!issue.table) {\n return notOk(issueConflict('indexIncompatible', 'Index issue has no table name'));\n }\n if (!isMissing(issue) || !issue.expected) {\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Index on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n }\n const columns = issue.expected.split(', ');\n const contractTable = ctx.toContract.storage.tables[issue.table];\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" not found in destination contract`,\n ),\n );\n }\n // Use the explicit-index name if one is declared for these columns;\n // otherwise fall back to `defaultIndexName` (which is also what\n // `verifySqlSchema` synthesizes for FK-backing indexes). Whether the\n // missing index originates from `contractTable.indexes` or from an FK\n // with `index: true` doesn't change the emitted DDL.\n const explicitIndex = contractTable.indexes.find(\n (idx) => idx.columns.join(',') === columns.join(','),\n );\n const indexName = explicitIndex?.name ?? defaultIndexName(issue.table, columns);\n return ok([new CreateIndexCall(issue.table, indexName, columns)]);\n }\n\n case 'extra_table': {\n if (!issue.table) {\n return notOk(issueConflict('unsupportedOperation', 'Extra table issue has no table name'));\n }\n // Runner-owned control tables must never be dropped.\n if (CONTROL_TABLE_NAMES.has(issue.table)) return ok([]);\n return ok([new DropTableCall(issue.table)]);\n }\n\n case 'extra_column': {\n if (!issue.table || !issue.column) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra column issue has no table/column name'),\n );\n }\n return ok([new DropColumnCall(issue.table, issue.column)]);\n }\n\n case 'extra_index': {\n if (!issue.table || !issue.indexOrConstraint) {\n return notOk(\n issueConflict('unsupportedOperation', 'Extra index issue has no table/index name'),\n );\n }\n return ok([new DropIndexCall(issue.table, issue.indexOrConstraint)]);\n }\n\n // SQLite has no enum types (capability `sql.enums: false`). The verifier\n // should never emit `enum_values_changed` against a SQLite schema, so if\n // we receive one it is a verifier bug — surface it as an explicit\n // conflict rather than silently dropping it.\n case 'enum_values_changed':\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Received enum_values_changed against a SQLite schema (sql.enums: false) — verifier bug',\n ),\n );\n\n // Everything below is absorbed by recreateTableStrategy. If it falls\n // through here, policy or context didn't allow the recreate — surface as\n // a conflict.\n case 'type_mismatch':\n case 'nullability_mismatch':\n case 'default_mismatch':\n case 'default_missing':\n case 'extra_default':\n case 'primary_key_mismatch':\n case 'unique_constraint_mismatch':\n case 'foreign_key_mismatch':\n case 'extra_foreign_key':\n case 'extra_unique_constraint':\n case 'extra_primary_key':\n return notOk(issueConflict(conflictKindForIssue(issue), issue.message, issueLocation(issue)));\n\n default:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Unhandled issue kind: ${(issue as SchemaIssue).kind}`,\n ),\n );\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 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 schema = options.schema ?? emptySchemaIR();\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n toContract: options.toContract,\n fromContract: options.fromContract,\n codecHooks: options.codecHooks,\n storageTypes: options.storageTypes,\n schema,\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 = issueOrder(a) - issueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = issueKey(a);\n const keyB = issueKey(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 = mapIssueToCall(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","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlanner,\n SqlMigrationPlannerPlanOptions,\n SqlMigrationPlanOperation,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { parseSqliteDefault } from '../default-normalizer';\nimport { normalizeSqliteNativeType } from '../native-type-normalizer';\nimport { planIssues } from './issue-planner';\nimport { RawSqlCall } from './op-factory-call';\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(): SqliteMigrationPlanner {\n return new SqliteMigrationPlanner();\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()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the registered\n * strategies. Strategies absorb groups of related issues into composite\n * recipes (e.g. recreating a table to apply type/nullability/default/\n * constraint changes at once); anything not absorbed by a strategy flows\n * through `mapIssueToCall` in the issue planner as a one-off call.\n *\n * FK-backing indexes are surfaced by `verifySqlSchema`'s index expansion\n * (see `verify-sql-schema.ts:459-469`), so `mapIssueToCall` handles them\n * uniformly alongside user-declared indexes.\n */\nexport class SqliteMigrationPlanner\n implements SqlMigrationPlanner<SqlitePlanTargetDetails>, MigrationPlanner<'sql', 'sqlite'>\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 }): 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 );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): SqlitePlanResult {\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) return policyResult;\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n\n const result = planIssues({\n issues: schemaIssues,\n toContract: options.contract,\n fromContract: options.fromContract,\n codecHooks,\n storageTypes,\n schema: options.schema,\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 // `extractCodecControlHooks` erases target-details to `unknown`; codec\n // authors target a specific lane (here, sqlite) and produce ops whose\n // target-details are `SqlitePlanTargetDetails`-shaped by construction.\n // The cast re-specializes the type at this trust boundary.\n const calls = [\n ...result.value.calls,\n ...fieldEventOps.map(\n (op) => new RawSqlCall(op as SqlMigrationPlanOperation<SqlitePlanTargetDetails>),\n ),\n ];\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 ),\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 private collectSchemaIssues(options: SqlMigrationPlannerPlanOptions): readonly SchemaIssue[] {\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyResult = verifySqlSchema({\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parseSqliteDefault,\n normalizeNativeType: normalizeSqliteNativeType,\n });\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;;;;;AAyDA,MAAM,uBAAuB,IAAI,IAAyB,CAAC,oBAAoB,kBAAkB,CAAC;AAElG,MAAM,0BAA0B,IAAI,IAAyB;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,cAAc,OAAuD;CAC5E,IAAI,MAAM,SAAS,uBAAuB,OAAO;CACjD,IAAI,CAAC,MAAM,OAAO,OAAO;CACzB,IAAI,MAAM,SAAS,wBAEjB,OAAO,MAAM,aAAa,SAAS,aAAa;CAElD,IAAI,qBAAqB,IAAI,MAAM,KAAK,EAAE,OAAO;CACjD,IAAI,wBAAwB,IAAI,MAAM,KAAK,EAAE,OAAO;CACpD,OAAO;;;;;;;;AAST,MAAa,yBAAgD,QAAQ,QAAQ;CAC3E,MAAM,0BAAU,IAAI,KAAiE;CACrF,MAAM,2BAAW,IAAI,KAAkB;CAEvC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,cAAc,MAAM;EAChC,IAAI,CAAC,KAAK;EACV,IAAI,MAAM,SAAS,uBAAuB;EAC1C,IAAI,CAAC,MAAM,OAAO;EAClB,MAAM,QAAQ,MAAM;EACpB,MAAM,QAAQ,QAAQ,IAAI,MAAM;EAChC,IAAI,OAAO;GACT,MAAM,OAAO,KAAK,MAAM;GACxB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AAO,MAAM,OAChB,GAAG,cAAc,KACd,OAAO,IAAI,WAAW,GAAyD,CACjF,CACF;EAED,MAAM,cAA8C;GAClD,aAAa,QAAQ,SAAS,QAAQ;GACtC,GAAI,QAAQ,SAAS,gBAAgB,KAAA,IACjC,EAAE,aAAa,QAAQ,SAAS,aAAa,GAC7C,EAAE;GACP;EAED,OAAO;GACL,MAAM;GACN,MAAM,IAAI,oCACR,OACA;IACE,MAAM,QAAQ,cAAc,QAAQ,eAAe;IACnD,IAAI,QAAQ,SAAS,QAAQ;IAC9B,EACD,QAAQ,SACR,YACD;GACF;;CAGH,qBAA6B,QAAkE;EAC7F,IAAI,CAAC,OAAO,wBAAwB,SAAS,WAAW,EACtD,OAAO,eAAe,CACpB;GACE,MAAM;GACN,SAAS;GACT,KAAK;GACN,CACF,CAAC;EAEJ,OAAO;;CAGT,oBAA4B,SAAiE;EAC3F,MAAM,UAAU,QAAQ,OAAO;EAC/B,MAAM,SAAS,QAAQ,SAAS,WAAW,IAAI,QAAQ,SAAS,cAAc;EAU9E,OATqB,gBAAgB;GACnC,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,KAAK;GAC/B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;GACtB,CACkB,CAAC,OAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
3
|
-
import {
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-DAb2NEX6.mjs";
|
|
3
|
+
import { u as SqliteOpFactoryCall } from "./op-factory-call-FrU2vXqw.mjs";
|
|
4
4
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
5
|
import { MigrationPlanWithAuthoringSurface } from "@prisma-next/framework-components/control";
|
|
6
6
|
import { MigrationMeta } from "@prisma-next/migration-tools/migration";
|
|
@@ -27,4 +27,4 @@ declare class TypeScriptRenderableSqliteMigration extends SqliteMigration implem
|
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
export { TypeScriptRenderableSqliteMigration as n, SqliteMigrationDestinationInfo as t };
|
|
30
|
-
//# sourceMappingURL=planner-produced-sqlite-migration-
|
|
30
|
+
//# sourceMappingURL=planner-produced-sqlite-migration-BblR19lI.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-sqlite-migration-BblR19lI.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-sqlite-migration.ts"],"mappings":";;;;;;;;KAUK,EAAA,GAAK,yBAAA,CAA0B,uBAAA;AAAA,UAEnB,8BAAA;EAAA,SACN,WAAA;EAAA,SACA,WAAA;AAAA;AAAA,cAGE,mCAAA,SACH,eAAA,YACG,iCAAA;EAAA;cAQT,KAAA,WAAgB,mBAAA,IAChB,IAAA,EAAM,aAAA,EACN,OAAA,UACA,WAAA,GAAc,8BAAA;EAAA,IASH,UAAA,CAAA,YAAuB,EAAA;EAI3B,QAAA,CAAA,GAAY,aAAA;EAAA,IAIR,WAAA,CAAA,GAAe,8BAAA;EAjCR;AAGtB;;;;EAHsB,IA0ChB,OAAA,CAAA;EAIJ,gBAAA,CAAA;AAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as renderOps } from "./render-ops-
|
|
2
|
-
import { t as SqliteMigration } from "./sqlite-migration-
|
|
1
|
+
import { t as renderOps } from "./render-ops-CSRDT4YL.mjs";
|
|
2
|
+
import { t as SqliteMigration } from "./sqlite-migration-BBJktVVw.mjs";
|
|
3
3
|
import { jsonToTsSource, renderImports } from "@prisma-next/ts-render";
|
|
4
4
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
5
5
|
import { detectScaffoldRuntime, shebangLineFor } from "@prisma-next/migration-tools/migration-ts";
|
|
6
|
-
|
|
7
6
|
//#region src/core/migrations/render-typescript.ts
|
|
8
7
|
/**
|
|
9
8
|
* Polymorphic TypeScript emitter for the SQLite migration IR. Mirrors the
|
|
@@ -71,7 +70,6 @@ function indent(text, spaces) {
|
|
|
71
70
|
const pad = " ".repeat(spaces);
|
|
72
71
|
return text.split("\n").map((line) => line.trim() ? `${pad}${line}` : line).join("\n");
|
|
73
72
|
}
|
|
74
|
-
|
|
75
73
|
//#endregion
|
|
76
74
|
//#region src/core/migrations/planner-produced-sqlite-migration.ts
|
|
77
75
|
var TypeScriptRenderableSqliteMigration = class extends SqliteMigration {
|
|
@@ -111,7 +109,7 @@ var TypeScriptRenderableSqliteMigration = class extends SqliteMigration {
|
|
|
111
109
|
});
|
|
112
110
|
}
|
|
113
111
|
};
|
|
114
|
-
|
|
115
112
|
//#endregion
|
|
116
113
|
export { TypeScriptRenderableSqliteMigration as t };
|
|
117
|
-
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=planner-produced-sqlite-migration-CH7YGZf6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-produced-sqlite-migration-CH7YGZf6.mjs","names":["#calls","#meta","#destination","#spaceId"],"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 { detectScaffoldRuntime, shebangLineFor } from '@prisma-next/migration-tools/migration-ts';\nimport { type ImportRequirement, jsonToTsSource, renderImports } from '@prisma-next/ts-render';\nimport type { SqliteOpFactoryCall } from './op-factory-call';\n\nexport interface RenderMigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n/**\n * Always-present base imports for the rendered scaffold. Both come from\n * `@prisma-next/target-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 target-owned 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/target-sqlite/migration', symbol: 'Migration' },\n { moduleSpecifier: '@prisma-next/target-sqlite/migration', symbol: 'MigrationCLI' },\n];\n\nexport function renderCallsToTypeScript(\n calls: ReadonlyArray<SqliteOpFactoryCall>,\n meta: RenderMigrationMeta,\n): string {\n const imports = buildImports(calls);\n const operationsBody = calls.map((c) => c.renderTypeScript()).join(',\\n');\n\n return [\n shebangLineFor(detectScaffoldRuntime()),\n imports,\n '',\n 'export default class M extends Migration {',\n buildDescribeMethod(meta),\n ' override get operations() {',\n ' return [',\n indent(operationsBody, 6),\n ' ];',\n ' }',\n '}',\n '',\n 'MigrationCLI.run(import.meta.url, M);',\n '',\n ].join('\\n');\n}\n\nfunction buildImports(calls: ReadonlyArray<SqliteOpFactoryCall>): string {\n const requirements: ImportRequirement[] = [...BASE_IMPORTS];\n for (const call of calls) {\n for (const req of call.importRequirements()) {\n requirements.push(req);\n }\n }\n return renderImports(requirements);\n}\n\nfunction buildDescribeMethod(meta: RenderMigrationMeta): string {\n const lines: string[] = [];\n lines.push(' override describe() {');\n lines.push(' return {');\n lines.push(` from: ${JSON.stringify(meta.from)},`);\n lines.push(` to: ${JSON.stringify(meta.to)},`);\n if (meta.labels && meta.labels.length > 0) {\n lines.push(` labels: ${jsonToTsSource(meta.labels)},`);\n }\n lines.push(' };');\n lines.push(' }');\n lines.push('');\n return lines.join('\\n');\n}\n\nfunction indent(text: string, spaces: number): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => (line.trim() ? `${pad}${line}` : line))\n .join('\\n');\n}\n","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { MigrationPlanWithAuthoringSurface } from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { SqliteOpFactoryCall } from './op-factory-call';\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 SqliteOpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #destination: SqliteMigrationDestinationInfo;\n readonly #spaceId: string;\n\n constructor(\n calls: readonly SqliteOpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n destination?: SqliteMigrationDestinationInfo,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#destination = destination ?? { storageHash: meta.to };\n }\n\n override get operations(): readonly Op[] {\n return renderOps(this.#calls);\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n 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 ...ifDefined('labels', this.#meta.labels),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,eAA6C,CACjD;CAAE,iBAAi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ACA,aACA;EACA,OAAO;EACP,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKE,WAAW;EAChB,KAAKD,eAAe,eAAe,EAAE,aAAa,KAAK,IAAI;;CAG7D,IAAa,aAA4B;EACvC,OAAO,UAAU,KAAKF,OAAO;;CAG/B,WAAmC;EACjC,OAAO,KAAKC;;CAGd,IAAa,cAA8C;EACzD,OAAO,KAAKC;;;;;;;CAQd,IAAI,UAAkB;EACpB,OAAO,KAAKC;;CAGd,mBAA2B;EACzB,OAAO,wBAAwB,KAAKH,QAAQ;GAC1C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,GAAG,UAAU,UAAU,KAAKA,MAAM,OAAO;GAC1C,CAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./sqlite-migration-BeR1cikr.mjs";
|
|
3
|
-
import "./op-factory-call-dUIOao68.mjs";
|
|
4
|
-
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-CJr8ATRH.mjs";
|
|
1
|
+
import { n as TypeScriptRenderableSqliteMigration, t as SqliteMigrationDestinationInfo } from "./planner-produced-sqlite-migration-BblR19lI.mjs";
|
|
5
2
|
export { type SqliteMigrationDestinationInfo, TypeScriptRenderableSqliteMigration };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-
|
|
2
|
-
|
|
3
|
-
export { TypeScriptRenderableSqliteMigration };
|
|
1
|
+
import { t as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CH7YGZf6.mjs";
|
|
2
|
+
export { TypeScriptRenderableSqliteMigration };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
|
-
|
|
3
2
|
//#region src/core/migrations/planner-target-details.ts
|
|
4
3
|
const DEFAULT_SCHEMA = "main";
|
|
5
4
|
function buildTargetDetails(objectType, name, table) {
|
|
@@ -10,7 +9,7 @@ function buildTargetDetails(objectType, name, table) {
|
|
|
10
9
|
...ifDefined("table", table)
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
export { buildTargetDetails as t };
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=planner-target-details-Bm71XPKb.mjs.map
|
package/dist/{planner-target-details-BQIWQlBu.mjs.map → planner-target-details-Bm71XPKb.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-target-details-
|
|
1
|
+
{"version":3,"file":"planner-target-details-Bm71XPKb.mjs","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type OperationClass = 'table' | 'column' | 'primaryKey' | 'unique' | 'index' | 'foreignKey';\n\n// SQLite's default (and only) schema name; keeps `SqlitePlanTargetDetails`\n// conformant with `SqlPlanTargetDetails`, which mandates a `schema` field.\nconst DEFAULT_SCHEMA = 'main';\n\nexport interface SqlitePlanTargetDetails {\n readonly schema: string;\n readonly objectType: OperationClass;\n readonly name: string;\n readonly table?: string;\n}\n\nexport interface PlanningMode {\n readonly includeExtraObjects: boolean;\n readonly allowWidening: boolean;\n readonly allowDestructive: boolean;\n}\n\nexport function buildTargetDetails(\n objectType: OperationClass,\n name: string,\n table?: string,\n): SqlitePlanTargetDetails {\n return {\n schema: DEFAULT_SCHEMA,\n objectType,\n name,\n ...ifDefined('table', table),\n };\n}\n"],"mappings":";;AAMA,MAAM,iBAAiB;AAevB,SAAgB,mBACd,YACA,MACA,OACyB;CACzB,OAAO;EACL,QAAQ;EACR;EACA;EACA,GAAG,UAAU,SAAS,MAAM;EAC7B"}
|
package/dist/{planner-target-details-CtWRvse0.d.mts → planner-target-details-vhvZDWK1.d.mts}
RENAMED
|
@@ -9,4 +9,4 @@ interface SqlitePlanTargetDetails {
|
|
|
9
9
|
declare function buildTargetDetails(objectType: OperationClass, name: string, table?: string): SqlitePlanTargetDetails;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { buildTargetDetails as n, SqlitePlanTargetDetails as t };
|
|
12
|
-
//# sourceMappingURL=planner-target-details-
|
|
12
|
+
//# sourceMappingURL=planner-target-details-vhvZDWK1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-target-details-vhvZDWK1.d.mts","names":[],"sources":["../src/core/migrations/planner-target-details.ts"],"mappings":";KAEY,cAAA;AAAA,UAMK,uBAAA;EAAA,SACN,MAAA;EAAA,SACA,UAAA,EAAY,cAAA;EAAA,SACZ,IAAA;EAAA,SACA,KAAA;AAAA;AAAA,iBASK,kBAAA,CACd,UAAA,EAAY,cAAA,EACZ,IAAA,UACA,KAAA,YACC,uBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { n as buildTargetDetails, t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
2
|
export { type SqlitePlanTargetDetails, buildTargetDetails };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as buildTargetDetails } from "./planner-target-details-
|
|
2
|
-
|
|
3
|
-
export { buildTargetDetails };
|
|
1
|
+
import { t as buildTargetDetails } from "./planner-target-details-Bm71XPKb.mjs";
|
|
2
|
+
export { buildTargetDetails };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import "./
|
|
3
|
-
import "./sqlite-migration-BeR1cikr.mjs";
|
|
4
|
-
import "./op-factory-call-dUIOao68.mjs";
|
|
5
|
-
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-CJr8ATRH.mjs";
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
|
+
import { n as TypeScriptRenderableSqliteMigration } from "./planner-produced-sqlite-migration-BblR19lI.mjs";
|
|
6
3
|
import { MigrationOperationPolicy, SqlMigrationPlanner, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
7
4
|
import { MigrationPlanner, MigrationScaffoldContext } from "@prisma-next/framework-components/control";
|
|
8
5
|
import { Contract } from "@prisma-next/contract/types";
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"
|
|
1
|
+
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/planner.ts"],"mappings":";;;;;;;;iBA+BgB,4BAAA,CAAA,GAAgC,sBAAA;AAAA,KAIpC,gBAAA;EAAA,SACG,IAAA;EAAA,SAA0B,IAAA,EAAM,mCAAA;AAAA,IAC3C,uBAAA;;;AAFJ;;;;;;;;;;AAkBA;;cAAa,sBAAA,YACA,mBAAA,CAAoB,uBAAA,GAA0B,gBAAA;EAEzD,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IAYa;;;;;;;;;;IAAA,SADrB,YAAA,EAAc,QAAA;IAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAdnC;;;;;IAAA,SAoBA,OAAA;EAAA,IACP,gBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,mCAAA;EAAA,QAWK,OAAA;EAAA,QAmEA,oBAAA;EAAA,QAaA,mBAAA;AAAA"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-
|
|
2
|
-
|
|
3
|
-
export { SqliteMigrationPlanner, createSqliteMigrationPlanner };
|
|
1
|
+
import { n as createSqliteMigrationPlanner, t as SqliteMigrationPlanner } from "./planner-C94LJeIM.mjs";
|
|
2
|
+
export { SqliteMigrationPlanner, createSqliteMigrationPlanner };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops-
|
|
1
|
+
{"version":3,"file":"render-ops-CSRDT4YL.mjs","names":[],"sources":["../src/core/migrations/render-ops.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqliteOpFactoryCall } from './op-factory-call';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport function renderOps(calls: readonly SqliteOpFactoryCall[]): Op[] {\n return calls.map((c) => c.toOp());\n}\n"],"mappings":";AAMA,SAAgB,UAAU,OAA6C;CACrE,OAAO,MAAM,KAAK,MAAM,EAAE,MAAM,CAAC"}
|
package/dist/render-ops.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
2
|
-
import "./
|
|
3
|
-
import { l as SqliteOpFactoryCall } from "./op-factory-call-dUIOao68.mjs";
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
|
+
import { u as SqliteOpFactoryCall } from "./op-factory-call-FrU2vXqw.mjs";
|
|
4
3
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
5
4
|
|
|
6
5
|
//#region src/core/migrations/render-ops.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"
|
|
1
|
+
{"version":3,"file":"render-ops.d.mts","names":[],"sources":["../src/core/migrations/render-ops.ts"],"mappings":";;;;;KAIK,EAAA,GAAK,yBAAA,CAA0B,uBAAA;AAAA,iBAEpB,SAAA,CAAU,KAAA,WAAgB,mBAAA,KAAwB,EAAA"}
|
package/dist/render-ops.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as renderOps } from "./render-ops-
|
|
2
|
-
|
|
3
|
-
export { renderOps };
|
|
1
|
+
import { t as renderOps } from "./render-ops-CSRDT4YL.mjs";
|
|
2
|
+
export { renderOps };
|
package/dist/runtime.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/core/runtime-target.ts"],"mappings":";;;;UAIiB,2BAAA,SAAoC,qBAAA;AAAA,cAE/C,6BAAA,EAA+B,0BAAA,WAEnC,2BAAA"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-
|
|
2
|
-
|
|
1
|
+
import { t as sqliteTargetDescriptorMeta } from "./descriptor-meta-CE2Kbn9b.mjs";
|
|
3
2
|
//#region src/core/runtime-target.ts
|
|
4
3
|
const sqliteRuntimeTargetDescriptor = {
|
|
5
4
|
...sqliteTargetDescriptorMeta,
|
|
@@ -11,8 +10,7 @@ const sqliteRuntimeTargetDescriptor = {
|
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
|
-
var runtime_target_default = sqliteRuntimeTargetDescriptor;
|
|
15
|
-
|
|
16
13
|
//#endregion
|
|
17
|
-
export {
|
|
14
|
+
export { sqliteRuntimeTargetDescriptor as default };
|
|
15
|
+
|
|
18
16
|
//# sourceMappingURL=runtime.mjs.map
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../src/core/runtime-target.ts"],"sourcesContent":["import type { RuntimeTargetInstance } from '@prisma-next/framework-components/execution';\nimport type { SqlRuntimeTargetDescriptor } from '@prisma-next/sql-runtime';\nimport { sqliteTargetDescriptorMeta } from './descriptor-meta';\n\nexport interface SqliteRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'sqlite'> {}\n\nconst sqliteRuntimeTargetDescriptor: SqlRuntimeTargetDescriptor<\n 'sqlite',\n SqliteRuntimeTargetInstance\n> = {\n ...sqliteTargetDescriptorMeta,\n codecs: () => [],\n create(): SqliteRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'sqlite',\n };\n },\n};\n\nexport default sqliteRuntimeTargetDescriptor;\n"],"mappings":";;AAMA,MAAM,gCAGF;CACF,GAAG;CACH,cAAc,EAAE;CAChB,SAAsC;EACpC,OAAO;GACL,UAAU;GACV,UAAU;GACX;;CAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
2
|
import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
|
|
3
3
|
import { ReferentialAction } from "@prisma-next/sql-contract/types";
|
|
4
4
|
|
|
@@ -66,4 +66,4 @@ interface SqliteIndexSpec {
|
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
68
|
export { SqliteTableSpec as i, SqliteColumnSpec as n, SqliteIndexSpec as r, Op as t };
|
|
69
|
-
//# sourceMappingURL=shared-
|
|
69
|
+
//# sourceMappingURL=shared-qLsgTOZs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-qLsgTOZs.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAKY,EAAA,GAAK,yBAAA,CAA0B,uBAAA;;;AAsB3C;;;;;;;;;;;AAQA;;;UARiB,gBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACA,6BAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;AAAA;AAAA,UAGM,gBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;AAAA;AAAA,UAGM,oBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,IAAA;EAAA,SACA,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;EAAA,SACX,UAAA;AAAA;;;;;UAOM,eAAA;EAAA,SACN,OAAA,WAAkB,gBAAA;EAAA,SAClB,UAAA,GAAa,oBAAA;EAAA,SACb,OAAA,YAAmB,gBAAA;EAAA,SACnB,WAAA,YAAuB,oBAAA;AAAA;;;;;;UAQjB,eAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;AAAA"}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* back into `adapter-sqlite` for these primitives.
|
|
12
12
|
*/
|
|
13
13
|
var SqlEscapeError = class extends Error {
|
|
14
|
+
value;
|
|
15
|
+
kind;
|
|
14
16
|
constructor(message, value, kind) {
|
|
15
17
|
super(message);
|
|
16
18
|
this.value = value;
|
|
@@ -27,7 +29,7 @@ function escapeLiteral(value) {
|
|
|
27
29
|
if (value.includes("\0")) throw new SqlEscapeError("Literal value cannot contain null bytes", value.replace(/\0/g, "\\0"), "literal");
|
|
28
30
|
return value.replace(/'/g, "''");
|
|
29
31
|
}
|
|
30
|
-
|
|
31
32
|
//#endregion
|
|
32
33
|
export { escapeLiteral as n, quoteIdentifier as r, SqlEscapeError as t };
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=sql-utils-DhevMgef.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-utils-DhevMgef.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the SQLite target.\n *\n * These functions handle safe SQL identifier and literal escaping. They\n * live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)\n * so both the control adapter (used at emit time) and the runtime adapter\n * (used at execute time) can depend on them through a single one-way edge:\n * `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the\n * cyclic workspace dependency that would arise if `target-sqlite` reached\n * back into `adapter-sqlite` for these primitives.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,QAAQ;EAHE,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;;;AAIhB,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,aAAa;CAElF,IAAI,WAAW,SAAS,KAAK,EAC3B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,MAAM,EAChC,aACD;CAEH,OAAO,IAAI,WAAW,QAAQ,MAAM,OAAK,CAAC;;AAG5C,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,KAAK,EACtB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,MAAM,EAC3B,UACD;CAEH,OAAO,MAAM,QAAQ,MAAM,KAAK"}
|
package/dist/sql-utils.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"
|
|
1
|
+
{"version":3,"file":"sql-utils.d.mts","names":[],"sources":["../src/core/sql-utils.ts"],"mappings":";;AAYA;;;;;;;;;;cAAa,cAAA,SAAuB,KAAA;EAAA,SAGhB,KAAA;EAAA,SACA,IAAA;cAFhB,OAAA,UACgB,KAAA,UACA,IAAA;AAAA;AAAA,iBAOJ,eAAA,CAAgB,UAAA;AAAA,iBAchB,aAAA,CAAc,KAAA"}
|
package/dist/sql-utils.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as escapeLiteral, r as quoteIdentifier, t as SqlEscapeError } from "./sql-utils-
|
|
2
|
-
|
|
3
|
-
export { SqlEscapeError, escapeLiteral, quoteIdentifier };
|
|
1
|
+
import { n as escapeLiteral, r as quoteIdentifier, t as SqlEscapeError } from "./sql-utils-DhevMgef.mjs";
|
|
2
|
+
export { SqlEscapeError, escapeLiteral, quoteIdentifier };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
2
|
-
|
|
3
2
|
//#region src/core/migrations/sqlite-migration.ts
|
|
4
3
|
/**
|
|
5
4
|
* Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
|
|
@@ -11,7 +10,7 @@ import { Migration } from "@prisma-next/family-sql/migration";
|
|
|
11
10
|
var SqliteMigration = class extends Migration {
|
|
12
11
|
targetId = "sqlite";
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
//#endregion
|
|
16
14
|
export { SqliteMigration as t };
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=sqlite-migration-BBJktVVw.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-migration-
|
|
1
|
+
{"version":3,"file":"sqlite-migration-BBJktVVw.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\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 */\nexport abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetails> {\n readonly targetId = 'sqlite' as const;\n}\n"],"mappings":";;;;;;;;;AAUA,IAAsB,kBAAtB,cAA8CA,UAAsC;CAClF,WAAoB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { t as SqlitePlanTargetDetails } from "./planner-target-details-
|
|
1
|
+
import { t as SqlitePlanTargetDetails } from "./planner-target-details-vhvZDWK1.mjs";
|
|
2
2
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
3
3
|
|
|
4
4
|
//#region src/core/migrations/sqlite-migration.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
|
|
8
7
|
* generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
|
|
@@ -15,4 +14,4 @@ declare abstract class SqliteMigration extends Migration<SqlitePlanTargetDetails
|
|
|
15
14
|
}
|
|
16
15
|
//#endregion
|
|
17
16
|
export { SqliteMigration as t };
|
|
18
|
-
//# sourceMappingURL=sqlite-migration-
|
|
17
|
+
//# sourceMappingURL=sqlite-migration-DAb2NEX6.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-migration-DAb2NEX6.d.mts","names":[],"sources":["../src/core/migrations/sqlite-migration.ts"],"mappings":";;;;;;AAUA;;;;;uBAAsB,eAAA,SAAwB,SAAA,CAAa,uBAAA;EAAA,SAChD,QAAA;AAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
2
|
-
|
|
1
|
+
import { APP_SPACE_ID as APP_SPACE_ID$1 } from "@prisma-next/framework-components/control";
|
|
3
2
|
//#region src/core/migrations/statement-builders.ts
|
|
4
3
|
const MARKER_TABLE_NAME = "_prisma_marker";
|
|
5
4
|
const LEDGER_TABLE_NAME = "_prisma_ledger";
|
|
@@ -19,7 +18,7 @@ const CONTROL_TABLE_NAMES = new Set([MARKER_TABLE_NAME, LEDGER_TABLE_NAME]);
|
|
|
19
18
|
*/
|
|
20
19
|
const ensureMarkerTableStatement = {
|
|
21
20
|
sql: `CREATE TABLE IF NOT EXISTS _prisma_marker (
|
|
22
|
-
space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID}',
|
|
21
|
+
space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID$1}',
|
|
23
22
|
core_hash TEXT NOT NULL,
|
|
24
23
|
profile_hash TEXT NOT NULL,
|
|
25
24
|
contract_json TEXT,
|
|
@@ -153,7 +152,7 @@ function buildLedgerInsertStatement(input) {
|
|
|
153
152
|
function jsonParam(value) {
|
|
154
153
|
return JSON.stringify(value ?? null);
|
|
155
154
|
}
|
|
156
|
-
|
|
157
155
|
//#endregion
|
|
158
|
-
export { buildLedgerInsertStatement as a, ensureMarkerTableStatement as c, MARKER_TABLE_NAME as i, readMarkerStatement as l, CONTROL_TABLE_NAMES as n, buildWriteMarkerStatements as o, LEDGER_TABLE_NAME as r, ensureLedgerTableStatement as s, APP_SPACE_ID as t };
|
|
159
|
-
|
|
156
|
+
export { buildLedgerInsertStatement as a, ensureMarkerTableStatement as c, MARKER_TABLE_NAME as i, readMarkerStatement as l, CONTROL_TABLE_NAMES as n, buildWriteMarkerStatements as o, LEDGER_TABLE_NAME as r, ensureLedgerTableStatement as s, APP_SPACE_ID$1 as t };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=statement-builders-Dne-LkAV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement-builders-Dne-LkAV.mjs","names":["APP_SPACE_ID"],"sources":["../src/core/migrations/statement-builders.ts"],"sourcesContent":["import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\n\nexport { APP_SPACE_ID };\n\nexport interface SqlStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n}\n\nexport const MARKER_TABLE_NAME = '_prisma_marker';\nexport const LEDGER_TABLE_NAME = '_prisma_ledger';\n\n/**\n * Control tables the runner creates/manages. The planner must not drop these\n * when reconciling \"extra\" tables against the contract.\n */\nexport const CONTROL_TABLE_NAMES: ReadonlySet<string> = new Set([\n MARKER_TABLE_NAME,\n LEDGER_TABLE_NAME,\n]);\n\n/**\n * Schema for `_prisma_marker`. The `space TEXT PRIMARY KEY` shape\n * supports one row per loaded contract space (`'app'`,\n * `'<extension-id>'`, …); brand-new databases create this shape\n * directly. The migration runner detects pre-1.0 single-row markers\n * (no `space` column) at boot and fails with a structured\n * `LEGACY_MARKER_SHAPE` error rather than auto-rebuilding the table —\n * see `specs/framework-mechanism.spec.md § 2`.\n */\nexport const ensureMarkerTableStatement: SqlStatement = {\n sql: `CREATE TABLE IF NOT EXISTS _prisma_marker (\n space TEXT NOT NULL PRIMARY KEY DEFAULT '${APP_SPACE_ID}',\n core_hash TEXT NOT NULL,\n profile_hash TEXT NOT NULL,\n contract_json TEXT,\n canonical_version INTEGER,\n updated_at TEXT NOT NULL DEFAULT (datetime('now')),\n app_tag TEXT,\n meta TEXT NOT NULL DEFAULT '{}',\n invariants TEXT NOT NULL DEFAULT '[]'\n )`,\n params: [],\n};\n\nexport const ensureLedgerTableStatement: SqlStatement = {\n sql: `CREATE TABLE IF NOT EXISTS _prisma_ledger (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n created_at TEXT NOT NULL DEFAULT (datetime('now')),\n origin_core_hash TEXT,\n origin_profile_hash TEXT,\n destination_core_hash TEXT NOT NULL,\n destination_profile_hash TEXT,\n contract_json_before TEXT,\n contract_json_after TEXT,\n operations TEXT NOT NULL\n )`,\n params: [],\n};\n\nexport function readMarkerStatement(space: string): SqlStatement {\n return {\n sql: `SELECT\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n FROM _prisma_marker\n WHERE space = ?`,\n params: [space],\n };\n}\n\nexport interface WriteMarkerInput {\n /**\n * Logical space identifier for this marker row. Required at every\n * call site so the type system surfaces every place that needs to\n * thread the value (rather than letting an `?? APP_SPACE_ID`\n * fall-through silently collapse multi-space markers onto the\n * `'app'` row). App-plan callers pass {@link APP_SPACE_ID}\n * (`'app'`); per-extension callers pass the extension's space id.\n */\n readonly space: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number | null;\n readonly appTag?: string | null;\n readonly meta?: Record<string, unknown>;\n /**\n * Invariants to write into `marker.invariants`. Stored as a JSON-encoded\n * TEXT array — SQLite has no native array type. The runner is responsible\n * for merging with the existing column (no SQL-side merge here, unlike\n * Postgres) before passing them in: BEGIN EXCLUSIVE on the migration\n * transaction makes the read-then-merge-then-write sequence safe.\n */\n readonly invariants: readonly string[];\n}\n\nexport function buildWriteMarkerStatements(input: WriteMarkerInput): {\n readonly insert: SqlStatement;\n readonly update: SqlStatement;\n} {\n const params: readonly unknown[] = [\n input.space,\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n jsonParam(input.invariants),\n ];\n\n return {\n insert: {\n sql: `INSERT INTO _prisma_marker (\n space,\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta,\n invariants\n ) VALUES (\n ?,\n ?,\n ?,\n ?,\n ?,\n datetime('now'),\n ?,\n ?,\n ?\n )`,\n params,\n },\n update: {\n sql: `UPDATE _prisma_marker SET\n core_hash = ?,\n profile_hash = ?,\n contract_json = ?,\n canonical_version = ?,\n updated_at = datetime('now'),\n app_tag = ?,\n meta = ?,\n invariants = ?\n WHERE space = ?`,\n params: [\n input.storageHash,\n input.profileHash,\n jsonParam(input.contractJson),\n input.canonicalVersion ?? null,\n input.appTag ?? null,\n jsonParam(input.meta ?? {}),\n jsonParam(input.invariants),\n input.space,\n ],\n },\n };\n}\n\nexport interface LedgerInsertInput {\n readonly originStorageHash?: string | null;\n readonly originProfileHash?: string | null;\n readonly destinationStorageHash: string;\n readonly destinationProfileHash?: string | null;\n readonly contractJsonBefore?: unknown;\n readonly contractJsonAfter?: unknown;\n readonly operations: unknown;\n}\n\nexport function buildLedgerInsertStatement(input: LedgerInsertInput): SqlStatement {\n return {\n sql: `INSERT INTO _prisma_ledger (\n origin_core_hash,\n origin_profile_hash,\n destination_core_hash,\n destination_profile_hash,\n contract_json_before,\n contract_json_after,\n operations\n ) VALUES (\n ?,\n ?,\n ?,\n ?,\n ?,\n ?,\n ?\n )`,\n params: [\n input.originStorageHash ?? null,\n input.originProfileHash ?? null,\n input.destinationStorageHash,\n input.destinationProfileHash ?? null,\n jsonParam(input.contractJsonBefore),\n jsonParam(input.contractJsonAfter),\n jsonParam(input.operations),\n ],\n };\n}\n\nfunction jsonParam(value: unknown): string {\n return JSON.stringify(value ?? null);\n}\n"],"mappings":";;AASA,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;;;;;AAMjC,MAAa,sBAA2C,IAAI,IAAI,CAC9D,mBACA,kBACD,CAAC;;;;;;;;;;AAWF,MAAa,6BAA2C;CACtD,KAAK;+CACwCA,eAAa;;;;;;;;;;CAU1D,QAAQ,EAAE;CACX;AAED,MAAa,6BAA2C;CACtD,KAAK;;;;;;;;;;;CAWL,QAAQ,EAAE;CACX;AAED,SAAgB,oBAAoB,OAA6B;CAC/D,OAAO;EACL,KAAK;;;;;;;;;;;EAWL,QAAQ,CAAC,MAAM;EAChB;;AA6B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