@prisma/orm-target-sqlite 8.0.0-rc.16-dev.5 → 8.0.0-rc.16-dev.7
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/{adapter-Cy1Xx1rP-CJcOoS_O.mjs → adapter-Cfp6xn4m-C6mXiIUR.mjs} +8 -11
- package/dist/adapter-Cfp6xn4m-C6mXiIUR.mjs.map +1 -0
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +2 -2
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__codec-types.d.mts +2 -2
- package/dist/adapter__control.mjs +3 -3
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +1 -1
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/adapter__sql-renderer.mjs +1 -1
- package/dist/codec-types-6UMpZZ70.d.mts +1 -0
- package/dist/codec-types-FAF08DkX.d.mts +2 -0
- package/dist/{codec-types-0AMy_n05-BJvXpaEh.d.mts → codec-types-nBSWEx87-B8Jiv6Mm.d.mts} +3 -2
- package/dist/codec-types-nBSWEx87-B8Jiv6Mm.d.mts.map +1 -0
- package/dist/{contract-free-CH8tBLLe.mjs → contract-free-CEPqytba.mjs} +2 -2
- package/dist/{contract-free-CH8tBLLe.mjs.map → contract-free-CEPqytba.mjs.map} +1 -1
- package/dist/{control-CtIPKwqL.mjs → control-D6F1gWDe.mjs} +6 -5
- package/dist/control-D6F1gWDe.mjs.map +1 -0
- package/dist/{ddl-CXduXyOT-nlDP6DGx.mjs → ddl-CDoa1Ehx-BOT670XL.mjs} +40 -3
- package/dist/ddl-CDoa1Ehx-BOT670XL.mjs.map +1 -0
- package/dist/{migration-Ccuxti02.d.mts → migration-CGyA6YVp.d.mts} +2 -2
- package/dist/{migration-Ccuxti02.d.mts.map → migration-CGyA6YVp.d.mts.map} +1 -1
- package/dist/{migration-65TwrHP0.mjs → migration-DNHWGn35.mjs} +2 -2
- package/dist/{migration-65TwrHP0.mjs.map → migration-DNHWGn35.mjs.map} +1 -1
- package/dist/{op-factory-call-B_WuATMN.d.mts → op-factory-call-B0N6txAF.d.mts} +51 -7
- package/dist/op-factory-call-B0N6txAF.d.mts.map +1 -0
- package/dist/{op-factory-call-Bwp3QS4h-MwflmSX3.mjs → op-factory-call-BrLX8AMg-BSyJWo6f.mjs} +129 -17
- package/dist/op-factory-call-BrLX8AMg-BSyJWo6f.mjs.map +1 -0
- package/dist/{pack-BIZIGw3P.d.mts → pack-D3pJo5Xh.d.mts} +2 -2
- package/dist/{pack-BIZIGw3P.d.mts.map → pack-D3pJo5Xh.d.mts.map} +1 -1
- package/dist/{planner-CFIbY54l.d.mts → planner-B0nz2W_R.d.mts} +14 -6
- package/dist/planner-B0nz2W_R.d.mts.map +1 -0
- package/dist/{planner-DcRJaFjk-C9iIWF69.mjs → planner-CP704vdn-D0Nn5ZH6.mjs} +57 -14
- package/dist/planner-CP704vdn-D0Nn5ZH6.mjs.map +1 -0
- package/dist/{planner-produced-sqlite-migration-DTTOgkuK-CppVPY1d.mjs → planner-produced-sqlite-migration-Bi5jMcKu-dz5lhOAP.mjs} +4 -4
- package/dist/{planner-produced-sqlite-migration-DTTOgkuK-CppVPY1d.mjs.map → planner-produced-sqlite-migration-Bi5jMcKu-dz5lhOAP.mjs.map} +1 -1
- package/dist/planner-produced-sqlite-migration-CBmtR7UQ.d.mts +1 -0
- package/dist/{planner-produced-sqlite-migration-DXcx0sOR-CcMQKE7n.d.mts → planner-produced-sqlite-migration-aUyGmguF-BORtY3yL.d.mts} +3 -3
- package/dist/planner-produced-sqlite-migration-aUyGmguF-BORtY3yL.d.mts.map +1 -0
- package/dist/{render-ops-KxAmAz6d-W2xyvA5y.mjs → render-ops-CUUasMx_-CFXpgruj.mjs} +16 -9
- package/dist/render-ops-CUUasMx_-CFXpgruj.mjs.map +1 -0
- package/dist/{sqlite-contract-view-BYR10usg-BteDAUZr.mjs → sqlite-contract-view-BrXalcTm-DYDH4LQC.mjs} +4 -3
- package/dist/sqlite-contract-view-BrXalcTm-DYDH4LQC.mjs.map +1 -0
- package/dist/{sqlite-migration-DckJS_3w-BIKXWN5h.mjs → sqlite-migration-Dtcdl9x4-SNwSvz0C.mjs} +327 -35
- package/dist/sqlite-migration-Dtcdl9x4-SNwSvz0C.mjs.map +1 -0
- package/dist/{sqlite-migration-BSUZhMDG-DZU3d7bZ.d.mts → sqlite-migration-Kqf6dAgP-DDc4wuXM.d.mts} +27 -3
- package/dist/sqlite-migration-Kqf6dAgP-DDc4wuXM.d.mts.map +1 -0
- package/dist/target.d.mts +10 -10
- package/dist/target.mjs +12 -12
- package/dist/target__codec-types.d.mts +2 -2
- package/dist/target__contract-free.mjs +2 -2
- package/dist/target__control.mjs +2 -2
- package/dist/target__migration.d.mts +2 -2
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +2 -2
- package/dist/target__op-factory-call.mjs +2 -2
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__planner-produced-sqlite-migration.d.mts +2 -2
- package/dist/target__planner-produced-sqlite-migration.mjs +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +1 -1
- package/dist/target__render-ops.mjs +1 -1
- package/dist/target__runtime.mjs +1 -1
- package/dist/target__runtime.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/adapter-Cy1Xx1rP-CJcOoS_O.mjs.map +0 -1
- package/dist/codec-types-0AMy_n05-BJvXpaEh.d.mts.map +0 -1
- package/dist/codec-types-BV1uyhho.d.mts +0 -1
- package/dist/codec-types-CLFLW8jd.d.mts +0 -2
- package/dist/control-CtIPKwqL.mjs.map +0 -1
- package/dist/ddl-CXduXyOT-nlDP6DGx.mjs.map +0 -1
- package/dist/op-factory-call-B_WuATMN.d.mts.map +0 -1
- package/dist/op-factory-call-Bwp3QS4h-MwflmSX3.mjs.map +0 -1
- package/dist/planner-CFIbY54l.d.mts.map +0 -1
- package/dist/planner-DcRJaFjk-C9iIWF69.mjs.map +0 -1
- package/dist/planner-produced-sqlite-migration-DXcx0sOR-CcMQKE7n.d.mts.map +0 -1
- package/dist/planner-produced-sqlite-migration-sYbbeyyS.d.mts +0 -1
- package/dist/render-ops-KxAmAz6d-W2xyvA5y.mjs.map +0 -1
- package/dist/sqlite-contract-view-BYR10usg-BteDAUZr.mjs.map +0 -1
- package/dist/sqlite-migration-BSUZhMDG-DZU3d7bZ.d.mts.map +0 -1
- package/dist/sqlite-migration-DckJS_3w-BIKXWN5h.mjs.map +0 -1
|
@@ -2,7 +2,7 @@ import { c as SQLITE_TEXT_CODEC_ID } from "./codec-ids-KMliSCRp-BhTbmbGr.mjs";
|
|
|
2
2
|
import { t as SqliteCreateTable } from "./nodes-DUZSdX86-BBEEaxXY.mjs";
|
|
3
3
|
import { FunctionSource } from "@prisma/orm-family-sql/relational-core/ast";
|
|
4
4
|
import { cfExpr, cfTable, exprSelect } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
5
|
-
//#region ../../../3-targets/3-targets/sqlite/dist/ddl-
|
|
5
|
+
//#region ../../../3-targets/3-targets/sqlite/dist/ddl-CDoa1Ehx.mjs
|
|
6
6
|
/**
|
|
7
7
|
* Typed builder for the migration planner's column-existence checks. Produces
|
|
8
8
|
* `SELECT COUNT(*) {=|>} 0 AS "result" FROM pragma_table_info(?) WHERE "name" = ?`
|
|
@@ -18,6 +18,25 @@ function columnExistsAst(table, column) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
+
* Typed builder for the check that no column of the table has a name SQLite takes for `column`.
|
|
22
|
+
* Produces `SELECT COUNT(*) = 0 AS "result" FROM pragma_table_info(?) WHERE "name" COLLATE NOCASE
|
|
23
|
+
* = ?`: SQLite compares column names without regard to the case of ASCII letters, as `NOCASE`
|
|
24
|
+
* does.
|
|
25
|
+
*/
|
|
26
|
+
function columnNameTakenAst(table, column) {
|
|
27
|
+
const source = FunctionSource.of("pragma_table_info", [cfExpr.param(table, SQLITE_TEXT_CODEC_ID).ast]);
|
|
28
|
+
const where = cfExpr.fn({
|
|
29
|
+
method: "collateNocase",
|
|
30
|
+
template: "{{self}} COLLATE NOCASE",
|
|
31
|
+
self: cfExpr.identifierRef("name"),
|
|
32
|
+
returns: {
|
|
33
|
+
codecId: SQLITE_TEXT_CODEC_ID,
|
|
34
|
+
nullable: false
|
|
35
|
+
}
|
|
36
|
+
}).eqParam(column, SQLITE_TEXT_CODEC_ID);
|
|
37
|
+
return { nameFree: () => exprSelect().from(source).project("result", cfExpr.countStar().eqLit(0)).where(where).build() };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
21
40
|
* Typed builder for table-existence checks over `sqlite_master`.
|
|
22
41
|
* Produces `SELECT COUNT(*) {=|>} 0 AS "result" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?`
|
|
23
42
|
* with the table name and the literal `'table'` bound as text parameters.
|
|
@@ -31,6 +50,24 @@ function tableExistsAst(tableName) {
|
|
|
31
50
|
};
|
|
32
51
|
}
|
|
33
52
|
/**
|
|
53
|
+
* Typed builder for the check that no table, index or view has a name SQLite takes for `name`.
|
|
54
|
+
* Produces `SELECT COUNT(*) = 0 AS "result" FROM "sqlite_master" WHERE "name" COLLATE NOCASE = ?`:
|
|
55
|
+
* tables, indexes and views share one set of names, which SQLite compares without regard to the
|
|
56
|
+
* case of ASCII letters.
|
|
57
|
+
*/
|
|
58
|
+
function tableNameTakenAst(tableName) {
|
|
59
|
+
const where = cfExpr.fn({
|
|
60
|
+
method: "collateNocase",
|
|
61
|
+
template: "{{self}} COLLATE NOCASE",
|
|
62
|
+
self: cfExpr.identifierRef("name"),
|
|
63
|
+
returns: {
|
|
64
|
+
codecId: SQLITE_TEXT_CODEC_ID,
|
|
65
|
+
nullable: false
|
|
66
|
+
}
|
|
67
|
+
}).eqParam(tableName, SQLITE_TEXT_CODEC_ID);
|
|
68
|
+
return { nameFree: () => exprSelect().from(cfTable("sqlite_master")).project("result", cfExpr.countStar().eqLit(0)).where(where).build() };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
34
71
|
* Typed builder for index-existence checks over `sqlite_master`.
|
|
35
72
|
* Produces `SELECT COUNT(*) {=|>} 0 AS "result" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?`
|
|
36
73
|
* with the index name and the literal `'index'` bound as text parameters.
|
|
@@ -61,6 +98,6 @@ function createTable(options) {
|
|
|
61
98
|
return new SqliteCreateTable(options);
|
|
62
99
|
}
|
|
63
100
|
//#endregion
|
|
64
|
-
export { tableExistsAst as i,
|
|
101
|
+
export { tableExistsAst as a, indexExistsAst as i, columnNameTakenAst as n, tableNameTakenAst as o, createTable as r, columnExistsAst as t };
|
|
65
102
|
|
|
66
|
-
//# sourceMappingURL=ddl-
|
|
103
|
+
//# sourceMappingURL=ddl-CDoa1Ehx-BOT670XL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl-CDoa1Ehx-BOT670XL.mjs","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/ddl-CDoa1Ehx.mjs"],"sourcesContent":["import { c as SQLITE_TEXT_CODEC_ID } from \"./codec-ids-KMliSCRp.mjs\";\nimport { t as SqliteCreateTable } from \"./nodes-DUZSdX86.mjs\";\nimport { FunctionSource } from \"@internal/sql-relational-core/ast\";\nimport { cfExpr, cfTable, exprSelect } from \"@internal/sql-relational-core/contract-free\";\n//#region src/contract-free/checks.ts\n/**\n* Typed builder for the migration planner's column-existence checks. Produces\n* `SELECT COUNT(*) {=|>} 0 AS \"result\" FROM pragma_table_info(?) WHERE \"name\" = ?`\n* ASTs with the table and column names bound as text parameters — never\n* inlined into the SQL.\n*/\nfunction columnExistsAst(table, column) {\n\tconst source = FunctionSource.of(\"pragma_table_info\", [cfExpr.param(table, SQLITE_TEXT_CODEC_ID).ast]);\n\tconst where = cfExpr.identifierRef(\"name\").eqParam(column, SQLITE_TEXT_CODEC_ID);\n\treturn {\n\t\tcolumnAbsent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().eqLit(0)).where(where).build(),\n\t\tcolumnPresent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().gtLit(0)).where(where).build()\n\t};\n}\n/**\n* Typed builder for the check that no column of the table has a name SQLite takes for `column`.\n* Produces `SELECT COUNT(*) = 0 AS \"result\" FROM pragma_table_info(?) WHERE \"name\" COLLATE NOCASE\n* = ?`: SQLite compares column names without regard to the case of ASCII letters, as `NOCASE`\n* does.\n*/\nfunction columnNameTakenAst(table, column) {\n\tconst source = FunctionSource.of(\"pragma_table_info\", [cfExpr.param(table, SQLITE_TEXT_CODEC_ID).ast]);\n\tconst where = cfExpr.fn({\n\t\tmethod: \"collateNocase\",\n\t\ttemplate: \"{{self}} COLLATE NOCASE\",\n\t\tself: cfExpr.identifierRef(\"name\"),\n\t\treturns: {\n\t\t\tcodecId: SQLITE_TEXT_CODEC_ID,\n\t\t\tnullable: false\n\t\t}\n\t}).eqParam(column, SQLITE_TEXT_CODEC_ID);\n\treturn { nameFree: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().eqLit(0)).where(where).build() };\n}\n/**\n* Typed builder for table-existence checks over `sqlite_master`.\n* Produces `SELECT COUNT(*) {=|>} 0 AS \"result\" FROM \"sqlite_master\" WHERE \"type\" = ? AND \"name\" = ?`\n* with the table name and the literal `'table'` bound as text parameters.\n*/\nfunction tableExistsAst(tableName) {\n\tconst source = cfTable(\"sqlite_master\");\n\tconst where = cfExpr.allOf([cfExpr.identifierRef(\"type\").eqParam(\"table\", SQLITE_TEXT_CODEC_ID), cfExpr.identifierRef(\"name\").eqParam(tableName, SQLITE_TEXT_CODEC_ID)]);\n\treturn {\n\t\ttableAbsent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().eqLit(0)).where(where).build(),\n\t\ttablePresent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().gtLit(0)).where(where).build()\n\t};\n}\n/**\n* Typed builder for the check that no table, index or view has a name SQLite takes for `name`.\n* Produces `SELECT COUNT(*) = 0 AS \"result\" FROM \"sqlite_master\" WHERE \"name\" COLLATE NOCASE = ?`:\n* tables, indexes and views share one set of names, which SQLite compares without regard to the\n* case of ASCII letters.\n*/\nfunction tableNameTakenAst(tableName) {\n\tconst where = cfExpr.fn({\n\t\tmethod: \"collateNocase\",\n\t\ttemplate: \"{{self}} COLLATE NOCASE\",\n\t\tself: cfExpr.identifierRef(\"name\"),\n\t\treturns: {\n\t\t\tcodecId: SQLITE_TEXT_CODEC_ID,\n\t\t\tnullable: false\n\t\t}\n\t}).eqParam(tableName, SQLITE_TEXT_CODEC_ID);\n\treturn { nameFree: () => exprSelect().from(cfTable(\"sqlite_master\")).project(\"result\", cfExpr.countStar().eqLit(0)).where(where).build() };\n}\n/**\n* Typed builder for index-existence checks over `sqlite_master`.\n* Produces `SELECT COUNT(*) {=|>} 0 AS \"result\" FROM \"sqlite_master\" WHERE \"type\" = ? AND \"name\" = ?`\n* with the index name and the literal `'index'` bound as text parameters.\n*/\nfunction indexExistsAst(indexName) {\n\tconst source = cfTable(\"sqlite_master\");\n\tconst where = cfExpr.allOf([cfExpr.identifierRef(\"type\").eqParam(\"index\", SQLITE_TEXT_CODEC_ID), cfExpr.identifierRef(\"name\").eqParam(indexName, SQLITE_TEXT_CODEC_ID)]);\n\treturn {\n\t\tindexAbsent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().eqLit(0)).where(where).build(),\n\t\tindexPresent: () => exprSelect().from(source).project(\"result\", cfExpr.countStar().gtLit(0)).where(where).build()\n\t};\n}\n//#endregion\n//#region src/contract-free/ddl.ts\n/**\n* Build a SQLite `CREATE TABLE` query node.\n*\n* Pass `constraints` for table-level composite primary keys, foreign keys, and\n* unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},\n* and {@link UniqueConstraint} classes from `@internal/sql-relational-core/ast`.\n*\n* Precondition: identifiers (`table`, column names/types) are emitted to SQL\n* verbatim — they are not quoted or escaped, so callers must pass pre-trusted\n* values (e.g. fixed control-plane identifiers). String-literal default values,\n* by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.\n* Identifier quoting for untrusted identifiers is added when the migration\n* planner adopts this lowering path.\n*/\nfunction createTable(options) {\n\treturn new SqliteCreateTable(options);\n}\n//#endregion\nexport { tableExistsAst as a, indexExistsAst as i, columnExistsAst as n, tableNameTakenAst as o, columnNameTakenAst as r, createTable as t };\n\n//# sourceMappingURL=ddl-CDoa1Ehx.mjs.map"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Op } from "./tables-CvLOKCiJ-Ca1eFkWN.mjs";
|
|
2
|
-
import "./sqlite-migration-
|
|
2
|
+
import "./sqlite-migration-Kqf6dAgP-DDc4wuXM.mjs";
|
|
3
3
|
import { col as col$1, fn as fn$1, foreignKey, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
4
4
|
import { placeholder } from "@prisma/orm-framework/errors/migration";
|
|
5
5
|
import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
|
|
@@ -40,4 +40,4 @@ declare function dataTransform(opts: DataTransformOptions): Op;
|
|
|
40
40
|
declare function rawSql(op: Op): Op;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { fn$1 as a, placeholder as c, unique as d, dataTransform as i, primaryKey as l, MigrationCLI as n, foreignKey as o, col$1 as r, lit$1 as s, DataTransformOptions as t, rawSql as u };
|
|
43
|
-
//# sourceMappingURL=migration-
|
|
43
|
+
//# sourceMappingURL=migration-CGyA6YVp.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-
|
|
1
|
+
{"version":3,"file":"migration-CGyA6YVp.d.mts","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/migration.d.mts"],"mappings":";;;;;;;UAMU;;WAEC;;WAEA;;WAEA;;;;;WAKA;;;;;;;;;WASA;;iBAEM,cAAc,MAAM,uBAAuB;;;;;;;;;;iBAU3C,OAAO,IAAI,KAAK"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as buildTargetDetails } from "./planner-target-details-CIQ789Gc-C5U4yVY9.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { x as step } from "./op-factory-call-BrLX8AMg-BSyJWo6f.mjs";
|
|
3
3
|
import { col as col$1, fn as fn$1, foreignKey, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
4
4
|
import { placeholder } from "@prisma/orm-framework/errors/migration";
|
|
5
5
|
import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
|
|
@@ -44,4 +44,4 @@ function rawSql(op) {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { foreignKey as a, primaryKey as c, fn$1 as i, rawSql as l, col$1 as n, lit$1 as o, dataTransform as r, placeholder as s, MigrationCLI as t, unique as u };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=migration-
|
|
47
|
+
//# sourceMappingURL=migration-DNHWGn35.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-
|
|
1
|
+
{"version":3,"file":"migration-DNHWGn35.mjs","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/migration.mjs"],"sourcesContent":["import { v as step } from \"./op-factory-call-BrLX8AMg.mjs\";\nimport { t as SqliteMigration } from \"./sqlite-migration-Dtcdl9x4.mjs\";\nimport { t as buildTargetDetails } from \"./planner-target-details-CIQ789Gc.mjs\";\nimport { placeholder } from \"@internal/errors/migration\";\nimport { col, fn, foreignKey, lit, primaryKey, unique } from \"@internal/sql-relational-core/contract-free\";\nimport { MigrationCLI } from \"@internal/cli/migration-cli\";\n//#region src/core/migrations/operations/data-transform.ts\n/**\n* User-facing `dataTransform` factory for the SQLite migration authoring\n* surface. Invoked directly inside a `migration.ts` file to supply a\n* user-authored SQL statement that runs with operation class `'data'`.\n*\n* Typical use: the planner emits a `DataTransformCall` stub when a NOT NULL\n* tightening requires a backfill. The rendered `migration.ts` exposes the\n* backfill as a `placeholder(\"…\")` slot the user fills in with an\n* `UPDATE … WHERE col IS NULL` statement. The filled-in `dataTransform(...)`\n* invocation returns a runnable operation the runner executes before the\n* subsequent recreate-table op copies data into the tightened schema.\n*/\nfunction dataTransform(opts) {\n\treturn {\n\t\tid: opts.id,\n\t\tlabel: opts.label,\n\t\tsummary: opts.description,\n\t\toperationClass: \"data\",\n\t\ttarget: {\n\t\t\tid: \"sqlite\",\n\t\t\tdetails: buildTargetDetails(\"table\", opts.table)\n\t\t},\n\t\tprecheck: [],\n\t\texecute: [step(opts.description, opts.run())],\n\t\tpostcheck: []\n\t};\n}\n//#endregion\n//#region src/core/migrations/operations/raw.ts\n/**\n* Identity factory for an already-materialized\n* `SqlMigrationPlanOperation<SqlitePlanTargetDetails>`. Mirrors the Postgres\n* `rawSql` factory: the planner uses this to carry ops produced by SQL-family\n* paths (codec lifecycle hooks, raw-SQL escape hatches) alongside structured\n* call IR without reverse-engineering their shape.\n*/\nfunction rawSql(op) {\n\treturn op;\n}\n//#endregion\nexport { SqliteMigration as Migration, MigrationCLI, col, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAAS,cAAc,MAAM;CAC5B,OAAO;EACN,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,SAAS,KAAK;EACd,gBAAgB;EAChB,QAAQ;GACP,IAAI;GACJ,SAAS,mBAAmB,SAAS,KAAK,KAAK;EAChD;EACA,UAAU,CAAC;EACX,SAAS,CAAC,KAAK,KAAK,aAAa,KAAK,IAAI,CAAC,CAAC;EAC5C,WAAW,CAAC;CACb;AACD;;;;;;;;AAUA,SAAS,OAAO,IAAI;CACnB,OAAO;AACR"}
|
|
@@ -13,6 +13,8 @@ declare abstract class SqliteOpFactoryCallNode extends TsExpression implements O
|
|
|
13
13
|
abstract readonly operationClass: MigrationOperationClass;
|
|
14
14
|
abstract readonly label: string;
|
|
15
15
|
abstract toOp(lowerer?: Lowerer): Op | Promise<Op>;
|
|
16
|
+
/** The operations this call lowers to, in order: one, unless the call carries companions. */
|
|
17
|
+
toOps(lowerer?: ExecuteRequestLowerer): readonly (Op | Promise<Op>)[];
|
|
16
18
|
importRequirements(): readonly ImportRequirement[];
|
|
17
19
|
protected freeze(): void;
|
|
18
20
|
}
|
|
@@ -38,6 +40,13 @@ declare class DropTableCall extends SqliteOpFactoryCallNode {
|
|
|
38
40
|
renderTypeScript(): string;
|
|
39
41
|
importRequirements(): readonly ImportRequirement[];
|
|
40
42
|
}
|
|
43
|
+
/** An index SQLite cannot rename, dropped and created again under its new name. */
|
|
44
|
+
interface IndexReplacement {
|
|
45
|
+
readonly drop: DropIndexCall;
|
|
46
|
+
readonly create: CreateIndexCall;
|
|
47
|
+
}
|
|
48
|
+
/** A call a table or column rename carries to replace an index whose name derives from the old name. */
|
|
49
|
+
type RenameCompanionCall = DropIndexCall | CreateIndexCall;
|
|
41
50
|
declare class RenameTableCall extends SqliteOpFactoryCallNode {
|
|
42
51
|
readonly factoryName: "renameTable";
|
|
43
52
|
readonly operationClass: "widening";
|
|
@@ -45,7 +54,38 @@ declare class RenameTableCall extends SqliteOpFactoryCallNode {
|
|
|
45
54
|
/** The new name: the table's contract-side identity after the rename. */
|
|
46
55
|
readonly tableName: string;
|
|
47
56
|
readonly label: string;
|
|
48
|
-
|
|
57
|
+
/** The indexes named after the old table, which SQLite cannot rename, so it replaces them. */
|
|
58
|
+
readonly indexReplacements: readonly IndexReplacement[];
|
|
59
|
+
/**
|
|
60
|
+
* The replacements' drops, then their creates. They run after the table rename and are never
|
|
61
|
+
* rendered on their own.
|
|
62
|
+
*/
|
|
63
|
+
readonly companions: readonly RenameCompanionCall[];
|
|
64
|
+
constructor(oldTableName: string, tableName: string, indexReplacements: readonly IndexReplacement[]);
|
|
65
|
+
/** The id of the operation this call lowers to. */
|
|
66
|
+
get operationId(): string;
|
|
67
|
+
toOps(lowerer?: ExecuteRequestLowerer): readonly Promise<Op>[];
|
|
68
|
+
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
69
|
+
renderTypeScript(): string;
|
|
70
|
+
importRequirements(): readonly ImportRequirement[];
|
|
71
|
+
}
|
|
72
|
+
declare class RenameColumnCall extends SqliteOpFactoryCallNode {
|
|
73
|
+
readonly factoryName: "renameColumn";
|
|
74
|
+
readonly operationClass: "widening";
|
|
75
|
+
readonly tableName: string;
|
|
76
|
+
readonly oldColumnName: string;
|
|
77
|
+
/** The new name: the column's contract-side identity after the rename. */
|
|
78
|
+
readonly columnName: string;
|
|
79
|
+
readonly label: string;
|
|
80
|
+
/** The indexes on the column whose wire names change, which SQLite cannot rename. */
|
|
81
|
+
readonly indexReplacements: readonly IndexReplacement[];
|
|
82
|
+
/**
|
|
83
|
+
* The replacements' drops, then their creates. They run after the column rename and are never
|
|
84
|
+
* rendered on their own.
|
|
85
|
+
*/
|
|
86
|
+
readonly companions: readonly RenameCompanionCall[];
|
|
87
|
+
constructor(tableName: string, oldColumnName: string, columnName: string, indexReplacements: readonly IndexReplacement[]);
|
|
88
|
+
toOps(lowerer?: ExecuteRequestLowerer): readonly Promise<Op>[];
|
|
49
89
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
50
90
|
renderTypeScript(): string;
|
|
51
91
|
importRequirements(): readonly ImportRequirement[];
|
|
@@ -104,17 +144,21 @@ declare class CreateIndexCall extends SqliteOpFactoryCallNode {
|
|
|
104
144
|
readonly columns: readonly string[];
|
|
105
145
|
readonly label: string;
|
|
106
146
|
constructor(tableName: string, indexName: string, columns: readonly string[]);
|
|
147
|
+
/** The id of the operation this call lowers to. */
|
|
148
|
+
get operationId(): string;
|
|
107
149
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
108
150
|
renderTypeScript(): string;
|
|
109
151
|
importRequirements(): readonly ImportRequirement[];
|
|
110
152
|
}
|
|
111
153
|
declare class DropIndexCall extends SqliteOpFactoryCallNode {
|
|
112
154
|
readonly factoryName: "dropIndex";
|
|
113
|
-
readonly operationClass: "
|
|
155
|
+
readonly operationClass: "widening";
|
|
114
156
|
readonly tableName: string;
|
|
115
157
|
readonly indexName: string;
|
|
116
158
|
readonly label: string;
|
|
117
159
|
constructor(tableName: string, indexName: string);
|
|
160
|
+
/** The id of the operation this call lowers to. */
|
|
161
|
+
get operationId(): string;
|
|
118
162
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
119
163
|
renderTypeScript(): string;
|
|
120
164
|
importRequirements(): readonly ImportRequirement[];
|
|
@@ -127,7 +171,7 @@ declare class DropIndexCall extends SqliteOpFactoryCallNode {
|
|
|
127
171
|
* any future strategy that needs a placeholder data step can construct one
|
|
128
172
|
* with its own id/label.
|
|
129
173
|
*
|
|
130
|
-
* `toOp()` always
|
|
174
|
+
* `toOp()` always rejects with `MIGRATION.UNFILLED_PLACEHOLDER`: the planner cannot lower a stubbed
|
|
131
175
|
* transform to a runtime op — the user must edit the rendered
|
|
132
176
|
* `migration.ts` and re-emit.
|
|
133
177
|
*/
|
|
@@ -139,7 +183,7 @@ declare class DataTransformCall extends SqliteOpFactoryCallNode {
|
|
|
139
183
|
readonly tableName: string;
|
|
140
184
|
readonly columnName: string;
|
|
141
185
|
constructor(id: string, label: string, tableName: string, columnName: string);
|
|
142
|
-
toOp(_lowerer?: Lowerer): Op
|
|
186
|
+
toOp(_lowerer?: Lowerer): Promise<Op>;
|
|
143
187
|
renderTypeScript(): string;
|
|
144
188
|
importRequirements(): readonly ImportRequirement[];
|
|
145
189
|
}
|
|
@@ -161,7 +205,7 @@ declare class RawSqlCall extends SqliteOpFactoryCallNode {
|
|
|
161
205
|
toOp(_lowerer?: Lowerer): Op;
|
|
162
206
|
renderTypeScript(): string;
|
|
163
207
|
}
|
|
164
|
-
type SqliteOpFactoryCall = CreateTableCall | DropTableCall | RecreateTableCall | RenameTableCall | AddColumnCall | DropColumnCall | CreateIndexCall | DropIndexCall | DataTransformCall | RawSqlCall;
|
|
208
|
+
type SqliteOpFactoryCall = CreateTableCall | DropTableCall | RecreateTableCall | RenameTableCall | RenameColumnCall | AddColumnCall | DropColumnCall | CreateIndexCall | DropIndexCall | DataTransformCall | RawSqlCall;
|
|
165
209
|
//#endregion
|
|
166
|
-
export { DropColumnCall as a, RawSqlCall as c,
|
|
167
|
-
//# sourceMappingURL=op-factory-call-
|
|
210
|
+
export { DropColumnCall as a, RawSqlCall as c, RenameTableCall as d, SqliteOpFactoryCall as f, DataTransformCall as i, RecreateTableCall as l, CreateIndexCall as n, DropIndexCall as o, CreateTableCall as r, DropTableCall as s, AddColumnCall as t, RenameColumnCall as u };
|
|
211
|
+
//# sourceMappingURL=op-factory-call-B0N6txAF.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-factory-call-B0N6txAF.d.mts","names":[],"sources":["../../../../3-targets/3-targets/sqlite/dist/op-factory-call.d.mts"],"mappings":";;;;;;;;;KAQK,KAAK,0BAA0B;uBACb,gCAAgC,wBAAwB;oBAC3D;oBACA,gBAAgB;oBAChB;WACT,KAAK,UAAU,UAAU,KAAK,QAAQ;;EAE/C,MAAM,UAAU,kCAAkC,KAAK,QAAQ;EAC/D,+BAA+B;YACrB;;cAEE,wBAAwB;WAC3B;WACA;WACA;WACA,kBAAkB;WAClB,sBAAsB;WACtB;EACT,YAAY,mBAAmB,kBAAkB,aAAa,uBAAuB;EACrF,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,sBAAsB;WACzB;WACA;WACA;WACA;EACT,YAAY;EACZ,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;;UAGvB;WACC,MAAM;WACN,QAAQ;;;KAGd,sBAAsB,gBAAgB;cAC7B,wBAAwB;WAC3B;WACA;WACA;;WAEA;WACA;;WAEA,4BAA4B;;;;;WAK5B,qBAAqB;EAC9B,YAAY,sBAAsB,mBAAmB,4BAA4B;;MAE7E;EACJ,MAAM,UAAU,iCAAiC,QAAQ;EACzD,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,yBAAyB;WAC5B;WACA;WACA;WACA;;WAEA;WACA;;WAEA,4BAA4B;;;;;WAK5B,qBAAqB;EAC9B,YAAY,mBAAmB,uBAAuB,oBAAoB,4BAA4B;EACtG,MAAM,UAAU,iCAAiC,QAAQ;EACzD,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,0BAA0B;WAC7B;WACA,gBAAgB;WAChB;WACA,eAAe;WACf;WACA,kBAAkB;WAClB;WACA,qBAAqB;WACrB;EACT,YAAY;IACV;IACA,eAAe;IACf;IACA,kBAAkB;IAClB;IACA,qBAAqB;IACrB,gBAAgB;;EAElB,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,sBAAsB;WACzB;WACA;WACA;WACA;WACA,QAAQ;WACR;EACT,YAAY,mBAAmB,QAAQ;EACvC,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,uBAAuB;WAC1B;WACA;WACA;WACA;WACA;EACT,YAAY,mBAAmB;EAC/B,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,wBAAwB;WAC3B;WACA;WACA;WACA;WACA;WACA;EACT,YAAY,mBAAmB,mBAAmB;;MAE9C;EACJ,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,sBAAsB;WACzB;WACA;WACA;WACA;WACA;EACT,YAAY,mBAAmB;;MAE3B;EACJ,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;;;;;;;;;;;;;cAcnB,0BAA0B;WAC7B;WACA;WACA;WACA;WACA;WACA;EACT,YAAY,YAAY,eAAe,mBAAmB;EAC1D,KAAK,WAAW,UAAU,QAAQ;EAClC;EACA,+BAA+B;;;;;;;;;;;cAWnB,mBAAmB;WACtB;WACA,gBAAgB;WAChB;WACA,IAAI;EACb,YAAY,IAAI;EAChB,KAAK,WAAW,UAAU;EAC1B;;KAEG,sBAAsB,kBAAkB,gBAAgB,oBAAoB,kBAAkB,mBAAmB,gBAAgB,iBAAiB,kBAAkB,gBAAgB,oBAAoB"}
|
package/dist/{op-factory-call-Bwp3QS4h-MwflmSX3.mjs → op-factory-call-BrLX8AMg-BSyJWo6f.mjs}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { o as sqliteInteger } from "./data-types-pFQMl37_-B-3aK_wd.mjs";
|
|
2
2
|
import { n as sqliteError } from "./errors-DnR-sMHS-KkMLIP2U.mjs";
|
|
3
3
|
import { n as decodeSqliteDatetime, r as encodeSqliteDatetime } from "./codecs-BctEWIFt-DgMd3dUl.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { r as stripOuterParens } from "./default-normalizer-Ch3VFnEH-C-h1XtlJ.mjs";
|
|
4
|
+
import { a as tableExistsAst, i as indexExistsAst, n as columnNameTakenAst, o as tableNameTakenAst, r as createTable, t as columnExistsAst } from "./ddl-CDoa1Ehx-BOT670XL.mjs";
|
|
6
5
|
import { n as quoteIdentifier, t as escapeLiteral } from "./sql-utils-C2O4zVkP-Dz3Hb85I.mjs";
|
|
6
|
+
import { r as stripOuterParens } from "./default-normalizer-Ch3VFnEH-C-h1XtlJ.mjs";
|
|
7
7
|
import { t as buildTargetDetails } from "./planner-target-details-CIQ789Gc-C5U4yVY9.mjs";
|
|
8
8
|
import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
|
|
9
9
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -12,10 +12,10 @@ import { dataTypeParams, renderSqlTypeName, sqlDataTypeOfCodec } from "@prisma/o
|
|
|
12
12
|
import { issueOutcome } from "@prisma/orm-framework/components/control";
|
|
13
13
|
import { RelationalSchemaNodeKind } from "@prisma/orm-family-sql/schema-ir/types";
|
|
14
14
|
import { assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
15
|
-
import { errorMigrationOperationOptionRemoved,
|
|
15
|
+
import { errorMigrationOperationOptionRemoved, unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
|
|
16
16
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
17
17
|
import { TsExpression, jsonToTsSource, tsArraySource, tsObjectSource, tsQuotedTextSource } from "@prisma/orm-framework/ts-render";
|
|
18
|
-
//#region ../../../3-targets/3-targets/sqlite/dist/op-factory-call-
|
|
18
|
+
//#region ../../../3-targets/3-targets/sqlite/dist/op-factory-call-BrLX8AMg.mjs
|
|
19
19
|
/**
|
|
20
20
|
* Low-level DDL fragment builders for SQLite migrations.
|
|
21
21
|
*
|
|
@@ -178,6 +178,39 @@ async function addColumn(tableName, column, lowerer) {
|
|
|
178
178
|
postcheck: [step(`verify column "${column.name}" exists`, present.sql, present.params)]
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
+
function renameColumnExecuteSql(tableName, fromName, toName) {
|
|
182
|
+
return `ALTER TABLE ${quoteIdentifier(tableName)} RENAME COLUMN ${quoteIdentifier(fromName)} TO ${quoteIdentifier(toName)}`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Renames a column. SQLite updates the indexes, foreign keys and triggers that name it, and keeps
|
|
186
|
+
* index names. SQLite takes names that differ only in case for the same name, so the new name
|
|
187
|
+
* must be free whatever its case, except in a rename that only changes case, which SQLite performs
|
|
188
|
+
* in one statement.
|
|
189
|
+
*/
|
|
190
|
+
function renameColumnOperationId(tableName, fromName) {
|
|
191
|
+
return `renameColumn.${tableName}.${fromName}`;
|
|
192
|
+
}
|
|
193
|
+
async function renameColumn(tableName, fromName, toName, lowerer) {
|
|
194
|
+
const fromChecks = columnExistsAst(tableName, fromName);
|
|
195
|
+
const toChecks = columnExistsAst(tableName, toName);
|
|
196
|
+
const fromPresent = await lowerer.lowerToExecuteRequest(fromChecks.columnPresent());
|
|
197
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(sqliteIdentifiersCollide(fromName, toName) ? toChecks.columnAbsent() : columnNameTakenAst(tableName, toName).nameFree());
|
|
198
|
+
const toPresent = await lowerer.lowerToExecuteRequest(toChecks.columnPresent());
|
|
199
|
+
const fromAbsent = await lowerer.lowerToExecuteRequest(fromChecks.columnAbsent());
|
|
200
|
+
return {
|
|
201
|
+
id: renameColumnOperationId(tableName, fromName),
|
|
202
|
+
label: `Rename column ${fromName} on ${tableName} to ${toName}`,
|
|
203
|
+
summary: `Renames column ${fromName} on ${tableName} to ${toName}, keeping its values`,
|
|
204
|
+
operationClass: "widening",
|
|
205
|
+
target: {
|
|
206
|
+
id: "sqlite",
|
|
207
|
+
details: buildTargetDetails("column", toName, tableName)
|
|
208
|
+
},
|
|
209
|
+
precheck: [step(`ensure column "${fromName}" exists on "${tableName}"`, fromPresent.sql, fromPresent.params), step(`ensure column "${toName}" does not exist on "${tableName}"`, toAbsent.sql, toAbsent.params)],
|
|
210
|
+
execute: [step(`rename column "${fromName}" on "${tableName}" to "${toName}"`, renameColumnExecuteSql(tableName, fromName, toName))],
|
|
211
|
+
postcheck: [step(`verify column "${toName}" exists on "${tableName}"`, toPresent.sql, toPresent.params), step(`verify column "${fromName}" no longer exists on "${tableName}"`, fromAbsent.sql, fromAbsent.params)]
|
|
212
|
+
};
|
|
213
|
+
}
|
|
181
214
|
async function tableExistsSteps(lowerer, tableName) {
|
|
182
215
|
const checks = tableExistsAst(tableName);
|
|
183
216
|
return {
|
|
@@ -451,6 +484,10 @@ function buildRecreatePostchecks(tableName, issues, spec) {
|
|
|
451
484
|
}
|
|
452
485
|
const TARGET_MIGRATION_MODULE = "@internal/sqlite/migration";
|
|
453
486
|
var SqliteOpFactoryCallNode = class extends TsExpression {
|
|
487
|
+
/** The operations this call lowers to, in order: one, unless the call carries companions. */
|
|
488
|
+
toOps(lowerer) {
|
|
489
|
+
return [this.toOp(lowerer)];
|
|
490
|
+
}
|
|
454
491
|
importRequirements() {
|
|
455
492
|
return [{
|
|
456
493
|
moduleSpecifier: TARGET_MIGRATION_MODULE,
|
|
@@ -461,6 +498,10 @@ var SqliteOpFactoryCallNode = class extends TsExpression {
|
|
|
461
498
|
Object.freeze(this);
|
|
462
499
|
}
|
|
463
500
|
};
|
|
501
|
+
/** Whether `call` is one of this target's calls, which lower through {@link SqliteOpFactoryCallNode.toOps}. */
|
|
502
|
+
function isSqliteOpFactoryCall(call) {
|
|
503
|
+
return call instanceof SqliteOpFactoryCallNode;
|
|
504
|
+
}
|
|
464
505
|
function renderDdlColumnDefault(def) {
|
|
465
506
|
if (!def) return "";
|
|
466
507
|
if (def.kind === "literal") return `lit(${jsonToTsSource(def.value)})`;
|
|
@@ -626,6 +667,10 @@ var DropTableCall = class extends SqliteOpFactoryCallNode {
|
|
|
626
667
|
return [];
|
|
627
668
|
}
|
|
628
669
|
};
|
|
670
|
+
/** The replaced indexes' drops, then their creates, since a create may take a dropped name. */
|
|
671
|
+
function indexReplacementCalls(replacements) {
|
|
672
|
+
return [...replacements.map(({ drop }) => drop), ...replacements.map(({ create }) => create)];
|
|
673
|
+
}
|
|
629
674
|
var RenameTableCall = class extends SqliteOpFactoryCallNode {
|
|
630
675
|
factoryName = "renameTable";
|
|
631
676
|
operationClass = "widening";
|
|
@@ -633,13 +678,29 @@ var RenameTableCall = class extends SqliteOpFactoryCallNode {
|
|
|
633
678
|
/** The new name: the table's contract-side identity after the rename. */
|
|
634
679
|
tableName;
|
|
635
680
|
label;
|
|
636
|
-
|
|
681
|
+
/** The indexes named after the old table, which SQLite cannot rename, so it replaces them. */
|
|
682
|
+
indexReplacements;
|
|
683
|
+
/**
|
|
684
|
+
* The replacements' drops, then their creates. They run after the table rename and are never
|
|
685
|
+
* rendered on their own.
|
|
686
|
+
*/
|
|
687
|
+
companions;
|
|
688
|
+
constructor(oldTableName, tableName, indexReplacements) {
|
|
637
689
|
super();
|
|
638
690
|
this.oldTableName = oldTableName;
|
|
639
691
|
this.tableName = tableName;
|
|
640
692
|
this.label = `Rename table ${oldTableName} to ${tableName}`;
|
|
693
|
+
this.indexReplacements = Object.freeze([...indexReplacements]);
|
|
694
|
+
this.companions = Object.freeze(indexReplacementCalls(indexReplacements));
|
|
641
695
|
this.freeze();
|
|
642
696
|
}
|
|
697
|
+
/** The id of the operation this call lowers to. */
|
|
698
|
+
get operationId() {
|
|
699
|
+
return `renameTable.${this.oldTableName}`;
|
|
700
|
+
}
|
|
701
|
+
toOps(lowerer) {
|
|
702
|
+
return [this.toOp(lowerer), ...this.companions.map((companion) => companion.toOp(lowerer))];
|
|
703
|
+
}
|
|
643
704
|
async toOp(lowerer) {
|
|
644
705
|
if (lowerer === void 0) throw sqliteError("MIGRATION.SQLITE_CONTROL_STACK_MISSING", `RenameTableCall.toOp: a lowerer is required on the SQLite planner path (table "${this.oldTableName}"). Pass the control adapter to createSqliteMigrationPlanner.`, { meta: {
|
|
645
706
|
factory: this.factoryName,
|
|
@@ -648,13 +709,14 @@ var RenameTableCall = class extends SqliteOpFactoryCallNode {
|
|
|
648
709
|
const fromChecks = tableExistsAst(this.oldTableName);
|
|
649
710
|
const toChecks = tableExistsAst(this.tableName);
|
|
650
711
|
const fromPresent = await lowerer.lowerToExecuteRequest(fromChecks.tablePresent());
|
|
651
|
-
const
|
|
712
|
+
const onlyCase = renameChangesOnlyCase(this.oldTableName, this.tableName);
|
|
713
|
+
const toAbsent = await lowerer.lowerToExecuteRequest(onlyCase ? toChecks.tableAbsent() : tableNameTakenAst(this.tableName).nameFree());
|
|
652
714
|
const viaName = renameTableViaName(this.tableName);
|
|
653
|
-
const viaAbsent =
|
|
715
|
+
const viaAbsent = onlyCase ? await lowerer.lowerToExecuteRequest(tableExistsAst(viaName).tableAbsent()) : void 0;
|
|
654
716
|
const toPresent = await lowerer.lowerToExecuteRequest(toChecks.tablePresent());
|
|
655
717
|
const fromAbsent = await lowerer.lowerToExecuteRequest(fromChecks.tableAbsent());
|
|
656
718
|
return {
|
|
657
|
-
id:
|
|
719
|
+
id: this.operationId,
|
|
658
720
|
label: this.label,
|
|
659
721
|
summary: `Renames table ${this.oldTableName} to ${this.tableName}, keeping its rows`,
|
|
660
722
|
operationClass: "widening",
|
|
@@ -664,7 +726,7 @@ var RenameTableCall = class extends SqliteOpFactoryCallNode {
|
|
|
664
726
|
},
|
|
665
727
|
precheck: [
|
|
666
728
|
step(`ensure table "${this.oldTableName}" exists`, fromPresent.sql, fromPresent.params),
|
|
667
|
-
step(`ensure table "${this.tableName}" does not exist`, toAbsent.sql, toAbsent.params),
|
|
729
|
+
step(onlyCase ? `ensure table "${this.tableName}" does not exist` : `ensure no table or index is named "${this.tableName}" in any case`, toAbsent.sql, toAbsent.params),
|
|
668
730
|
...viaAbsent === void 0 ? [] : [step(`ensure table "${viaName}" does not exist (a rename that only changes case passes through this temporary name, because SQLite compares table names without case)`, viaAbsent.sql, viaAbsent.params)]
|
|
669
731
|
],
|
|
670
732
|
execute: renameTableSteps(this.oldTableName, this.tableName),
|
|
@@ -678,6 +740,48 @@ var RenameTableCall = class extends SqliteOpFactoryCallNode {
|
|
|
678
740
|
return [];
|
|
679
741
|
}
|
|
680
742
|
};
|
|
743
|
+
var RenameColumnCall = class extends SqliteOpFactoryCallNode {
|
|
744
|
+
factoryName = "renameColumn";
|
|
745
|
+
operationClass = "widening";
|
|
746
|
+
tableName;
|
|
747
|
+
oldColumnName;
|
|
748
|
+
/** The new name: the column's contract-side identity after the rename. */
|
|
749
|
+
columnName;
|
|
750
|
+
label;
|
|
751
|
+
/** The indexes on the column whose wire names change, which SQLite cannot rename. */
|
|
752
|
+
indexReplacements;
|
|
753
|
+
/**
|
|
754
|
+
* The replacements' drops, then their creates. They run after the column rename and are never
|
|
755
|
+
* rendered on their own.
|
|
756
|
+
*/
|
|
757
|
+
companions;
|
|
758
|
+
constructor(tableName, oldColumnName, columnName, indexReplacements) {
|
|
759
|
+
super();
|
|
760
|
+
this.tableName = tableName;
|
|
761
|
+
this.oldColumnName = oldColumnName;
|
|
762
|
+
this.columnName = columnName;
|
|
763
|
+
this.label = `Rename column ${oldColumnName} on ${tableName} to ${columnName}`;
|
|
764
|
+
this.indexReplacements = Object.freeze([...indexReplacements]);
|
|
765
|
+
this.companions = Object.freeze(indexReplacementCalls(indexReplacements));
|
|
766
|
+
this.freeze();
|
|
767
|
+
}
|
|
768
|
+
toOps(lowerer) {
|
|
769
|
+
return [this.toOp(lowerer), ...this.companions.map((companion) => companion.toOp(lowerer))];
|
|
770
|
+
}
|
|
771
|
+
async toOp(lowerer) {
|
|
772
|
+
if (lowerer === void 0) throw sqliteError("MIGRATION.SQLITE_CONTROL_STACK_MISSING", `RenameColumnCall.toOp: a lowerer is required on the SQLite planner path (column "${this.oldColumnName}" on table "${this.tableName}"). Pass the control adapter to createSqliteMigrationPlanner.`, { meta: {
|
|
773
|
+
factory: this.factoryName,
|
|
774
|
+
tableName: this.tableName
|
|
775
|
+
} });
|
|
776
|
+
return renameColumn(this.tableName, this.oldColumnName, this.columnName, lowerer);
|
|
777
|
+
}
|
|
778
|
+
renderTypeScript() {
|
|
779
|
+
return `...this.renameColumn({ table: ${jsonToTsSource(this.tableName)}, column: ${jsonToTsSource(this.oldColumnName)}, to: ${jsonToTsSource(this.columnName)} })`;
|
|
780
|
+
}
|
|
781
|
+
importRequirements() {
|
|
782
|
+
return [];
|
|
783
|
+
}
|
|
784
|
+
};
|
|
681
785
|
var RecreateTableCall = class extends SqliteOpFactoryCallNode {
|
|
682
786
|
factoryName = "recreateTable";
|
|
683
787
|
operationClass;
|
|
@@ -818,6 +922,10 @@ var CreateIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
818
922
|
this.label = `Create index ${indexName} on ${tableName}`;
|
|
819
923
|
this.freeze();
|
|
820
924
|
}
|
|
925
|
+
/** The id of the operation this call lowers to. */
|
|
926
|
+
get operationId() {
|
|
927
|
+
return `index.${this.tableName}.${this.indexName}`;
|
|
928
|
+
}
|
|
821
929
|
async toOp(lowerer) {
|
|
822
930
|
if (lowerer === void 0) throw sqliteError("MIGRATION.SQLITE_CONTROL_STACK_MISSING", `CreateIndexCall.toOp: a lowerer is required on the SQLite planner path (index "${this.indexName}" on table "${this.tableName}"). Pass the control adapter to createSqliteMigrationPlanner.`, { meta: {
|
|
823
931
|
factory: this.factoryName,
|
|
@@ -828,7 +936,7 @@ var CreateIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
828
936
|
const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());
|
|
829
937
|
const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());
|
|
830
938
|
return {
|
|
831
|
-
id:
|
|
939
|
+
id: this.operationId,
|
|
832
940
|
label: `Create index ${this.indexName} on ${this.tableName}`,
|
|
833
941
|
summary: `Creates index ${this.indexName} on ${this.tableName}`,
|
|
834
942
|
operationClass: "additive",
|
|
@@ -850,7 +958,7 @@ var CreateIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
850
958
|
};
|
|
851
959
|
var DropIndexCall = class extends SqliteOpFactoryCallNode {
|
|
852
960
|
factoryName = "dropIndex";
|
|
853
|
-
operationClass = "
|
|
961
|
+
operationClass = "widening";
|
|
854
962
|
tableName;
|
|
855
963
|
indexName;
|
|
856
964
|
label;
|
|
@@ -861,6 +969,10 @@ var DropIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
861
969
|
this.label = `Drop index ${indexName} on ${tableName}`;
|
|
862
970
|
this.freeze();
|
|
863
971
|
}
|
|
972
|
+
/** The id of the operation this call lowers to. */
|
|
973
|
+
get operationId() {
|
|
974
|
+
return `dropIndex.${this.tableName}.${this.indexName}`;
|
|
975
|
+
}
|
|
864
976
|
async toOp(lowerer) {
|
|
865
977
|
if (lowerer === void 0) throw sqliteError("MIGRATION.SQLITE_CONTROL_STACK_MISSING", `DropIndexCall.toOp: a lowerer is required on the SQLite planner path (index "${this.indexName}" on table "${this.tableName}"). Pass the control adapter to createSqliteMigrationPlanner.`, { meta: {
|
|
866
978
|
factory: this.factoryName,
|
|
@@ -871,10 +983,10 @@ var DropIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
871
983
|
const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());
|
|
872
984
|
const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());
|
|
873
985
|
return {
|
|
874
|
-
id:
|
|
986
|
+
id: this.operationId,
|
|
875
987
|
label: `Drop index ${this.indexName} on ${this.tableName}`,
|
|
876
988
|
summary: `Drops index ${this.indexName} on ${this.tableName} which is not in the contract`,
|
|
877
|
-
operationClass: "
|
|
989
|
+
operationClass: "widening",
|
|
878
990
|
target: {
|
|
879
991
|
id: "sqlite",
|
|
880
992
|
details: buildTargetDetails("index", this.indexName, this.tableName)
|
|
@@ -899,7 +1011,7 @@ var DropIndexCall = class extends SqliteOpFactoryCallNode {
|
|
|
899
1011
|
* any future strategy that needs a placeholder data step can construct one
|
|
900
1012
|
* with its own id/label.
|
|
901
1013
|
*
|
|
902
|
-
* `toOp()` always
|
|
1014
|
+
* `toOp()` always rejects with `MIGRATION.UNFILLED_PLACEHOLDER`: the planner cannot lower a stubbed
|
|
903
1015
|
* transform to a runtime op — the user must edit the rendered
|
|
904
1016
|
* `migration.ts` and re-emit.
|
|
905
1017
|
*/
|
|
@@ -919,7 +1031,7 @@ var DataTransformCall = class extends SqliteOpFactoryCallNode {
|
|
|
919
1031
|
this.freeze();
|
|
920
1032
|
}
|
|
921
1033
|
toOp(_lowerer) {
|
|
922
|
-
|
|
1034
|
+
return unfilledPlaceholderOperation(this.label);
|
|
923
1035
|
}
|
|
924
1036
|
renderTypeScript() {
|
|
925
1037
|
const slot = `${this.tableName}-${this.columnName}-backfill-sql`;
|
|
@@ -1013,6 +1125,6 @@ function renderPostcheck(postcheck) {
|
|
|
1013
1125
|
}));
|
|
1014
1126
|
}
|
|
1015
1127
|
//#endregion
|
|
1016
|
-
export {
|
|
1128
|
+
export { renameTableSteps as _, DropColumnCall as a, sqliteIdentifiersCollide as b, RawSqlCall as c, RenameTableCall as d, buildColumnTypeSql as f, isSqliteOpFactoryCall as g, indexReplacementCalls as h, DataTransformCall as i, RecreateTableCall as l, buildRecreateSummary as m, CreateIndexCall as n, DropIndexCall as o, buildRecreatePostchecks as p, CreateTableCall as r, DropTableCall as s, AddColumnCall as t, RenameColumnCall as u, renderDefaultLiteral as v, step as x, sqliteDefaultToDdlColumnDefault as y };
|
|
1017
1129
|
|
|
1018
|
-
//# sourceMappingURL=op-factory-call-
|
|
1130
|
+
//# sourceMappingURL=op-factory-call-BrLX8AMg-BSyJWo6f.mjs.map
|