drizzle-kit 0.18.1-a48fd5c → 0.18.1-b5dc75c
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/{index.mjs → index.cjs} +527 -548
- package/loader.mjs +42 -8
- package/package.json +4 -5
- package/utils.js +21 -29
package/loader.mjs
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import esbuild from "esbuild";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
|
|
5
|
+
export function resolve(specifier, context, nextResolve) {
|
|
6
|
+
if (specifier.startsWith("drizzle://")) {
|
|
7
|
+
if (!specifier.endsWith(".ts")) {
|
|
8
|
+
const url = specifier.slice("drizzle://".length).toString();
|
|
9
|
+
return nextResolve(url);
|
|
10
|
+
}
|
|
2
11
|
|
|
3
|
-
export async function load(url, context, defaultLoad) {
|
|
4
|
-
if (extensionsRegex.test(url)) {
|
|
5
|
-
const { source } = await defaultLoad(url, { ...context, format: 'module' })
|
|
6
12
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
shortCircuit: true,
|
|
14
|
+
url: specifier,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { parentURL: url } = context;
|
|
19
|
+
const parentURL = url?.startsWith("drizzle://")
|
|
20
|
+
? new URL(`file://${path.resolve(url.slice("drizzle://".length))}`)
|
|
21
|
+
: url;
|
|
22
|
+
|
|
23
|
+
// Let Node.js handle all other specifiers.
|
|
24
|
+
return nextResolve(specifier, { ...context, parentURL });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function load(url, context, defaultLoad) {
|
|
28
|
+
if (url.startsWith("drizzle://")) {
|
|
29
|
+
|
|
30
|
+
const path = url.slice("drizzle://".length).trim();
|
|
31
|
+
const file = readFileSync(path, "utf-8");
|
|
32
|
+
if (path.endsWith(".ts") || path.endsWith(".mts")) {
|
|
33
|
+
const source = esbuild.transformSync(file, {
|
|
34
|
+
loader: "ts",
|
|
35
|
+
format: "esm",
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
format: "module",
|
|
39
|
+
shortCircuit: true,
|
|
40
|
+
source: source.code,
|
|
41
|
+
};
|
|
9
42
|
}
|
|
10
43
|
}
|
|
44
|
+
|
|
11
45
|
// let Node.js handle all other URLs
|
|
12
|
-
return defaultLoad(url, context, defaultLoad)
|
|
13
|
-
}
|
|
46
|
+
return defaultLoad(url, context, defaultLoad);
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.18.1-
|
|
3
|
+
"version": "0.18.1-b5dc75c",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
8
|
-
"drizzle-kit": "./index.
|
|
8
|
+
"drizzle-kit": "./index.cjs"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@esbuild-kit/esm-loader": "^2.5.5",
|
|
50
51
|
"camelcase": "^7.0.1",
|
|
51
52
|
"chalk": "^5.2.0",
|
|
52
53
|
"commander": "^9.4.1",
|
|
53
|
-
"esbuild-register": "^3.4.2",
|
|
54
54
|
"glob": "^8.1.0",
|
|
55
55
|
"hanji": "^0.0.5",
|
|
56
56
|
"json-diff": "0.9.0",
|
|
@@ -68,8 +68,7 @@
|
|
|
68
68
|
"ava": "^5.1.0",
|
|
69
69
|
"dockerode": "^3.3.4",
|
|
70
70
|
"dotenv": "^16.0.3",
|
|
71
|
-
"drizzle-
|
|
72
|
-
"drizzle-orm": "0.25.1",
|
|
71
|
+
"drizzle-orm": "0.26.5-ad5d574",
|
|
73
72
|
"esbuild": "^0.17.19",
|
|
74
73
|
"eslint": "^8.29.0",
|
|
75
74
|
"eslint-config-prettier": "^8.5.0",
|
package/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env -S node --loader @esbuild-kit/esm-loader --no-warnings
|
|
1
|
+
#!/usr/bin/env -S node --loader @esbuild-kit/esm-loader --no-warnings
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -337,9 +337,9 @@ function createSupportsColor(stream, options = {}) {
|
|
|
337
337
|
var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
|
|
338
338
|
var init_supports_color = __esm({
|
|
339
339
|
"node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
|
|
340
|
-
import_node_process = __toESM(require("process"), 1);
|
|
341
|
-
import_node_os = __toESM(require("os"), 1);
|
|
342
|
-
import_node_tty = __toESM(require("tty"), 1);
|
|
340
|
+
import_node_process = __toESM(require("node:process"), 1);
|
|
341
|
+
import_node_os = __toESM(require("node:os"), 1);
|
|
342
|
+
import_node_tty = __toESM(require("node:tty"), 1);
|
|
343
343
|
({ env } = import_node_process.default);
|
|
344
344
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
345
345
|
flagForceColor = 0;
|
|
@@ -12825,9 +12825,8 @@ var schemaSquashedV4 = objectType({
|
|
|
12825
12825
|
}).strict();
|
|
12826
12826
|
var MySqlSquasher = {
|
|
12827
12827
|
squashIdx: (idx) => {
|
|
12828
|
-
var _a, _b, _c;
|
|
12829
12828
|
index.parse(idx);
|
|
12830
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${
|
|
12829
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
|
|
12831
12830
|
},
|
|
12832
12831
|
unsquashIdx: (input) => {
|
|
12833
12832
|
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
|
@@ -12849,8 +12848,7 @@ var MySqlSquasher = {
|
|
|
12849
12848
|
return { name: splitted[0], columns: splitted[1].split(",") };
|
|
12850
12849
|
},
|
|
12851
12850
|
squashFK: (fk4) => {
|
|
12852
|
-
|
|
12853
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${(_a = fk4.onUpdate) != null ? _a : ""};${(_b = fk4.onDelete) != null ? _b : ""}`;
|
|
12851
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
|
12854
12852
|
},
|
|
12855
12853
|
unsquashFK: (input) => {
|
|
12856
12854
|
const [
|
|
@@ -13077,8 +13075,7 @@ var PgSquasher = {
|
|
|
13077
13075
|
return result;
|
|
13078
13076
|
},
|
|
13079
13077
|
squashFK: (fk4) => {
|
|
13080
|
-
|
|
13081
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${(_a = fk4.onUpdate) != null ? _a : ""};${(_b = fk4.onDelete) != null ? _b : ""}`;
|
|
13078
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
|
13082
13079
|
},
|
|
13083
13080
|
squashPK: (pk) => {
|
|
13084
13081
|
return `${pk.columns.join(",")}`;
|
|
@@ -13242,9 +13239,8 @@ var schemaSquashed2 = objectType({
|
|
|
13242
13239
|
}).strict();
|
|
13243
13240
|
var SQLiteSquasher = {
|
|
13244
13241
|
squashIdx: (idx) => {
|
|
13245
|
-
var _a;
|
|
13246
13242
|
index3.parse(idx);
|
|
13247
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${
|
|
13243
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
|
|
13248
13244
|
},
|
|
13249
13245
|
unsquashIdx: (input) => {
|
|
13250
13246
|
const [name, columnsString, isUnique, where] = input.split(";");
|
|
@@ -13252,13 +13248,12 @@ var SQLiteSquasher = {
|
|
|
13252
13248
|
name,
|
|
13253
13249
|
columns: columnsString.split(","),
|
|
13254
13250
|
isUnique: isUnique === "true",
|
|
13255
|
-
where: where
|
|
13251
|
+
where: where ?? void 0
|
|
13256
13252
|
});
|
|
13257
13253
|
return result;
|
|
13258
13254
|
},
|
|
13259
13255
|
squashFK: (fk4) => {
|
|
13260
|
-
|
|
13261
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${(_a = fk4.onUpdate) != null ? _a : ""};${(_b = fk4.onDelete) != null ? _b : ""}`;
|
|
13256
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
|
13262
13257
|
},
|
|
13263
13258
|
unsquashFK: (input) => {
|
|
13264
13259
|
const [
|
|
@@ -13333,7 +13328,6 @@ function diffForRenamedColumn(t1, t2) {
|
|
|
13333
13328
|
return alternationsInColumn(diffed);
|
|
13334
13329
|
}
|
|
13335
13330
|
function applyJsonDiff(json1, json2) {
|
|
13336
|
-
var _a, _b, _c;
|
|
13337
13331
|
json1 = JSON.parse(JSON.stringify(json1));
|
|
13338
13332
|
json2 = JSON.parse(JSON.stringify(json2));
|
|
13339
13333
|
const rawDiff = (0, import_json_diff.diff)(json1, json2);
|
|
@@ -13344,9 +13338,9 @@ function applyJsonDiff(json1, json2) {
|
|
|
13344
13338
|
}, {});
|
|
13345
13339
|
if (!difference)
|
|
13346
13340
|
return {};
|
|
13347
|
-
difference.tables =
|
|
13348
|
-
difference.enums =
|
|
13349
|
-
difference.schemas =
|
|
13341
|
+
difference.tables = difference.tables ?? {};
|
|
13342
|
+
difference.enums = difference.enums ?? {};
|
|
13343
|
+
difference.schemas = difference.schemas ?? {};
|
|
13350
13344
|
const tableEntries = Object.entries(difference.tables);
|
|
13351
13345
|
const addedTables = tableEntries.filter((it) => it[0].includes("__added")).map((it) => it[1]);
|
|
13352
13346
|
const deletedTables = tableEntries.filter((it) => it[0].includes("__deleted")).map((it) => it[1]);
|
|
@@ -13384,8 +13378,7 @@ function applyJsonDiff(json1, json2) {
|
|
|
13384
13378
|
};
|
|
13385
13379
|
}
|
|
13386
13380
|
var findAlternationsInTable = (table4, tableSchema) => {
|
|
13387
|
-
|
|
13388
|
-
const columns = (_a = table4.columns) != null ? _a : {};
|
|
13381
|
+
const columns = table4.columns ?? {};
|
|
13389
13382
|
let schema4 = {
|
|
13390
13383
|
type: "none",
|
|
13391
13384
|
value: tableSchema
|
|
@@ -15414,7 +15407,7 @@ var diffResultScheme = objectType({
|
|
|
15414
15407
|
deletedSchemas: stringType().array()
|
|
15415
15408
|
}).strict();
|
|
15416
15409
|
var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
|
15417
|
-
var _a, _b
|
|
15410
|
+
var _a, _b;
|
|
15418
15411
|
const diffResult = applyJsonDiff(json1, json2);
|
|
15419
15412
|
if (Object.keys(diffResult).length === 0) {
|
|
15420
15413
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
|
@@ -15674,12 +15667,12 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
15674
15667
|
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
|
15675
15668
|
(t) => t.type === "delete_reference"
|
|
15676
15669
|
);
|
|
15677
|
-
const createEnums = (
|
|
15670
|
+
const createEnums = ((_a = typedResult.addedEnums) == null ? void 0 : _a.map((it) => {
|
|
15678
15671
|
return prepareCreateEnumJson(it.name, it.values);
|
|
15679
|
-
}))
|
|
15680
|
-
const jsonAlterEnumsWithAddedValues = (
|
|
15672
|
+
})) ?? [];
|
|
15673
|
+
const jsonAlterEnumsWithAddedValues = ((_b = typedResult.alteredEnums) == null ? void 0 : _b.map((it) => {
|
|
15681
15674
|
return prepareAddValuesToEnumJson(it.name, it.addedValues);
|
|
15682
|
-
}).flat())
|
|
15675
|
+
}).flat()) ?? [];
|
|
15683
15676
|
if (dialect3 === "mysql") {
|
|
15684
15677
|
createdSchemas.push(...renamedSchemas.map((it) => it.to));
|
|
15685
15678
|
deletedSchemas.push(...renamedSchemas.map((it) => it.from));
|
|
@@ -15923,7 +15916,6 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
|
15923
15916
|
const { validator, version } = validatorForDialect(dialect3);
|
|
15924
15917
|
const result = snapshots.reduce(
|
|
15925
15918
|
(accum, it) => {
|
|
15926
|
-
var _a;
|
|
15927
15919
|
const raw = JSON.parse((0, import_fs.readFileSync)(`./${it}`).toString());
|
|
15928
15920
|
accum.rawMap[it] = raw;
|
|
15929
15921
|
if (raw["version"] && Number(raw["version"]) > version) {
|
|
@@ -15944,7 +15936,7 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
|
15944
15936
|
accum.nonLatest.push(it);
|
|
15945
15937
|
return accum;
|
|
15946
15938
|
}
|
|
15947
|
-
const idEntry =
|
|
15939
|
+
const idEntry = accum.idsMap[snapshot["prevId"]] ?? {
|
|
15948
15940
|
parent: it,
|
|
15949
15941
|
snapshots: []
|
|
15950
15942
|
};
|
|
@@ -16039,7 +16031,7 @@ var kloudMeta = () => {
|
|
|
16039
16031
|
};
|
|
16040
16032
|
};
|
|
16041
16033
|
var statementsForDiffs = async (in1, in2) => {
|
|
16042
|
-
const left = pgSchema.parse(in1
|
|
16034
|
+
const left = pgSchema.parse(in1 ?? dryPg);
|
|
16043
16035
|
const right = pgSchema.parse(in2);
|
|
16044
16036
|
const lsquashed = squashPgScheme(left);
|
|
16045
16037
|
const rsquashed = squashPgScheme(right);
|