drizzle-kit 0.20.15-f37ba6f → 0.20.16-0fef055
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/bin.cjs +548 -376
- package/package.json +1 -1
package/bin.cjs
CHANGED
|
@@ -82,27 +82,27 @@ function floatSafeRemainder(val, step) {
|
|
|
82
82
|
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
83
83
|
return valInt % stepInt / Math.pow(10, decCount);
|
|
84
84
|
}
|
|
85
|
-
function deepPartialify(
|
|
86
|
-
if (
|
|
85
|
+
function deepPartialify(schema5) {
|
|
86
|
+
if (schema5 instanceof ZodObject) {
|
|
87
87
|
const newShape = {};
|
|
88
|
-
for (const key in
|
|
89
|
-
const fieldSchema =
|
|
88
|
+
for (const key in schema5.shape) {
|
|
89
|
+
const fieldSchema = schema5.shape[key];
|
|
90
90
|
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
91
91
|
}
|
|
92
92
|
return new ZodObject({
|
|
93
|
-
...
|
|
93
|
+
...schema5._def,
|
|
94
94
|
shape: () => newShape
|
|
95
95
|
});
|
|
96
|
-
} else if (
|
|
97
|
-
return ZodArray.create(deepPartialify(
|
|
98
|
-
} else if (
|
|
99
|
-
return ZodOptional.create(deepPartialify(
|
|
100
|
-
} else if (
|
|
101
|
-
return ZodNullable.create(deepPartialify(
|
|
102
|
-
} else if (
|
|
103
|
-
return ZodTuple.create(
|
|
96
|
+
} else if (schema5 instanceof ZodArray) {
|
|
97
|
+
return ZodArray.create(deepPartialify(schema5.element));
|
|
98
|
+
} else if (schema5 instanceof ZodOptional) {
|
|
99
|
+
return ZodOptional.create(deepPartialify(schema5.unwrap()));
|
|
100
|
+
} else if (schema5 instanceof ZodNullable) {
|
|
101
|
+
return ZodNullable.create(deepPartialify(schema5.unwrap()));
|
|
102
|
+
} else if (schema5 instanceof ZodTuple) {
|
|
103
|
+
return ZodTuple.create(schema5.items.map((item) => deepPartialify(item)));
|
|
104
104
|
} else {
|
|
105
|
-
return
|
|
105
|
+
return schema5;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function mergeValues(a, b) {
|
|
@@ -1728,9 +1728,9 @@ var init_lib = __esm({
|
|
|
1728
1728
|
return this.min(1, message);
|
|
1729
1729
|
}
|
|
1730
1730
|
};
|
|
1731
|
-
ZodArray.create = (
|
|
1731
|
+
ZodArray.create = (schema5, params) => {
|
|
1732
1732
|
return new ZodArray({
|
|
1733
|
-
type:
|
|
1733
|
+
type: schema5,
|
|
1734
1734
|
minLength: null,
|
|
1735
1735
|
maxLength: null,
|
|
1736
1736
|
exactLength: null,
|
|
@@ -1892,8 +1892,8 @@ var init_lib = __esm({
|
|
|
1892
1892
|
unknownKeys: "passthrough"
|
|
1893
1893
|
});
|
|
1894
1894
|
}
|
|
1895
|
-
setKey(key,
|
|
1896
|
-
return this.augment({ [key]:
|
|
1895
|
+
setKey(key, schema5) {
|
|
1896
|
+
return this.augment({ [key]: schema5 });
|
|
1897
1897
|
}
|
|
1898
1898
|
/**
|
|
1899
1899
|
* Prior to zod@1.0.12 there was a bug in the
|
|
@@ -2301,10 +2301,10 @@ var init_lib = __esm({
|
|
|
2301
2301
|
status.dirty();
|
|
2302
2302
|
}
|
|
2303
2303
|
const items = ctx.data.map((item, itemIndex) => {
|
|
2304
|
-
const
|
|
2305
|
-
if (!
|
|
2304
|
+
const schema5 = this._def.items[itemIndex] || this._def.rest;
|
|
2305
|
+
if (!schema5)
|
|
2306
2306
|
return null;
|
|
2307
|
-
return
|
|
2307
|
+
return schema5._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
2308
2308
|
}).filter((x) => !!x);
|
|
2309
2309
|
if (ctx.common.async) {
|
|
2310
2310
|
return Promise.all(items).then((results) => {
|
|
@@ -2790,9 +2790,9 @@ var init_lib = __esm({
|
|
|
2790
2790
|
}));
|
|
2791
2791
|
}
|
|
2792
2792
|
};
|
|
2793
|
-
ZodPromise.create = (
|
|
2793
|
+
ZodPromise.create = (schema5, params) => {
|
|
2794
2794
|
return new ZodPromise({
|
|
2795
|
-
type:
|
|
2795
|
+
type: schema5,
|
|
2796
2796
|
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
2797
2797
|
...processCreateParams(params)
|
|
2798
2798
|
});
|
|
@@ -2899,17 +2899,17 @@ var init_lib = __esm({
|
|
|
2899
2899
|
util.assertNever(effect);
|
|
2900
2900
|
}
|
|
2901
2901
|
};
|
|
2902
|
-
ZodEffects.create = (
|
|
2902
|
+
ZodEffects.create = (schema5, effect, params) => {
|
|
2903
2903
|
return new ZodEffects({
|
|
2904
|
-
schema:
|
|
2904
|
+
schema: schema5,
|
|
2905
2905
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2906
2906
|
effect,
|
|
2907
2907
|
...processCreateParams(params)
|
|
2908
2908
|
});
|
|
2909
2909
|
};
|
|
2910
|
-
ZodEffects.createWithPreprocess = (preprocess,
|
|
2910
|
+
ZodEffects.createWithPreprocess = (preprocess, schema5, params) => {
|
|
2911
2911
|
return new ZodEffects({
|
|
2912
|
-
schema:
|
|
2912
|
+
schema: schema5,
|
|
2913
2913
|
effect: { type: "preprocess", transform: preprocess },
|
|
2914
2914
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2915
2915
|
...processCreateParams(params)
|
|
@@ -4375,8 +4375,8 @@ var init_views = __esm({
|
|
|
4375
4375
|
error = (error2, greyMsg = "") => {
|
|
4376
4376
|
return `${source_default.red.bold("Err:")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
|
4377
4377
|
};
|
|
4378
|
-
schema = (
|
|
4379
|
-
const tables = Object.values(
|
|
4378
|
+
schema = (schema5) => {
|
|
4379
|
+
const tables = Object.values(schema5.tables);
|
|
4380
4380
|
let msg = source_default.bold(`${tables.length} tables
|
|
4381
4381
|
`);
|
|
4382
4382
|
msg += tables.map((t) => {
|
|
@@ -4388,7 +4388,7 @@ var init_views = __esm({
|
|
|
4388
4388
|
)}`;
|
|
4389
4389
|
}).join("\n");
|
|
4390
4390
|
msg += "\n";
|
|
4391
|
-
const enums = Object.values(
|
|
4391
|
+
const enums = Object.values(schema5["enums"] || {});
|
|
4392
4392
|
if (enums.length > 0) {
|
|
4393
4393
|
msg += "\n";
|
|
4394
4394
|
msg += source_default.bold(`${enums.length} enums
|
|
@@ -5625,22 +5625,22 @@ var init_jsonDiffer = __esm({
|
|
|
5625
5625
|
import_json_diff = require("json-diff");
|
|
5626
5626
|
findAlternationsInTable = (table4, tableSchema) => {
|
|
5627
5627
|
const columns = table4.columns ?? {};
|
|
5628
|
-
let
|
|
5628
|
+
let schema5 = {
|
|
5629
5629
|
type: "none",
|
|
5630
5630
|
value: tableSchema
|
|
5631
5631
|
};
|
|
5632
5632
|
if ("schema" in table4) {
|
|
5633
5633
|
if (table4.schema.__new) {
|
|
5634
|
-
|
|
5634
|
+
schema5 = { type: "changed", old: table4.schema.__old, new: table4.schema.__new };
|
|
5635
5635
|
} else {
|
|
5636
|
-
|
|
5636
|
+
schema5 = { type: "deleted", value: table4.schema.__old };
|
|
5637
5637
|
}
|
|
5638
5638
|
}
|
|
5639
5639
|
if ("schema__added" in table4) {
|
|
5640
|
-
|
|
5640
|
+
schema5 = { type: "added", value: table4.schema__added };
|
|
5641
5641
|
}
|
|
5642
5642
|
if ("schema__deleted" in table4) {
|
|
5643
|
-
|
|
5643
|
+
schema5 = { type: "deleted", value: table4.schema__deleted };
|
|
5644
5644
|
}
|
|
5645
5645
|
const added = Object.keys(columns).filter((it) => it.includes("__added")).map((it) => {
|
|
5646
5646
|
return { ...columns[it] };
|
|
@@ -5688,7 +5688,7 @@ var init_jsonDiffer = __esm({
|
|
|
5688
5688
|
const mappedAltered = altered.map((it) => alternationsInColumn(it));
|
|
5689
5689
|
return {
|
|
5690
5690
|
name: table4.name,
|
|
5691
|
-
schema:
|
|
5691
|
+
schema: schema5,
|
|
5692
5692
|
deleted,
|
|
5693
5693
|
added,
|
|
5694
5694
|
altered: mappedAltered,
|
|
@@ -6370,7 +6370,7 @@ var require_node = __commonJS({
|
|
|
6370
6370
|
"node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js"(exports, module2) {
|
|
6371
6371
|
var tty2 = require("tty");
|
|
6372
6372
|
var util2 = require("util");
|
|
6373
|
-
exports.init =
|
|
6373
|
+
exports.init = init2;
|
|
6374
6374
|
exports.log = log2;
|
|
6375
6375
|
exports.formatArgs = formatArgs;
|
|
6376
6376
|
exports.save = save;
|
|
@@ -6519,7 +6519,7 @@ var require_node = __commonJS({
|
|
|
6519
6519
|
function load() {
|
|
6520
6520
|
return process.env.DEBUG;
|
|
6521
6521
|
}
|
|
6522
|
-
function
|
|
6522
|
+
function init2(debug) {
|
|
6523
6523
|
debug.inspectOpts = {};
|
|
6524
6524
|
const keys = Object.keys(exports.inspectOpts);
|
|
6525
6525
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -11460,8 +11460,8 @@ var init_utils = __esm({
|
|
|
11460
11460
|
return res;
|
|
11461
11461
|
};
|
|
11462
11462
|
prepareGenerateConfig = async (options) => {
|
|
11463
|
-
const { schema:
|
|
11464
|
-
if (!(
|
|
11463
|
+
const { schema: schema5, out, config, breakpoints, custom: custom2 } = options;
|
|
11464
|
+
if (!(schema5 && out)) {
|
|
11465
11465
|
const drizzleConfig = await drizzleConfigFromFile(config);
|
|
11466
11466
|
if (!drizzleConfig.out) {
|
|
11467
11467
|
console.log("You must specify 'out' param in config file");
|
|
@@ -11475,20 +11475,20 @@ var init_utils = __esm({
|
|
|
11475
11475
|
bundle: drizzleConfig.driver === "expo"
|
|
11476
11476
|
};
|
|
11477
11477
|
}
|
|
11478
|
-
if (!
|
|
11478
|
+
if (!schema5) {
|
|
11479
11479
|
console.error(`'schema' param must be set`);
|
|
11480
11480
|
process.exit(1);
|
|
11481
11481
|
}
|
|
11482
|
-
const fileNames = prepareFilenames(
|
|
11482
|
+
const fileNames = prepareFilenames(schema5);
|
|
11483
11483
|
if (fileNames.length === 0) {
|
|
11484
|
-
(0, import_hanji2.render)(`[${source_default.blue("i")}] No schema file in ${
|
|
11484
|
+
(0, import_hanji2.render)(`[${source_default.blue("i")}] No schema file in ${schema5} was found`);
|
|
11485
11485
|
process.exit(0);
|
|
11486
11486
|
}
|
|
11487
11487
|
if (!out) {
|
|
11488
11488
|
console.error(`'out' param must be set`);
|
|
11489
11489
|
process.exit(1);
|
|
11490
11490
|
}
|
|
11491
|
-
return { schema:
|
|
11491
|
+
return { schema: schema5, out, breakpoints, custom: custom2, bundle: false };
|
|
11492
11492
|
};
|
|
11493
11493
|
assertOutFolder = async (it) => {
|
|
11494
11494
|
if ("out" in it)
|
|
@@ -11793,7 +11793,7 @@ var init_mysqlSerializer = __esm({
|
|
|
11793
11793
|
columns,
|
|
11794
11794
|
indexes,
|
|
11795
11795
|
foreignKeys,
|
|
11796
|
-
schema:
|
|
11796
|
+
schema: schema5,
|
|
11797
11797
|
primaryKeys,
|
|
11798
11798
|
uniqueConstraints
|
|
11799
11799
|
} = (0, import_mysql_core3.getTableConfig)(table4);
|
|
@@ -11991,7 +11991,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
|
11991
11991
|
});
|
|
11992
11992
|
result[tableName] = {
|
|
11993
11993
|
name: tableName,
|
|
11994
|
-
schema:
|
|
11994
|
+
schema: schema5,
|
|
11995
11995
|
columns: columnsObject,
|
|
11996
11996
|
indexes: indexesObject,
|
|
11997
11997
|
foreignKeys: foreignKeysObject,
|
|
@@ -12038,9 +12038,9 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
|
12038
12038
|
if (progressCallback) {
|
|
12039
12039
|
progressCallback("columns", columnsCount, "fetching");
|
|
12040
12040
|
}
|
|
12041
|
-
const
|
|
12041
|
+
const schema5 = column7["TABLE_SCHEMA"];
|
|
12042
12042
|
const tableName = column7["TABLE_NAME"];
|
|
12043
|
-
tablesCount.add(`${
|
|
12043
|
+
tablesCount.add(`${schema5}.${tableName}`);
|
|
12044
12044
|
if (progressCallback) {
|
|
12045
12045
|
progressCallback("columns", tablesCount.size, "fetching");
|
|
12046
12046
|
}
|
|
@@ -12059,8 +12059,8 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
|
12059
12059
|
isAutoincrement = column7["EXTRA"] === "auto_increment";
|
|
12060
12060
|
isDefaultAnExpression = column7["EXTRA"].includes("DEFAULT_GENERATED");
|
|
12061
12061
|
}
|
|
12062
|
-
if (
|
|
12063
|
-
schemas.push(
|
|
12062
|
+
if (schema5 !== inputSchema) {
|
|
12063
|
+
schemas.push(schema5);
|
|
12064
12064
|
}
|
|
12065
12065
|
const table4 = result[tableName];
|
|
12066
12066
|
let changedType = columnType;
|
|
@@ -12110,7 +12110,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
|
12110
12110
|
if (!table4) {
|
|
12111
12111
|
result[tableName] = {
|
|
12112
12112
|
name: tableName,
|
|
12113
|
-
schema:
|
|
12113
|
+
schema: schema5 !== inputSchema ? schema5 : void 0,
|
|
12114
12114
|
columns: {
|
|
12115
12115
|
[columnName]: newColumn
|
|
12116
12116
|
},
|
|
@@ -12353,11 +12353,11 @@ var init_pgSerializer = __esm({
|
|
|
12353
12353
|
indexes,
|
|
12354
12354
|
foreignKeys,
|
|
12355
12355
|
checks,
|
|
12356
|
-
schema:
|
|
12356
|
+
schema: schema5,
|
|
12357
12357
|
primaryKeys,
|
|
12358
12358
|
uniqueConstraints
|
|
12359
12359
|
} = (0, import_pg_core3.getTableConfig)(table4);
|
|
12360
|
-
if (schemaFilter && !schemaFilter.includes(
|
|
12360
|
+
if (schemaFilter && !schemaFilter.includes(schema5 ?? "public")) {
|
|
12361
12361
|
continue;
|
|
12362
12362
|
}
|
|
12363
12363
|
const columnsObject = {};
|
|
@@ -12499,13 +12499,13 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
|
12499
12499
|
return it.name;
|
|
12500
12500
|
}
|
|
12501
12501
|
});
|
|
12502
|
-
if (typeof indexesInSchema[
|
|
12503
|
-
if (indexesInSchema[
|
|
12502
|
+
if (typeof indexesInSchema[schema5 ?? "public"] !== "undefined") {
|
|
12503
|
+
if (indexesInSchema[schema5 ?? "public"].includes(name)) {
|
|
12504
12504
|
console.log(
|
|
12505
12505
|
`
|
|
12506
12506
|
${withStyle.errorWarning(
|
|
12507
12507
|
`We've found duplicated index name across ${source_default.underline.blue(
|
|
12508
|
-
|
|
12508
|
+
schema5 ?? "public"
|
|
12509
12509
|
)} schema. Please rename your index in either the ${source_default.underline.blue(
|
|
12510
12510
|
tableName
|
|
12511
12511
|
)} table or the table with the duplicated index name`
|
|
@@ -12513,9 +12513,9 @@ ${withStyle.errorWarning(
|
|
|
12513
12513
|
);
|
|
12514
12514
|
process.exit(1);
|
|
12515
12515
|
}
|
|
12516
|
-
indexesInSchema[
|
|
12516
|
+
indexesInSchema[schema5 ?? "public"].push(name);
|
|
12517
12517
|
} else {
|
|
12518
|
-
indexesInSchema[
|
|
12518
|
+
indexesInSchema[schema5 ?? "public"] = [name];
|
|
12519
12519
|
}
|
|
12520
12520
|
indexesObject[name] = {
|
|
12521
12521
|
name,
|
|
@@ -12525,7 +12525,7 @@ ${withStyle.errorWarning(
|
|
|
12525
12525
|
});
|
|
12526
12526
|
result[tableName] = {
|
|
12527
12527
|
name: tableName,
|
|
12528
|
-
schema:
|
|
12528
|
+
schema: schema5 ?? "",
|
|
12529
12529
|
columns: columnsObject,
|
|
12530
12530
|
indexes: indexesObject,
|
|
12531
12531
|
foreignKeys: foreignKeysObject,
|
|
@@ -15508,9 +15508,9 @@ var init_sqlgenerator = __esm({
|
|
|
15508
15508
|
return statement.type === "create_table" && dialect6 === "pg";
|
|
15509
15509
|
}
|
|
15510
15510
|
convert(st) {
|
|
15511
|
-
const { tableName, schema:
|
|
15511
|
+
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints } = st;
|
|
15512
15512
|
let statement = "";
|
|
15513
|
-
const name =
|
|
15513
|
+
const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15514
15514
|
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
|
15515
15515
|
`;
|
|
15516
15516
|
for (let i = 0; i < columns.length; i++) {
|
|
@@ -15547,9 +15547,9 @@ var init_sqlgenerator = __esm({
|
|
|
15547
15547
|
return statement.type === "create_table" && dialect6 === "mysql";
|
|
15548
15548
|
}
|
|
15549
15549
|
convert(st) {
|
|
15550
|
-
const { tableName, columns, schema:
|
|
15550
|
+
const { tableName, columns, schema: schema5, compositePKs, uniqueConstraints } = st;
|
|
15551
15551
|
let statement = "";
|
|
15552
|
-
const tName =
|
|
15552
|
+
const tName = schema5 ? `\`${schema5}\`.\`${tableName}\`` : `\`${tableName}\``;
|
|
15553
15553
|
statement += `CREATE TABLE ${tName} (
|
|
15554
15554
|
`;
|
|
15555
15555
|
for (let i = 0; i < columns.length; i++) {
|
|
@@ -15746,8 +15746,8 @@ var init_sqlgenerator = __esm({
|
|
|
15746
15746
|
return statement.type === "drop_table" && dialect6 === "pg";
|
|
15747
15747
|
}
|
|
15748
15748
|
convert(statement) {
|
|
15749
|
-
const { tableName, schema:
|
|
15750
|
-
const tableNameWithSchema =
|
|
15749
|
+
const { tableName, schema: schema5 } = statement;
|
|
15750
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15751
15751
|
return `DROP TABLE ${tableNameWithSchema};`;
|
|
15752
15752
|
}
|
|
15753
15753
|
};
|
|
@@ -15805,8 +15805,8 @@ var init_sqlgenerator = __esm({
|
|
|
15805
15805
|
return statement.type === "alter_table_rename_column" && dialect6 === "pg";
|
|
15806
15806
|
}
|
|
15807
15807
|
convert(statement) {
|
|
15808
|
-
const { tableName, oldColumnName, newColumnName, schema:
|
|
15809
|
-
const tableNameWithSchema =
|
|
15808
|
+
const { tableName, oldColumnName, newColumnName, schema: schema5 } = statement;
|
|
15809
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15810
15810
|
return `ALTER TABLE ${tableNameWithSchema} RENAME COLUMN "${oldColumnName}" TO "${newColumnName}";`;
|
|
15811
15811
|
}
|
|
15812
15812
|
};
|
|
@@ -15833,8 +15833,8 @@ var init_sqlgenerator = __esm({
|
|
|
15833
15833
|
return statement.type === "alter_table_drop_column" && dialect6 === "pg";
|
|
15834
15834
|
}
|
|
15835
15835
|
convert(statement) {
|
|
15836
|
-
const { tableName, columnName, schema:
|
|
15837
|
-
const tableNameWithSchema =
|
|
15836
|
+
const { tableName, columnName, schema: schema5 } = statement;
|
|
15837
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15838
15838
|
return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN IF EXISTS "${columnName}";`;
|
|
15839
15839
|
}
|
|
15840
15840
|
};
|
|
@@ -15861,9 +15861,9 @@ var init_sqlgenerator = __esm({
|
|
|
15861
15861
|
return statement.type === "alter_table_add_column" && dialect6 === "pg";
|
|
15862
15862
|
}
|
|
15863
15863
|
convert(statement) {
|
|
15864
|
-
const { tableName, column: column7, schema:
|
|
15864
|
+
const { tableName, column: column7, schema: schema5 } = statement;
|
|
15865
15865
|
const { name, type, notNull } = column7;
|
|
15866
|
-
const tableNameWithSchema =
|
|
15866
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15867
15867
|
const defaultStatement = `${column7.default !== void 0 ? ` DEFAULT ${column7.default}` : ""}`;
|
|
15868
15868
|
const fixedType = isPgNativeType(column7.type) ? column7.type : `"${column7.type}"`;
|
|
15869
15869
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
|
@@ -15905,8 +15905,8 @@ var init_sqlgenerator = __esm({
|
|
|
15905
15905
|
return statement.type === "alter_table_alter_column_set_type" && dialect6 === "pg";
|
|
15906
15906
|
}
|
|
15907
15907
|
convert(statement) {
|
|
15908
|
-
const { tableName, columnName, newDataType, schema:
|
|
15909
|
-
const tableNameWithSchema =
|
|
15908
|
+
const { tableName, columnName, newDataType, schema: schema5 } = statement;
|
|
15909
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15910
15910
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${newDataType};`;
|
|
15911
15911
|
}
|
|
15912
15912
|
};
|
|
@@ -15930,8 +15930,8 @@ var init_sqlgenerator = __esm({
|
|
|
15930
15930
|
return statement.type === "alter_table_alter_column_set_default" && dialect6 === "pg";
|
|
15931
15931
|
}
|
|
15932
15932
|
convert(statement) {
|
|
15933
|
-
const { tableName, columnName, schema:
|
|
15934
|
-
const tableNameWithSchema =
|
|
15933
|
+
const { tableName, columnName, schema: schema5 } = statement;
|
|
15934
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15935
15935
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DEFAULT ${statement.newDefaultValue};`;
|
|
15936
15936
|
}
|
|
15937
15937
|
};
|
|
@@ -15955,8 +15955,8 @@ var init_sqlgenerator = __esm({
|
|
|
15955
15955
|
return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "pg";
|
|
15956
15956
|
}
|
|
15957
15957
|
convert(statement) {
|
|
15958
|
-
const { tableName, columnName, schema:
|
|
15959
|
-
const tableNameWithSchema =
|
|
15958
|
+
const { tableName, columnName, schema: schema5 } = statement;
|
|
15959
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
15960
15960
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" DROP DEFAULT;`;
|
|
15961
15961
|
}
|
|
15962
15962
|
};
|
|
@@ -16220,7 +16220,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16220
16220
|
return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "pg";
|
|
16221
16221
|
}
|
|
16222
16222
|
convert(statement) {
|
|
16223
|
-
const { tableName, columnName, schema:
|
|
16223
|
+
const { tableName, columnName, schema: schema5 } = statement;
|
|
16224
16224
|
return `/*
|
|
16225
16225
|
Unfortunately in current drizzle-kit version we can't automatically get name for primary key.
|
|
16226
16226
|
We are working on making it available!
|
|
@@ -16228,7 +16228,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16228
16228
|
Meanwhile you can:
|
|
16229
16229
|
1. Check pk name in your database, by running
|
|
16230
16230
|
SELECT constraint_name FROM information_schema.table_constraints
|
|
16231
|
-
WHERE table_schema = '${typeof
|
|
16231
|
+
WHERE table_schema = '${typeof schema5 === "undefined" || schema5 === "" ? "public" : schema5}'
|
|
16232
16232
|
AND table_name = '${tableName}'
|
|
16233
16233
|
AND constraint_type = 'PRIMARY KEY';
|
|
16234
16234
|
2. Uncomment code below and paste pk name manually
|
|
@@ -16543,8 +16543,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16543
16543
|
return statement.type === "alter_table_set_schema" && dialect6 === "pg";
|
|
16544
16544
|
}
|
|
16545
16545
|
convert(statement) {
|
|
16546
|
-
const { tableName, schema:
|
|
16547
|
-
return `ALTER TABLE "${tableName}" SET SCHEMA "${
|
|
16546
|
+
const { tableName, schema: schema5 } = statement;
|
|
16547
|
+
return `ALTER TABLE "${tableName}" SET SCHEMA "${schema5}";
|
|
16548
16548
|
`;
|
|
16549
16549
|
}
|
|
16550
16550
|
};
|
|
@@ -16564,8 +16564,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16564
16564
|
return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
|
|
16565
16565
|
}
|
|
16566
16566
|
convert(statement) {
|
|
16567
|
-
const { tableName, schema:
|
|
16568
|
-
const tableNameWithSchema =
|
|
16567
|
+
const { tableName, schema: schema5 } = statement;
|
|
16568
|
+
const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
|
16569
16569
|
return `ALTER TABLE ${tableNameWithSchema} SET SCHEMA public;
|
|
16570
16570
|
`;
|
|
16571
16571
|
}
|
|
@@ -16604,9 +16604,9 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16604
16604
|
return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
|
|
16605
16605
|
}
|
|
16606
16606
|
convert(statement) {
|
|
16607
|
-
const { tableName, schema:
|
|
16607
|
+
const { tableName, schema: schema5 } = statement;
|
|
16608
16608
|
const nameFrom = `\`${tableName}\``;
|
|
16609
|
-
const nameTo = `\`${
|
|
16609
|
+
const nameTo = `\`${schema5}\`.\`${tableName}\``;
|
|
16610
16610
|
return `RENAME TABLE ${nameFrom} TO ${nameTo};
|
|
16611
16611
|
`;
|
|
16612
16612
|
}
|
|
@@ -16628,8 +16628,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
16628
16628
|
return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
|
|
16629
16629
|
}
|
|
16630
16630
|
convert(statement) {
|
|
16631
|
-
const { tableName, schema:
|
|
16632
|
-
const nameFrom = `\`${
|
|
16631
|
+
const { tableName, schema: schema5 } = statement;
|
|
16632
|
+
const nameFrom = `\`${schema5}\`.\`${tableName}\``;
|
|
16633
16633
|
const nameTo = `\`${tableName}\``;
|
|
16634
16634
|
return `RENAME TABLE ${nameFrom} TO ${nameTo};
|
|
16635
16635
|
`;
|
|
@@ -16771,11 +16771,11 @@ var init_jsonStatements = __esm({
|
|
|
16771
16771
|
init_pgSchema();
|
|
16772
16772
|
init_sqliteSchema();
|
|
16773
16773
|
preparePgCreateTableJson = (table4, json2) => {
|
|
16774
|
-
const { name, schema:
|
|
16774
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
|
16775
16775
|
return {
|
|
16776
16776
|
type: "create_table",
|
|
16777
16777
|
tableName: name,
|
|
16778
|
-
schema:
|
|
16778
|
+
schema: schema5,
|
|
16779
16779
|
columns: Object.values(columns),
|
|
16780
16780
|
compositePKs: Object.values(compositePrimaryKeys),
|
|
16781
16781
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
|
|
@@ -16785,11 +16785,11 @@ var init_jsonStatements = __esm({
|
|
|
16785
16785
|
};
|
|
16786
16786
|
};
|
|
16787
16787
|
prepareMySqlCreateTableJson = (table4, json2) => {
|
|
16788
|
-
const { name, schema:
|
|
16788
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
|
16789
16789
|
return {
|
|
16790
16790
|
type: "create_table",
|
|
16791
16791
|
tableName: name,
|
|
16792
|
-
schema:
|
|
16792
|
+
schema: schema5,
|
|
16793
16793
|
columns: Object.values(columns),
|
|
16794
16794
|
compositePKs: Object.values(compositePrimaryKeys),
|
|
16795
16795
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
|
@@ -16868,21 +16868,21 @@ var init_jsonStatements = __esm({
|
|
|
16868
16868
|
};
|
|
16869
16869
|
});
|
|
16870
16870
|
};
|
|
16871
|
-
prepareRenameColumns = (tableName,
|
|
16871
|
+
prepareRenameColumns = (tableName, schema5, pairs) => {
|
|
16872
16872
|
return pairs.map((it) => {
|
|
16873
16873
|
return {
|
|
16874
16874
|
type: "alter_table_rename_column",
|
|
16875
16875
|
tableName,
|
|
16876
16876
|
oldColumnName: it.from.name,
|
|
16877
16877
|
newColumnName: it.to.name,
|
|
16878
|
-
schema:
|
|
16878
|
+
schema: schema5
|
|
16879
16879
|
};
|
|
16880
16880
|
});
|
|
16881
16881
|
};
|
|
16882
|
-
prepareAlterTableColumnsJson = (tableName,
|
|
16882
|
+
prepareAlterTableColumnsJson = (tableName, schema5, deleted, added, altered, addedFk, json2, dialect6) => {
|
|
16883
16883
|
const addColumns = [];
|
|
16884
|
-
const dropColumns = _prepareDropColumns(tableName,
|
|
16885
|
-
const alterColumns = _prepareAlterColumns(tableName,
|
|
16884
|
+
const dropColumns = _prepareDropColumns(tableName, schema5, deleted);
|
|
16885
|
+
const alterColumns = _prepareAlterColumns(tableName, schema5, altered, json2);
|
|
16886
16886
|
if (dialect6 === "sqlite") {
|
|
16887
16887
|
let jsonCreateFKStatements = Object.values(addedFk);
|
|
16888
16888
|
const sqliteAddColumns = _prepareSQLiteAddColumns(
|
|
@@ -16892,27 +16892,27 @@ var init_jsonStatements = __esm({
|
|
|
16892
16892
|
);
|
|
16893
16893
|
addColumns.push(...sqliteAddColumns);
|
|
16894
16894
|
} else {
|
|
16895
|
-
addColumns.push(..._prepareAddColumns(tableName,
|
|
16895
|
+
addColumns.push(..._prepareAddColumns(tableName, schema5, added));
|
|
16896
16896
|
}
|
|
16897
16897
|
return { addColumns, dropColumns, alterColumns };
|
|
16898
16898
|
};
|
|
16899
|
-
_prepareDropColumns = (taleName,
|
|
16899
|
+
_prepareDropColumns = (taleName, schema5, columns) => {
|
|
16900
16900
|
return columns.map((it) => {
|
|
16901
16901
|
return {
|
|
16902
16902
|
type: "alter_table_drop_column",
|
|
16903
16903
|
tableName: taleName,
|
|
16904
16904
|
columnName: it.name,
|
|
16905
|
-
schema:
|
|
16905
|
+
schema: schema5
|
|
16906
16906
|
};
|
|
16907
16907
|
});
|
|
16908
16908
|
};
|
|
16909
|
-
_prepareAddColumns = (tableName,
|
|
16909
|
+
_prepareAddColumns = (tableName, schema5, columns) => {
|
|
16910
16910
|
return columns.map((it) => {
|
|
16911
16911
|
return {
|
|
16912
16912
|
type: "alter_table_add_column",
|
|
16913
16913
|
tableName,
|
|
16914
16914
|
column: it,
|
|
16915
|
-
schema:
|
|
16915
|
+
schema: schema5
|
|
16916
16916
|
};
|
|
16917
16917
|
});
|
|
16918
16918
|
};
|
|
@@ -16932,7 +16932,7 @@ var init_jsonStatements = __esm({
|
|
|
16932
16932
|
};
|
|
16933
16933
|
});
|
|
16934
16934
|
};
|
|
16935
|
-
_prepareAlterColumns = (tableName,
|
|
16935
|
+
_prepareAlterColumns = (tableName, schema5, columns, json2) => {
|
|
16936
16936
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
16937
16937
|
let statements = [];
|
|
16938
16938
|
let dropPkStatements = [];
|
|
@@ -16950,7 +16950,7 @@ var init_jsonStatements = __esm({
|
|
|
16950
16950
|
type: "alter_table_alter_column_set_autoincrement",
|
|
16951
16951
|
tableName,
|
|
16952
16952
|
columnName,
|
|
16953
|
-
schema:
|
|
16953
|
+
schema: schema5,
|
|
16954
16954
|
newDataType: columnType,
|
|
16955
16955
|
columnDefault,
|
|
16956
16956
|
columnOnUpdate,
|
|
@@ -16965,7 +16965,7 @@ var init_jsonStatements = __esm({
|
|
|
16965
16965
|
type,
|
|
16966
16966
|
tableName,
|
|
16967
16967
|
columnName,
|
|
16968
|
-
schema:
|
|
16968
|
+
schema: schema5,
|
|
16969
16969
|
newDataType: columnType,
|
|
16970
16970
|
columnDefault,
|
|
16971
16971
|
columnOnUpdate,
|
|
@@ -16979,7 +16979,7 @@ var init_jsonStatements = __esm({
|
|
|
16979
16979
|
type: "alter_table_alter_column_drop_autoincrement",
|
|
16980
16980
|
tableName,
|
|
16981
16981
|
columnName,
|
|
16982
|
-
schema:
|
|
16982
|
+
schema: schema5,
|
|
16983
16983
|
newDataType: columnType,
|
|
16984
16984
|
columnDefault,
|
|
16985
16985
|
columnOnUpdate,
|
|
@@ -17004,7 +17004,7 @@ var init_jsonStatements = __esm({
|
|
|
17004
17004
|
tableName,
|
|
17005
17005
|
oldColumnName: column7.name.old,
|
|
17006
17006
|
newColumnName: column7.name.new,
|
|
17007
|
-
schema:
|
|
17007
|
+
schema: schema5
|
|
17008
17008
|
});
|
|
17009
17009
|
}
|
|
17010
17010
|
if (((_d = column7.type) == null ? void 0 : _d.type) === "changed") {
|
|
@@ -17014,7 +17014,7 @@ var init_jsonStatements = __esm({
|
|
|
17014
17014
|
columnName,
|
|
17015
17015
|
newDataType: column7.type.new,
|
|
17016
17016
|
oldDataType: column7.type.old,
|
|
17017
|
-
schema:
|
|
17017
|
+
schema: schema5,
|
|
17018
17018
|
columnDefault,
|
|
17019
17019
|
columnOnUpdate,
|
|
17020
17020
|
columnNotNull,
|
|
@@ -17028,7 +17028,7 @@ var init_jsonStatements = __esm({
|
|
|
17028
17028
|
type: "alter_table_alter_column_drop_pk",
|
|
17029
17029
|
tableName,
|
|
17030
17030
|
columnName,
|
|
17031
|
-
schema:
|
|
17031
|
+
schema: schema5
|
|
17032
17032
|
});
|
|
17033
17033
|
}
|
|
17034
17034
|
if (((_g = column7.default) == null ? void 0 : _g.type) === "added") {
|
|
@@ -17037,7 +17037,7 @@ var init_jsonStatements = __esm({
|
|
|
17037
17037
|
tableName,
|
|
17038
17038
|
columnName,
|
|
17039
17039
|
newDefaultValue: column7.default.value,
|
|
17040
|
-
schema:
|
|
17040
|
+
schema: schema5,
|
|
17041
17041
|
columnOnUpdate,
|
|
17042
17042
|
columnNotNull,
|
|
17043
17043
|
columnAutoIncrement,
|
|
@@ -17052,7 +17052,7 @@ var init_jsonStatements = __esm({
|
|
|
17052
17052
|
columnName,
|
|
17053
17053
|
newDefaultValue: column7.default.new,
|
|
17054
17054
|
oldDefaultValue: column7.default.old,
|
|
17055
|
-
schema:
|
|
17055
|
+
schema: schema5,
|
|
17056
17056
|
columnOnUpdate,
|
|
17057
17057
|
columnNotNull,
|
|
17058
17058
|
columnAutoIncrement,
|
|
@@ -17065,7 +17065,7 @@ var init_jsonStatements = __esm({
|
|
|
17065
17065
|
type: "alter_table_alter_column_drop_default",
|
|
17066
17066
|
tableName,
|
|
17067
17067
|
columnName,
|
|
17068
|
-
schema:
|
|
17068
|
+
schema: schema5,
|
|
17069
17069
|
columnDefault,
|
|
17070
17070
|
columnOnUpdate,
|
|
17071
17071
|
columnNotNull,
|
|
@@ -17079,7 +17079,7 @@ var init_jsonStatements = __esm({
|
|
|
17079
17079
|
type: "alter_table_alter_column_set_notnull",
|
|
17080
17080
|
tableName,
|
|
17081
17081
|
columnName,
|
|
17082
|
-
schema:
|
|
17082
|
+
schema: schema5,
|
|
17083
17083
|
newDataType: columnType,
|
|
17084
17084
|
columnDefault,
|
|
17085
17085
|
columnOnUpdate,
|
|
@@ -17094,7 +17094,7 @@ var init_jsonStatements = __esm({
|
|
|
17094
17094
|
type,
|
|
17095
17095
|
tableName,
|
|
17096
17096
|
columnName,
|
|
17097
|
-
schema:
|
|
17097
|
+
schema: schema5,
|
|
17098
17098
|
newDataType: columnType,
|
|
17099
17099
|
columnDefault,
|
|
17100
17100
|
columnOnUpdate,
|
|
@@ -17108,7 +17108,7 @@ var init_jsonStatements = __esm({
|
|
|
17108
17108
|
type: "alter_table_alter_column_drop_notnull",
|
|
17109
17109
|
tableName,
|
|
17110
17110
|
columnName,
|
|
17111
|
-
schema:
|
|
17111
|
+
schema: schema5,
|
|
17112
17112
|
newDataType: columnType,
|
|
17113
17113
|
columnDefault,
|
|
17114
17114
|
columnOnUpdate,
|
|
@@ -17125,7 +17125,7 @@ var init_jsonStatements = __esm({
|
|
|
17125
17125
|
setPkStatements.push({
|
|
17126
17126
|
type: "alter_table_alter_column_set_pk",
|
|
17127
17127
|
tableName,
|
|
17128
|
-
schema:
|
|
17128
|
+
schema: schema5,
|
|
17129
17129
|
columnName
|
|
17130
17130
|
});
|
|
17131
17131
|
}
|
|
@@ -17135,7 +17135,7 @@ var init_jsonStatements = __esm({
|
|
|
17135
17135
|
type: "alter_table_alter_column_set_on_update",
|
|
17136
17136
|
tableName,
|
|
17137
17137
|
columnName,
|
|
17138
|
-
schema:
|
|
17138
|
+
schema: schema5,
|
|
17139
17139
|
newDataType: columnType,
|
|
17140
17140
|
columnDefault,
|
|
17141
17141
|
columnOnUpdate,
|
|
@@ -17149,7 +17149,7 @@ var init_jsonStatements = __esm({
|
|
|
17149
17149
|
type: "alter_table_alter_column_drop_on_update",
|
|
17150
17150
|
tableName,
|
|
17151
17151
|
columnName,
|
|
17152
|
-
schema:
|
|
17152
|
+
schema: schema5,
|
|
17153
17153
|
newDataType: columnType,
|
|
17154
17154
|
columnDefault,
|
|
17155
17155
|
columnOnUpdate,
|
|
@@ -17161,60 +17161,60 @@ var init_jsonStatements = __esm({
|
|
|
17161
17161
|
}
|
|
17162
17162
|
return [...dropPkStatements, ...setPkStatements, ...statements];
|
|
17163
17163
|
};
|
|
17164
|
-
prepareCreateIndexesJson = (tableName,
|
|
17164
|
+
prepareCreateIndexesJson = (tableName, schema5, indexes) => {
|
|
17165
17165
|
return Object.values(indexes).map((indexData) => {
|
|
17166
17166
|
return {
|
|
17167
17167
|
type: "create_index",
|
|
17168
17168
|
tableName,
|
|
17169
17169
|
data: indexData,
|
|
17170
|
-
schema:
|
|
17170
|
+
schema: schema5
|
|
17171
17171
|
};
|
|
17172
17172
|
});
|
|
17173
17173
|
};
|
|
17174
|
-
prepareCreateReferencesJson = (tableName,
|
|
17174
|
+
prepareCreateReferencesJson = (tableName, schema5, foreignKeys) => {
|
|
17175
17175
|
return Object.values(foreignKeys).map((fkData) => {
|
|
17176
17176
|
return {
|
|
17177
17177
|
type: "create_reference",
|
|
17178
17178
|
tableName,
|
|
17179
17179
|
data: fkData,
|
|
17180
|
-
schema:
|
|
17180
|
+
schema: schema5
|
|
17181
17181
|
};
|
|
17182
17182
|
});
|
|
17183
17183
|
};
|
|
17184
|
-
prepareDropReferencesJson = (tableName,
|
|
17184
|
+
prepareDropReferencesJson = (tableName, schema5, foreignKeys) => {
|
|
17185
17185
|
return Object.values(foreignKeys).map((fkData) => {
|
|
17186
17186
|
return {
|
|
17187
17187
|
type: "delete_reference",
|
|
17188
17188
|
tableName,
|
|
17189
17189
|
data: fkData,
|
|
17190
|
-
schema:
|
|
17190
|
+
schema: schema5
|
|
17191
17191
|
};
|
|
17192
17192
|
});
|
|
17193
17193
|
};
|
|
17194
|
-
prepareAlterReferencesJson = (tableName,
|
|
17194
|
+
prepareAlterReferencesJson = (tableName, schema5, foreignKeys) => {
|
|
17195
17195
|
const keys = Object.keys(foreignKeys);
|
|
17196
17196
|
const stmts = [];
|
|
17197
17197
|
if (keys.length > 0) {
|
|
17198
17198
|
stmts.push(
|
|
17199
|
-
...prepareDropReferencesJson(tableName,
|
|
17199
|
+
...prepareDropReferencesJson(tableName, schema5, {
|
|
17200
17200
|
[keys[0]]: foreignKeys[keys[0]].__old
|
|
17201
17201
|
})
|
|
17202
17202
|
);
|
|
17203
17203
|
stmts.push(
|
|
17204
|
-
...prepareCreateReferencesJson(tableName,
|
|
17204
|
+
...prepareCreateReferencesJson(tableName, schema5, {
|
|
17205
17205
|
[keys[0]]: foreignKeys[keys[0]].__new
|
|
17206
17206
|
})
|
|
17207
17207
|
);
|
|
17208
17208
|
}
|
|
17209
17209
|
return stmts;
|
|
17210
17210
|
};
|
|
17211
|
-
prepareDropIndexesJson = (tableName,
|
|
17211
|
+
prepareDropIndexesJson = (tableName, schema5, indexes) => {
|
|
17212
17212
|
return Object.values(indexes).map((indexData) => {
|
|
17213
17213
|
return {
|
|
17214
17214
|
type: "drop_index",
|
|
17215
17215
|
tableName,
|
|
17216
17216
|
data: indexData,
|
|
17217
|
-
schema:
|
|
17217
|
+
schema: schema5
|
|
17218
17218
|
};
|
|
17219
17219
|
});
|
|
17220
17220
|
};
|
|
@@ -17246,59 +17246,59 @@ var init_jsonStatements = __esm({
|
|
|
17246
17246
|
};
|
|
17247
17247
|
});
|
|
17248
17248
|
};
|
|
17249
|
-
prepareAddCompositePrimaryKeyPg = (tableName,
|
|
17249
|
+
prepareAddCompositePrimaryKeyPg = (tableName, schema5, pks, json2) => {
|
|
17250
17250
|
return Object.values(pks).map((it) => {
|
|
17251
17251
|
const unsquashed = PgSquasher.unsquashPK(it);
|
|
17252
17252
|
return {
|
|
17253
17253
|
type: "create_composite_pk",
|
|
17254
17254
|
tableName,
|
|
17255
17255
|
data: it,
|
|
17256
|
-
schema:
|
|
17256
|
+
schema: schema5,
|
|
17257
17257
|
constraintName: json2.tables[tableName].compositePrimaryKeys[unsquashed.name].name
|
|
17258
17258
|
};
|
|
17259
17259
|
});
|
|
17260
17260
|
};
|
|
17261
|
-
prepareDeleteCompositePrimaryKeyPg = (tableName,
|
|
17261
|
+
prepareDeleteCompositePrimaryKeyPg = (tableName, schema5, pks, json1) => {
|
|
17262
17262
|
return Object.values(pks).map((it) => {
|
|
17263
17263
|
return {
|
|
17264
17264
|
type: "delete_composite_pk",
|
|
17265
17265
|
tableName,
|
|
17266
17266
|
data: it,
|
|
17267
|
-
schema:
|
|
17267
|
+
schema: schema5,
|
|
17268
17268
|
constraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
|
|
17269
17269
|
};
|
|
17270
17270
|
});
|
|
17271
17271
|
};
|
|
17272
|
-
prepareAlterCompositePrimaryKeyPg = (tableName,
|
|
17272
|
+
prepareAlterCompositePrimaryKeyPg = (tableName, schema5, pks, json1, json2) => {
|
|
17273
17273
|
return Object.values(pks).map((it) => {
|
|
17274
17274
|
return {
|
|
17275
17275
|
type: "alter_composite_pk",
|
|
17276
17276
|
tableName,
|
|
17277
17277
|
old: it.__old,
|
|
17278
17278
|
new: it.__new,
|
|
17279
|
-
schema:
|
|
17279
|
+
schema: schema5,
|
|
17280
17280
|
oldConstraintName: json1.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
|
|
17281
17281
|
newConstraintName: json2.tables[tableName].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
|
|
17282
17282
|
};
|
|
17283
17283
|
});
|
|
17284
17284
|
};
|
|
17285
|
-
prepareAddUniqueConstraintPg = (tableName,
|
|
17285
|
+
prepareAddUniqueConstraintPg = (tableName, schema5, unqs) => {
|
|
17286
17286
|
return Object.values(unqs).map((it) => {
|
|
17287
17287
|
return {
|
|
17288
17288
|
type: "create_unique_constraint",
|
|
17289
17289
|
tableName,
|
|
17290
17290
|
data: it,
|
|
17291
|
-
schema:
|
|
17291
|
+
schema: schema5
|
|
17292
17292
|
};
|
|
17293
17293
|
});
|
|
17294
17294
|
};
|
|
17295
|
-
prepareDeleteUniqueConstraintPg = (tableName,
|
|
17295
|
+
prepareDeleteUniqueConstraintPg = (tableName, schema5, unqs) => {
|
|
17296
17296
|
return Object.values(unqs).map((it) => {
|
|
17297
17297
|
return {
|
|
17298
17298
|
type: "delete_unique_constraint",
|
|
17299
17299
|
tableName,
|
|
17300
17300
|
data: it,
|
|
17301
|
-
schema:
|
|
17301
|
+
schema: schema5
|
|
17302
17302
|
};
|
|
17303
17303
|
});
|
|
17304
17304
|
};
|
|
@@ -17355,58 +17355,58 @@ var init_snapshotsDiffer = __esm({
|
|
|
17355
17355
|
init_utils2();
|
|
17356
17356
|
init_sqliteSchema();
|
|
17357
17357
|
init_mysqlSchema();
|
|
17358
|
-
makeChanged = (
|
|
17358
|
+
makeChanged = (schema5) => {
|
|
17359
17359
|
return objectType({
|
|
17360
17360
|
type: enumType(["changed"]),
|
|
17361
|
-
old:
|
|
17362
|
-
new:
|
|
17361
|
+
old: schema5,
|
|
17362
|
+
new: schema5
|
|
17363
17363
|
});
|
|
17364
17364
|
};
|
|
17365
|
-
makeSelfOrChanged = (
|
|
17365
|
+
makeSelfOrChanged = (schema5) => {
|
|
17366
17366
|
return unionType([
|
|
17367
|
-
|
|
17367
|
+
schema5,
|
|
17368
17368
|
objectType({
|
|
17369
17369
|
type: enumType(["changed"]),
|
|
17370
|
-
old:
|
|
17371
|
-
new:
|
|
17370
|
+
old: schema5,
|
|
17371
|
+
new: schema5
|
|
17372
17372
|
})
|
|
17373
17373
|
]);
|
|
17374
17374
|
};
|
|
17375
|
-
makePatched = (
|
|
17375
|
+
makePatched = (schema5) => {
|
|
17376
17376
|
return unionType([
|
|
17377
17377
|
objectType({
|
|
17378
17378
|
type: literalType("added"),
|
|
17379
|
-
value:
|
|
17379
|
+
value: schema5
|
|
17380
17380
|
}),
|
|
17381
17381
|
objectType({
|
|
17382
17382
|
type: literalType("deleted"),
|
|
17383
|
-
value:
|
|
17383
|
+
value: schema5
|
|
17384
17384
|
}),
|
|
17385
17385
|
objectType({
|
|
17386
17386
|
type: literalType("changed"),
|
|
17387
|
-
old:
|
|
17388
|
-
new:
|
|
17387
|
+
old: schema5,
|
|
17388
|
+
new: schema5
|
|
17389
17389
|
})
|
|
17390
17390
|
]);
|
|
17391
17391
|
};
|
|
17392
|
-
makeSelfOrPatched = (
|
|
17392
|
+
makeSelfOrPatched = (schema5) => {
|
|
17393
17393
|
return unionType([
|
|
17394
17394
|
objectType({
|
|
17395
17395
|
type: literalType("none"),
|
|
17396
|
-
value:
|
|
17396
|
+
value: schema5.optional()
|
|
17397
17397
|
}),
|
|
17398
17398
|
objectType({
|
|
17399
17399
|
type: literalType("added"),
|
|
17400
|
-
value:
|
|
17400
|
+
value: schema5
|
|
17401
17401
|
}),
|
|
17402
17402
|
objectType({
|
|
17403
17403
|
type: literalType("deleted"),
|
|
17404
|
-
value:
|
|
17404
|
+
value: schema5
|
|
17405
17405
|
}),
|
|
17406
17406
|
objectType({
|
|
17407
17407
|
type: literalType("changed"),
|
|
17408
|
-
old:
|
|
17409
|
-
new:
|
|
17408
|
+
old: schema5,
|
|
17409
|
+
new: schema5
|
|
17410
17410
|
})
|
|
17411
17411
|
]);
|
|
17412
17412
|
};
|
|
@@ -17600,9 +17600,9 @@ var init_snapshotsDiffer = __esm({
|
|
|
17600
17600
|
created: table4.added,
|
|
17601
17601
|
deleted: table4.deleted
|
|
17602
17602
|
});
|
|
17603
|
-
const
|
|
17603
|
+
const schema5 = valueFromSelfOrPatchedNew(table4.schema);
|
|
17604
17604
|
jsonRenameColumnsStatements.push(
|
|
17605
|
-
...prepareRenameColumns(table4.name,
|
|
17605
|
+
...prepareRenameColumns(table4.name, schema5, result.renamed)
|
|
17606
17606
|
);
|
|
17607
17607
|
const renamedColumnsAltered = result.renamed.map(
|
|
17608
17608
|
(it) => alteredColumnSchema.parse(diffForRenamedColumn(it.from, it.to))
|
|
@@ -17787,17 +17787,17 @@ var init_snapshotsDiffer = __esm({
|
|
|
17787
17787
|
});
|
|
17788
17788
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
|
17789
17789
|
const tableName = it.tableName;
|
|
17790
|
-
const
|
|
17790
|
+
const schema5 = it.schema;
|
|
17791
17791
|
return {
|
|
17792
|
-
from: { schema:
|
|
17793
|
-
to: { schema:
|
|
17792
|
+
from: { schema: schema5, table: tableName, column: it.oldColumnName },
|
|
17793
|
+
to: { schema: schema5, table: tableName, column: it.newColumnName }
|
|
17794
17794
|
};
|
|
17795
17795
|
});
|
|
17796
17796
|
const jsonTableAlternations = allAlteredResolved.map((it) => {
|
|
17797
|
-
const
|
|
17797
|
+
const schema5 = valueFromSelfOrPatchedNew(it.schema);
|
|
17798
17798
|
return prepareAlterTableColumnsJson(
|
|
17799
17799
|
it.name,
|
|
17800
|
-
|
|
17800
|
+
schema5,
|
|
17801
17801
|
it.deleted,
|
|
17802
17802
|
it.added,
|
|
17803
17803
|
it.altered,
|
|
@@ -17815,15 +17815,15 @@ var init_snapshotsDiffer = __esm({
|
|
|
17815
17815
|
{ createColumns: [], dropColumns: [], alterColumns: [] }
|
|
17816
17816
|
);
|
|
17817
17817
|
const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
|
|
17818
|
-
const
|
|
17819
|
-
return prepareCreateIndexesJson(it.name,
|
|
17818
|
+
const schema5 = valueFromSelfOrPatchedNew(it.schema);
|
|
17819
|
+
return prepareCreateIndexesJson(it.name, schema5, it.addedIndexes || {});
|
|
17820
17820
|
}).flat();
|
|
17821
17821
|
const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
|
|
17822
|
-
const
|
|
17823
|
-
return prepareDropIndexesJson(it.name,
|
|
17822
|
+
const schema5 = valueFromSelfOrPatchedNew(it.schema);
|
|
17823
|
+
return prepareDropIndexesJson(it.name, schema5, it.deletedIndexes || {});
|
|
17824
17824
|
}).flat();
|
|
17825
17825
|
allAltered.forEach((it) => {
|
|
17826
|
-
const
|
|
17826
|
+
const schema5 = valueFromSelfOrPatchedNew(it.schema);
|
|
17827
17827
|
const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
|
|
17828
17828
|
(current, item) => {
|
|
17829
17829
|
current[item] = it.alteredIndexes[item].__old;
|
|
@@ -17839,30 +17839,30 @@ var init_snapshotsDiffer = __esm({
|
|
|
17839
17839
|
{}
|
|
17840
17840
|
);
|
|
17841
17841
|
jsonCreateIndexesForAllAlteredTables.push(
|
|
17842
|
-
...prepareCreateIndexesJson(it.name,
|
|
17842
|
+
...prepareCreateIndexesJson(it.name, schema5, createdIndexes || {})
|
|
17843
17843
|
);
|
|
17844
17844
|
jsonDropIndexesForAllAlteredTables.push(
|
|
17845
|
-
...prepareDropIndexesJson(it.name,
|
|
17845
|
+
...prepareDropIndexesJson(it.name, schema5, droppedIndexes || {})
|
|
17846
17846
|
);
|
|
17847
17847
|
});
|
|
17848
17848
|
const jsonCreateReferencesForCreatedTables = created.map((it) => {
|
|
17849
17849
|
return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
|
|
17850
17850
|
}).flat();
|
|
17851
17851
|
const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
|
|
17852
|
-
const
|
|
17852
|
+
const schema5 = valueFromSelfOrPatchedNew(it.schema);
|
|
17853
17853
|
const forAdded = prepareCreateReferencesJson(
|
|
17854
17854
|
it.name,
|
|
17855
|
-
|
|
17855
|
+
schema5,
|
|
17856
17856
|
it.addedForeignKeys
|
|
17857
17857
|
);
|
|
17858
17858
|
const forAltered = prepareDropReferencesJson(
|
|
17859
17859
|
it.name,
|
|
17860
|
-
|
|
17860
|
+
schema5,
|
|
17861
17861
|
it.deletedForeignKeys
|
|
17862
17862
|
);
|
|
17863
17863
|
const alteredFKs = prepareAlterReferencesJson(
|
|
17864
17864
|
it.name,
|
|
17865
|
-
|
|
17865
|
+
schema5,
|
|
17866
17866
|
it.alteredForeignKeys
|
|
17867
17867
|
);
|
|
17868
17868
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
@@ -18582,11 +18582,11 @@ var init_upFolders = __esm({
|
|
|
18582
18582
|
sql2
|
|
18583
18583
|
);
|
|
18584
18584
|
const tableName = table4.name;
|
|
18585
|
-
const
|
|
18585
|
+
const schema5 = typeof table4.schema === "string" ? table4.schema : "";
|
|
18586
18586
|
return result.renamed.map((it) => {
|
|
18587
18587
|
return {
|
|
18588
|
-
from: { schema:
|
|
18589
|
-
to: { schema:
|
|
18588
|
+
from: { schema: schema5, table: tableName, column: it.from.name },
|
|
18589
|
+
to: { schema: schema5, table: tableName, column: it.to.name }
|
|
18590
18590
|
};
|
|
18591
18591
|
});
|
|
18592
18592
|
}).flat();
|
|
@@ -18654,11 +18654,11 @@ var init_upFolders = __esm({
|
|
|
18654
18654
|
sql2
|
|
18655
18655
|
);
|
|
18656
18656
|
const tableName = table4.name;
|
|
18657
|
-
const
|
|
18657
|
+
const schema5 = typeof table4.schema === "string" ? table4.schema : "";
|
|
18658
18658
|
return result.renamed.map((it) => {
|
|
18659
18659
|
return {
|
|
18660
|
-
from: { schema:
|
|
18661
|
-
to: { schema:
|
|
18660
|
+
from: { schema: schema5, table: tableName, column: it.from.name },
|
|
18661
|
+
to: { schema: schema5, table: tableName, column: it.to.name }
|
|
18662
18662
|
};
|
|
18663
18663
|
});
|
|
18664
18664
|
}).flat();
|
|
@@ -18736,11 +18736,11 @@ var init_upFolders = __esm({
|
|
|
18736
18736
|
sql2
|
|
18737
18737
|
);
|
|
18738
18738
|
const tableName = table4.name;
|
|
18739
|
-
const
|
|
18739
|
+
const schema5 = typeof table4.schema === "string" ? table4.schema : "";
|
|
18740
18740
|
return result.renamed.map((it) => {
|
|
18741
18741
|
return {
|
|
18742
|
-
from: { schema:
|
|
18743
|
-
to: { schema:
|
|
18742
|
+
from: { schema: schema5, table: tableName, column: it.from.name },
|
|
18743
|
+
to: { schema: schema5, table: tableName, column: it.to.name }
|
|
18744
18744
|
};
|
|
18745
18745
|
});
|
|
18746
18746
|
}).flat();
|
|
@@ -19009,8 +19009,8 @@ var init_utils2 = __esm({
|
|
|
19009
19009
|
const out = it.schema ? `"${it.schema}"."${it.name}"` : `"${it.name}"`;
|
|
19010
19010
|
return out;
|
|
19011
19011
|
};
|
|
19012
|
-
columnRenameKey = (table4,
|
|
19013
|
-
const out =
|
|
19012
|
+
columnRenameKey = (table4, schema5, column7) => {
|
|
19013
|
+
const out = schema5 ? `"${schema5}"."${table4}"."${column7}"` : `"${table4}"."${column7}"`;
|
|
19014
19014
|
return out;
|
|
19015
19015
|
};
|
|
19016
19016
|
}
|
|
@@ -22108,7 +22108,7 @@ var init_mysql = __esm({
|
|
|
22108
22108
|
}
|
|
22109
22109
|
const {
|
|
22110
22110
|
out,
|
|
22111
|
-
schema:
|
|
22111
|
+
schema: schema5,
|
|
22112
22112
|
driver: driver2,
|
|
22113
22113
|
schemaFilter,
|
|
22114
22114
|
tablesFilter,
|
|
@@ -22118,7 +22118,7 @@ var init_mysql = __esm({
|
|
|
22118
22118
|
} = cliRes.data;
|
|
22119
22119
|
return {
|
|
22120
22120
|
out,
|
|
22121
|
-
schema:
|
|
22121
|
+
schema: schema5,
|
|
22122
22122
|
driver: driver2,
|
|
22123
22123
|
schemaFilter,
|
|
22124
22124
|
tablesFilter,
|
|
@@ -22154,7 +22154,7 @@ var init_mysql = __esm({
|
|
|
22154
22154
|
const {
|
|
22155
22155
|
strict,
|
|
22156
22156
|
verbose,
|
|
22157
|
-
schema:
|
|
22157
|
+
schema: schema5,
|
|
22158
22158
|
driver: driver2,
|
|
22159
22159
|
schemaFilter,
|
|
22160
22160
|
tablesFilter,
|
|
@@ -22162,7 +22162,7 @@ var init_mysql = __esm({
|
|
|
22162
22162
|
} = cliRes.data;
|
|
22163
22163
|
return {
|
|
22164
22164
|
driver: driver2,
|
|
22165
|
-
schema:
|
|
22165
|
+
schema: schema5,
|
|
22166
22166
|
strict,
|
|
22167
22167
|
verbose,
|
|
22168
22168
|
tablesFilter,
|
|
@@ -22453,23 +22453,23 @@ var require_isexe = __commonJS({
|
|
|
22453
22453
|
throw new TypeError("callback not provided");
|
|
22454
22454
|
}
|
|
22455
22455
|
return new Promise(function(resolve2, reject) {
|
|
22456
|
-
isexe(path5, options || {}, function(er,
|
|
22456
|
+
isexe(path5, options || {}, function(er, is9) {
|
|
22457
22457
|
if (er) {
|
|
22458
22458
|
reject(er);
|
|
22459
22459
|
} else {
|
|
22460
|
-
resolve2(
|
|
22460
|
+
resolve2(is9);
|
|
22461
22461
|
}
|
|
22462
22462
|
});
|
|
22463
22463
|
});
|
|
22464
22464
|
}
|
|
22465
|
-
core(path5, options || {}, function(er,
|
|
22465
|
+
core(path5, options || {}, function(er, is9) {
|
|
22466
22466
|
if (er) {
|
|
22467
22467
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
22468
22468
|
er = null;
|
|
22469
|
-
|
|
22469
|
+
is9 = false;
|
|
22470
22470
|
}
|
|
22471
22471
|
}
|
|
22472
|
-
cb(er,
|
|
22472
|
+
cb(er, is9);
|
|
22473
22473
|
});
|
|
22474
22474
|
}
|
|
22475
22475
|
function sync2(path5, options) {
|
|
@@ -22532,8 +22532,8 @@ var require_lib = __commonJS({
|
|
|
22532
22532
|
const p2 = getPathPart(envPart, cmd);
|
|
22533
22533
|
for (const ext2 of pathExt) {
|
|
22534
22534
|
const withExt = p2 + ext2;
|
|
22535
|
-
const
|
|
22536
|
-
if (
|
|
22535
|
+
const is9 = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
22536
|
+
if (is9) {
|
|
22537
22537
|
if (!opt.all) {
|
|
22538
22538
|
return withExt;
|
|
22539
22539
|
}
|
|
@@ -22556,8 +22556,8 @@ var require_lib = __commonJS({
|
|
|
22556
22556
|
const p2 = getPathPart(pathEnvPart, cmd);
|
|
22557
22557
|
for (const ext2 of pathExt) {
|
|
22558
22558
|
const withExt = p2 + ext2;
|
|
22559
|
-
const
|
|
22560
|
-
if (
|
|
22559
|
+
const is9 = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
22560
|
+
if (is9) {
|
|
22561
22561
|
if (!opt.all) {
|
|
22562
22562
|
return withExt;
|
|
22563
22563
|
}
|
|
@@ -30217,7 +30217,7 @@ var require_createNode = __commonJS({
|
|
|
30217
30217
|
if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) {
|
|
30218
30218
|
value = value.valueOf();
|
|
30219
30219
|
}
|
|
30220
|
-
const { aliasDuplicateObjects, onAnchor, onTagObj, schema:
|
|
30220
|
+
const { aliasDuplicateObjects, onAnchor, onTagObj, schema: schema5, sourceObjects } = ctx;
|
|
30221
30221
|
let ref = void 0;
|
|
30222
30222
|
if (aliasDuplicateObjects && value && typeof value === "object") {
|
|
30223
30223
|
ref = sourceObjects.get(value);
|
|
@@ -30232,7 +30232,7 @@ var require_createNode = __commonJS({
|
|
|
30232
30232
|
}
|
|
30233
30233
|
if (tagName == null ? void 0 : tagName.startsWith("!!"))
|
|
30234
30234
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
30235
|
-
let tagObj = findTagObject(value, tagName,
|
|
30235
|
+
let tagObj = findTagObject(value, tagName, schema5.tags);
|
|
30236
30236
|
if (!tagObj) {
|
|
30237
30237
|
if (value && typeof value.toJSON === "function") {
|
|
30238
30238
|
value = value.toJSON();
|
|
@@ -30243,7 +30243,7 @@ var require_createNode = __commonJS({
|
|
|
30243
30243
|
ref.node = node2;
|
|
30244
30244
|
return node2;
|
|
30245
30245
|
}
|
|
30246
|
-
tagObj = value instanceof Map ?
|
|
30246
|
+
tagObj = value instanceof Map ? schema5[identity.MAP] : Symbol.iterator in Object(value) ? schema5[identity.SEQ] : schema5[identity.MAP];
|
|
30247
30247
|
}
|
|
30248
30248
|
if (onTagObj) {
|
|
30249
30249
|
onTagObj(tagObj);
|
|
@@ -30269,7 +30269,7 @@ var require_Collection = __commonJS({
|
|
|
30269
30269
|
var createNode = require_createNode();
|
|
30270
30270
|
var identity = require_identity();
|
|
30271
30271
|
var Node3 = require_Node();
|
|
30272
|
-
function collectionFromPath(
|
|
30272
|
+
function collectionFromPath(schema5, path5, value) {
|
|
30273
30273
|
let v = value;
|
|
30274
30274
|
for (let i = path5.length - 1; i >= 0; --i) {
|
|
30275
30275
|
const k = path5[i];
|
|
@@ -30287,16 +30287,16 @@ var require_Collection = __commonJS({
|
|
|
30287
30287
|
onAnchor: () => {
|
|
30288
30288
|
throw new Error("This should not happen, please report a bug.");
|
|
30289
30289
|
},
|
|
30290
|
-
schema:
|
|
30290
|
+
schema: schema5,
|
|
30291
30291
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
30292
30292
|
});
|
|
30293
30293
|
}
|
|
30294
30294
|
var isEmptyPath = (path5) => path5 == null || typeof path5 === "object" && !!path5[Symbol.iterator]().next().done;
|
|
30295
30295
|
var Collection = class extends Node3.NodeBase {
|
|
30296
|
-
constructor(type,
|
|
30296
|
+
constructor(type, schema5) {
|
|
30297
30297
|
super(type);
|
|
30298
30298
|
Object.defineProperty(this, "schema", {
|
|
30299
|
-
value:
|
|
30299
|
+
value: schema5,
|
|
30300
30300
|
configurable: true,
|
|
30301
30301
|
enumerable: false,
|
|
30302
30302
|
writable: true
|
|
@@ -30307,11 +30307,11 @@ var require_Collection = __commonJS({
|
|
|
30307
30307
|
*
|
|
30308
30308
|
* @param schema - If defined, overwrites the original's schema
|
|
30309
30309
|
*/
|
|
30310
|
-
clone(
|
|
30310
|
+
clone(schema5) {
|
|
30311
30311
|
const copy2 = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
30312
|
-
if (
|
|
30313
|
-
copy2.schema =
|
|
30314
|
-
copy2.items = copy2.items.map((it) => identity.isNode(it) || identity.isPair(it) ? it.clone(
|
|
30312
|
+
if (schema5)
|
|
30313
|
+
copy2.schema = schema5;
|
|
30314
|
+
copy2.items = copy2.items.map((it) => identity.isNode(it) || identity.isPair(it) ? it.clone(schema5) : it);
|
|
30315
30315
|
if (this.range)
|
|
30316
30316
|
copy2.range = this.range.slice();
|
|
30317
30317
|
return copy2;
|
|
@@ -31218,12 +31218,12 @@ var require_Pair = __commonJS({
|
|
|
31218
31218
|
this.key = key;
|
|
31219
31219
|
this.value = value;
|
|
31220
31220
|
}
|
|
31221
|
-
clone(
|
|
31221
|
+
clone(schema5) {
|
|
31222
31222
|
let { key, value } = this;
|
|
31223
31223
|
if (identity.isNode(key))
|
|
31224
|
-
key = key.clone(
|
|
31224
|
+
key = key.clone(schema5);
|
|
31225
31225
|
if (identity.isNode(value))
|
|
31226
|
-
value = value.clone(
|
|
31226
|
+
value = value.clone(schema5);
|
|
31227
31227
|
return new _Pair(key, value);
|
|
31228
31228
|
}
|
|
31229
31229
|
toJSON(_2, ctx) {
|
|
@@ -31417,17 +31417,17 @@ var require_YAMLMap = __commonJS({
|
|
|
31417
31417
|
static get tagName() {
|
|
31418
31418
|
return "tag:yaml.org,2002:map";
|
|
31419
31419
|
}
|
|
31420
|
-
constructor(
|
|
31421
|
-
super(identity.MAP,
|
|
31420
|
+
constructor(schema5) {
|
|
31421
|
+
super(identity.MAP, schema5);
|
|
31422
31422
|
this.items = [];
|
|
31423
31423
|
}
|
|
31424
31424
|
/**
|
|
31425
31425
|
* A generic collection parsing method that can be extended
|
|
31426
31426
|
* to other node classes that inherit from YAMLMap
|
|
31427
31427
|
*/
|
|
31428
|
-
static from(
|
|
31428
|
+
static from(schema5, obj, ctx) {
|
|
31429
31429
|
const { keepUndefined, replacer } = ctx;
|
|
31430
|
-
const map = new this(
|
|
31430
|
+
const map = new this(schema5);
|
|
31431
31431
|
const add = (key, value) => {
|
|
31432
31432
|
if (typeof replacer === "function")
|
|
31433
31433
|
value = replacer.call(obj, key, value);
|
|
@@ -31443,8 +31443,8 @@ var require_YAMLMap = __commonJS({
|
|
|
31443
31443
|
for (const key of Object.keys(obj))
|
|
31444
31444
|
add(key, obj[key]);
|
|
31445
31445
|
}
|
|
31446
|
-
if (typeof
|
|
31447
|
-
map.items.sort(
|
|
31446
|
+
if (typeof schema5.sortMapEntries === "function") {
|
|
31447
|
+
map.items.sort(schema5.sortMapEntries);
|
|
31448
31448
|
}
|
|
31449
31449
|
return map;
|
|
31450
31450
|
}
|
|
@@ -31552,7 +31552,7 @@ var require_map = __commonJS({
|
|
|
31552
31552
|
onError("Expected a mapping for this tag");
|
|
31553
31553
|
return map2;
|
|
31554
31554
|
},
|
|
31555
|
-
createNode: (
|
|
31555
|
+
createNode: (schema5, obj, ctx) => YAMLMap.YAMLMap.from(schema5, obj, ctx)
|
|
31556
31556
|
};
|
|
31557
31557
|
exports.map = map;
|
|
31558
31558
|
}
|
|
@@ -31572,8 +31572,8 @@ var require_YAMLSeq = __commonJS({
|
|
|
31572
31572
|
static get tagName() {
|
|
31573
31573
|
return "tag:yaml.org,2002:seq";
|
|
31574
31574
|
}
|
|
31575
|
-
constructor(
|
|
31576
|
-
super(identity.SEQ,
|
|
31575
|
+
constructor(schema5) {
|
|
31576
|
+
super(identity.SEQ, schema5);
|
|
31577
31577
|
this.items = [];
|
|
31578
31578
|
}
|
|
31579
31579
|
add(value) {
|
|
@@ -31648,9 +31648,9 @@ var require_YAMLSeq = __commonJS({
|
|
|
31648
31648
|
onComment
|
|
31649
31649
|
});
|
|
31650
31650
|
}
|
|
31651
|
-
static from(
|
|
31651
|
+
static from(schema5, obj, ctx) {
|
|
31652
31652
|
const { replacer } = ctx;
|
|
31653
|
-
const seq = new this(
|
|
31653
|
+
const seq = new this(schema5);
|
|
31654
31654
|
if (obj && Symbol.iterator in Object(obj)) {
|
|
31655
31655
|
let i = 0;
|
|
31656
31656
|
for (let it of obj) {
|
|
@@ -31690,7 +31690,7 @@ var require_seq = __commonJS({
|
|
|
31690
31690
|
onError("Expected a sequence for this tag");
|
|
31691
31691
|
return seq2;
|
|
31692
31692
|
},
|
|
31693
|
-
createNode: (
|
|
31693
|
+
createNode: (schema5, obj, ctx) => YAMLSeq.YAMLSeq.from(schema5, obj, ctx)
|
|
31694
31694
|
};
|
|
31695
31695
|
exports.seq = seq;
|
|
31696
31696
|
}
|
|
@@ -31886,7 +31886,7 @@ var require_schema = __commonJS({
|
|
|
31886
31886
|
var bool = require_bool();
|
|
31887
31887
|
var float = require_float();
|
|
31888
31888
|
var int = require_int();
|
|
31889
|
-
var
|
|
31889
|
+
var schema5 = [
|
|
31890
31890
|
map.map,
|
|
31891
31891
|
seq.seq,
|
|
31892
31892
|
string.string,
|
|
@@ -31899,7 +31899,7 @@ var require_schema = __commonJS({
|
|
|
31899
31899
|
float.floatExp,
|
|
31900
31900
|
float.float
|
|
31901
31901
|
];
|
|
31902
|
-
exports.schema =
|
|
31902
|
+
exports.schema = schema5;
|
|
31903
31903
|
}
|
|
31904
31904
|
});
|
|
31905
31905
|
|
|
@@ -31965,8 +31965,8 @@ var require_schema2 = __commonJS({
|
|
|
31965
31965
|
return str;
|
|
31966
31966
|
}
|
|
31967
31967
|
};
|
|
31968
|
-
var
|
|
31969
|
-
exports.schema =
|
|
31968
|
+
var schema5 = [map.map, seq.seq].concat(jsonScalars, jsonError);
|
|
31969
|
+
exports.schema = schema5;
|
|
31970
31970
|
}
|
|
31971
31971
|
});
|
|
31972
31972
|
|
|
@@ -32067,9 +32067,9 @@ ${cn.comment}` : item.comment;
|
|
|
32067
32067
|
onError("Expected a sequence for this tag");
|
|
32068
32068
|
return seq;
|
|
32069
32069
|
}
|
|
32070
|
-
function createPairs(
|
|
32070
|
+
function createPairs(schema5, iterable, ctx) {
|
|
32071
32071
|
const { replacer } = ctx;
|
|
32072
|
-
const pairs2 = new YAMLSeq.YAMLSeq(
|
|
32072
|
+
const pairs2 = new YAMLSeq.YAMLSeq(schema5);
|
|
32073
32073
|
pairs2.tag = "tag:yaml.org,2002:pairs";
|
|
32074
32074
|
let i = 0;
|
|
32075
32075
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
@@ -32154,8 +32154,8 @@ var require_omap = __commonJS({
|
|
|
32154
32154
|
}
|
|
32155
32155
|
return map;
|
|
32156
32156
|
}
|
|
32157
|
-
static from(
|
|
32158
|
-
const pairs$1 = pairs.createPairs(
|
|
32157
|
+
static from(schema5, iterable, ctx) {
|
|
32158
|
+
const pairs$1 = pairs.createPairs(schema5, iterable, ctx);
|
|
32159
32159
|
const omap2 = new this();
|
|
32160
32160
|
omap2.items = pairs$1.items;
|
|
32161
32161
|
return omap2;
|
|
@@ -32182,7 +32182,7 @@ var require_omap = __commonJS({
|
|
|
32182
32182
|
}
|
|
32183
32183
|
return Object.assign(new YAMLOMap(), pairs$1);
|
|
32184
32184
|
},
|
|
32185
|
-
createNode: (
|
|
32185
|
+
createNode: (schema5, iterable, ctx) => YAMLOMap.from(schema5, iterable, ctx)
|
|
32186
32186
|
};
|
|
32187
32187
|
exports.YAMLOMap = YAMLOMap;
|
|
32188
32188
|
exports.omap = omap;
|
|
@@ -32357,8 +32357,8 @@ var require_set = __commonJS({
|
|
|
32357
32357
|
var Pair = require_Pair();
|
|
32358
32358
|
var YAMLMap = require_YAMLMap();
|
|
32359
32359
|
var YAMLSet = class _YAMLSet extends YAMLMap.YAMLMap {
|
|
32360
|
-
constructor(
|
|
32361
|
-
super(
|
|
32360
|
+
constructor(schema5) {
|
|
32361
|
+
super(schema5);
|
|
32362
32362
|
this.tag = _YAMLSet.tag;
|
|
32363
32363
|
}
|
|
32364
32364
|
add(key) {
|
|
@@ -32402,9 +32402,9 @@ var require_set = __commonJS({
|
|
|
32402
32402
|
else
|
|
32403
32403
|
throw new Error("Set items must all have null values");
|
|
32404
32404
|
}
|
|
32405
|
-
static from(
|
|
32405
|
+
static from(schema5, iterable, ctx) {
|
|
32406
32406
|
const { replacer } = ctx;
|
|
32407
|
-
const set3 = new this(
|
|
32407
|
+
const set3 = new this(schema5);
|
|
32408
32408
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
32409
32409
|
for (let value of iterable) {
|
|
32410
32410
|
if (typeof replacer === "function")
|
|
@@ -32421,7 +32421,7 @@ var require_set = __commonJS({
|
|
|
32421
32421
|
nodeClass: YAMLSet,
|
|
32422
32422
|
default: false,
|
|
32423
32423
|
tag: "tag:yaml.org,2002:set",
|
|
32424
|
-
createNode: (
|
|
32424
|
+
createNode: (schema5, iterable, ctx) => YAMLSet.from(schema5, iterable, ctx),
|
|
32425
32425
|
resolve(map, onError) {
|
|
32426
32426
|
if (identity.isMap(map)) {
|
|
32427
32427
|
if (map.hasAllNullValues(true))
|
|
@@ -32542,7 +32542,7 @@ var require_schema3 = __commonJS({
|
|
|
32542
32542
|
var pairs = require_pairs();
|
|
32543
32543
|
var set2 = require_set();
|
|
32544
32544
|
var timestamp = require_timestamp();
|
|
32545
|
-
var
|
|
32545
|
+
var schema5 = [
|
|
32546
32546
|
map.map,
|
|
32547
32547
|
seq.seq,
|
|
32548
32548
|
string.string,
|
|
@@ -32564,7 +32564,7 @@ var require_schema3 = __commonJS({
|
|
|
32564
32564
|
timestamp.floatTime,
|
|
32565
32565
|
timestamp.timestamp
|
|
32566
32566
|
];
|
|
32567
|
-
exports.schema =
|
|
32567
|
+
exports.schema = schema5;
|
|
32568
32568
|
}
|
|
32569
32569
|
});
|
|
32570
32570
|
|
|
@@ -32579,7 +32579,7 @@ var require_tags = __commonJS({
|
|
|
32579
32579
|
var bool = require_bool();
|
|
32580
32580
|
var float = require_float();
|
|
32581
32581
|
var int = require_int();
|
|
32582
|
-
var
|
|
32582
|
+
var schema5 = require_schema();
|
|
32583
32583
|
var schema$1 = require_schema2();
|
|
32584
32584
|
var binary = require_binary();
|
|
32585
32585
|
var omap = require_omap();
|
|
@@ -32588,7 +32588,7 @@ var require_tags = __commonJS({
|
|
|
32588
32588
|
var set2 = require_set();
|
|
32589
32589
|
var timestamp = require_timestamp();
|
|
32590
32590
|
var schemas = /* @__PURE__ */ new Map([
|
|
32591
|
-
["core",
|
|
32591
|
+
["core", schema5.schema],
|
|
32592
32592
|
["failsafe", [map.map, seq.seq, string.string]],
|
|
32593
32593
|
["json", schema$1.schema],
|
|
32594
32594
|
["yaml11", schema$2.schema],
|
|
@@ -32662,10 +32662,10 @@ var require_Schema = __commonJS({
|
|
|
32662
32662
|
var tags = require_tags();
|
|
32663
32663
|
var sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
32664
32664
|
var Schema = class _Schema {
|
|
32665
|
-
constructor({ compat, customTags, merge, resolveKnownTags, schema:
|
|
32665
|
+
constructor({ compat, customTags, merge, resolveKnownTags, schema: schema5, sortMapEntries, toStringDefaults }) {
|
|
32666
32666
|
this.compat = Array.isArray(compat) ? tags.getTags(compat, "compat") : compat ? tags.getTags(null, compat) : null;
|
|
32667
32667
|
this.merge = !!merge;
|
|
32668
|
-
this.name = typeof
|
|
32668
|
+
this.name = typeof schema5 === "string" && schema5 || "core";
|
|
32669
32669
|
this.knownTags = resolveKnownTags ? tags.coreKnownTags : {};
|
|
32670
32670
|
this.tags = tags.getTags(customTags, this.name);
|
|
32671
32671
|
this.toStringOptions = toStringDefaults ?? null;
|
|
@@ -34192,12 +34192,12 @@ var require_compose_scalar = __commonJS({
|
|
|
34192
34192
|
scalar.comment = comment;
|
|
34193
34193
|
return scalar;
|
|
34194
34194
|
}
|
|
34195
|
-
function findScalarTagByName(
|
|
34195
|
+
function findScalarTagByName(schema5, value, tagName, tagToken, onError) {
|
|
34196
34196
|
var _a;
|
|
34197
34197
|
if (tagName === "!")
|
|
34198
|
-
return
|
|
34198
|
+
return schema5[identity.SCALAR];
|
|
34199
34199
|
const matchWithTest = [];
|
|
34200
|
-
for (const tag of
|
|
34200
|
+
for (const tag of schema5.tags) {
|
|
34201
34201
|
if (!tag.collection && tag.tag === tagName) {
|
|
34202
34202
|
if (tag.default && tag.test)
|
|
34203
34203
|
matchWithTest.push(tag);
|
|
@@ -34208,24 +34208,24 @@ var require_compose_scalar = __commonJS({
|
|
|
34208
34208
|
for (const tag of matchWithTest)
|
|
34209
34209
|
if ((_a = tag.test) == null ? void 0 : _a.test(value))
|
|
34210
34210
|
return tag;
|
|
34211
|
-
const kt =
|
|
34211
|
+
const kt = schema5.knownTags[tagName];
|
|
34212
34212
|
if (kt && !kt.collection) {
|
|
34213
|
-
|
|
34213
|
+
schema5.tags.push(Object.assign({}, kt, { default: false, test: void 0 }));
|
|
34214
34214
|
return kt;
|
|
34215
34215
|
}
|
|
34216
34216
|
onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
|
|
34217
|
-
return
|
|
34217
|
+
return schema5[identity.SCALAR];
|
|
34218
34218
|
}
|
|
34219
|
-
function findScalarTagByTest({ directives, schema:
|
|
34220
|
-
const tag =
|
|
34219
|
+
function findScalarTagByTest({ directives, schema: schema5 }, value, token, onError) {
|
|
34220
|
+
const tag = schema5.tags.find((tag2) => {
|
|
34221
34221
|
var _a;
|
|
34222
34222
|
return tag2.default && ((_a = tag2.test) == null ? void 0 : _a.test(value));
|
|
34223
|
-
}) ||
|
|
34224
|
-
if (
|
|
34225
|
-
const compat =
|
|
34223
|
+
}) || schema5[identity.SCALAR];
|
|
34224
|
+
if (schema5.compat) {
|
|
34225
|
+
const compat = schema5.compat.find((tag2) => {
|
|
34226
34226
|
var _a;
|
|
34227
34227
|
return tag2.default && ((_a = tag2.test) == null ? void 0 : _a.test(value));
|
|
34228
|
-
}) ??
|
|
34228
|
+
}) ?? schema5[identity.SCALAR];
|
|
34229
34229
|
if (tag.tag !== compat.tag) {
|
|
34230
34230
|
const ts = directives.tagString(tag.tag);
|
|
34231
34231
|
const cs = directives.tagString(compat.tag);
|
|
@@ -36698,15 +36698,15 @@ var init_dist = __esm({
|
|
|
36698
36698
|
headerRecord.push([key, value]);
|
|
36699
36699
|
}
|
|
36700
36700
|
}
|
|
36701
|
-
const
|
|
36701
|
+
const init2 = {
|
|
36702
36702
|
method,
|
|
36703
36703
|
headers: headerRecord,
|
|
36704
36704
|
signal: abortController.signal
|
|
36705
36705
|
};
|
|
36706
36706
|
if (!(method === "GET" || method === "HEAD")) {
|
|
36707
|
-
|
|
36707
|
+
init2.body = import_stream.Readable.toWeb(incoming);
|
|
36708
36708
|
}
|
|
36709
|
-
return new Request2(url,
|
|
36709
|
+
return new Request2(url, init2);
|
|
36710
36710
|
};
|
|
36711
36711
|
getRequestCache = Symbol("getRequestCache");
|
|
36712
36712
|
requestCache = Symbol("requestCache");
|
|
@@ -36799,27 +36799,27 @@ var init_dist = __esm({
|
|
|
36799
36799
|
delete this[cacheKey];
|
|
36800
36800
|
return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
|
|
36801
36801
|
}
|
|
36802
|
-
constructor(body,
|
|
36802
|
+
constructor(body, init2) {
|
|
36803
36803
|
this.#body = body;
|
|
36804
|
-
if (
|
|
36805
|
-
const cachedGlobalResponse =
|
|
36804
|
+
if (init2 instanceof _Response) {
|
|
36805
|
+
const cachedGlobalResponse = init2[responseCache];
|
|
36806
36806
|
if (cachedGlobalResponse) {
|
|
36807
36807
|
this.#init = cachedGlobalResponse;
|
|
36808
36808
|
this[getResponseCache]();
|
|
36809
36809
|
return;
|
|
36810
36810
|
} else {
|
|
36811
|
-
this.#init =
|
|
36811
|
+
this.#init = init2.#init;
|
|
36812
36812
|
}
|
|
36813
36813
|
} else {
|
|
36814
|
-
this.#init =
|
|
36814
|
+
this.#init = init2;
|
|
36815
36815
|
}
|
|
36816
36816
|
if (typeof body === "string" || body instanceof ReadableStream) {
|
|
36817
|
-
let headers = (
|
|
36817
|
+
let headers = (init2 == null ? void 0 : init2.headers) || { "content-type": "text/plain; charset=UTF-8" };
|
|
36818
36818
|
if (headers instanceof Headers) {
|
|
36819
36819
|
headers = buildOutgoingHttpHeaders(headers);
|
|
36820
36820
|
}
|
|
36821
36821
|
;
|
|
36822
|
-
this[cacheKey] = [(
|
|
36822
|
+
this[cacheKey] = [(init2 == null ? void 0 : init2.status) || 200, body, headers];
|
|
36823
36823
|
}
|
|
36824
36824
|
}
|
|
36825
36825
|
};
|
|
@@ -36864,14 +36864,14 @@ var init_dist = __esm({
|
|
|
36864
36864
|
if (typeof global.crypto === "undefined") {
|
|
36865
36865
|
global.crypto = import_crypto3.default;
|
|
36866
36866
|
}
|
|
36867
|
-
global.fetch = (info3,
|
|
36868
|
-
|
|
36867
|
+
global.fetch = (info3, init2) => {
|
|
36868
|
+
init2 = {
|
|
36869
36869
|
// Disable compression handling so people can return the result of a fetch
|
|
36870
36870
|
// directly in the loader without messing with the Content-Encoding header.
|
|
36871
36871
|
compress: false,
|
|
36872
|
-
...
|
|
36872
|
+
...init2
|
|
36873
36873
|
};
|
|
36874
|
-
return webFetch(info3,
|
|
36874
|
+
return webFetch(info3, init2);
|
|
36875
36875
|
};
|
|
36876
36876
|
regBuffer = /^no$/i;
|
|
36877
36877
|
regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
|
|
@@ -37433,10 +37433,10 @@ var zValidator;
|
|
|
37433
37433
|
var init_esm = __esm({
|
|
37434
37434
|
"node_modules/.pnpm/@hono+zod-validator@0.2.1_hono@4.1.5_zod@3.20.2/node_modules/@hono/zod-validator/dist/esm/index.js"() {
|
|
37435
37435
|
init_validator2();
|
|
37436
|
-
zValidator = (target,
|
|
37436
|
+
zValidator = (target, schema5, hook2) => (
|
|
37437
37437
|
// @ts-expect-error not typed well
|
|
37438
37438
|
validator(target, async (value, c) => {
|
|
37439
|
-
const result = await
|
|
37439
|
+
const result = await schema5.safeParseAsync(value);
|
|
37440
37440
|
if (hook2) {
|
|
37441
37441
|
const hookResult = hook2({ data: value, ...result }, c);
|
|
37442
37442
|
if (hookResult) {
|
|
@@ -38576,8 +38576,8 @@ var init_router3 = __esm({
|
|
|
38576
38576
|
name = "SmartRouter";
|
|
38577
38577
|
routers = [];
|
|
38578
38578
|
routes = [];
|
|
38579
|
-
constructor(
|
|
38580
|
-
Object.assign(this,
|
|
38579
|
+
constructor(init2) {
|
|
38580
|
+
Object.assign(this, init2);
|
|
38581
38581
|
}
|
|
38582
38582
|
add(method, path5, handler) {
|
|
38583
38583
|
if (!this.routes) {
|
|
@@ -40294,7 +40294,7 @@ var require_textParsers = __commonJS({
|
|
|
40294
40294
|
result.radius = parseFloat(radius);
|
|
40295
40295
|
return result;
|
|
40296
40296
|
};
|
|
40297
|
-
var
|
|
40297
|
+
var init2 = function(register) {
|
|
40298
40298
|
register(20, parseBigInteger);
|
|
40299
40299
|
register(21, parseInteger);
|
|
40300
40300
|
register(23, parseInteger);
|
|
@@ -40341,7 +40341,7 @@ var require_textParsers = __commonJS({
|
|
|
40341
40341
|
register(1270, parseStringArray);
|
|
40342
40342
|
};
|
|
40343
40343
|
module2.exports = {
|
|
40344
|
-
init
|
|
40344
|
+
init: init2
|
|
40345
40345
|
};
|
|
40346
40346
|
}
|
|
40347
40347
|
});
|
|
@@ -40603,7 +40603,7 @@ var require_binaryParsers = __commonJS({
|
|
|
40603
40603
|
return null;
|
|
40604
40604
|
return parseBits(value, 8) > 0;
|
|
40605
40605
|
};
|
|
40606
|
-
var
|
|
40606
|
+
var init2 = function(register) {
|
|
40607
40607
|
register(20, parseInt64);
|
|
40608
40608
|
register(21, parseInt16);
|
|
40609
40609
|
register(23, parseInt32);
|
|
@@ -40622,7 +40622,7 @@ var require_binaryParsers = __commonJS({
|
|
|
40622
40622
|
register(25, parseText);
|
|
40623
40623
|
};
|
|
40624
40624
|
module2.exports = {
|
|
40625
|
-
init
|
|
40625
|
+
init: init2
|
|
40626
40626
|
};
|
|
40627
40627
|
}
|
|
40628
40628
|
});
|
|
@@ -60336,9 +60336,12 @@ __export(studio_exports, {
|
|
|
60336
60336
|
drizzleForMySQL: () => drizzleForMySQL,
|
|
60337
60337
|
drizzleForPostgres: () => drizzleForPostgres,
|
|
60338
60338
|
drizzleForSQLite: () => drizzleForSQLite,
|
|
60339
|
+
prepareMySqlSchema: () => prepareMySqlSchema,
|
|
60340
|
+
preparePgSchema: () => preparePgSchema,
|
|
60341
|
+
prepareSQLiteSchema: () => prepareSQLiteSchema,
|
|
60339
60342
|
prepareServer: () => prepareServer
|
|
60340
60343
|
});
|
|
60341
|
-
var import_node_https, drizzleForPostgres, drizzleForMySQL, prepareParams, drizzleForSQLite, proxySchema, jsonStringify, prepareServer;
|
|
60344
|
+
var import_node_https, import_pg_core4, import_drizzle_orm8, import_mysql_core4, import_sqlite_core3, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, prepareParams, drizzleForSQLite, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
|
|
60342
60345
|
var init_studio = __esm({
|
|
60343
60346
|
"src/serializer/studio.ts"() {
|
|
60344
60347
|
init_dist();
|
|
@@ -60350,7 +60353,110 @@ var init_studio = __esm({
|
|
|
60350
60353
|
init_lib();
|
|
60351
60354
|
init_utils3();
|
|
60352
60355
|
init_global();
|
|
60353
|
-
|
|
60356
|
+
init_serializer();
|
|
60357
|
+
import_pg_core4 = require("drizzle-orm/pg-core");
|
|
60358
|
+
import_drizzle_orm8 = require("drizzle-orm");
|
|
60359
|
+
init_utils();
|
|
60360
|
+
import_mysql_core4 = require("drizzle-orm/mysql-core");
|
|
60361
|
+
import_sqlite_core3 = require("drizzle-orm/sqlite-core");
|
|
60362
|
+
preparePgSchema = async (path5) => {
|
|
60363
|
+
const imports = prepareFilenames(path5);
|
|
60364
|
+
const pgSchema3 = {};
|
|
60365
|
+
const relations4 = {};
|
|
60366
|
+
const { unregister } = await safeRegister();
|
|
60367
|
+
for (let i = 0; i < imports.length; i++) {
|
|
60368
|
+
const it = imports[i];
|
|
60369
|
+
const i0 = require(`${it}`);
|
|
60370
|
+
const i0values = Object.entries(i0);
|
|
60371
|
+
i0values.forEach(([k, t]) => {
|
|
60372
|
+
if ((0, import_drizzle_orm8.is)(t, import_pg_core4.PgTable)) {
|
|
60373
|
+
const schema5 = (0, import_pg_core4.getTableConfig)(t).schema || "public";
|
|
60374
|
+
pgSchema3[schema5] = pgSchema3[schema5] || {};
|
|
60375
|
+
pgSchema3[schema5][k] = t;
|
|
60376
|
+
}
|
|
60377
|
+
if ((0, import_drizzle_orm8.is)(t, import_drizzle_orm8.Relations)) {
|
|
60378
|
+
relations4[k] = t;
|
|
60379
|
+
}
|
|
60380
|
+
});
|
|
60381
|
+
}
|
|
60382
|
+
unregister();
|
|
60383
|
+
return { schema: pgSchema3, relations: relations4 };
|
|
60384
|
+
};
|
|
60385
|
+
prepareMySqlSchema = async (path5) => {
|
|
60386
|
+
const imports = prepareFilenames(path5);
|
|
60387
|
+
const mysqlSchema5 = {
|
|
60388
|
+
public: {}
|
|
60389
|
+
};
|
|
60390
|
+
const relations4 = {};
|
|
60391
|
+
const { unregister } = await safeRegister();
|
|
60392
|
+
for (let i = 0; i < imports.length; i++) {
|
|
60393
|
+
const it = imports[i];
|
|
60394
|
+
const i0 = require(`${it}`);
|
|
60395
|
+
const i0values = Object.entries(i0);
|
|
60396
|
+
i0values.forEach(([k, t]) => {
|
|
60397
|
+
if ((0, import_drizzle_orm8.is)(t, import_mysql_core4.MySqlTable)) {
|
|
60398
|
+
const schema5 = (0, import_mysql_core4.getTableConfig)(t).schema || "public";
|
|
60399
|
+
mysqlSchema5[schema5][k] = t;
|
|
60400
|
+
}
|
|
60401
|
+
if ((0, import_drizzle_orm8.is)(t, import_drizzle_orm8.Relations)) {
|
|
60402
|
+
relations4[k] = t;
|
|
60403
|
+
}
|
|
60404
|
+
});
|
|
60405
|
+
}
|
|
60406
|
+
unregister();
|
|
60407
|
+
return { schema: mysqlSchema5, relations: relations4 };
|
|
60408
|
+
};
|
|
60409
|
+
prepareSQLiteSchema = async (path5) => {
|
|
60410
|
+
const imports = prepareFilenames(path5);
|
|
60411
|
+
const sqliteSchema3 = {
|
|
60412
|
+
public: {}
|
|
60413
|
+
};
|
|
60414
|
+
const relations4 = {};
|
|
60415
|
+
const { unregister } = await safeRegister();
|
|
60416
|
+
for (let i = 0; i < imports.length; i++) {
|
|
60417
|
+
const it = imports[i];
|
|
60418
|
+
const i0 = require(`${it}`);
|
|
60419
|
+
const i0values = Object.entries(i0);
|
|
60420
|
+
i0values.forEach(([k, t]) => {
|
|
60421
|
+
if ((0, import_drizzle_orm8.is)(t, import_sqlite_core3.SQLiteTable)) {
|
|
60422
|
+
const schema5 = "public";
|
|
60423
|
+
sqliteSchema3[schema5][k] = t;
|
|
60424
|
+
}
|
|
60425
|
+
if ((0, import_drizzle_orm8.is)(t, import_drizzle_orm8.Relations)) {
|
|
60426
|
+
relations4[k] = t;
|
|
60427
|
+
}
|
|
60428
|
+
});
|
|
60429
|
+
}
|
|
60430
|
+
unregister();
|
|
60431
|
+
return { schema: sqliteSchema3, relations: relations4 };
|
|
60432
|
+
};
|
|
60433
|
+
getCustomDefaults = (schema5) => {
|
|
60434
|
+
const customDefaults = [];
|
|
60435
|
+
Object.entries(schema5).map(([schema6, tables]) => {
|
|
60436
|
+
Object.entries(tables).map(([, table4]) => {
|
|
60437
|
+
let tableConfig;
|
|
60438
|
+
if ((0, import_drizzle_orm8.is)(table4, import_pg_core4.PgTable)) {
|
|
60439
|
+
tableConfig = (0, import_pg_core4.getTableConfig)(table4);
|
|
60440
|
+
} else if ((0, import_drizzle_orm8.is)(table4, import_mysql_core4.MySqlTable)) {
|
|
60441
|
+
tableConfig = (0, import_mysql_core4.getTableConfig)(table4);
|
|
60442
|
+
} else {
|
|
60443
|
+
tableConfig = (0, import_sqlite_core3.getTableConfig)(table4);
|
|
60444
|
+
}
|
|
60445
|
+
tableConfig.columns.map((column7) => {
|
|
60446
|
+
if (column7.defaultFn) {
|
|
60447
|
+
customDefaults.push({
|
|
60448
|
+
schema: schema6,
|
|
60449
|
+
table: tableConfig.name,
|
|
60450
|
+
column: column7.name,
|
|
60451
|
+
func: column7.defaultFn
|
|
60452
|
+
});
|
|
60453
|
+
}
|
|
60454
|
+
});
|
|
60455
|
+
});
|
|
60456
|
+
});
|
|
60457
|
+
return customDefaults;
|
|
60458
|
+
};
|
|
60459
|
+
drizzleForPostgres = async (connectionConfig, pgSchema3, relations4) => {
|
|
60354
60460
|
assertPackages("pg");
|
|
60355
60461
|
const pg = await Promise.resolve().then(() => __toESM(require_lib3()));
|
|
60356
60462
|
const client = new pg.default.Pool(connectionConfig.dbCredentials);
|
|
@@ -60362,12 +60468,14 @@ var init_studio = __esm({
|
|
|
60362
60468
|
});
|
|
60363
60469
|
return result.rows;
|
|
60364
60470
|
};
|
|
60471
|
+
const customDefaults = getCustomDefaults(pgSchema3);
|
|
60365
60472
|
return {
|
|
60366
60473
|
dialect: "pg",
|
|
60367
|
-
proxy
|
|
60474
|
+
proxy,
|
|
60475
|
+
customDefaults
|
|
60368
60476
|
};
|
|
60369
60477
|
};
|
|
60370
|
-
drizzleForMySQL = async (config) => {
|
|
60478
|
+
drizzleForMySQL = async (config, mysqlSchema5, relations4) => {
|
|
60371
60479
|
assertPackages("mysql2");
|
|
60372
60480
|
const { createPool } = await Promise.resolve().then(() => __toESM(require_promise()));
|
|
60373
60481
|
const client = createPool({ ...config.dbCredentials, connectionLimit: 1 });
|
|
@@ -60379,9 +60487,11 @@ var init_studio = __esm({
|
|
|
60379
60487
|
});
|
|
60380
60488
|
return result[0];
|
|
60381
60489
|
};
|
|
60490
|
+
const customDefaults = getCustomDefaults(mysqlSchema5);
|
|
60382
60491
|
return {
|
|
60383
60492
|
dialect: "mysql",
|
|
60384
|
-
proxy
|
|
60493
|
+
proxy,
|
|
60494
|
+
customDefaults
|
|
60385
60495
|
};
|
|
60386
60496
|
};
|
|
60387
60497
|
prepareParams = (params) => {
|
|
@@ -60392,15 +60502,17 @@ var init_studio = __esm({
|
|
|
60392
60502
|
return param;
|
|
60393
60503
|
});
|
|
60394
60504
|
};
|
|
60395
|
-
drizzleForSQLite = async (config) => {
|
|
60505
|
+
drizzleForSQLite = async (config, sqliteSchema3, relations4) => {
|
|
60396
60506
|
const { driver: driver2, dbCredentials } = config;
|
|
60507
|
+
const customDefaults = getCustomDefaults(sqliteSchema3);
|
|
60397
60508
|
if (driver2 === "d1") {
|
|
60398
60509
|
const proxy = async (params) => {
|
|
60399
60510
|
throw new Error("Proxy is not implemented for D1");
|
|
60400
60511
|
};
|
|
60401
60512
|
return {
|
|
60402
60513
|
dialect: "sqlite",
|
|
60403
|
-
proxy
|
|
60514
|
+
proxy,
|
|
60515
|
+
customDefaults
|
|
60404
60516
|
};
|
|
60405
60517
|
}
|
|
60406
60518
|
if (driver2 === "better-sqlite") {
|
|
@@ -60416,7 +60528,8 @@ var init_studio = __esm({
|
|
|
60416
60528
|
};
|
|
60417
60529
|
return {
|
|
60418
60530
|
dialect: "sqlite",
|
|
60419
|
-
proxy
|
|
60531
|
+
proxy,
|
|
60532
|
+
customDefaults
|
|
60420
60533
|
};
|
|
60421
60534
|
}
|
|
60422
60535
|
if (driver2 === "libsql" || driver2 === "turso") {
|
|
@@ -60437,17 +60550,37 @@ var init_studio = __esm({
|
|
|
60437
60550
|
};
|
|
60438
60551
|
return {
|
|
60439
60552
|
dialect: "sqlite",
|
|
60440
|
-
proxy
|
|
60553
|
+
proxy,
|
|
60554
|
+
customDefaults
|
|
60441
60555
|
};
|
|
60442
60556
|
}
|
|
60443
60557
|
assertUnreachable(driver2);
|
|
60444
60558
|
};
|
|
60559
|
+
init = mod.object({
|
|
60560
|
+
type: mod.literal("init")
|
|
60561
|
+
});
|
|
60445
60562
|
proxySchema = mod.object({
|
|
60446
|
-
|
|
60447
|
-
|
|
60448
|
-
|
|
60449
|
-
|
|
60563
|
+
type: mod.literal("proxy"),
|
|
60564
|
+
data: mod.object({
|
|
60565
|
+
sql: mod.string(),
|
|
60566
|
+
params: mod.array(mod.any()).optional(),
|
|
60567
|
+
mode: mod.enum(["array", "object"]).default("object"),
|
|
60568
|
+
method: mod.union([mod.literal("values"), mod.literal("get"), mod.literal("all"), mod.literal("run"), mod.literal("execute")])
|
|
60569
|
+
})
|
|
60450
60570
|
});
|
|
60571
|
+
defaultsSchema = mod.object({
|
|
60572
|
+
type: mod.literal("defaults"),
|
|
60573
|
+
data: mod.array(mod.object({
|
|
60574
|
+
schema: mod.string(),
|
|
60575
|
+
table: mod.string(),
|
|
60576
|
+
column: mod.string()
|
|
60577
|
+
})).min(1)
|
|
60578
|
+
});
|
|
60579
|
+
schema4 = mod.union([
|
|
60580
|
+
init,
|
|
60581
|
+
proxySchema,
|
|
60582
|
+
defaultsSchema
|
|
60583
|
+
]);
|
|
60451
60584
|
SuperJSON.registerCustom(
|
|
60452
60585
|
{
|
|
60453
60586
|
isApplicable: (v) => v instanceof Buffer,
|
|
@@ -60469,7 +60602,7 @@ var init_studio = __esm({
|
|
|
60469
60602
|
return value;
|
|
60470
60603
|
});
|
|
60471
60604
|
};
|
|
60472
|
-
prepareServer = async ({ dialect: dialect6, proxy }, app) => {
|
|
60605
|
+
prepareServer = async ({ dialect: dialect6, proxy, customDefaults }, app) => {
|
|
60473
60606
|
app = app !== void 0 ? app : new Hono2();
|
|
60474
60607
|
app.use(cors());
|
|
60475
60608
|
app.onError((err2, ctx) => {
|
|
@@ -60479,18 +60612,45 @@ var init_studio = __esm({
|
|
|
60479
60612
|
error: err2.message
|
|
60480
60613
|
});
|
|
60481
60614
|
});
|
|
60482
|
-
app.
|
|
60483
|
-
|
|
60484
|
-
|
|
60485
|
-
|
|
60486
|
-
|
|
60487
|
-
|
|
60488
|
-
|
|
60489
|
-
|
|
60490
|
-
|
|
60491
|
-
|
|
60492
|
-
}
|
|
60493
|
-
|
|
60615
|
+
app.post("/", zValidator("json", schema4), async (c) => {
|
|
60616
|
+
const body = c.req.valid("json");
|
|
60617
|
+
const { type } = body;
|
|
60618
|
+
if (type === "init") {
|
|
60619
|
+
const preparedDefaults = customDefaults.map((d) => ({
|
|
60620
|
+
schema: d.schema,
|
|
60621
|
+
table: d.table,
|
|
60622
|
+
column: d.column
|
|
60623
|
+
}));
|
|
60624
|
+
return c.json({ version: "4", dialect: dialect6, customDefaults: preparedDefaults });
|
|
60625
|
+
}
|
|
60626
|
+
if (type === "proxy") {
|
|
60627
|
+
const { sql: sql2, params, mode, method } = body.data;
|
|
60628
|
+
const result = await proxy({
|
|
60629
|
+
sql: sql2,
|
|
60630
|
+
params: params || [],
|
|
60631
|
+
mode,
|
|
60632
|
+
method
|
|
60633
|
+
});
|
|
60634
|
+
return c.json(JSON.parse(jsonStringify(result)));
|
|
60635
|
+
}
|
|
60636
|
+
if (type === "defaults") {
|
|
60637
|
+
const columns = body.data;
|
|
60638
|
+
const result = columns.map((column7) => {
|
|
60639
|
+
const found = customDefaults.find((d) => {
|
|
60640
|
+
return d.schema === column7.schema && d.table === column7.table && d.column === column7.column;
|
|
60641
|
+
});
|
|
60642
|
+
if (!found) {
|
|
60643
|
+
throw new Error(`Custom default not found for ${column7.schema}.${column7.table}.${column7.column}`);
|
|
60644
|
+
}
|
|
60645
|
+
const value = found.func();
|
|
60646
|
+
return {
|
|
60647
|
+
...column7,
|
|
60648
|
+
value
|
|
60649
|
+
};
|
|
60650
|
+
});
|
|
60651
|
+
return c.json(JSON.parse(jsonStringify(result)));
|
|
60652
|
+
}
|
|
60653
|
+
throw new Error(`Unknown type: ${type}`);
|
|
60494
60654
|
});
|
|
60495
60655
|
return {
|
|
60496
60656
|
start: (params) => {
|
|
@@ -60593,20 +60753,20 @@ var init_introspect_mysql = __esm({
|
|
|
60593
60753
|
}
|
|
60594
60754
|
return value;
|
|
60595
60755
|
};
|
|
60596
|
-
schemaToTypeScript = (
|
|
60756
|
+
schemaToTypeScript = (schema5, casing) => {
|
|
60597
60757
|
const withCasing3 = prepareCasing(casing);
|
|
60598
|
-
Object.values(
|
|
60758
|
+
Object.values(schema5.tables).forEach((table4) => {
|
|
60599
60759
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
|
60600
60760
|
const relation = `${fk4.tableFrom}-${fk4.tableTo}`;
|
|
60601
60761
|
relations.add(relation);
|
|
60602
60762
|
});
|
|
60603
60763
|
});
|
|
60604
60764
|
const schemas = Object.fromEntries(
|
|
60605
|
-
Object.entries(
|
|
60765
|
+
Object.entries(schema5.schemas).map((it) => {
|
|
60606
60766
|
return [it[0], withCasing3(it[1])];
|
|
60607
60767
|
})
|
|
60608
60768
|
);
|
|
60609
|
-
const imports = Object.values(
|
|
60769
|
+
const imports = Object.values(schema5.tables).reduce(
|
|
60610
60770
|
(res, it) => {
|
|
60611
60771
|
const idxImports = Object.values(it.indexes).map(
|
|
60612
60772
|
(idx) => idx.isUnique ? "uniqueIndex" : "index"
|
|
@@ -60646,7 +60806,7 @@ var init_introspect_mysql = __esm({
|
|
|
60646
60806
|
return `export const ${it[1]} = mysqlSchema("${it[0]}");
|
|
60647
60807
|
`;
|
|
60648
60808
|
}).join();
|
|
60649
|
-
const tableStatements = Object.values(
|
|
60809
|
+
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
|
60650
60810
|
const tableSchema = schemas[table4.schema];
|
|
60651
60811
|
const func = tableSchema ? tableSchema : "mysqlTable";
|
|
60652
60812
|
let statement = "";
|
|
@@ -60664,7 +60824,7 @@ var init_introspect_mysql = __esm({
|
|
|
60664
60824
|
Object.values(table4.foreignKeys),
|
|
60665
60825
|
withCasing3,
|
|
60666
60826
|
table4.name,
|
|
60667
|
-
|
|
60827
|
+
schema5
|
|
60668
60828
|
);
|
|
60669
60829
|
statement += "}";
|
|
60670
60830
|
const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
|
|
@@ -60712,7 +60872,7 @@ import { sql } from "drizzle-orm"
|
|
|
60712
60872
|
const file = importsTs + decalrations;
|
|
60713
60873
|
const schemaEntry = `
|
|
60714
60874
|
{
|
|
60715
|
-
${Object.values(
|
|
60875
|
+
${Object.values(schema5.tables).map((it) => withCasing3(it.name)).join(",")}
|
|
60716
60876
|
}
|
|
60717
60877
|
`;
|
|
60718
60878
|
return {
|
|
@@ -60947,7 +61107,7 @@ import { sql } from "drizzle-orm"
|
|
|
60947
61107
|
return `// Warning: Can't parse ${type} from database
|
|
60948
61108
|
// ${type}Type: ${type}("${name}")`;
|
|
60949
61109
|
};
|
|
60950
|
-
createTableColumns = (columns, fks, casing, tableName,
|
|
61110
|
+
createTableColumns = (columns, fks, casing, tableName, schema5) => {
|
|
60951
61111
|
let statement = "";
|
|
60952
61112
|
const oneColumnsFKs = Object.values(fks).filter((it) => {
|
|
60953
61113
|
return !isSelf(it);
|
|
@@ -60968,7 +61128,7 @@ import { sql } from "drizzle-orm"
|
|
|
60968
61128
|
it.default,
|
|
60969
61129
|
it.autoincrement,
|
|
60970
61130
|
it.onUpdate,
|
|
60971
|
-
((_c = (_b = (_a =
|
|
61131
|
+
((_c = (_b = (_a = schema5.internal) == null ? void 0 : _a.tables[tableName]) == null ? void 0 : _b.columns[it.name]) == null ? void 0 : _c.isDefaultAnExpression) ?? false
|
|
60972
61132
|
);
|
|
60973
61133
|
statement += it.primaryKey ? ".primaryKey()" : "";
|
|
60974
61134
|
statement += it.notNull ? ".notNull()" : "";
|
|
@@ -62356,10 +62516,10 @@ __export(drivers_exports, {
|
|
|
62356
62516
|
PgPostgres: () => PgPostgres,
|
|
62357
62517
|
TursoSqlite: () => TursoSqlite
|
|
62358
62518
|
});
|
|
62359
|
-
var
|
|
62519
|
+
var import_drizzle_orm9, DrizzleDbClient, DrizzleORMPgClient, DrizzleORMMySQLClient, DrizzleORMSQLiteClient, BetterSqlite, MySQL2Client, TursoSqlite, PgPostgres;
|
|
62360
62520
|
var init_drivers = __esm({
|
|
62361
62521
|
"src/drivers/index.ts"() {
|
|
62362
|
-
|
|
62522
|
+
import_drizzle_orm9 = require("drizzle-orm");
|
|
62363
62523
|
DrizzleDbClient = class {
|
|
62364
62524
|
constructor(db) {
|
|
62365
62525
|
this.db = db;
|
|
@@ -62367,30 +62527,30 @@ var init_drivers = __esm({
|
|
|
62367
62527
|
};
|
|
62368
62528
|
DrizzleORMPgClient = class extends DrizzleDbClient {
|
|
62369
62529
|
async query(query, values) {
|
|
62370
|
-
const res = await this.db.execute(
|
|
62530
|
+
const res = await this.db.execute(import_drizzle_orm9.sql.raw(query));
|
|
62371
62531
|
return res.rows;
|
|
62372
62532
|
}
|
|
62373
62533
|
async run(query) {
|
|
62374
|
-
const res = await this.db.execute(
|
|
62534
|
+
const res = await this.db.execute(import_drizzle_orm9.sql.raw(query));
|
|
62375
62535
|
return res.rows;
|
|
62376
62536
|
}
|
|
62377
62537
|
};
|
|
62378
62538
|
DrizzleORMMySQLClient = class extends DrizzleDbClient {
|
|
62379
62539
|
async query(query, values) {
|
|
62380
|
-
const res = await this.db.execute(
|
|
62540
|
+
const res = await this.db.execute(import_drizzle_orm9.sql.raw(query));
|
|
62381
62541
|
return res[0];
|
|
62382
62542
|
}
|
|
62383
62543
|
async run(query) {
|
|
62384
|
-
await this.db.execute(
|
|
62544
|
+
await this.db.execute(import_drizzle_orm9.sql.raw(query));
|
|
62385
62545
|
}
|
|
62386
62546
|
};
|
|
62387
62547
|
DrizzleORMSQLiteClient = class extends DrizzleDbClient {
|
|
62388
62548
|
async query(query, values) {
|
|
62389
|
-
const res = this.db.all(
|
|
62549
|
+
const res = this.db.all(import_drizzle_orm9.sql.raw(query));
|
|
62390
62550
|
return res;
|
|
62391
62551
|
}
|
|
62392
62552
|
async run(query) {
|
|
62393
|
-
this.db.run(
|
|
62553
|
+
this.db.run(import_drizzle_orm9.sql.raw(query));
|
|
62394
62554
|
}
|
|
62395
62555
|
};
|
|
62396
62556
|
BetterSqlite = class extends DrizzleDbClient {
|
|
@@ -62493,9 +62653,9 @@ var init_mysqlIntrospect = __esm({
|
|
|
62493
62653
|
progress.update(stage, count, status);
|
|
62494
62654
|
})
|
|
62495
62655
|
);
|
|
62496
|
-
const
|
|
62497
|
-
const ts = schemaToTypeScript(
|
|
62498
|
-
const { internal, ...schemaWithoutInternals } =
|
|
62656
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
62657
|
+
const ts = schemaToTypeScript(schema5, config.introspect.casing);
|
|
62658
|
+
const { internal, ...schemaWithoutInternals } = schema5;
|
|
62499
62659
|
return { schema: schemaWithoutInternals, ts };
|
|
62500
62660
|
};
|
|
62501
62661
|
mysqlPushIntrospect = async (connection, filters) => {
|
|
@@ -62514,8 +62674,8 @@ var init_mysqlIntrospect = __esm({
|
|
|
62514
62674
|
return false;
|
|
62515
62675
|
};
|
|
62516
62676
|
const res = await fromDatabase(client, databaseName, filter2);
|
|
62517
|
-
const
|
|
62518
|
-
const { internal, ...schemaWithoutInternals } =
|
|
62677
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
62678
|
+
const { internal, ...schemaWithoutInternals } = schema5;
|
|
62519
62679
|
return { schema: schemaWithoutInternals };
|
|
62520
62680
|
};
|
|
62521
62681
|
}
|
|
@@ -62545,10 +62705,10 @@ var init_pgConnect = __esm({
|
|
|
62545
62705
|
});
|
|
62546
62706
|
|
|
62547
62707
|
// src/introspect-pg.ts
|
|
62548
|
-
var
|
|
62708
|
+
var import_drizzle_orm10, import_relations, pgImportsList, objToStatement22, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, importsPatch2, relations2, withCasing, schemaToTypeScript2, isCyclic2, isSelf2, column5, dimensionsInArray, createTableColumns2, createTableIndexes2, createTablePKs2, createTableUniques2, createTableFKs2;
|
|
62549
62709
|
var init_introspect_pg = __esm({
|
|
62550
62710
|
"src/introspect-pg.ts"() {
|
|
62551
|
-
|
|
62711
|
+
import_drizzle_orm10 = require("drizzle-orm");
|
|
62552
62712
|
import_relations = require("drizzle-orm/relations");
|
|
62553
62713
|
init_utils4();
|
|
62554
62714
|
init_pgSerializer();
|
|
@@ -62668,20 +62828,20 @@ var init_introspect_pg = __esm({
|
|
|
62668
62828
|
}
|
|
62669
62829
|
return value;
|
|
62670
62830
|
};
|
|
62671
|
-
schemaToTypeScript2 = (
|
|
62672
|
-
Object.values(
|
|
62831
|
+
schemaToTypeScript2 = (schema5, casing) => {
|
|
62832
|
+
Object.values(schema5.tables).forEach((table4) => {
|
|
62673
62833
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
|
62674
62834
|
const relation = `${fk4.tableFrom}-${fk4.tableTo}`;
|
|
62675
62835
|
relations2.add(relation);
|
|
62676
62836
|
});
|
|
62677
62837
|
});
|
|
62678
62838
|
const schemas = Object.fromEntries(
|
|
62679
|
-
Object.entries(
|
|
62839
|
+
Object.entries(schema5.schemas).map((it) => {
|
|
62680
62840
|
return [it[0], withCasing(it[1], casing)];
|
|
62681
62841
|
})
|
|
62682
62842
|
);
|
|
62683
|
-
const enumTypes = new Set(Object.values(
|
|
62684
|
-
const imports = Object.values(
|
|
62843
|
+
const enumTypes = new Set(Object.values(schema5.enums).map((it) => it.name));
|
|
62844
|
+
const imports = Object.values(schema5.tables).reduce(
|
|
62685
62845
|
(res, it) => {
|
|
62686
62846
|
const idxImports = Object.values(it.indexes).map(
|
|
62687
62847
|
(idx) => idx.isUnique ? "uniqueIndex" : "index"
|
|
@@ -62722,7 +62882,7 @@ var init_introspect_pg = __esm({
|
|
|
62722
62882
|
},
|
|
62723
62883
|
{ pg: [] }
|
|
62724
62884
|
);
|
|
62725
|
-
const enumStatements = Object.values(
|
|
62885
|
+
const enumStatements = Object.values(schema5.enums).map((it) => {
|
|
62726
62886
|
const values = Object.values(it.values).map((it2) => `'${it2}'`).join(", ");
|
|
62727
62887
|
return `export const ${withCasing(it.name, casing)} = pgEnum("${it.name}", [${values}])
|
|
62728
62888
|
`;
|
|
@@ -62731,7 +62891,7 @@ var init_introspect_pg = __esm({
|
|
|
62731
62891
|
return `export const ${it[1]} = pgSchema("${it[0]}");
|
|
62732
62892
|
`;
|
|
62733
62893
|
}).join("");
|
|
62734
|
-
const tableStatements = Object.values(
|
|
62894
|
+
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
|
62735
62895
|
const tableSchema = schemas[table4.schema];
|
|
62736
62896
|
const func = tableSchema ? `${tableSchema}.table` : "pgTable";
|
|
62737
62897
|
let statement = `export const ${withCasing(
|
|
@@ -62745,7 +62905,7 @@ var init_introspect_pg = __esm({
|
|
|
62745
62905
|
Object.values(table4.foreignKeys),
|
|
62746
62906
|
enumTypes,
|
|
62747
62907
|
casing,
|
|
62748
|
-
|
|
62908
|
+
schema5.internal
|
|
62749
62909
|
);
|
|
62750
62910
|
statement += "}";
|
|
62751
62911
|
const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
|
|
@@ -62789,7 +62949,7 @@ var init_introspect_pg = __esm({
|
|
|
62789
62949
|
const file = importsTs + decalrations;
|
|
62790
62950
|
const schemaEntry = `
|
|
62791
62951
|
{
|
|
62792
|
-
${Object.values(
|
|
62952
|
+
${Object.values(schema5.tables).map((it) => withCasing(it.name, casing)).join(",\n")}
|
|
62793
62953
|
}
|
|
62794
62954
|
`;
|
|
62795
62955
|
return { file, imports: importsTs, decalrations, schemaEntry };
|
|
@@ -63180,8 +63340,8 @@ var init_pgIntrospect = __esm({
|
|
|
63180
63340
|
return false;
|
|
63181
63341
|
};
|
|
63182
63342
|
const res = await fromDatabase2(client, filter2, schemaFilters);
|
|
63183
|
-
const
|
|
63184
|
-
const { internal, ...schemaWithoutInternals } =
|
|
63343
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
63344
|
+
const { internal, ...schemaWithoutInternals } = schema5;
|
|
63185
63345
|
return { schema: schemaWithoutInternals };
|
|
63186
63346
|
};
|
|
63187
63347
|
pgIntrospect = async (config, filters, schemaFilters) => {
|
|
@@ -63207,9 +63367,9 @@ var init_pgIntrospect = __esm({
|
|
|
63207
63367
|
progress.update(stage, count, status);
|
|
63208
63368
|
})
|
|
63209
63369
|
);
|
|
63210
|
-
const
|
|
63211
|
-
const ts = schemaToTypeScript2(
|
|
63212
|
-
const { internal, ...schemaWithoutInternals } =
|
|
63370
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
63371
|
+
const ts = schemaToTypeScript2(schema5, { casing: config.introspect.casing });
|
|
63372
|
+
const { internal, ...schemaWithoutInternals } = schema5;
|
|
63213
63373
|
return { schema: schemaWithoutInternals, ts };
|
|
63214
63374
|
};
|
|
63215
63375
|
}
|
|
@@ -63251,14 +63411,14 @@ var init_introspect_sqlite = __esm({
|
|
|
63251
63411
|
}
|
|
63252
63412
|
return value;
|
|
63253
63413
|
};
|
|
63254
|
-
schemaToTypeScript3 = (
|
|
63255
|
-
Object.values(
|
|
63414
|
+
schemaToTypeScript3 = (schema5, casing) => {
|
|
63415
|
+
Object.values(schema5.tables).forEach((table4) => {
|
|
63256
63416
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
|
63257
63417
|
const relation = `${fk4.tableFrom}-${fk4.tableTo}`;
|
|
63258
63418
|
relations3.add(relation);
|
|
63259
63419
|
});
|
|
63260
63420
|
});
|
|
63261
|
-
const imports = Object.values(
|
|
63421
|
+
const imports = Object.values(schema5.tables).reduce(
|
|
63262
63422
|
(res, it) => {
|
|
63263
63423
|
const idxImports = Object.values(it.indexes).map(
|
|
63264
63424
|
(idx) => idx.isUnique ? "uniqueIndex" : "index"
|
|
@@ -63284,7 +63444,7 @@ var init_introspect_sqlite = __esm({
|
|
|
63284
63444
|
},
|
|
63285
63445
|
{ sqlite: [] }
|
|
63286
63446
|
);
|
|
63287
|
-
const tableStatements = Object.values(
|
|
63447
|
+
const tableStatements = Object.values(schema5.tables).map((table4) => {
|
|
63288
63448
|
const func = "sqliteTable";
|
|
63289
63449
|
let statement = "";
|
|
63290
63450
|
if (imports.sqlite.includes(withCasing2(table4.name, casing))) {
|
|
@@ -63345,7 +63505,7 @@ var init_introspect_sqlite = __esm({
|
|
|
63345
63505
|
const file = importsTs + decalrations;
|
|
63346
63506
|
const schemaEntry = `
|
|
63347
63507
|
{
|
|
63348
|
-
${Object.values(
|
|
63508
|
+
${Object.values(schema5.tables).map((it) => withCasing2(it.name, casing)).join(",")}
|
|
63349
63509
|
}
|
|
63350
63510
|
`;
|
|
63351
63511
|
return { file, imports: importsTs, decalrations, schemaEntry };
|
|
@@ -63577,9 +63737,9 @@ var init_sqliteIntrospect = __esm({
|
|
|
63577
63737
|
progress.update(stage, count, status);
|
|
63578
63738
|
})
|
|
63579
63739
|
);
|
|
63580
|
-
const
|
|
63581
|
-
const ts = schemaToTypeScript3(
|
|
63582
|
-
return { schema:
|
|
63740
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
63741
|
+
const ts = schemaToTypeScript3(schema5, config.introspect.casing);
|
|
63742
|
+
return { schema: schema5, ts };
|
|
63583
63743
|
};
|
|
63584
63744
|
sqlitePushIntrospect = async (client, filters) => {
|
|
63585
63745
|
const matchers = filters.map((it) => {
|
|
@@ -63596,8 +63756,8 @@ var init_sqliteIntrospect = __esm({
|
|
|
63596
63756
|
return false;
|
|
63597
63757
|
};
|
|
63598
63758
|
const res = await fromDatabase3(client, filter2);
|
|
63599
|
-
const
|
|
63600
|
-
return { schema:
|
|
63759
|
+
const schema5 = { id: originUUID, prevId: "", ...res };
|
|
63760
|
+
return { schema: schema5 };
|
|
63601
63761
|
};
|
|
63602
63762
|
}
|
|
63603
63763
|
});
|
|
@@ -63730,7 +63890,7 @@ init_source();
|
|
|
63730
63890
|
// package.json
|
|
63731
63891
|
var package_default = {
|
|
63732
63892
|
name: "drizzle-kit",
|
|
63733
|
-
version: "0.20.
|
|
63893
|
+
version: "0.20.16",
|
|
63734
63894
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
63735
63895
|
author: "Drizzle Team",
|
|
63736
63896
|
license: "MIT",
|
|
@@ -65436,8 +65596,8 @@ function log(entry) {
|
|
|
65436
65596
|
case "fetch":
|
|
65437
65597
|
if (!$.verbose)
|
|
65438
65598
|
return;
|
|
65439
|
-
const
|
|
65440
|
-
process.stderr.write("$ " + source_default.greenBright("fetch") + ` ${entry.url}${
|
|
65599
|
+
const init2 = entry.init ? " " + (0, import_node_util2.inspect)(entry.init) : "";
|
|
65600
|
+
process.stderr.write("$ " + source_default.greenBright("fetch") + ` ${entry.url}${init2}
|
|
65441
65601
|
`);
|
|
65442
65602
|
break;
|
|
65443
65603
|
case "retry":
|
|
@@ -65912,11 +66072,11 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
65912
66072
|
const connection = await connectToMySQL2(drizzleConfig);
|
|
65913
66073
|
const filterConfig = drizzleConfig.tablesFilter;
|
|
65914
66074
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
65915
|
-
const { schema:
|
|
66075
|
+
const { schema: schema5 } = await mysqlPushIntrospect2(connection, tablesFilter);
|
|
65916
66076
|
const { prepareMySQLPush: prepareMySQLPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
|
65917
66077
|
const statements = await prepareMySQLPush2(
|
|
65918
66078
|
{ schema: drizzleConfig.schema },
|
|
65919
|
-
|
|
66079
|
+
schema5
|
|
65920
66080
|
);
|
|
65921
66081
|
const filteredStatements = filterStatements(
|
|
65922
66082
|
(statements == null ? void 0 : statements.statements) ?? [],
|
|
@@ -66034,7 +66194,7 @@ var dbPushPgCommand = new import_commander.Command("push:pg").option(
|
|
|
66034
66194
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
66035
66195
|
const schemaFilterConfig = drizzleConfig.schemaFilter;
|
|
66036
66196
|
const schemasFilter = schemaFilterConfig ? typeof schemaFilterConfig === "string" ? [schemaFilterConfig] : schemaFilterConfig : [];
|
|
66037
|
-
const { schema:
|
|
66197
|
+
const { schema: schema5 } = await pgPushIntrospect2(
|
|
66038
66198
|
connection,
|
|
66039
66199
|
tablesFilter,
|
|
66040
66200
|
schemasFilter
|
|
@@ -66042,7 +66202,7 @@ var dbPushPgCommand = new import_commander.Command("push:pg").option(
|
|
|
66042
66202
|
const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
|
66043
66203
|
const statements = await preparePgPush2(
|
|
66044
66204
|
{ schema: drizzleConfig.schema },
|
|
66045
|
-
|
|
66205
|
+
schema5,
|
|
66046
66206
|
schemasFilter
|
|
66047
66207
|
);
|
|
66048
66208
|
try {
|
|
@@ -66134,12 +66294,12 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
66134
66294
|
const connection = await connectToSQLite2(res);
|
|
66135
66295
|
const filterConfig = res.tablesFilter;
|
|
66136
66296
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
66137
|
-
const { schema:
|
|
66297
|
+
const { schema: schema5 } = await sqlitePushIntrospect2(
|
|
66138
66298
|
connection.client,
|
|
66139
66299
|
tablesFilter
|
|
66140
66300
|
);
|
|
66141
66301
|
const { prepareSQLitePush: prepareSQLitePush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
|
66142
|
-
const statements = await prepareSQLitePush2({ schema: res.schema },
|
|
66302
|
+
const statements = await prepareSQLitePush2({ schema: res.schema }, schema5);
|
|
66143
66303
|
try {
|
|
66144
66304
|
if (typeof statements === "undefined") {
|
|
66145
66305
|
} else if (statements.sqlStatements.length === 0) {
|
|
@@ -66355,7 +66515,7 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
|
|
|
66355
66515
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
66356
66516
|
const schemaFilterConfig = validatedConfig.schemaFilter;
|
|
66357
66517
|
const schemasFilter = schemaFilterConfig ? typeof schemaFilterConfig === "string" ? [schemaFilterConfig] : schemaFilterConfig : [];
|
|
66358
|
-
const { schema:
|
|
66518
|
+
const { schema: schema5, ts } = await pgIntrospect2(
|
|
66359
66519
|
validatedConfig,
|
|
66360
66520
|
tablesFilter,
|
|
66361
66521
|
schemasFilter
|
|
@@ -66366,13 +66526,13 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
|
|
|
66366
66526
|
if (snapshots.length === 0) {
|
|
66367
66527
|
const { sqlStatements, _meta } = await prepareSQL(
|
|
66368
66528
|
squashPgScheme(dryPg),
|
|
66369
|
-
squashPgScheme(
|
|
66529
|
+
squashPgScheme(schema5),
|
|
66370
66530
|
"pg",
|
|
66371
66531
|
dryMySql,
|
|
66372
|
-
|
|
66532
|
+
schema5
|
|
66373
66533
|
);
|
|
66374
66534
|
writeResult({
|
|
66375
|
-
cur:
|
|
66535
|
+
cur: schema5,
|
|
66376
66536
|
sqlStatements,
|
|
66377
66537
|
journal,
|
|
66378
66538
|
_meta,
|
|
@@ -66412,20 +66572,20 @@ var introspectMySqlCommand = new import_commander.Command("introspect:mysql").op
|
|
|
66412
66572
|
const { snapshots, journal } = prepareOutFolder2(out, "mysql");
|
|
66413
66573
|
const filterConfig = res.tablesFilter;
|
|
66414
66574
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
66415
|
-
const { schema:
|
|
66575
|
+
const { schema: schema5, ts } = await mysqlIntrospect2(res, tablesFilter);
|
|
66416
66576
|
const schemaFile = import_path8.default.join(out, "schema.ts");
|
|
66417
66577
|
(0, import_fs13.writeFileSync)(schemaFile, ts.file);
|
|
66418
66578
|
console.log();
|
|
66419
66579
|
if (snapshots.length === 0) {
|
|
66420
66580
|
const { sqlStatements, _meta } = await prepareSQL(
|
|
66421
66581
|
squashMysqlScheme(dryMySql),
|
|
66422
|
-
squashMysqlScheme(
|
|
66582
|
+
squashMysqlScheme(schema5),
|
|
66423
66583
|
"mysql",
|
|
66424
66584
|
dryMySql,
|
|
66425
|
-
|
|
66585
|
+
schema5
|
|
66426
66586
|
);
|
|
66427
66587
|
writeResult({
|
|
66428
|
-
cur:
|
|
66588
|
+
cur: schema5,
|
|
66429
66589
|
sqlStatements,
|
|
66430
66590
|
journal,
|
|
66431
66591
|
_meta,
|
|
@@ -66465,20 +66625,20 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
|
|
|
66465
66625
|
const { snapshots, journal } = prepareOutFolder2(out, "sqlite");
|
|
66466
66626
|
const filterConfig = res.tablesFilter;
|
|
66467
66627
|
const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
|
|
66468
|
-
const { schema:
|
|
66628
|
+
const { schema: schema5, ts } = await sqliteIntrospect2(res, tablesFilter);
|
|
66469
66629
|
const schemaFile = import_path8.default.join(out, "schema.ts");
|
|
66470
66630
|
(0, import_fs13.writeFileSync)(schemaFile, ts.file);
|
|
66471
66631
|
console.log();
|
|
66472
66632
|
if (snapshots.length === 0) {
|
|
66473
66633
|
const { sqlStatements, _meta } = await prepareSQL(
|
|
66474
66634
|
squashSqliteScheme(drySQLite),
|
|
66475
|
-
squashSqliteScheme(
|
|
66635
|
+
squashSqliteScheme(schema5),
|
|
66476
66636
|
"sqlite",
|
|
66477
66637
|
drySQLite,
|
|
66478
|
-
|
|
66638
|
+
schema5
|
|
66479
66639
|
);
|
|
66480
66640
|
writeResult({
|
|
66481
|
-
cur:
|
|
66641
|
+
cur: schema5,
|
|
66482
66642
|
sqlStatements,
|
|
66483
66643
|
journal,
|
|
66484
66644
|
_meta,
|
|
@@ -66535,22 +66695,34 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
|
66535
66695
|
const drizzleConfig = await validateStudio2(options);
|
|
66536
66696
|
const {
|
|
66537
66697
|
drizzleForPostgres: drizzleForPostgres2,
|
|
66698
|
+
preparePgSchema: preparePgSchema2,
|
|
66699
|
+
prepareMySqlSchema: prepareMySqlSchema2,
|
|
66538
66700
|
drizzleForMySQL: drizzleForMySQL2,
|
|
66701
|
+
prepareSQLiteSchema: prepareSQLiteSchema2,
|
|
66539
66702
|
drizzleForSQLite: drizzleForSQLite2
|
|
66540
66703
|
} = await Promise.resolve().then(() => (init_studio(), studio_exports));
|
|
66541
66704
|
const { driver: driver2, schema: schemaPath } = drizzleConfig;
|
|
66542
66705
|
let setup;
|
|
66543
66706
|
if (driver2 === "pg") {
|
|
66707
|
+
const { schema: schema5, relations: relations4 } = await preparePgSchema2(schemaPath);
|
|
66544
66708
|
setup = await drizzleForPostgres2(
|
|
66545
|
-
drizzleConfig
|
|
66709
|
+
drizzleConfig,
|
|
66710
|
+
schema5,
|
|
66711
|
+
relations4
|
|
66546
66712
|
);
|
|
66547
66713
|
} else if (driver2 === "mysql2") {
|
|
66714
|
+
const { schema: schema5, relations: relations4 } = await prepareMySqlSchema2(schemaPath);
|
|
66548
66715
|
setup = await drizzleForMySQL2(
|
|
66549
|
-
drizzleConfig
|
|
66716
|
+
drizzleConfig,
|
|
66717
|
+
schema5,
|
|
66718
|
+
relations4
|
|
66550
66719
|
);
|
|
66551
66720
|
} else if (driver2 === "better-sqlite" || driver2 === "d1" || driver2 === "libsql" || driver2 === "turso") {
|
|
66721
|
+
const { schema: schema5, relations: relations4 } = await prepareSQLiteSchema2(schemaPath);
|
|
66552
66722
|
setup = await drizzleForSQLite2(
|
|
66553
|
-
drizzleConfig
|
|
66723
|
+
drizzleConfig,
|
|
66724
|
+
schema5,
|
|
66725
|
+
relations4
|
|
66554
66726
|
);
|
|
66555
66727
|
} else {
|
|
66556
66728
|
assertUnreachable(driver2);
|