@prisma-next/target-sqlite 0.5.0-dev.8 → 0.5.0-dev.81
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-CYwMu3-4.d.mts +13 -0
- package/dist/codec-ids-CYwMu3-4.d.mts.map +1 -0
- package/dist/codec-ids-CuUxYcd0.mjs +13 -0
- package/dist/codec-ids-CuUxYcd0.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -0
- package/dist/codec-ids.mjs +2 -0
- package/dist/codec-types-DNauB5UT.d.mts +23 -0
- package/dist/codec-types-DNauB5UT.d.mts.map +1 -0
- package/dist/codec-types.d.mts +3 -0
- package/dist/codec-types.mjs +2 -0
- package/dist/codecs-BAlEiSeP.d.mts +126 -0
- package/dist/codecs-BAlEiSeP.d.mts.map +1 -0
- package/dist/codecs-DVnHtVWW.mjs +220 -0
- package/dist/codecs-DVnHtVWW.mjs.map +1 -0
- package/dist/codecs.d.mts +2 -0
- package/dist/codecs.mjs +13 -0
- package/dist/codecs.mjs.map +1 -0
- package/dist/control.d.mts +4 -3
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +428 -5
- package/dist/control.mjs.map +1 -1
- package/dist/default-normalizer-3Fccw7yw.mjs +69 -0
- package/dist/default-normalizer-3Fccw7yw.mjs.map +1 -0
- package/dist/default-normalizer.d.mts +7 -0
- package/dist/default-normalizer.d.mts.map +1 -0
- package/dist/default-normalizer.mjs +2 -0
- package/dist/descriptor-meta-CE2Kbn9b.mjs +17 -0
- package/dist/descriptor-meta-CE2Kbn9b.mjs.map +1 -0
- package/dist/migration.d.mts +85 -0
- package/dist/migration.d.mts.map +1 -0
- package/dist/migration.mjs +49 -0
- package/dist/migration.mjs.map +1 -0
- package/dist/native-type-normalizer-BlN5XfD-.mjs +14 -0
- package/dist/native-type-normalizer-BlN5XfD-.mjs.map +1 -0
- package/dist/native-type-normalizer.d.mts +11 -0
- package/dist/native-type-normalizer.d.mts.map +1 -0
- package/dist/native-type-normalizer.mjs +2 -0
- package/dist/op-factory-call-DRKKURAO.mjs +279 -0
- package/dist/op-factory-call-DRKKURAO.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +151 -0
- package/dist/op-factory-call.d.mts.map +1 -0
- package/dist/op-factory-call.mjs +2 -0
- package/dist/pack.d.mts +35 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +2 -3
- package/dist/planner-CdCU0v1B.mjs +525 -0
- package/dist/planner-CdCU0v1B.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts +29 -0
- package/dist/planner-produced-sqlite-migration-CI9LdXPr.d.mts.map +1 -0
- package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs +110 -0
- package/dist/planner-produced-sqlite-migration-C_TzWbT0.mjs.map +1 -0
- package/dist/planner-produced-sqlite-migration.d.mts +2 -0
- package/dist/planner-produced-sqlite-migration.mjs +2 -0
- package/dist/planner-target-details-Bm71XPKb.mjs +15 -0
- package/dist/planner-target-details-Bm71XPKb.mjs.map +1 -0
- package/dist/planner-target-details-vhvZDWK1.d.mts +12 -0
- package/dist/planner-target-details-vhvZDWK1.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +2 -0
- package/dist/planner-target-details.mjs +2 -0
- package/dist/planner.d.mts +59 -0
- package/dist/planner.d.mts.map +1 -0
- package/dist/planner.mjs +2 -0
- package/dist/render-ops-CSRDT4YL.mjs +8 -0
- package/dist/render-ops-CSRDT4YL.mjs.map +1 -0
- package/dist/render-ops.d.mts +10 -0
- package/dist/render-ops.d.mts.map +1 -0
- package/dist/render-ops.mjs +2 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +4 -8
- package/dist/runtime.mjs.map +1 -1
- package/dist/shared-qLsgTOZs.d.mts +69 -0
- package/dist/shared-qLsgTOZs.d.mts.map +1 -0
- package/dist/sql-utils-DhevMgef.mjs +35 -0
- package/dist/sql-utils-DhevMgef.mjs.map +1 -0
- package/dist/sql-utils.d.mts +22 -0
- package/dist/sql-utils.d.mts.map +1 -0
- package/dist/sql-utils.mjs +2 -0
- package/dist/sqlite-migration-BBJktVVw.mjs +16 -0
- package/dist/sqlite-migration-BBJktVVw.mjs.map +1 -0
- package/dist/sqlite-migration-DAb2NEX6.d.mts +17 -0
- package/dist/sqlite-migration-DAb2NEX6.d.mts.map +1 -0
- package/dist/statement-builders-Dne-LkAV.mjs +158 -0
- package/dist/statement-builders-Dne-LkAV.mjs.map +1 -0
- package/dist/statement-builders.d.mts +68 -0
- package/dist/statement-builders.d.mts.map +1 -0
- package/dist/statement-builders.mjs +2 -0
- package/dist/tables-D84zfPZI.mjs +403 -0
- package/dist/tables-D84zfPZI.mjs.map +1 -0
- package/package.json +33 -11
- package/src/core/authoring.ts +9 -0
- package/src/core/codec-helpers.ts +11 -0
- package/src/core/codec-ids.ts +13 -0
- package/src/core/codecs.ts +337 -0
- package/src/core/control-target.ts +54 -11
- package/src/core/default-normalizer.ts +92 -0
- package/src/core/descriptor-meta.ts +5 -1
- package/src/core/migrations/issue-planner.ts +586 -0
- package/src/core/migrations/op-factory-call.ts +369 -0
- package/src/core/migrations/operations/columns.ts +62 -0
- package/src/core/migrations/operations/data-transform.ts +51 -0
- package/src/core/migrations/operations/indexes.ts +52 -0
- package/src/core/migrations/operations/raw.ts +12 -0
- package/src/core/migrations/operations/shared.ts +120 -0
- package/src/core/migrations/operations/tables.ts +388 -0
- package/src/core/migrations/planner-ddl-builders.ts +142 -0
- package/src/core/migrations/planner-produced-sqlite-migration.ts +70 -0
- package/src/core/migrations/planner-strategies.ts +231 -0
- package/src/core/migrations/planner-target-details.ts +33 -0
- package/src/core/migrations/planner.ts +183 -0
- package/src/core/migrations/render-ops.ts +15 -0
- package/src/core/migrations/render-typescript.ts +91 -0
- package/src/core/migrations/runner.ts +724 -0
- package/src/core/migrations/sqlite-migration.ts +13 -0
- package/src/core/migrations/statement-builders.ts +212 -0
- package/src/core/native-type-normalizer.ts +9 -0
- package/src/core/registry.ts +11 -0
- package/src/core/runtime-target.ts +1 -3
- package/src/core/sql-utils.ts +47 -0
- package/src/exports/codec-ids.ts +13 -0
- package/src/exports/codec-types.ts +43 -0
- package/src/exports/codecs.ts +20 -0
- package/src/exports/control.ts +1 -0
- package/src/exports/default-normalizer.ts +1 -0
- package/src/exports/migration.ts +24 -0
- package/src/exports/native-type-normalizer.ts +1 -0
- package/src/exports/op-factory-call.ts +12 -0
- package/src/exports/planner-produced-sqlite-migration.ts +4 -0
- package/src/exports/planner-target-details.ts +2 -0
- package/src/exports/planner.ts +2 -0
- package/src/exports/render-ops.ts +1 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/statement-builders.ts +12 -0
- package/dist/descriptor-meta-DbuuziYA.mjs +0 -14
- package/dist/descriptor-meta-DbuuziYA.mjs.map +0 -1
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { n as stripOuterParens } from "./default-normalizer-3Fccw7yw.mjs";
|
|
2
|
+
import { n as escapeLiteral, r as quoteIdentifier } from "./sql-utils-DhevMgef.mjs";
|
|
3
|
+
import { t as buildTargetDetails } from "./planner-target-details-Bm71XPKb.mjs";
|
|
4
|
+
//#region src/core/migrations/operations/shared.ts
|
|
5
|
+
function step(description, sql) {
|
|
6
|
+
return {
|
|
7
|
+
description,
|
|
8
|
+
sql
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const REFERENTIAL_ACTION_SQL = {
|
|
12
|
+
noAction: "NO ACTION",
|
|
13
|
+
restrict: "RESTRICT",
|
|
14
|
+
cascade: "CASCADE",
|
|
15
|
+
setNull: "SET NULL",
|
|
16
|
+
setDefault: "SET DEFAULT"
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Renders a single column's inline DDL fragment within a `CREATE TABLE`
|
|
20
|
+
* statement. Honours the `inlineAutoincrementPrimaryKey` flag — SQLite
|
|
21
|
+
* treats `INTEGER PRIMARY KEY AUTOINCREMENT` as a special form that aliases
|
|
22
|
+
* `rowid`, and the column must not carry a `DEFAULT` or repeat `NOT NULL`.
|
|
23
|
+
*/
|
|
24
|
+
function renderColumnDefinition(column) {
|
|
25
|
+
const parts = [quoteIdentifier(column.name), column.typeSql];
|
|
26
|
+
if (column.inlineAutoincrementPrimaryKey) parts.push("PRIMARY KEY AUTOINCREMENT");
|
|
27
|
+
else {
|
|
28
|
+
if (column.defaultSql) parts.push(column.defaultSql);
|
|
29
|
+
if (!column.nullable) parts.push("NOT NULL");
|
|
30
|
+
}
|
|
31
|
+
return parts.join(" ");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders an inline FOREIGN KEY constraint clause for a `CREATE TABLE`
|
|
35
|
+
* body. Returns the empty string when `constraint` is false (the FK is
|
|
36
|
+
* tracked at the contract level for index-creation purposes only and must
|
|
37
|
+
* not produce DDL).
|
|
38
|
+
*/
|
|
39
|
+
function renderForeignKeyClause(fk) {
|
|
40
|
+
if (!fk.constraint) return "";
|
|
41
|
+
let sql = `${fk.name ? `CONSTRAINT ${quoteIdentifier(fk.name)} ` : ""}FOREIGN KEY (${fk.columns.map(quoteIdentifier).join(", ")}) REFERENCES ${quoteIdentifier(fk.references.table)} (${fk.references.columns.map(quoteIdentifier).join(", ")})`;
|
|
42
|
+
if (fk.onDelete !== void 0) sql += ` ON DELETE ${REFERENTIAL_ACTION_SQL[fk.onDelete]}`;
|
|
43
|
+
if (fk.onUpdate !== void 0) sql += ` ON UPDATE ${REFERENTIAL_ACTION_SQL[fk.onUpdate]}`;
|
|
44
|
+
return sql;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/core/migrations/operations/columns.ts
|
|
48
|
+
function addColumn(tableName, column) {
|
|
49
|
+
const addSql = [
|
|
50
|
+
`ALTER TABLE ${quoteIdentifier(tableName)}`,
|
|
51
|
+
`ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,
|
|
52
|
+
column.defaultSql,
|
|
53
|
+
column.nullable ? "" : "NOT NULL"
|
|
54
|
+
].filter(Boolean).join(" ");
|
|
55
|
+
return {
|
|
56
|
+
id: `column.${tableName}.${column.name}`,
|
|
57
|
+
label: `Add column ${column.name} on ${tableName}`,
|
|
58
|
+
summary: `Adds column ${column.name} on ${tableName}`,
|
|
59
|
+
operationClass: "additive",
|
|
60
|
+
target: {
|
|
61
|
+
id: "sqlite",
|
|
62
|
+
details: buildTargetDetails("column", column.name, tableName)
|
|
63
|
+
},
|
|
64
|
+
precheck: [step(`ensure column "${column.name}" is missing`, `SELECT COUNT(*) = 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(column.name)}'`)],
|
|
65
|
+
execute: [step(`add column "${column.name}"`, addSql)],
|
|
66
|
+
postcheck: [step(`verify column "${column.name}" exists`, `SELECT COUNT(*) > 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(column.name)}'`)]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function dropColumn(tableName, columnName) {
|
|
70
|
+
return {
|
|
71
|
+
id: `dropColumn.${tableName}.${columnName}`,
|
|
72
|
+
label: `Drop column ${columnName} on ${tableName}`,
|
|
73
|
+
summary: `Drops column ${columnName} on ${tableName} which is not in the contract`,
|
|
74
|
+
operationClass: "destructive",
|
|
75
|
+
target: {
|
|
76
|
+
id: "sqlite",
|
|
77
|
+
details: buildTargetDetails("column", columnName, tableName)
|
|
78
|
+
},
|
|
79
|
+
precheck: [step(`ensure column "${columnName}" exists on "${tableName}"`, `SELECT COUNT(*) > 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(columnName)}'`)],
|
|
80
|
+
execute: [step(`drop column "${columnName}" from "${tableName}"`, `ALTER TABLE ${quoteIdentifier(tableName)} DROP COLUMN ${quoteIdentifier(columnName)}`)],
|
|
81
|
+
postcheck: [step(`verify column "${columnName}" is gone from "${tableName}"`, `SELECT COUNT(*) = 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(columnName)}'`)]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/core/migrations/planner-ddl-builders.ts
|
|
86
|
+
const SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*$/;
|
|
87
|
+
function assertSafeNativeType(nativeType) {
|
|
88
|
+
if (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) throw new Error(`Unsafe native type name in contract: "${nativeType}". Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*\$/`);
|
|
89
|
+
}
|
|
90
|
+
function assertSafeDefaultExpression(expression) {
|
|
91
|
+
if (expression.includes(";") || /--|\/\*|\bSELECT\b/i.test(expression)) throw new Error(`Unsafe default expression in contract: "${expression}". Default expressions must not contain semicolons, SQL comment tokens, or subqueries.`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Renders the column's DDL type token (e.g. `"INTEGER"`, `"TEXT"`).
|
|
95
|
+
* Resolves `typeRef` against `storageTypes` and validates the resulting
|
|
96
|
+
* native type against a safe-identifier pattern.
|
|
97
|
+
*/
|
|
98
|
+
function buildColumnTypeSql(column, storageTypes = {}) {
|
|
99
|
+
const resolved = resolveColumnTypeMetadata(column, storageTypes);
|
|
100
|
+
assertSafeNativeType(resolved.nativeType);
|
|
101
|
+
return resolved.nativeType.toUpperCase();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Renders the column's `DEFAULT …` clause. Returns the empty string when
|
|
105
|
+
* there is no default, and also when the default is `autoincrement()` —
|
|
106
|
+
* SQLite encodes that as `INTEGER PRIMARY KEY AUTOINCREMENT` inline on the
|
|
107
|
+
* column definition, not as a separate DEFAULT.
|
|
108
|
+
*/
|
|
109
|
+
function buildColumnDefaultSql(columnDefault) {
|
|
110
|
+
if (!columnDefault) return "";
|
|
111
|
+
switch (columnDefault.kind) {
|
|
112
|
+
case "literal": return `DEFAULT ${renderDefaultLiteral(columnDefault.value)}`;
|
|
113
|
+
case "function":
|
|
114
|
+
if (columnDefault.expression === "autoincrement()") return "";
|
|
115
|
+
if (columnDefault.expression === "now()") return "DEFAULT (datetime('now'))";
|
|
116
|
+
assertSafeDefaultExpression(columnDefault.expression);
|
|
117
|
+
return `DEFAULT (${columnDefault.expression})`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function renderDefaultLiteral(value) {
|
|
121
|
+
if (value instanceof Date) return `'${escapeLiteral(value.toISOString())}'`;
|
|
122
|
+
if (typeof value === "string") return `'${escapeLiteral(value)}'`;
|
|
123
|
+
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
124
|
+
if (typeof value === "boolean") return value ? "1" : "0";
|
|
125
|
+
if (value === null) return "NULL";
|
|
126
|
+
return `'${escapeLiteral(JSON.stringify(value))}'`;
|
|
127
|
+
}
|
|
128
|
+
function buildCreateIndexSql(tableName, indexName, columns, unique = false) {
|
|
129
|
+
return `CREATE ${unique ? "UNIQUE " : ""}INDEX ${quoteIdentifier(indexName)} ON ${quoteIdentifier(tableName)} (${columns.map(quoteIdentifier).join(", ")})`;
|
|
130
|
+
}
|
|
131
|
+
function buildDropIndexSql(indexName) {
|
|
132
|
+
return `DROP INDEX IF EXISTS ${quoteIdentifier(indexName)}`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* True when the column is rendered inline as `INTEGER PRIMARY KEY
|
|
136
|
+
* AUTOINCREMENT`. Requires the column's default to be `autoincrement()` and
|
|
137
|
+
* the column to be the sole member of the table's primary key — anything
|
|
138
|
+
* else falls back to a separate PRIMARY KEY constraint with a default
|
|
139
|
+
* AUTOINCREMENT semantics expressed elsewhere.
|
|
140
|
+
*/
|
|
141
|
+
function isInlineAutoincrementPrimaryKey(table, columnName) {
|
|
142
|
+
if (table.primaryKey?.columns.length !== 1) return false;
|
|
143
|
+
if (table.primaryKey.columns[0] !== columnName) return false;
|
|
144
|
+
const column = table.columns[columnName];
|
|
145
|
+
return column?.default?.kind === "function" && column.default.expression === "autoincrement()";
|
|
146
|
+
}
|
|
147
|
+
function resolveColumnTypeMetadata(column, storageTypes) {
|
|
148
|
+
if (!column.typeRef) return column;
|
|
149
|
+
const referencedType = storageTypes[column.typeRef];
|
|
150
|
+
if (!referencedType) throw new Error(`Storage type "${column.typeRef}" referenced by column is not defined in storage.types.`);
|
|
151
|
+
return {
|
|
152
|
+
codecId: referencedType.codecId,
|
|
153
|
+
nativeType: referencedType.nativeType,
|
|
154
|
+
typeParams: referencedType.typeParams
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/core/migrations/operations/indexes.ts
|
|
159
|
+
function createIndex(tableName, indexName, columns) {
|
|
160
|
+
return {
|
|
161
|
+
id: `index.${tableName}.${indexName}`,
|
|
162
|
+
label: `Create index ${indexName} on ${tableName}`,
|
|
163
|
+
summary: `Creates index ${indexName} on ${tableName}`,
|
|
164
|
+
operationClass: "additive",
|
|
165
|
+
target: {
|
|
166
|
+
id: "sqlite",
|
|
167
|
+
details: buildTargetDetails("index", indexName, tableName)
|
|
168
|
+
},
|
|
169
|
+
precheck: [step(`ensure index "${indexName}" is missing`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`)],
|
|
170
|
+
execute: [step(`create index "${indexName}"`, buildCreateIndexSql(tableName, indexName, columns))],
|
|
171
|
+
postcheck: [step(`verify index "${indexName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`)]
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function dropIndex(tableName, indexName) {
|
|
175
|
+
return {
|
|
176
|
+
id: `dropIndex.${tableName}.${indexName}`,
|
|
177
|
+
label: `Drop index ${indexName} on ${tableName}`,
|
|
178
|
+
summary: `Drops index ${indexName} on ${tableName} which is not in the contract`,
|
|
179
|
+
operationClass: "destructive",
|
|
180
|
+
target: {
|
|
181
|
+
id: "sqlite",
|
|
182
|
+
details: buildTargetDetails("index", indexName, tableName)
|
|
183
|
+
},
|
|
184
|
+
precheck: [step(`ensure index "${indexName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`)],
|
|
185
|
+
execute: [step(`drop index "${indexName}"`, buildDropIndexSql(indexName))],
|
|
186
|
+
postcheck: [step(`verify index "${indexName}" is gone`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`)]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/core/migrations/operations/tables.ts
|
|
191
|
+
/**
|
|
192
|
+
* Renders the body of a `CREATE TABLE <name> ( … )` statement from a flat
|
|
193
|
+
* `SqliteTableSpec`. SQLite's `INTEGER PRIMARY KEY AUTOINCREMENT` form is
|
|
194
|
+
* inline on the column; the table-level PRIMARY KEY clause is emitted only
|
|
195
|
+
* when no column carries `inlineAutoincrementPrimaryKey`.
|
|
196
|
+
*/
|
|
197
|
+
function renderCreateTableSql(tableName, spec) {
|
|
198
|
+
const columnDefs = spec.columns.map(renderColumnDefinition);
|
|
199
|
+
const constraintDefs = [];
|
|
200
|
+
const hasInlinePk = spec.columns.some((c) => c.inlineAutoincrementPrimaryKey);
|
|
201
|
+
if (spec.primaryKey && !hasInlinePk) constraintDefs.push(`PRIMARY KEY (${spec.primaryKey.columns.map(quoteIdentifier).join(", ")})`);
|
|
202
|
+
for (const u of spec.uniques ?? []) {
|
|
203
|
+
const name = u.name ? `CONSTRAINT ${quoteIdentifier(u.name)} ` : "";
|
|
204
|
+
constraintDefs.push(`${name}UNIQUE (${u.columns.map(quoteIdentifier).join(", ")})`);
|
|
205
|
+
}
|
|
206
|
+
for (const fk of spec.foreignKeys ?? []) {
|
|
207
|
+
const clause = renderForeignKeyClause(fk);
|
|
208
|
+
if (clause) constraintDefs.push(clause);
|
|
209
|
+
}
|
|
210
|
+
const allDefs = [...columnDefs, ...constraintDefs];
|
|
211
|
+
return `CREATE TABLE ${quoteIdentifier(tableName)} (\n ${allDefs.join(",\n ")}\n)`;
|
|
212
|
+
}
|
|
213
|
+
function createTable(tableName, spec) {
|
|
214
|
+
return {
|
|
215
|
+
id: `table.${tableName}`,
|
|
216
|
+
label: `Create table ${tableName}`,
|
|
217
|
+
summary: `Creates table ${tableName} with required columns`,
|
|
218
|
+
operationClass: "additive",
|
|
219
|
+
target: {
|
|
220
|
+
id: "sqlite",
|
|
221
|
+
details: buildTargetDetails("table", tableName)
|
|
222
|
+
},
|
|
223
|
+
precheck: [step(`ensure table "${tableName}" does not exist`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`)],
|
|
224
|
+
execute: [step(`create table "${tableName}"`, renderCreateTableSql(tableName, spec))],
|
|
225
|
+
postcheck: [step(`verify table "${tableName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`)]
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function dropTable(tableName) {
|
|
229
|
+
return {
|
|
230
|
+
id: `dropTable.${tableName}`,
|
|
231
|
+
label: `Drop table ${tableName}`,
|
|
232
|
+
summary: `Drops table ${tableName} which is not in the contract`,
|
|
233
|
+
operationClass: "destructive",
|
|
234
|
+
target: {
|
|
235
|
+
id: "sqlite",
|
|
236
|
+
details: buildTargetDetails("table", tableName)
|
|
237
|
+
},
|
|
238
|
+
precheck: [step(`ensure table "${tableName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`)],
|
|
239
|
+
execute: [step(`drop table "${tableName}"`, `DROP TABLE ${quoteIdentifier(tableName)}`)],
|
|
240
|
+
postcheck: [step(`verify table "${tableName}" is gone`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`)]
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function recreateTable(args) {
|
|
244
|
+
const { tableName, contractTable, schemaColumnNames, indexes, summary, postchecks, operationClass } = args;
|
|
245
|
+
const tempName = `_prisma_new_${tableName}`;
|
|
246
|
+
const liveSet = new Set(schemaColumnNames);
|
|
247
|
+
const sharedColumns = contractTable.columns.filter((c) => liveSet.has(c.name)).map((c) => c.name);
|
|
248
|
+
const columnList = sharedColumns.map(quoteIdentifier).join(", ");
|
|
249
|
+
const indexStatements = indexes.map((idx) => ({
|
|
250
|
+
description: `recreate index "${idx.name}" on "${tableName}"`,
|
|
251
|
+
sql: buildCreateIndexSql(tableName, idx.name, idx.columns)
|
|
252
|
+
}));
|
|
253
|
+
const copyStep = sharedColumns.length > 0 ? [step(`copy data from "${tableName}" to "${tempName}"`, `INSERT INTO ${quoteIdentifier(tempName)} (${columnList}) SELECT ${columnList} FROM ${quoteIdentifier(tableName)}`)] : [];
|
|
254
|
+
return {
|
|
255
|
+
id: `recreateTable.${tableName}`,
|
|
256
|
+
label: `Recreate table ${tableName}`,
|
|
257
|
+
summary,
|
|
258
|
+
operationClass,
|
|
259
|
+
target: {
|
|
260
|
+
id: "sqlite",
|
|
261
|
+
details: buildTargetDetails("table", tableName)
|
|
262
|
+
},
|
|
263
|
+
precheck: [step(`ensure table "${tableName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`), step(`ensure temp table "${tempName}" does not exist`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`)],
|
|
264
|
+
execute: [
|
|
265
|
+
step(`create new table "${tempName}" with desired schema`, renderCreateTableSql(tempName, contractTable)),
|
|
266
|
+
...copyStep,
|
|
267
|
+
step(`drop old table "${tableName}"`, `DROP TABLE ${quoteIdentifier(tableName)}`),
|
|
268
|
+
step(`rename "${tempName}" to "${tableName}"`, `ALTER TABLE ${quoteIdentifier(tempName)} RENAME TO ${quoteIdentifier(tableName)}`),
|
|
269
|
+
...indexStatements
|
|
270
|
+
],
|
|
271
|
+
postcheck: [
|
|
272
|
+
step(`verify table "${tableName}" exists`, `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`),
|
|
273
|
+
step(`verify temp table "${tempName}" is gone`, `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`),
|
|
274
|
+
...postchecks
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Build a one-line summary of a recreate-table operation from the schema
|
|
280
|
+
* issues that triggered it. Lives next to `recreateTable` so the planner
|
|
281
|
+
* (which has the issues) can produce the same description the factory
|
|
282
|
+
* used to build inline. Keeping the formatting target-side keeps
|
|
283
|
+
* `RecreateTableCall` issue-free at the IR layer.
|
|
284
|
+
*/
|
|
285
|
+
function buildRecreateSummary(tableName, issues) {
|
|
286
|
+
return `Recreates table ${tableName} to apply schema changes: ${issues.map((i) => i.message).join("; ")}`;
|
|
287
|
+
}
|
|
288
|
+
const COLUMN_LEVEL_ISSUE_KINDS = new Set([
|
|
289
|
+
"nullability_mismatch",
|
|
290
|
+
"default_mismatch",
|
|
291
|
+
"default_missing",
|
|
292
|
+
"extra_default",
|
|
293
|
+
"type_mismatch"
|
|
294
|
+
]);
|
|
295
|
+
const PK_ISSUE_KINDS = new Set(["primary_key_mismatch", "extra_primary_key"]);
|
|
296
|
+
const UNIQUE_ISSUE_KINDS = new Set(["unique_constraint_mismatch", "extra_unique_constraint"]);
|
|
297
|
+
const FK_ISSUE_KINDS = new Set(["foreign_key_mismatch", "extra_foreign_key"]);
|
|
298
|
+
/**
|
|
299
|
+
* Returns the columns the contract expects as the table's primary key. Picks
|
|
300
|
+
* up SQLite's inline `INTEGER PRIMARY KEY AUTOINCREMENT` form when no
|
|
301
|
+
* explicit `primaryKey` clause is set on the spec.
|
|
302
|
+
*/
|
|
303
|
+
function expectedPrimaryKeyColumns(spec) {
|
|
304
|
+
if (spec.primaryKey) return spec.primaryKey.columns;
|
|
305
|
+
const inlinePk = spec.columns.find((c) => c.inlineAutoincrementPrimaryKey);
|
|
306
|
+
return inlinePk ? [inlinePk.name] : [];
|
|
307
|
+
}
|
|
308
|
+
function quoteSqlList(values) {
|
|
309
|
+
return values.map((v) => `'${escapeLiteral(v)}'`).join(", ");
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Per-issue postchecks verifying the recreated table's shape against the
|
|
313
|
+
* contract spec. Column-level issues (`nullability_mismatch`,
|
|
314
|
+
* `default_mismatch`, …) emit one targeted check each; constraint-level
|
|
315
|
+
* issues (`primary_key_mismatch`, `unique_constraint_mismatch`,
|
|
316
|
+
* `foreign_key_mismatch`, plus their `extra_*` siblings) emit one
|
|
317
|
+
* `pragma_*`-driven check per declared constraint in the contract spec, so
|
|
318
|
+
* a recreated table with the right columns but the wrong PK / unique / FK
|
|
319
|
+
* shape fails the postcheck instead of passing silently. Exported so the
|
|
320
|
+
* planner can pre-build the list at construction time and
|
|
321
|
+
* `RecreateTableCall` doesn't have to carry `SchemaIssue` objects through
|
|
322
|
+
* to render time.
|
|
323
|
+
*/
|
|
324
|
+
function buildRecreatePostchecks(tableName, issues, spec) {
|
|
325
|
+
const checks = [];
|
|
326
|
+
const t = escapeLiteral(tableName);
|
|
327
|
+
const byName = new Map(spec.columns.map((c) => [c.name, c]));
|
|
328
|
+
for (const issue of issues) {
|
|
329
|
+
if (issue.kind === "enum_values_changed") continue;
|
|
330
|
+
if (!COLUMN_LEVEL_ISSUE_KINDS.has(issue.kind)) continue;
|
|
331
|
+
if (!issue.column) continue;
|
|
332
|
+
const c = escapeLiteral(issue.column);
|
|
333
|
+
if (issue.kind === "nullability_mismatch") {
|
|
334
|
+
let wantNotNull;
|
|
335
|
+
if (issue.expected === "false") wantNotNull = true;
|
|
336
|
+
else if (issue.expected === "true") wantNotNull = false;
|
|
337
|
+
if (wantNotNull !== void 0) checks.push({
|
|
338
|
+
description: `verify "${issue.column}" nullability on "${tableName}"`,
|
|
339
|
+
sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND "notnull" = ${wantNotNull ? 1 : 0}`
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
if (issue.kind === "default_mismatch" || issue.kind === "default_missing") {
|
|
343
|
+
const colSpec = byName.get(issue.column);
|
|
344
|
+
const expectedRaw = colSpec?.defaultSql.startsWith("DEFAULT ") ? stripOuterParens(colSpec.defaultSql.slice(8)) : null;
|
|
345
|
+
if (expectedRaw) checks.push({
|
|
346
|
+
description: `verify "${issue.column}" default on "${tableName}"`,
|
|
347
|
+
sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value = '${escapeLiteral(expectedRaw)}'`
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (issue.kind === "type_mismatch") {
|
|
351
|
+
const colSpec = byName.get(issue.column);
|
|
352
|
+
if (colSpec) checks.push({
|
|
353
|
+
description: `verify "${issue.column}" type on "${tableName}"`,
|
|
354
|
+
sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND LOWER(type) = '${escapeLiteral(colSpec.typeSql.toLowerCase())}'`
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
if (issue.kind === "extra_default") checks.push({
|
|
358
|
+
description: `verify "${issue.column}" has no default on "${tableName}"`,
|
|
359
|
+
sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value IS NULL`
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
const hasPkIssue = issues.some((i) => PK_ISSUE_KINDS.has(i.kind));
|
|
363
|
+
const hasUniqueIssue = issues.some((i) => UNIQUE_ISSUE_KINDS.has(i.kind));
|
|
364
|
+
const hasFkIssue = issues.some((i) => FK_ISSUE_KINDS.has(i.kind));
|
|
365
|
+
if (hasPkIssue) {
|
|
366
|
+
const pkColumns = expectedPrimaryKeyColumns(spec);
|
|
367
|
+
const colCount = pkColumns.length;
|
|
368
|
+
if (colCount === 0) checks.push({
|
|
369
|
+
description: `verify "${tableName}" has no primary key`,
|
|
370
|
+
sql: `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = 0`
|
|
371
|
+
});
|
|
372
|
+
else checks.push({
|
|
373
|
+
description: `verify primary key on "${tableName}"`,
|
|
374
|
+
sql: `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = ${colCount} AND (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0 AND name IN (${quoteSqlList(pkColumns)})) = ${colCount}`
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (hasUniqueIssue) for (const u of spec.uniques ?? []) {
|
|
378
|
+
const colCount = u.columns.length;
|
|
379
|
+
const description = u.name ? `verify unique constraint "${u.name}" on "${tableName}"` : `verify unique constraint (${u.columns.join(", ")}) on "${tableName}"`;
|
|
380
|
+
checks.push({
|
|
381
|
+
description,
|
|
382
|
+
sql: `SELECT EXISTS (SELECT 1 FROM pragma_index_list('${t}') l WHERE l."unique" = 1 AND (SELECT COUNT(*) FROM pragma_index_info(l.name)) = ${colCount} AND (SELECT COUNT(*) FROM pragma_index_info(l.name) WHERE name IN (${quoteSqlList(u.columns)})) = ${colCount})`
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (hasFkIssue) for (const fk of spec.foreignKeys ?? []) {
|
|
386
|
+
const refTable = escapeLiteral(fk.references.table);
|
|
387
|
+
const colCount = fk.columns.length;
|
|
388
|
+
const tuples = fk.columns.map((from, i) => {
|
|
389
|
+
const to = fk.references.columns[i] ?? from;
|
|
390
|
+
return `('${escapeLiteral(from)}', '${escapeLiteral(to)}')`;
|
|
391
|
+
}).join(", ");
|
|
392
|
+
const description = `verify foreign key (${fk.columns.join(", ")}) → ${fk.references.table}(${fk.references.columns.join(", ")}) on "${tableName}"`;
|
|
393
|
+
checks.push({
|
|
394
|
+
description,
|
|
395
|
+
sql: `SELECT EXISTS (SELECT 1 FROM pragma_foreign_key_list('${t}') f WHERE f."table" = '${refTable}' GROUP BY f.id HAVING COUNT(*) = ${colCount} AND SUM(CASE WHEN (f."from", f."to") IN (${tuples}) THEN 1 ELSE 0 END) = ${colCount})`
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
return checks;
|
|
399
|
+
}
|
|
400
|
+
//#endregion
|
|
401
|
+
export { recreateTable as a, buildColumnDefaultSql as c, renderDefaultLiteral as d, addColumn as f, dropTable as i, buildColumnTypeSql as l, step as m, buildRecreateSummary as n, createIndex as o, dropColumn as p, createTable as r, dropIndex as s, buildRecreatePostchecks as t, isInlineAutoincrementPrimaryKey as u };
|
|
402
|
+
|
|
403
|
+
//# sourceMappingURL=tables-D84zfPZI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables-D84zfPZI.mjs","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/operations/columns.ts","../src/core/migrations/planner-ddl-builders.ts","../src/core/migrations/operations/indexes.ts","../src/core/migrations/operations/tables.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { quoteIdentifier } from '../../sql-utils';\nimport type { SqlitePlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\nexport function step(description: string, sql: string): { description: string; sql: string } {\n return { description, sql };\n}\n\n/**\n * Flat, fully-resolved column shape consumed by `createTable`, `addColumn`,\n * and `recreateTable`. Codec / `typeRef` / default expansion happens at the\n * call-construction site (in the issue-planner / strategies) so the\n * operation factories deal only in pre-rendered SQL fragments — mirrors the\n * Postgres `ColumnSpec` pattern.\n *\n * - `typeSql` is the column's DDL type token (e.g. `\"INTEGER\"`, `\"TEXT\"`).\n * - `defaultSql` is the full `DEFAULT …` clause (or empty when there is no\n * default and when the column is rendered as `INTEGER PRIMARY KEY\n * AUTOINCREMENT`, since SQLite forbids a default on an autoincrement PK).\n * - `inlineAutoincrementPrimaryKey` directs the renderer to emit\n * `INTEGER PRIMARY KEY AUTOINCREMENT` inline and to skip the table-level\n * primary-key constraint for this column. SQLite-specific: the column\n * becomes an alias for `rowid` only when this exact form is used.\n */\nexport interface SqliteColumnSpec {\n readonly name: string;\n readonly typeSql: string;\n readonly defaultSql: string;\n readonly nullable: boolean;\n readonly inlineAutoincrementPrimaryKey?: boolean;\n}\n\nexport interface SqlitePrimaryKeySpec {\n readonly columns: readonly string[];\n}\n\nexport interface SqliteUniqueSpec {\n readonly columns: readonly string[];\n readonly name?: string;\n}\n\nexport interface SqliteForeignKeySpec {\n readonly columns: readonly string[];\n readonly references: {\n readonly table: string;\n readonly columns: readonly string[];\n };\n readonly name?: string;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n readonly constraint: boolean;\n}\n\n/**\n * Flat shape of a contract table for DDL emission. Used by both\n * `createTable` (additive) and `recreateTable` (widening/destructive).\n */\nexport interface SqliteTableSpec {\n readonly columns: readonly SqliteColumnSpec[];\n readonly primaryKey?: SqlitePrimaryKeySpec;\n readonly uniques?: readonly SqliteUniqueSpec[];\n readonly foreignKeys?: readonly SqliteForeignKeySpec[];\n}\n\n/**\n * Index recreation spec for `recreateTable`. Both declared indexes and\n * FK-backing indexes flatten to the same shape; the planner dedupes by\n * column-set before constructing the call.\n */\nexport interface SqliteIndexSpec {\n readonly name: string;\n readonly columns: readonly string[];\n}\n\nconst REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\n};\n\n/**\n * Renders a single column's inline DDL fragment within a `CREATE TABLE`\n * statement. Honours the `inlineAutoincrementPrimaryKey` flag — SQLite\n * treats `INTEGER PRIMARY KEY AUTOINCREMENT` as a special form that aliases\n * `rowid`, and the column must not carry a `DEFAULT` or repeat `NOT NULL`.\n */\nexport function renderColumnDefinition(column: SqliteColumnSpec): string {\n const parts: string[] = [quoteIdentifier(column.name), column.typeSql];\n if (column.inlineAutoincrementPrimaryKey) {\n parts.push('PRIMARY KEY AUTOINCREMENT');\n } else {\n if (column.defaultSql) parts.push(column.defaultSql);\n if (!column.nullable) parts.push('NOT NULL');\n }\n return parts.join(' ');\n}\n\n/**\n * Renders an inline FOREIGN KEY constraint clause for a `CREATE TABLE`\n * body. Returns the empty string when `constraint` is false (the FK is\n * tracked at the contract level for index-creation purposes only and must\n * not produce DDL).\n */\nexport function renderForeignKeyClause(fk: SqliteForeignKeySpec): string {\n if (!fk.constraint) return '';\n const name = fk.name ? `CONSTRAINT ${quoteIdentifier(fk.name)} ` : '';\n let sql = `${name}FOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')}) REFERENCES ${quoteIdentifier(fk.references.table)} (${fk.references.columns.map(quoteIdentifier).join(', ')})`;\n if (fk.onDelete !== undefined) {\n sql += ` ON DELETE ${REFERENTIAL_ACTION_SQL[fk.onDelete]}`;\n }\n if (fk.onUpdate !== undefined) {\n sql += ` ON UPDATE ${REFERENTIAL_ACTION_SQL[fk.onUpdate]}`;\n }\n return sql;\n}\n","import { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { buildTargetDetails } from '../planner-target-details';\nimport { type Op, type SqliteColumnSpec, step } from './shared';\n\nexport function addColumn(tableName: string, column: SqliteColumnSpec): Op {\n const parts = [\n `ALTER TABLE ${quoteIdentifier(tableName)}`,\n `ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n const addSql = parts.join(' ');\n\n return {\n id: `column.${tableName}.${column.name}`,\n label: `Add column ${column.name} on ${tableName}`,\n summary: `Adds column ${column.name} on ${tableName}`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('column', column.name, tableName) },\n precheck: [\n step(\n `ensure column \"${column.name}\" is missing`,\n `SELECT COUNT(*) = 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(column.name)}'`,\n ),\n ],\n execute: [step(`add column \"${column.name}\"`, addSql)],\n postcheck: [\n step(\n `verify column \"${column.name}\" exists`,\n `SELECT COUNT(*) > 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(column.name)}'`,\n ),\n ],\n };\n}\n\nexport function dropColumn(tableName: string, columnName: string): Op {\n return {\n id: `dropColumn.${tableName}.${columnName}`,\n label: `Drop column ${columnName} on ${tableName}`,\n summary: `Drops column ${columnName} on ${tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('column', columnName, tableName) },\n precheck: [\n step(\n `ensure column \"${columnName}\" exists on \"${tableName}\"`,\n `SELECT COUNT(*) > 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(columnName)}'`,\n ),\n ],\n execute: [\n step(\n `drop column \"${columnName}\" from \"${tableName}\"`,\n `ALTER TABLE ${quoteIdentifier(tableName)} DROP COLUMN ${quoteIdentifier(columnName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" is gone from \"${tableName}\"`,\n `SELECT COUNT(*) = 0 FROM pragma_table_info('${escapeLiteral(tableName)}') WHERE name = '${escapeLiteral(columnName)}'`,\n ),\n ],\n };\n}\n","/**\n * Low-level DDL fragment builders for SQLite migrations.\n *\n * These helpers consume `StorageColumn` (the contract shape, possibly with\n * `typeRef`) and produce string fragments. They are called once per column\n * at the call-construction boundary in `issue-planner.ts` / strategies to\n * build flat `SqliteColumnSpec`s; the operation factories themselves never\n * see `StorageColumn` or `storageTypes`.\n */\n\nimport type {\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\n\ntype SqliteColumnDefault = StorageColumn['default'];\n\nconst SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*$/;\n\nfunction assertSafeNativeType(nativeType: string): void {\n if (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) {\n throw new Error(\n `Unsafe native type name in contract: \"${nativeType}\". ` +\n 'Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*$/',\n );\n }\n}\n\nfunction assertSafeDefaultExpression(expression: string): void {\n if (expression.includes(';') || /--|\\/\\*|\\bSELECT\\b/i.test(expression)) {\n throw new Error(\n `Unsafe default expression in contract: \"${expression}\". ` +\n 'Default expressions must not contain semicolons, SQL comment tokens, or subqueries.',\n );\n }\n}\n\n/**\n * Renders the column's DDL type token (e.g. `\"INTEGER\"`, `\"TEXT\"`).\n * Resolves `typeRef` against `storageTypes` and validates the resulting\n * native type against a safe-identifier pattern.\n */\nexport function buildColumnTypeSql(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n assertSafeNativeType(resolved.nativeType);\n return resolved.nativeType.toUpperCase();\n}\n\n/**\n * Renders the column's `DEFAULT …` clause. Returns the empty string when\n * there is no default, and also when the default is `autoincrement()` —\n * SQLite encodes that as `INTEGER PRIMARY KEY AUTOINCREMENT` inline on the\n * column definition, not as a separate DEFAULT.\n */\nexport function buildColumnDefaultSql(columnDefault: SqliteColumnDefault | undefined): string {\n if (!columnDefault) return '';\n\n switch (columnDefault.kind) {\n case 'literal':\n return `DEFAULT ${renderDefaultLiteral(columnDefault.value)}`;\n case 'function': {\n if (columnDefault.expression === 'autoincrement()') return '';\n if (columnDefault.expression === 'now()') return \"DEFAULT (datetime('now'))\";\n assertSafeDefaultExpression(columnDefault.expression);\n return `DEFAULT (${columnDefault.expression})`;\n }\n }\n}\n\nexport function renderDefaultLiteral(value: unknown): string {\n if (value instanceof Date) {\n return `'${escapeLiteral(value.toISOString())}'`;\n }\n if (typeof value === 'string') {\n return `'${escapeLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'bigint') {\n return String(value);\n }\n if (typeof value === 'boolean') {\n return value ? '1' : '0';\n }\n if (value === null) {\n return 'NULL';\n }\n return `'${escapeLiteral(JSON.stringify(value))}'`;\n}\n\nexport function buildCreateIndexSql(\n tableName: string,\n indexName: string,\n columns: readonly string[],\n unique = false,\n): string {\n const uniqueKeyword = unique ? 'UNIQUE ' : '';\n return `CREATE ${uniqueKeyword}INDEX ${quoteIdentifier(indexName)} ON ${quoteIdentifier(tableName)} (${columns.map(quoteIdentifier).join(', ')})`;\n}\n\nexport function buildDropIndexSql(indexName: string): string {\n return `DROP INDEX IF EXISTS ${quoteIdentifier(indexName)}`;\n}\n\n/**\n * True when the column is rendered inline as `INTEGER PRIMARY KEY\n * AUTOINCREMENT`. Requires the column's default to be `autoincrement()` and\n * the column to be the sole member of the table's primary key — anything\n * else falls back to a separate PRIMARY KEY constraint with a default\n * AUTOINCREMENT semantics expressed elsewhere.\n */\nexport function isInlineAutoincrementPrimaryKey(table: StorageTable, columnName: string): boolean {\n if (table.primaryKey?.columns.length !== 1) return false;\n if (table.primaryKey.columns[0] !== columnName) return false;\n const column = table.columns[columnName];\n return column?.default?.kind === 'function' && column.default.expression === 'autoincrement()';\n}\n\ntype ResolvedColumnTypeMetadata = Pick<StorageColumn, 'nativeType' | 'codecId' | 'typeParams'>;\n\nfunction resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Record<string, StorageTypeInstance>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n throw new Error(\n `Storage type \"${column.typeRef}\" referenced by column is not defined in storage.types.`,\n );\n }\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import { escapeLiteral } from '../../sql-utils';\nimport { buildCreateIndexSql, buildDropIndexSql } from '../planner-ddl-builders';\nimport { buildTargetDetails } from '../planner-target-details';\nimport { type Op, step } from './shared';\n\nexport function createIndex(tableName: string, indexName: string, columns: readonly string[]): Op {\n return {\n id: `index.${tableName}.${indexName}`,\n label: `Create index ${indexName} on ${tableName}`,\n summary: `Creates index ${indexName} on ${tableName}`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('index', indexName, tableName) },\n precheck: [\n step(\n `ensure index \"${indexName}\" is missing`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,\n ),\n ],\n execute: [\n step(`create index \"${indexName}\"`, buildCreateIndexSql(tableName, indexName, columns)),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,\n ),\n ],\n };\n}\n\nexport function dropIndex(tableName: string, indexName: string): Op {\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index ${indexName} on ${tableName}`,\n summary: `Drops index ${indexName} on ${tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('index', indexName, tableName) },\n precheck: [\n step(\n `ensure index \"${indexName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,\n ),\n ],\n execute: [step(`drop index \"${indexName}\"`, buildDropIndexSql(indexName))],\n postcheck: [\n step(\n `verify index \"${indexName}\" is gone`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,\n ),\n ],\n };\n}\n","import type { MigrationOperationClass } from '@prisma-next/family-sql/control';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { stripOuterParens } from '../../default-normalizer';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { buildCreateIndexSql } from '../planner-ddl-builders';\nimport { buildTargetDetails } from '../planner-target-details';\nimport {\n type Op,\n renderColumnDefinition,\n renderForeignKeyClause,\n type SqliteIndexSpec,\n type SqliteTableSpec,\n step,\n} from './shared';\n\n/**\n * Renders the body of a `CREATE TABLE <name> ( … )` statement from a flat\n * `SqliteTableSpec`. SQLite's `INTEGER PRIMARY KEY AUTOINCREMENT` form is\n * inline on the column; the table-level PRIMARY KEY clause is emitted only\n * when no column carries `inlineAutoincrementPrimaryKey`.\n */\nfunction renderCreateTableSql(tableName: string, spec: SqliteTableSpec): string {\n const columnDefs = spec.columns.map(renderColumnDefinition);\n\n const constraintDefs: string[] = [];\n const hasInlinePk = spec.columns.some((c) => c.inlineAutoincrementPrimaryKey);\n if (spec.primaryKey && !hasInlinePk) {\n constraintDefs.push(`PRIMARY KEY (${spec.primaryKey.columns.map(quoteIdentifier).join(', ')})`);\n }\n\n for (const u of spec.uniques ?? []) {\n const name = u.name ? `CONSTRAINT ${quoteIdentifier(u.name)} ` : '';\n constraintDefs.push(`${name}UNIQUE (${u.columns.map(quoteIdentifier).join(', ')})`);\n }\n\n for (const fk of spec.foreignKeys ?? []) {\n const clause = renderForeignKeyClause(fk);\n if (clause) constraintDefs.push(clause);\n }\n\n const allDefs = [...columnDefs, ...constraintDefs];\n return `CREATE TABLE ${quoteIdentifier(tableName)} (\\n ${allDefs.join(',\\n ')}\\n)`;\n}\n\nexport function createTable(tableName: string, spec: SqliteTableSpec): Op {\n return {\n id: `table.${tableName}`,\n label: `Create table ${tableName}`,\n summary: `Creates table ${tableName} with required columns`,\n operationClass: 'additive',\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [\n step(\n `ensure table \"${tableName}\" does not exist`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n ],\n execute: [step(`create table \"${tableName}\"`, renderCreateTableSql(tableName, spec))],\n postcheck: [\n step(\n `verify table \"${tableName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n ],\n };\n}\n\nexport function dropTable(tableName: string): Op {\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table ${tableName}`,\n summary: `Drops table ${tableName} which is not in the contract`,\n operationClass: 'destructive',\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [\n step(\n `ensure table \"${tableName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n ],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${quoteIdentifier(tableName)}`)],\n postcheck: [\n step(\n `verify table \"${tableName}\" is gone`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n ],\n };\n}\n\nexport interface RecreateTableArgs {\n readonly tableName: string;\n /** New (post-recreate) shape of the table. Same flat spec as `createTable`. */\n readonly contractTable: SqliteTableSpec;\n /**\n * Names of columns that exist in the live (pre-recreate) schema. Used to\n * compute the `INSERT INTO temp ... SELECT ... FROM old` column list — only\n * shared columns are copied, so dropped columns are left behind and added\n * columns come from defaults.\n */\n readonly schemaColumnNames: readonly string[];\n /**\n * Indexes (declared + FK-backing, deduped by column-set) to recreate after\n * the table has been replaced. The planner pre-merges these.\n */\n readonly indexes: readonly SqliteIndexSpec[];\n /** Human-readable summary of the change, built by the planner from issues. */\n readonly summary: string;\n /**\n * Per-issue postcheck steps appended after the structural postchecks. The\n * planner pre-builds these via `buildRecreatePostchecks` so the call IR\n * carries flat, serializable data only — no `SchemaIssue` references.\n */\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n}\n\nexport function recreateTable(args: RecreateTableArgs): Op {\n const {\n tableName,\n contractTable,\n schemaColumnNames,\n indexes,\n summary,\n postchecks,\n operationClass,\n } = args;\n const tempName = `_prisma_new_${tableName}`;\n const liveSet = new Set(schemaColumnNames);\n const sharedColumns = contractTable.columns.filter((c) => liveSet.has(c.name)).map((c) => c.name);\n const columnList = sharedColumns.map(quoteIdentifier).join(', ');\n\n const indexStatements = indexes.map((idx) => ({\n description: `recreate index \"${idx.name}\" on \"${tableName}\"`,\n sql: buildCreateIndexSql(tableName, idx.name, idx.columns),\n }));\n\n // If the contract retains no columns from the live table, an `INSERT INTO\n // tmp () SELECT FROM old` is invalid SQL — and would also be a no-op since\n // there's nothing to copy. Skip the copy step in that case; the new\n // (empty) table replaces the old one directly.\n const copyStep =\n sharedColumns.length > 0\n ? [\n step(\n `copy data from \"${tableName}\" to \"${tempName}\"`,\n `INSERT INTO ${quoteIdentifier(tempName)} (${columnList}) SELECT ${columnList} FROM ${quoteIdentifier(tableName)}`,\n ),\n ]\n : [];\n\n return {\n id: `recreateTable.${tableName}`,\n label: `Recreate table ${tableName}`,\n summary,\n operationClass,\n target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },\n precheck: [\n step(\n `ensure table \"${tableName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n step(\n `ensure temp table \"${tempName}\" does not exist`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`,\n ),\n ],\n execute: [\n step(\n `create new table \"${tempName}\" with desired schema`,\n renderCreateTableSql(tempName, contractTable),\n ),\n ...copyStep,\n step(`drop old table \"${tableName}\"`, `DROP TABLE ${quoteIdentifier(tableName)}`),\n step(\n `rename \"${tempName}\" to \"${tableName}\"`,\n `ALTER TABLE ${quoteIdentifier(tempName)} RENAME TO ${quoteIdentifier(tableName)}`,\n ),\n ...indexStatements,\n ],\n postcheck: [\n step(\n `verify table \"${tableName}\" exists`,\n `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,\n ),\n step(\n `verify temp table \"${tempName}\" is gone`,\n `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`,\n ),\n ...postchecks,\n ],\n };\n}\n\n/**\n * Build a one-line summary of a recreate-table operation from the schema\n * issues that triggered it. Lives next to `recreateTable` so the planner\n * (which has the issues) can produce the same description the factory\n * used to build inline. Keeping the formatting target-side keeps\n * `RecreateTableCall` issue-free at the IR layer.\n */\nexport function buildRecreateSummary(tableName: string, issues: readonly SchemaIssue[]): string {\n const messages = issues.map((i) => i.message).join('; ');\n return `Recreates table ${tableName} to apply schema changes: ${messages}`;\n}\n\nconst COLUMN_LEVEL_ISSUE_KINDS = new Set<SchemaIssue['kind']>([\n 'nullability_mismatch',\n 'default_mismatch',\n 'default_missing',\n 'extra_default',\n 'type_mismatch',\n]);\n\nconst PK_ISSUE_KINDS = new Set<SchemaIssue['kind']>(['primary_key_mismatch', 'extra_primary_key']);\n\nconst UNIQUE_ISSUE_KINDS = new Set<SchemaIssue['kind']>([\n 'unique_constraint_mismatch',\n 'extra_unique_constraint',\n]);\n\nconst FK_ISSUE_KINDS = new Set<SchemaIssue['kind']>(['foreign_key_mismatch', 'extra_foreign_key']);\n\n/**\n * Returns the columns the contract expects as the table's primary key. Picks\n * up SQLite's inline `INTEGER PRIMARY KEY AUTOINCREMENT` form when no\n * explicit `primaryKey` clause is set on the spec.\n */\nfunction expectedPrimaryKeyColumns(spec: SqliteTableSpec): readonly string[] {\n if (spec.primaryKey) return spec.primaryKey.columns;\n const inlinePk = spec.columns.find((c) => c.inlineAutoincrementPrimaryKey);\n return inlinePk ? [inlinePk.name] : [];\n}\n\nfunction quoteSqlList(values: readonly string[]): string {\n return values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n}\n\n/**\n * Per-issue postchecks verifying the recreated table's shape against the\n * contract spec. Column-level issues (`nullability_mismatch`,\n * `default_mismatch`, …) emit one targeted check each; constraint-level\n * issues (`primary_key_mismatch`, `unique_constraint_mismatch`,\n * `foreign_key_mismatch`, plus their `extra_*` siblings) emit one\n * `pragma_*`-driven check per declared constraint in the contract spec, so\n * a recreated table with the right columns but the wrong PK / unique / FK\n * shape fails the postcheck instead of passing silently. Exported so the\n * planner can pre-build the list at construction time and\n * `RecreateTableCall` doesn't have to carry `SchemaIssue` objects through\n * to render time.\n */\nexport function buildRecreatePostchecks(\n tableName: string,\n issues: readonly SchemaIssue[],\n spec: SqliteTableSpec,\n): Array<{ description: string; sql: string }> {\n const checks: Array<{ description: string; sql: string }> = [];\n const t = escapeLiteral(tableName);\n const byName = new Map(spec.columns.map((c) => [c.name, c]));\n\n for (const issue of issues) {\n if (issue.kind === 'enum_values_changed') continue;\n if (!COLUMN_LEVEL_ISSUE_KINDS.has(issue.kind)) continue;\n if (!issue.column) continue;\n const c = escapeLiteral(issue.column);\n if (issue.kind === 'nullability_mismatch') {\n // `expected` carries the contract's nullable flag as a string. We only\n // emit a postcheck when the value is recognized — anything else\n // (case-folded, numeric coding, etc.) is left to the structural\n // verifier so a typo here can't silently invert the meaning.\n let wantNotNull: boolean | undefined;\n if (issue.expected === 'false') wantNotNull = true;\n else if (issue.expected === 'true') wantNotNull = false;\n if (wantNotNull !== undefined) {\n checks.push({\n description: `verify \"${issue.column}\" nullability on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND \"notnull\" = ${wantNotNull ? 1 : 0}`,\n });\n }\n }\n if (issue.kind === 'default_mismatch' || issue.kind === 'default_missing') {\n const colSpec = byName.get(issue.column);\n const expectedRaw = colSpec?.defaultSql.startsWith('DEFAULT ')\n ? // SQLite's pragma_table_info.dflt_value strips outer parens for\n // expression defaults (per the SQLite docs), so `(datetime('now'))`\n // is stored as `datetime('now')`. Strip them here so the postcheck\n // matches.\n stripOuterParens(colSpec.defaultSql.slice('DEFAULT '.length))\n : null;\n if (expectedRaw) {\n checks.push({\n description: `verify \"${issue.column}\" default on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value = '${escapeLiteral(expectedRaw)}'`,\n });\n }\n }\n if (issue.kind === 'type_mismatch') {\n const colSpec = byName.get(issue.column);\n if (colSpec) {\n checks.push({\n description: `verify \"${issue.column}\" type on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND LOWER(type) = '${escapeLiteral(colSpec.typeSql.toLowerCase())}'`,\n });\n }\n }\n if (issue.kind === 'extra_default') {\n checks.push({\n description: `verify \"${issue.column}\" has no default on \"${tableName}\"`,\n sql: `SELECT COUNT(*) > 0 FROM pragma_table_info('${t}') WHERE name = '${c}' AND dflt_value IS NULL`,\n });\n }\n }\n\n // Constraint-level issues — emit one postcheck per declared constraint in\n // the contract spec when *any* issue of that kind fires, since recreate\n // rebuilds the entire table at once.\n const hasPkIssue = issues.some((i) => PK_ISSUE_KINDS.has(i.kind));\n const hasUniqueIssue = issues.some((i) => UNIQUE_ISSUE_KINDS.has(i.kind));\n const hasFkIssue = issues.some((i) => FK_ISSUE_KINDS.has(i.kind));\n\n if (hasPkIssue) {\n const pkColumns = expectedPrimaryKeyColumns(spec);\n // Verify pragma_table_info reports exactly these columns as PK members\n // (count + named membership); zero columns expected ⇒ no PK at all.\n const colCount = pkColumns.length;\n if (colCount === 0) {\n checks.push({\n description: `verify \"${tableName}\" has no primary key`,\n sql: `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = 0`,\n });\n } else {\n checks.push({\n description: `verify primary key on \"${tableName}\"`,\n sql:\n `SELECT (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0) = ${colCount}` +\n ` AND (SELECT COUNT(*) FROM pragma_table_info('${t}') WHERE pk > 0 AND name IN (${quoteSqlList(pkColumns)})) = ${colCount}`,\n });\n }\n }\n\n if (hasUniqueIssue) {\n for (const u of spec.uniques ?? []) {\n const colCount = u.columns.length;\n const description = u.name\n ? `verify unique constraint \"${u.name}\" on \"${tableName}\"`\n : `verify unique constraint (${u.columns.join(', ')}) on \"${tableName}\"`;\n // Match any unique index whose covered columns are exactly the expected\n // set. Order is intentionally not checked — SQLite's unique-index\n // identity is column-set, not column-sequence.\n checks.push({\n description,\n sql:\n `SELECT EXISTS (SELECT 1 FROM pragma_index_list('${t}') l` +\n ` WHERE l.\"unique\" = 1` +\n ` AND (SELECT COUNT(*) FROM pragma_index_info(l.name)) = ${colCount}` +\n ` AND (SELECT COUNT(*) FROM pragma_index_info(l.name) WHERE name IN (${quoteSqlList(u.columns)})) = ${colCount})`,\n });\n }\n }\n\n if (hasFkIssue) {\n for (const fk of spec.foreignKeys ?? []) {\n const refTable = escapeLiteral(fk.references.table);\n const colCount = fk.columns.length;\n // Build a `SUM(CASE WHEN (\"from\",\"to\") IN ((…)) …)` so the check works\n // for both single- and multi-column FKs without depending on FK row\n // ordering inside `pragma_foreign_key_list`.\n const tuples = fk.columns\n .map((from, i) => {\n const to = fk.references.columns[i] ?? from;\n return `('${escapeLiteral(from)}', '${escapeLiteral(to)}')`;\n })\n .join(', ');\n const description = `verify foreign key (${fk.columns.join(', ')}) → ${fk.references.table}(${fk.references.columns.join(', ')}) on \"${tableName}\"`;\n checks.push({\n description,\n sql:\n `SELECT EXISTS (SELECT 1 FROM pragma_foreign_key_list('${t}') f` +\n ` WHERE f.\"table\" = '${refTable}'` +\n ' GROUP BY f.id' +\n ` HAVING COUNT(*) = ${colCount}` +\n ` AND SUM(CASE WHEN (f.\"from\", f.\"to\") IN (${tuples}) THEN 1 ELSE 0 END) = ${colCount})`,\n });\n }\n }\n\n return checks;\n}\n"],"mappings":";;;;AAOA,SAAgB,KAAK,aAAqB,KAAmD;CAC3F,OAAO;EAAE;EAAa;EAAK;;AAqE7B,MAAM,yBAA4D;CAChE,UAAU;CACV,UAAU;CACV,SAAS;CACT,SAAS;CACT,YAAY;CACb;;;;;;;AAQD,SAAgB,uBAAuB,QAAkC;C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ACV;GACA,KACE,yDAAyD,EAAE,0BACpC,SAAS,oCAEV,SAAA,4CACuB,OAAO,yBAAyB,SAAS;GACzF,CAAC;;CAIN,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-sqlite",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.81",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@prisma-next/
|
|
8
|
-
"@prisma-next/
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/sql
|
|
11
|
-
"@prisma-next/
|
|
8
|
+
"@prisma-next/cli": "0.5.0-dev.81",
|
|
9
|
+
"@prisma-next/contract": "0.5.0-dev.81",
|
|
10
|
+
"@prisma-next/errors": "0.5.0-dev.81",
|
|
11
|
+
"@prisma-next/family-sql": "0.5.0-dev.81",
|
|
12
|
+
"@prisma-next/migration-tools": "0.5.0-dev.81",
|
|
13
|
+
"@prisma-next/framework-components": "0.5.0-dev.81",
|
|
14
|
+
"@prisma-next/sql-contract": "0.5.0-dev.81",
|
|
15
|
+
"@prisma-next/sql-errors": "0.5.0-dev.81",
|
|
16
|
+
"@prisma-next/sql-schema-ir": "0.5.0-dev.81",
|
|
17
|
+
"@prisma-next/sql-relational-core": "0.5.0-dev.81",
|
|
18
|
+
"@prisma-next/ts-render": "0.5.0-dev.81",
|
|
19
|
+
"@prisma-next/utils": "0.5.0-dev.81",
|
|
20
|
+
"@prisma-next/sql-runtime": "0.5.0-dev.81"
|
|
12
21
|
},
|
|
13
22
|
"devDependencies": {
|
|
14
|
-
"tsdown": "0.
|
|
23
|
+
"tsdown": "0.22.0",
|
|
15
24
|
"typescript": "5.9.3",
|
|
16
|
-
"vitest": "4.
|
|
17
|
-
"@prisma-next/
|
|
18
|
-
"@prisma-next/
|
|
25
|
+
"vitest": "4.1.5",
|
|
26
|
+
"@prisma-next/driver-sqlite": "0.5.0-dev.81",
|
|
27
|
+
"@prisma-next/test-utils": "0.0.1",
|
|
19
28
|
"@prisma-next/tsdown": "0.0.0",
|
|
20
|
-
"@prisma-next/
|
|
29
|
+
"@prisma-next/tsconfig": "0.0.0"
|
|
21
30
|
},
|
|
22
31
|
"files": [
|
|
23
32
|
"dist",
|
|
24
33
|
"src"
|
|
25
34
|
],
|
|
26
35
|
"exports": {
|
|
36
|
+
"./codec-ids": "./dist/codec-ids.mjs",
|
|
37
|
+
"./codec-types": "./dist/codec-types.mjs",
|
|
38
|
+
"./codecs": "./dist/codecs.mjs",
|
|
27
39
|
"./control": "./dist/control.mjs",
|
|
40
|
+
"./default-normalizer": "./dist/default-normalizer.mjs",
|
|
41
|
+
"./migration": "./dist/migration.mjs",
|
|
42
|
+
"./native-type-normalizer": "./dist/native-type-normalizer.mjs",
|
|
43
|
+
"./op-factory-call": "./dist/op-factory-call.mjs",
|
|
28
44
|
"./pack": "./dist/pack.mjs",
|
|
45
|
+
"./planner": "./dist/planner.mjs",
|
|
46
|
+
"./planner-produced-sqlite-migration": "./dist/planner-produced-sqlite-migration.mjs",
|
|
47
|
+
"./planner-target-details": "./dist/planner-target-details.mjs",
|
|
48
|
+
"./render-ops": "./dist/render-ops.mjs",
|
|
29
49
|
"./runtime": "./dist/runtime.mjs",
|
|
50
|
+
"./sql-utils": "./dist/sql-utils.mjs",
|
|
51
|
+
"./statement-builders": "./dist/statement-builders.mjs",
|
|
30
52
|
"./package.json": "./package.json"
|
|
31
53
|
},
|
|
32
54
|
"repository": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { temporalAuthoringPresets } from '@prisma-next/family-sql/control';
|
|
2
|
+
import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';
|
|
3
|
+
|
|
4
|
+
export const sqliteAuthoringFieldPresets = {
|
|
5
|
+
temporal: temporalAuthoringPresets({
|
|
6
|
+
codecId: 'sqlite/datetime@1',
|
|
7
|
+
nativeType: 'text',
|
|
8
|
+
}),
|
|
9
|
+
} as const satisfies AuthoringFieldNamespace;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local `JsonValue` alias for the SQLite target. Codec implementations live in `codecs.ts` (TML-2357); this module retains only the JSON-shape alias the surrounding adapter and tests still import.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type JsonValue =
|
|
6
|
+
| string
|
|
7
|
+
| number
|
|
8
|
+
| boolean
|
|
9
|
+
| null
|
|
10
|
+
| { readonly [key: string]: JsonValue }
|
|
11
|
+
| readonly JsonValue[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {
|
|
2
|
+
SQL_CHAR_CODEC_ID,
|
|
3
|
+
SQL_FLOAT_CODEC_ID,
|
|
4
|
+
SQL_INT_CODEC_ID,
|
|
5
|
+
SQL_VARCHAR_CODEC_ID,
|
|
6
|
+
} from '@prisma-next/sql-relational-core/ast';
|
|
7
|
+
export const SQLITE_TEXT_CODEC_ID = 'sqlite/text@1' as const;
|
|
8
|
+
export const SQLITE_INTEGER_CODEC_ID = 'sqlite/integer@1' as const;
|
|
9
|
+
export const SQLITE_REAL_CODEC_ID = 'sqlite/real@1' as const;
|
|
10
|
+
export const SQLITE_BLOB_CODEC_ID = 'sqlite/blob@1' as const;
|
|
11
|
+
export const SQLITE_DATETIME_CODEC_ID = 'sqlite/datetime@1' as const;
|
|
12
|
+
export const SQLITE_JSON_CODEC_ID = 'sqlite/json@1' as const;
|
|
13
|
+
export const SQLITE_BIGINT_CODEC_ID = 'sqlite/bigint@1' as const;
|