drizzle-kit 0.19.12 → 0.19.13-53915b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +220 -100
- package/package.json +2 -2
- package/utils.js +29 -10
package/index.cjs
CHANGED
|
@@ -4831,7 +4831,7 @@ var init_mysqlSchema = __esm({
|
|
|
4831
4831
|
});
|
|
4832
4832
|
|
|
4833
4833
|
// src/serializer/pgSchema.ts
|
|
4834
|
-
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgSchemeV4, squashPgScheme, dryPg;
|
|
4834
|
+
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals2, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgSchemeV4, squashPgScheme, dryPg;
|
|
4835
4835
|
var init_pgSchema = __esm({
|
|
4836
4836
|
"src/serializer/pgSchema.ts"() {
|
|
4837
4837
|
init_global();
|
|
@@ -4978,6 +4978,21 @@ var init_pgSchema = __esm({
|
|
|
4978
4978
|
columns: recordType(stringType(), stringType())
|
|
4979
4979
|
})
|
|
4980
4980
|
}).strict();
|
|
4981
|
+
kitInternals2 = objectType({
|
|
4982
|
+
tables: recordType(
|
|
4983
|
+
stringType(),
|
|
4984
|
+
objectType({
|
|
4985
|
+
columns: recordType(
|
|
4986
|
+
stringType(),
|
|
4987
|
+
objectType({
|
|
4988
|
+
isArray: booleanType().optional(),
|
|
4989
|
+
dimensions: numberType().optional(),
|
|
4990
|
+
rawType: stringType().optional()
|
|
4991
|
+
}).optional()
|
|
4992
|
+
)
|
|
4993
|
+
}).optional()
|
|
4994
|
+
)
|
|
4995
|
+
}).optional();
|
|
4981
4996
|
pgSchemaInternal = objectType({
|
|
4982
4997
|
version: literalType("5"),
|
|
4983
4998
|
dialect: literalType("pg"),
|
|
@@ -4988,7 +5003,8 @@ var init_pgSchema = __esm({
|
|
|
4988
5003
|
schemas: recordType(stringType(), stringType()),
|
|
4989
5004
|
tables: recordType(stringType(), stringType()),
|
|
4990
5005
|
columns: recordType(stringType(), stringType())
|
|
4991
|
-
})
|
|
5006
|
+
}),
|
|
5007
|
+
internal: kitInternals2
|
|
4992
5008
|
}).strict();
|
|
4993
5009
|
tableSquashed2 = objectType({
|
|
4994
5010
|
name: stringType(),
|
|
@@ -5057,12 +5073,12 @@ var init_pgSchema = __esm({
|
|
|
5057
5073
|
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
|
5058
5074
|
},
|
|
5059
5075
|
unsquashUnique: (unq) => {
|
|
5060
|
-
const [
|
|
5076
|
+
const [name, columns, nullsNotDistinct] = unq.split(";");
|
|
5077
|
+
return {
|
|
5061
5078
|
name,
|
|
5062
|
-
columns,
|
|
5063
|
-
nullsNotDistinct
|
|
5064
|
-
|
|
5065
|
-
return { name, columns: columns.split(","), nullsNotDistinct: nullsNotDistinct === "true" };
|
|
5079
|
+
columns: columns.split(","),
|
|
5080
|
+
nullsNotDistinct: nullsNotDistinct === "true"
|
|
5081
|
+
};
|
|
5066
5082
|
},
|
|
5067
5083
|
unsquashFK: (input) => {
|
|
5068
5084
|
const [
|
|
@@ -5127,9 +5143,12 @@ var init_pgSchema = __esm({
|
|
|
5127
5143
|
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
|
5128
5144
|
return PgSquasher.squashPK(pk);
|
|
5129
5145
|
});
|
|
5130
|
-
const squashedUniqueConstraints = mapValues(
|
|
5131
|
-
|
|
5132
|
-
|
|
5146
|
+
const squashedUniqueConstraints = mapValues(
|
|
5147
|
+
it[1].uniqueConstraints,
|
|
5148
|
+
(unq) => {
|
|
5149
|
+
return PgSquasher.squashUnique(unq);
|
|
5150
|
+
}
|
|
5151
|
+
);
|
|
5133
5152
|
return [
|
|
5134
5153
|
it[0],
|
|
5135
5154
|
{
|
|
@@ -11360,10 +11379,17 @@ var init_utils = __esm({
|
|
|
11360
11379
|
(0, import_path.join)((0, import_path.resolve)("drizzle.config.json"))
|
|
11361
11380
|
);
|
|
11362
11381
|
const defaultConfigPath = defaultTsConfigExists ? "drizzle.config.ts" : defaultJsConfigExists ? "drizzle.config.js" : "drizzle.config.json";
|
|
11382
|
+
if (configPath) {
|
|
11383
|
+
console.log(
|
|
11384
|
+
source_default.gray(
|
|
11385
|
+
`Custom config path was provided, using '${configPath}'`
|
|
11386
|
+
)
|
|
11387
|
+
);
|
|
11388
|
+
}
|
|
11363
11389
|
if (!configPath) {
|
|
11364
11390
|
console.log(
|
|
11365
11391
|
source_default.gray(
|
|
11366
|
-
`No config path provided, using default
|
|
11392
|
+
`No config path provided, using default path`
|
|
11367
11393
|
)
|
|
11368
11394
|
);
|
|
11369
11395
|
}
|
|
@@ -12239,17 +12265,13 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
|
12239
12265
|
return map;
|
|
12240
12266
|
}, {});
|
|
12241
12267
|
const schemasObject = Object.fromEntries(
|
|
12242
|
-
schemas.filter(
|
|
12243
|
-
(
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
return schemaFilter.includes(it.schemaName);
|
|
12248
|
-
} else {
|
|
12249
|
-
return true;
|
|
12250
|
-
}
|
|
12268
|
+
schemas.filter((it) => {
|
|
12269
|
+
if (schemaFilter) {
|
|
12270
|
+
return schemaFilter.includes(it.schemaName) && it.schemaName !== "public";
|
|
12271
|
+
} else {
|
|
12272
|
+
return it.schemaName !== "public";
|
|
12251
12273
|
}
|
|
12252
|
-
).map((it) => [it.schemaName, it.schemaName])
|
|
12274
|
+
}).map((it) => [it.schemaName, it.schemaName])
|
|
12253
12275
|
);
|
|
12254
12276
|
return {
|
|
12255
12277
|
version: "5",
|
|
@@ -12275,12 +12297,25 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
|
12275
12297
|
};
|
|
12276
12298
|
fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
|
|
12277
12299
|
const result = {};
|
|
12300
|
+
const internals = { tables: {} };
|
|
12278
12301
|
const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
|
|
12279
12302
|
const allTables = await db.query(
|
|
12280
12303
|
`SELECT table_schema, table_name FROM information_schema.tables WHERE ${where};`
|
|
12281
12304
|
);
|
|
12282
12305
|
const schemas = new Set(allTables.map((it) => it.table_schema));
|
|
12283
12306
|
schemas.delete("public");
|
|
12307
|
+
const allSchemas = await db.query(`select s.nspname as table_schema
|
|
12308
|
+
from pg_catalog.pg_namespace s
|
|
12309
|
+
join pg_catalog.pg_user u on u.usesysid = s.nspowner
|
|
12310
|
+
where nspname not in ('information_schema', 'pg_catalog', 'public')
|
|
12311
|
+
and nspname not like 'pg_toast%'
|
|
12312
|
+
and nspname not like 'pg_temp_%'
|
|
12313
|
+
order by table_schema;`);
|
|
12314
|
+
allSchemas.forEach((item) => {
|
|
12315
|
+
if (schemaFilters.includes(item.table_schema)) {
|
|
12316
|
+
schemas.add(item.table_schema);
|
|
12317
|
+
}
|
|
12318
|
+
});
|
|
12284
12319
|
let columnsCount = 0;
|
|
12285
12320
|
let indexesCount = 0;
|
|
12286
12321
|
let foreignKeysCount = 0;
|
|
@@ -12438,6 +12473,33 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
|
12438
12473
|
if (columnTypeMapped.startsWith("numeric(")) {
|
|
12439
12474
|
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
|
12440
12475
|
}
|
|
12476
|
+
if (columnAdditionalDT === "ARRAY") {
|
|
12477
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
|
12478
|
+
internals.tables[tableName] = {
|
|
12479
|
+
columns: {
|
|
12480
|
+
[columnName]: {
|
|
12481
|
+
isArray: true,
|
|
12482
|
+
dimensions: columnDimensions,
|
|
12483
|
+
rawType: columnTypeMapped.substring(
|
|
12484
|
+
0,
|
|
12485
|
+
columnTypeMapped.length - 2
|
|
12486
|
+
)
|
|
12487
|
+
}
|
|
12488
|
+
}
|
|
12489
|
+
};
|
|
12490
|
+
} else {
|
|
12491
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
|
12492
|
+
internals.tables[tableName].columns[columnName] = {
|
|
12493
|
+
isArray: true,
|
|
12494
|
+
dimensions: columnDimensions,
|
|
12495
|
+
rawType: columnTypeMapped.substring(
|
|
12496
|
+
0,
|
|
12497
|
+
columnTypeMapped.length - 2
|
|
12498
|
+
)
|
|
12499
|
+
};
|
|
12500
|
+
}
|
|
12501
|
+
}
|
|
12502
|
+
}
|
|
12441
12503
|
if (columnAdditionalDT === "ARRAY") {
|
|
12442
12504
|
for (let i = 1; i < Number(columnDimensions); i++) {
|
|
12443
12505
|
columnTypeMapped += "[]";
|
|
@@ -12562,7 +12624,8 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
|
12562
12624
|
schemas: {},
|
|
12563
12625
|
tables: {},
|
|
12564
12626
|
columns: {}
|
|
12565
|
-
}
|
|
12627
|
+
},
|
|
12628
|
+
internal: internals
|
|
12566
12629
|
};
|
|
12567
12630
|
};
|
|
12568
12631
|
columnToDefault = {
|
|
@@ -14652,14 +14715,14 @@ var init_migrate = __esm({
|
|
|
14652
14715
|
const validatedCur = sqliteSchema.parse(cur);
|
|
14653
14716
|
const squashedPrev = squashSqliteScheme(validatedPrev);
|
|
14654
14717
|
const squashedCur = squashSqliteScheme(validatedCur);
|
|
14655
|
-
const { sqlStatements, statements } = await prepareSQL(
|
|
14718
|
+
const { sqlStatements, statements, _meta } = await prepareSQL(
|
|
14656
14719
|
squashedPrev,
|
|
14657
14720
|
squashedCur,
|
|
14658
14721
|
"sqlite",
|
|
14659
14722
|
validatedPrev,
|
|
14660
14723
|
validatedCur
|
|
14661
14724
|
);
|
|
14662
|
-
return { sqlStatements, statements, squashedPrev, squashedCur };
|
|
14725
|
+
return { sqlStatements, statements, squashedPrev, squashedCur, meta: _meta };
|
|
14663
14726
|
} catch (e) {
|
|
14664
14727
|
console.error(e);
|
|
14665
14728
|
}
|
|
@@ -17494,12 +17557,12 @@ var init_snapshotsDiffer = __esm({
|
|
|
17494
17557
|
});
|
|
17495
17558
|
jsonStatements.push(...jsonMySqlCreateTables);
|
|
17496
17559
|
}
|
|
17497
|
-
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
|
17498
17560
|
jsonStatements.push(...jsonDropTables);
|
|
17499
17561
|
jsonStatements.push(...jsonRenameTables);
|
|
17500
17562
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
|
17501
17563
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
|
17502
17564
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
17565
|
+
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
|
17503
17566
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
|
17504
17567
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
|
17505
17568
|
jsonStatements.push(...jsonTableAlternations.createColumns);
|
|
@@ -36329,7 +36392,7 @@ import { sql } from "drizzle-orm"
|
|
|
36329
36392
|
statement += `${it.columns.map((c) => {
|
|
36330
36393
|
return `table.${withCasing(c, casing)}`;
|
|
36331
36394
|
}).join(", ")}`;
|
|
36332
|
-
statement += ")";
|
|
36395
|
+
statement += "),";
|
|
36333
36396
|
statement += `
|
|
36334
36397
|
`;
|
|
36335
36398
|
});
|
|
@@ -42408,16 +42471,25 @@ var init_introspect = __esm({
|
|
|
42408
42471
|
(idx) => idx.isUnique ? "uniqueIndex" : "index"
|
|
42409
42472
|
);
|
|
42410
42473
|
const fkImpots = Object.values(it.foreignKeys).map((it2) => "foreignKey");
|
|
42474
|
+
if (Object.values(it.foreignKeys).some((it2) => isCyclic2(it2) && !isSelf2(it2))) {
|
|
42475
|
+
res.pg.push("type AnyPgColumn");
|
|
42476
|
+
}
|
|
42411
42477
|
const pkImports = Object.values(it.compositePrimaryKeys).map(
|
|
42412
42478
|
(it2) => "primaryKey"
|
|
42413
42479
|
);
|
|
42414
42480
|
const uniqueImports = Object.values(it.uniqueConstraints).map(
|
|
42415
42481
|
(it2) => "unique"
|
|
42416
42482
|
);
|
|
42483
|
+
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
|
42484
|
+
res.pg.push("pgSchema");
|
|
42485
|
+
}
|
|
42417
42486
|
res.pg.push(...idxImports);
|
|
42418
42487
|
res.pg.push(...fkImpots);
|
|
42419
42488
|
res.pg.push(...pkImports);
|
|
42420
42489
|
res.pg.push(...uniqueImports);
|
|
42490
|
+
if (enumTypes.size > 0) {
|
|
42491
|
+
res.pg.push("pgEnum");
|
|
42492
|
+
}
|
|
42421
42493
|
const columnImports = Object.values(it.columns).map((col) => {
|
|
42422
42494
|
let patched = importsPatch2[col.type] ?? col.type;
|
|
42423
42495
|
patched = patched.startsWith("varchar(") ? "varchar" : patched;
|
|
@@ -42444,18 +42516,20 @@ var init_introspect = __esm({
|
|
|
42444
42516
|
`;
|
|
42445
42517
|
}).join();
|
|
42446
42518
|
const tableStatements = Object.values(schema4.tables).map((table4) => {
|
|
42447
|
-
const
|
|
42448
|
-
const func =
|
|
42519
|
+
const tableSchema = schemas[table4.schema];
|
|
42520
|
+
const func = tableSchema ? `${tableSchema}.table` : "pgTable";
|
|
42449
42521
|
let statement = `export const ${withCasing2(
|
|
42450
42522
|
table4.name,
|
|
42451
42523
|
casing
|
|
42452
42524
|
)} = ${func}("${table4.name}", {
|
|
42453
42525
|
`;
|
|
42454
42526
|
statement += createTableColumns2(
|
|
42527
|
+
table4.name,
|
|
42455
42528
|
Object.values(table4.columns),
|
|
42456
42529
|
Object.values(table4.foreignKeys),
|
|
42457
42530
|
enumTypes,
|
|
42458
|
-
casing
|
|
42531
|
+
casing,
|
|
42532
|
+
schema4.internal
|
|
42459
42533
|
);
|
|
42460
42534
|
statement += "}";
|
|
42461
42535
|
const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
|
|
@@ -42485,22 +42559,16 @@ var init_introspect = __esm({
|
|
|
42485
42559
|
statement += ");";
|
|
42486
42560
|
return statement;
|
|
42487
42561
|
});
|
|
42488
|
-
const uniquePgImports = [
|
|
42489
|
-
"pgTable",
|
|
42490
|
-
"pgEnum",
|
|
42491
|
-
"pgSchema",
|
|
42492
|
-
"AnyPgColumn",
|
|
42493
|
-
...new Set(imports.pg)
|
|
42494
|
-
];
|
|
42562
|
+
const uniquePgImports = ["pgTable", ...new Set(imports.pg)];
|
|
42495
42563
|
let result = `import { ${uniquePgImports.join(
|
|
42496
42564
|
", "
|
|
42497
42565
|
)} } from "drizzle-orm/pg-core"
|
|
42498
42566
|
|
|
42499
42567
|
`;
|
|
42500
|
-
result += enumStatements;
|
|
42501
|
-
result += schemaStatements;
|
|
42502
42568
|
result += `import { sql } from "drizzle-orm"
|
|
42503
42569
|
`;
|
|
42570
|
+
result += enumStatements;
|
|
42571
|
+
result += schemaStatements;
|
|
42504
42572
|
result += "\n";
|
|
42505
42573
|
result += tableStatements.join("\n\n");
|
|
42506
42574
|
return result;
|
|
@@ -42513,7 +42581,8 @@ var init_introspect = __esm({
|
|
|
42513
42581
|
isSelf2 = (fk4) => {
|
|
42514
42582
|
return fk4.tableFrom === fk4.tableTo;
|
|
42515
42583
|
};
|
|
42516
|
-
column5 = (type, name, enumTypes, defaultValue, casing) => {
|
|
42584
|
+
column5 = (tableName, type, name, enumTypes, defaultValue, casing, internals) => {
|
|
42585
|
+
var _a;
|
|
42517
42586
|
const lowered = type.toLowerCase();
|
|
42518
42587
|
if (lowered.startsWith("serial")) {
|
|
42519
42588
|
return `${withCasing2(name, casing)}: serial("${name}")`;
|
|
@@ -42687,6 +42756,17 @@ var init_introspect = __esm({
|
|
|
42687
42756
|
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
|
42688
42757
|
return out;
|
|
42689
42758
|
}
|
|
42759
|
+
const columnInternals = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[name];
|
|
42760
|
+
if (typeof columnInternals !== "undefined") {
|
|
42761
|
+
if (columnInternals.isArray && columnInternals.rawType && enumTypes.has(columnInternals.rawType)) {
|
|
42762
|
+
let out = `${withCasing2(columnInternals.rawType, casing)}: ${withCasing2(
|
|
42763
|
+
columnInternals.rawType,
|
|
42764
|
+
casing
|
|
42765
|
+
)}("${name}")`;
|
|
42766
|
+
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
|
42767
|
+
return out;
|
|
42768
|
+
}
|
|
42769
|
+
}
|
|
42690
42770
|
if (enumTypes.has(type)) {
|
|
42691
42771
|
let out = `${withCasing2(name, casing)}: ${withCasing2(
|
|
42692
42772
|
type,
|
|
@@ -42700,16 +42780,16 @@ var init_introspect = __esm({
|
|
|
42700
42780
|
unknown += ` ${withCasing2(name, casing)}: unknown("${name}")`;
|
|
42701
42781
|
return unknown;
|
|
42702
42782
|
};
|
|
42703
|
-
dimensionsInArray = (
|
|
42783
|
+
dimensionsInArray = (size) => {
|
|
42704
42784
|
let res = "";
|
|
42705
|
-
|
|
42706
|
-
|
|
42707
|
-
|
|
42708
|
-
|
|
42785
|
+
if (typeof size === "undefined")
|
|
42786
|
+
return res;
|
|
42787
|
+
for (let i = 0; i < size; i++) {
|
|
42788
|
+
res += ".array()";
|
|
42709
42789
|
}
|
|
42710
42790
|
return res;
|
|
42711
42791
|
};
|
|
42712
|
-
createTableColumns2 = (columns, fks, enumTypes, casing) => {
|
|
42792
|
+
createTableColumns2 = (tableName, columns, fks, enumTypes, casing, internals) => {
|
|
42713
42793
|
let statement = "";
|
|
42714
42794
|
const oneColumnsFKs = Object.values(fks).filter((it) => {
|
|
42715
42795
|
return !isSelf2(it);
|
|
@@ -42721,16 +42801,23 @@ var init_introspect = __esm({
|
|
|
42721
42801
|
return res;
|
|
42722
42802
|
}, {});
|
|
42723
42803
|
columns.forEach((it) => {
|
|
42804
|
+
var _a, _b, _c, _d;
|
|
42724
42805
|
const columnStatement = column5(
|
|
42806
|
+
tableName,
|
|
42725
42807
|
it.type,
|
|
42726
42808
|
it.name,
|
|
42727
42809
|
enumTypes,
|
|
42728
42810
|
it.default,
|
|
42729
|
-
casing
|
|
42811
|
+
casing,
|
|
42812
|
+
internals
|
|
42730
42813
|
);
|
|
42731
42814
|
statement += " ";
|
|
42732
42815
|
statement += columnStatement;
|
|
42733
|
-
|
|
42816
|
+
if ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[it.name]) == null ? void 0 : _b.isArray) {
|
|
42817
|
+
statement += dimensionsInArray(
|
|
42818
|
+
(_d = (_c = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _c.columns[it.name]) == null ? void 0 : _d.dimensions
|
|
42819
|
+
);
|
|
42820
|
+
}
|
|
42734
42821
|
statement += it.primaryKey ? ".primaryKey()" : "";
|
|
42735
42822
|
statement += it.notNull ? ".notNull()" : "";
|
|
42736
42823
|
const fks2 = fkByColumnName[it.name];
|
|
@@ -42909,7 +42996,8 @@ var init_pgIntrospect = __esm({
|
|
|
42909
42996
|
};
|
|
42910
42997
|
const res = await fromDatabase2(client, filter2, schemaFilters);
|
|
42911
42998
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
42912
|
-
|
|
42999
|
+
const { internal, ...schemaWithoutInternals } = schema4;
|
|
43000
|
+
return { schema: schemaWithoutInternals };
|
|
42913
43001
|
};
|
|
42914
43002
|
pgIntrospect = async (config, filters, schemaFilters) => {
|
|
42915
43003
|
const pool = await connectToPg(config);
|
|
@@ -42935,7 +43023,8 @@ var init_pgIntrospect = __esm({
|
|
|
42935
43023
|
);
|
|
42936
43024
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
42937
43025
|
const ts = schemaToTypeScript2(schema4, { casing: config.introspect.casing });
|
|
42938
|
-
|
|
43026
|
+
const { internal, ...schemaWithoutInternals } = schema4;
|
|
43027
|
+
return { schema: schemaWithoutInternals, ts };
|
|
42939
43028
|
};
|
|
42940
43029
|
}
|
|
42941
43030
|
});
|
|
@@ -51891,7 +51980,7 @@ var init_studio = __esm({
|
|
|
51891
51980
|
printDriverIssues = (options) => {
|
|
51892
51981
|
if (options.driver === "pg") {
|
|
51893
51982
|
printConfigConnectionIssues2(options);
|
|
51894
|
-
} else if (options.driver === "
|
|
51983
|
+
} else if (options.driver === "mysql2") {
|
|
51895
51984
|
printConfigConnectionIssues3(options);
|
|
51896
51985
|
} else if (["libsql", "turso", "better-sqlite"].includes(options.driver)) {
|
|
51897
51986
|
printConfigConnectionIssues(options);
|
|
@@ -52126,7 +52215,7 @@ init_source();
|
|
|
52126
52215
|
// package.json
|
|
52127
52216
|
var package_default = {
|
|
52128
52217
|
name: "drizzle-kit",
|
|
52129
|
-
version: "0.19.
|
|
52218
|
+
version: "0.19.13",
|
|
52130
52219
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
52131
52220
|
author: "Drizzle Team",
|
|
52132
52221
|
license: "MIT",
|
|
@@ -52179,7 +52268,7 @@ var package_default = {
|
|
|
52179
52268
|
]
|
|
52180
52269
|
},
|
|
52181
52270
|
dependencies: {
|
|
52182
|
-
"@drizzle-team/studio": "^0.0.
|
|
52271
|
+
"@drizzle-team/studio": "^0.0.8",
|
|
52183
52272
|
"@esbuild-kit/esm-loader": "^2.5.5",
|
|
52184
52273
|
camelcase: "^7.0.1",
|
|
52185
52274
|
chalk: "^5.2.0",
|
|
@@ -52563,11 +52652,30 @@ var _moveDataStatements = (tableName, json, dataLoss = false) => {
|
|
|
52563
52652
|
}
|
|
52564
52653
|
return statements;
|
|
52565
52654
|
};
|
|
52655
|
+
var getOldTableName = (tableName, meta) => {
|
|
52656
|
+
for (const key of Object.keys(meta.tables)) {
|
|
52657
|
+
const value = meta.tables[key];
|
|
52658
|
+
if (`"${tableName}"` === value) {
|
|
52659
|
+
return key.substring(1, key.length - 1);
|
|
52660
|
+
}
|
|
52661
|
+
}
|
|
52662
|
+
return tableName;
|
|
52663
|
+
};
|
|
52664
|
+
var getNewTableName = (tableName, meta) => {
|
|
52665
|
+
if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
|
|
52666
|
+
return meta.tables[`"${tableName}"`].substring(
|
|
52667
|
+
1,
|
|
52668
|
+
meta.tables[`"${tableName}"`].length - 1
|
|
52669
|
+
);
|
|
52670
|
+
}
|
|
52671
|
+
return tableName;
|
|
52672
|
+
};
|
|
52566
52673
|
var logSuggestionsAndReturn2 = async ({
|
|
52567
52674
|
connection,
|
|
52568
52675
|
statements,
|
|
52569
52676
|
json1,
|
|
52570
|
-
json2
|
|
52677
|
+
json2,
|
|
52678
|
+
meta
|
|
52571
52679
|
}) => {
|
|
52572
52680
|
let shouldAskForApprove = false;
|
|
52573
52681
|
const statementsToExecute = [];
|
|
@@ -52595,43 +52703,44 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52595
52703
|
const stmnt = fromJson([statement], "sqlite")[0];
|
|
52596
52704
|
statementsToExecute.push(stmnt);
|
|
52597
52705
|
} else if (statement.type === "alter_table_drop_column") {
|
|
52706
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
52598
52707
|
const columnIsPartOfPk = Object.values(
|
|
52599
|
-
json1.tables[
|
|
52708
|
+
json1.tables[newTableName].compositePrimaryKeys
|
|
52600
52709
|
).find(
|
|
52601
52710
|
(c) => SQLiteSquasher.unsquashPK(c).includes(statement.columnName)
|
|
52602
52711
|
);
|
|
52603
52712
|
const columnIsPartOfIndex = Object.values(
|
|
52604
|
-
json1.tables[
|
|
52713
|
+
json1.tables[newTableName].indexes
|
|
52605
52714
|
).find(
|
|
52606
52715
|
(c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName)
|
|
52607
52716
|
);
|
|
52608
|
-
const columnIsPk = json1.tables[
|
|
52717
|
+
const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
|
|
52609
52718
|
const columnIsPartOfFk = Object.values(
|
|
52610
|
-
json1.tables[
|
|
52719
|
+
json1.tables[newTableName].foreignKeys
|
|
52611
52720
|
).find(
|
|
52612
52721
|
(t) => SQLiteSquasher.unsquashFK(t).columnsFrom.includes(statement.columnName)
|
|
52613
52722
|
);
|
|
52614
52723
|
const res = await connection.query(
|
|
52615
|
-
`select count(*) as count from \`${
|
|
52724
|
+
`select count(*) as count from \`${newTableName}\``
|
|
52616
52725
|
);
|
|
52617
52726
|
const count = Number(res[0].count);
|
|
52618
52727
|
if (count > 0) {
|
|
52619
52728
|
infoToPrint.push(
|
|
52620
52729
|
`\xB7 You're about to delete ${source_default.underline(
|
|
52621
52730
|
statement.columnName
|
|
52622
|
-
)} column in ${
|
|
52731
|
+
)} column in ${newTableName} table with ${count} items`
|
|
52623
52732
|
);
|
|
52624
|
-
columnsToRemove.push(`${
|
|
52733
|
+
columnsToRemove.push(`${newTableName}_${statement.columnName}`);
|
|
52625
52734
|
shouldAskForApprove = true;
|
|
52626
52735
|
}
|
|
52627
52736
|
if (columnIsPk || columnIsPartOfPk || columnIsPartOfIndex || columnIsPartOfFk) {
|
|
52628
|
-
tablesContext[
|
|
52737
|
+
tablesContext[newTableName] = [
|
|
52629
52738
|
..._moveDataStatements(statement.tableName, json2, true)
|
|
52630
52739
|
];
|
|
52631
52740
|
const tablesReferncingCurrent = [];
|
|
52632
52741
|
for (const table4 of Object.values(json1.tables)) {
|
|
52633
52742
|
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
|
52634
|
-
(t) => SQLiteSquasher.unsquashFK(t).tableTo ===
|
|
52743
|
+
(t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
|
|
52635
52744
|
).map((t) => SQLiteSquasher.unsquashFK(t).tableFrom);
|
|
52636
52745
|
tablesReferncingCurrent.push(...tablesRefs);
|
|
52637
52746
|
}
|
|
@@ -52642,15 +52751,16 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52642
52751
|
}
|
|
52643
52752
|
}
|
|
52644
52753
|
} else {
|
|
52645
|
-
if (typeof tablesContext[
|
|
52754
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
52646
52755
|
const stmnt = fromJson([statement], "sqlite")[0];
|
|
52647
52756
|
statementsToExecute.push(stmnt);
|
|
52648
52757
|
}
|
|
52649
52758
|
}
|
|
52650
52759
|
} else if (statement.type === "sqlite_alter_table_add_column") {
|
|
52760
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
52651
52761
|
if (statement.column.notNull && !statement.column.default) {
|
|
52652
52762
|
const res = await connection.query(
|
|
52653
|
-
`select count(*) as count from \`${
|
|
52763
|
+
`select count(*) as count from \`${newTableName}\``
|
|
52654
52764
|
);
|
|
52655
52765
|
const count = Number(res[0].count);
|
|
52656
52766
|
if (count > 0) {
|
|
@@ -52659,19 +52769,19 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52659
52769
|
statement.column.name
|
|
52660
52770
|
)} column without default value, which contains ${count} items`
|
|
52661
52771
|
);
|
|
52662
|
-
tablesToTruncate.push(
|
|
52663
|
-
statementsToExecute.push(`delete from ${
|
|
52772
|
+
tablesToTruncate.push(newTableName);
|
|
52773
|
+
statementsToExecute.push(`delete from ${newTableName};`);
|
|
52664
52774
|
shouldAskForApprove = true;
|
|
52665
52775
|
}
|
|
52666
52776
|
}
|
|
52667
52777
|
if (statement.column.primaryKey) {
|
|
52668
|
-
tablesContext[
|
|
52778
|
+
tablesContext[newTableName] = [
|
|
52669
52779
|
..._moveDataStatements(statement.tableName, json2, true)
|
|
52670
52780
|
];
|
|
52671
52781
|
const tablesReferncingCurrent = [];
|
|
52672
52782
|
for (const table4 of Object.values(json1.tables)) {
|
|
52673
52783
|
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
|
52674
|
-
(t) => SQLiteSquasher.unsquashFK(t).tableTo ===
|
|
52784
|
+
(t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
|
|
52675
52785
|
).map((t) => SQLiteSquasher.unsquashFK(t).tableFrom);
|
|
52676
52786
|
tablesReferncingCurrent.push(...tablesRefs);
|
|
52677
52787
|
}
|
|
@@ -52682,15 +52792,16 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52682
52792
|
}
|
|
52683
52793
|
}
|
|
52684
52794
|
} else {
|
|
52685
|
-
if (typeof tablesContext[
|
|
52795
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
52686
52796
|
const stmnt = fromJson([statement], "sqlite")[0];
|
|
52687
52797
|
statementsToExecute.push(stmnt);
|
|
52688
52798
|
}
|
|
52689
52799
|
}
|
|
52690
52800
|
} else if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk") {
|
|
52801
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
52691
52802
|
if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
|
|
52692
52803
|
const res = await connection.query(
|
|
52693
|
-
`select count(*) as count from \`${
|
|
52804
|
+
`select count(*) as count from \`${newTableName}\``
|
|
52694
52805
|
);
|
|
52695
52806
|
const count = Number(res[0].count);
|
|
52696
52807
|
if (count > 0) {
|
|
@@ -52699,17 +52810,17 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52699
52810
|
statement.columnName
|
|
52700
52811
|
)} column without default value, which contains ${count} items`
|
|
52701
52812
|
);
|
|
52702
|
-
|
|
52703
|
-
statement.tableName,
|
|
52704
|
-
json2,
|
|
52705
|
-
true
|
|
52706
|
-
);
|
|
52707
|
-
tablesToTruncate.push(statement.tableName);
|
|
52813
|
+
tablesToTruncate.push(newTableName);
|
|
52708
52814
|
shouldAskForApprove = true;
|
|
52709
52815
|
}
|
|
52816
|
+
tablesContext[newTableName] = _moveDataStatements(
|
|
52817
|
+
statement.tableName,
|
|
52818
|
+
json2,
|
|
52819
|
+
true
|
|
52820
|
+
);
|
|
52710
52821
|
} else {
|
|
52711
|
-
if (typeof tablesContext[
|
|
52712
|
-
tablesContext[
|
|
52822
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
52823
|
+
tablesContext[newTableName] = _moveDataStatements(
|
|
52713
52824
|
statement.tableName,
|
|
52714
52825
|
json2
|
|
52715
52826
|
);
|
|
@@ -52717,9 +52828,12 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52717
52828
|
}
|
|
52718
52829
|
const tablesReferncingCurrent = [];
|
|
52719
52830
|
for (const table4 of Object.values(json1.tables)) {
|
|
52720
|
-
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
|
52721
|
-
|
|
52722
|
-
|
|
52831
|
+
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter((t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName).map((t) => {
|
|
52832
|
+
return getNewTableName(
|
|
52833
|
+
SQLiteSquasher.unsquashFK(t).tableFrom,
|
|
52834
|
+
meta
|
|
52835
|
+
);
|
|
52836
|
+
});
|
|
52723
52837
|
tablesReferncingCurrent.push(...tablesRefs);
|
|
52724
52838
|
}
|
|
52725
52839
|
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
|
@@ -52730,16 +52844,20 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
52730
52844
|
}
|
|
52731
52845
|
} else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
|
|
52732
52846
|
const fk4 = SQLiteSquasher.unsquashFK(statement.data);
|
|
52733
|
-
if (typeof tablesContext[fk4.tableFrom] === "undefined") {
|
|
52734
|
-
tablesContext[fk4.tableFrom] = _moveDataStatements(fk4.tableFrom, json2);
|
|
52735
|
-
}
|
|
52736
|
-
} else if (statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
|
|
52737
52847
|
if (typeof tablesContext[statement.tableName] === "undefined") {
|
|
52738
52848
|
tablesContext[statement.tableName] = _moveDataStatements(
|
|
52739
52849
|
statement.tableName,
|
|
52740
52850
|
json2
|
|
52741
52851
|
);
|
|
52742
52852
|
}
|
|
52853
|
+
} else if (statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
|
|
52854
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
52855
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
52856
|
+
tablesContext[newTableName] = _moveDataStatements(
|
|
52857
|
+
statement.tableName,
|
|
52858
|
+
json2
|
|
52859
|
+
);
|
|
52860
|
+
}
|
|
52743
52861
|
} else {
|
|
52744
52862
|
const stmnt = fromJson([statement], "sqlite")[0];
|
|
52745
52863
|
if (typeof stmnt !== "undefined") {
|
|
@@ -53012,7 +53130,7 @@ var optionsSchema = objectType({
|
|
|
53012
53130
|
}).strict();
|
|
53013
53131
|
var generatePgCommand = new import_commander.Command("generate:pg").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
|
|
53014
53132
|
"--config <config>",
|
|
53015
|
-
"Path to a config.json file, drizzle.config.
|
|
53133
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53016
53134
|
).action(async (options) => {
|
|
53017
53135
|
await printVersions();
|
|
53018
53136
|
await assertOrmCoreVersion();
|
|
@@ -53033,7 +53151,7 @@ var generatePgCommand = new import_commander.Command("generate:pg").option("--sc
|
|
|
53033
53151
|
});
|
|
53034
53152
|
var generateMysqlCommand = new import_commander.Command("generate:mysql").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
|
|
53035
53153
|
"--config <config>",
|
|
53036
|
-
"Path to a config.json file, drizzle.config.
|
|
53154
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53037
53155
|
).action(async (options) => {
|
|
53038
53156
|
await printVersions();
|
|
53039
53157
|
await assertOrmCoreVersion();
|
|
@@ -53081,7 +53199,7 @@ var Select = class extends import_hanji10.Prompt {
|
|
|
53081
53199
|
};
|
|
53082
53200
|
var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
53083
53201
|
"--config <config>",
|
|
53084
|
-
"Path to a config.json file, drizzle.config.
|
|
53202
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53085
53203
|
).option("--schema <schema...>", "Path to a schema file or folder").option("--tablesFilter", `Table name filters`).option("--connectionString <connectionString>", "MySQL connection string").option("--driver <driver>", "MySQL database path").option("--connectionString <connectionString>", "MySQL connection string").option("--host <host>", "MySQL host").option("--port <port>", "MySQL port").option("--user <user>", "MySQL user").option("--password <password>", "MySQL password").option("--database <database>", "MySQL database name").option("--verbose", "Print all statements for each push").option("--strict", "Always ask for confirmation").action(async (options) => {
|
|
53086
53204
|
await printVersions();
|
|
53087
53205
|
await assertPackages("drizzle-orm");
|
|
@@ -53339,7 +53457,8 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
53339
53457
|
connection: connection.client,
|
|
53340
53458
|
statements: statements.statements,
|
|
53341
53459
|
json1: statements.squashedPrev,
|
|
53342
|
-
json2: statements.squashedCur
|
|
53460
|
+
json2: statements.squashedCur,
|
|
53461
|
+
meta: statements.meta
|
|
53343
53462
|
});
|
|
53344
53463
|
if (res.verbose) {
|
|
53345
53464
|
console.log();
|
|
@@ -53394,7 +53513,7 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
53394
53513
|
});
|
|
53395
53514
|
var generateSqliteCommand = new import_commander.Command("generate:sqlite").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
|
|
53396
53515
|
"--config <config>",
|
|
53397
|
-
"Path to a config.json file, drizzle.config.
|
|
53516
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53398
53517
|
).action(async (options) => {
|
|
53399
53518
|
await printVersions();
|
|
53400
53519
|
await assertOrmCoreVersion();
|
|
@@ -53417,7 +53536,7 @@ var checkSchema = objectType({
|
|
|
53417
53536
|
out: stringType().optional(),
|
|
53418
53537
|
config: stringType().optional()
|
|
53419
53538
|
}).strict();
|
|
53420
|
-
var checkPgCommand = new import_commander.Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53539
|
+
var checkPgCommand = new import_commander.Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53421
53540
|
await printVersions();
|
|
53422
53541
|
await assertOrmCoreVersion();
|
|
53423
53542
|
const collisionRes = checkCollisions(
|
|
@@ -53433,7 +53552,7 @@ var checkPgCommand = new import_commander.Command("check:pg").option("--out <out
|
|
|
53433
53552
|
checkHandler(out, "pg");
|
|
53434
53553
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
53435
53554
|
});
|
|
53436
|
-
var checkSqliteCommand = new import_commander.Command("check:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53555
|
+
var checkSqliteCommand = new import_commander.Command("check:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53437
53556
|
await printVersions();
|
|
53438
53557
|
await assertOrmCoreVersion();
|
|
53439
53558
|
const collisionRes = checkCollisions(
|
|
@@ -53449,7 +53568,7 @@ var checkSqliteCommand = new import_commander.Command("check:sqlite").option("--
|
|
|
53449
53568
|
checkHandler(out, "sqlite");
|
|
53450
53569
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
53451
53570
|
});
|
|
53452
|
-
var checkMySqlCommand = new import_commander.Command("check:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53571
|
+
var checkMySqlCommand = new import_commander.Command("check:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53453
53572
|
await printVersions();
|
|
53454
53573
|
await assertOrmCoreVersion();
|
|
53455
53574
|
const collisionRes = checkCollisions(
|
|
@@ -53465,7 +53584,7 @@ var checkMySqlCommand = new import_commander.Command("check:mysql").option("--ou
|
|
|
53465
53584
|
checkHandler(out, "mysql");
|
|
53466
53585
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
53467
53586
|
});
|
|
53468
|
-
var upPgCommand = new import_commander.Command("up:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53587
|
+
var upPgCommand = new import_commander.Command("up:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53469
53588
|
await printVersions();
|
|
53470
53589
|
await assertOrmCoreVersion();
|
|
53471
53590
|
const collisionRes = checkCollisions(
|
|
@@ -53483,7 +53602,7 @@ var upPgCommand = new import_commander.Command("up:pg").option("--out <out>", `O
|
|
|
53483
53602
|
upgradeFolders("pg", out);
|
|
53484
53603
|
upPgHandler(out);
|
|
53485
53604
|
});
|
|
53486
|
-
var upMysqlCommand = new import_commander.Command("up:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53605
|
+
var upMysqlCommand = new import_commander.Command("up:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53487
53606
|
await printVersions();
|
|
53488
53607
|
await assertOrmCoreVersion();
|
|
53489
53608
|
const collisionRes = checkCollisions(
|
|
@@ -53573,7 +53692,7 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
|
|
|
53573
53692
|
});
|
|
53574
53693
|
var introspectMySqlCommand = new import_commander.Command("introspect:mysql").option(
|
|
53575
53694
|
"--config <config>",
|
|
53576
|
-
"Path to a config.json file, drizzle.config.
|
|
53695
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53577
53696
|
).option(
|
|
53578
53697
|
"--introspect-casing <introspectCasing>",
|
|
53579
53698
|
"Column object keys naming strategy"
|
|
@@ -53626,7 +53745,7 @@ var introspectMySqlCommand = new import_commander.Command("introspect:mysql").op
|
|
|
53626
53745
|
});
|
|
53627
53746
|
var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").option(
|
|
53628
53747
|
"--config <config>",
|
|
53629
|
-
"Path to a config.json file, drizzle.config.
|
|
53748
|
+
"Path to a config.json file, drizzle.config.ts by default"
|
|
53630
53749
|
).option(
|
|
53631
53750
|
"--introspect-casing <introspectCasing>",
|
|
53632
53751
|
"Column object keys naming strategy"
|
|
@@ -53677,7 +53796,7 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
|
|
|
53677
53796
|
);
|
|
53678
53797
|
process.exit(0);
|
|
53679
53798
|
});
|
|
53680
|
-
var dropCommand = new import_commander.Command("drop").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.
|
|
53799
|
+
var dropCommand = new import_commander.Command("drop").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53681
53800
|
await printVersions();
|
|
53682
53801
|
await assertOrmCoreVersion();
|
|
53683
53802
|
const collisionRes = checkCollisions(
|
|
@@ -53693,7 +53812,7 @@ var dropCommand = new import_commander.Command("drop").option("--out <out>", `Ou
|
|
|
53693
53812
|
assertV1OutFolder(out, "{dialect}");
|
|
53694
53813
|
await dropMigration(out);
|
|
53695
53814
|
});
|
|
53696
|
-
var studioCommand = new import_commander.Command("studio").option("--port <port>", "Custom port for drizzle studio [default=4983]").option("--verbose", "Print all stataments that are executed by Studio").option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53815
|
+
var studioCommand = new import_commander.Command("studio").option("--port <port>", "Custom port for drizzle studio [default=4983]").option("--host <host>", "Custom host for drizzle studio [default=0.0.0.0]").option("--verbose", "Print all stataments that are executed by Studio").option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
53697
53816
|
const { validateStudio: validateStudio2 } = await Promise.resolve().then(() => (init_studio(), studio_exports));
|
|
53698
53817
|
const drizzleConfig = await validateStudio2(options);
|
|
53699
53818
|
const { prepareModels: prepareModels2, drizzleDb: drizzleDb2 } = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
|
|
@@ -53705,6 +53824,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
|
53705
53824
|
);
|
|
53706
53825
|
const server = await (0, import_studio.prepareServer)(setup);
|
|
53707
53826
|
const port = options.port ?? 4983;
|
|
53827
|
+
const host = options.host ?? "0.0.0.0";
|
|
53708
53828
|
console.log();
|
|
53709
53829
|
console.log(
|
|
53710
53830
|
withStyle.fullWarning(
|
|
@@ -53712,7 +53832,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
|
53712
53832
|
)
|
|
53713
53833
|
);
|
|
53714
53834
|
server.start({
|
|
53715
|
-
host
|
|
53835
|
+
host,
|
|
53716
53836
|
port,
|
|
53717
53837
|
cb: (err2, address) => {
|
|
53718
53838
|
if (err2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.13-53915b2",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@drizzle-team/studio": "^0.0.
|
|
56
|
+
"@drizzle-team/studio": "^0.0.8",
|
|
57
57
|
"@esbuild-kit/esm-loader": "^2.5.5",
|
|
58
58
|
"camelcase": "^7.0.1",
|
|
59
59
|
"chalk": "^5.2.0",
|
package/utils.js
CHANGED
|
@@ -13068,6 +13068,21 @@ var pgSchemaExternal = objectType({
|
|
|
13068
13068
|
columns: recordType(stringType(), stringType())
|
|
13069
13069
|
})
|
|
13070
13070
|
}).strict();
|
|
13071
|
+
var kitInternals2 = objectType({
|
|
13072
|
+
tables: recordType(
|
|
13073
|
+
stringType(),
|
|
13074
|
+
objectType({
|
|
13075
|
+
columns: recordType(
|
|
13076
|
+
stringType(),
|
|
13077
|
+
objectType({
|
|
13078
|
+
isArray: booleanType().optional(),
|
|
13079
|
+
dimensions: numberType().optional(),
|
|
13080
|
+
rawType: stringType().optional()
|
|
13081
|
+
}).optional()
|
|
13082
|
+
)
|
|
13083
|
+
}).optional()
|
|
13084
|
+
)
|
|
13085
|
+
}).optional();
|
|
13071
13086
|
var pgSchemaInternal = objectType({
|
|
13072
13087
|
version: literalType("5"),
|
|
13073
13088
|
dialect: literalType("pg"),
|
|
@@ -13078,7 +13093,8 @@ var pgSchemaInternal = objectType({
|
|
|
13078
13093
|
schemas: recordType(stringType(), stringType()),
|
|
13079
13094
|
tables: recordType(stringType(), stringType()),
|
|
13080
13095
|
columns: recordType(stringType(), stringType())
|
|
13081
|
-
})
|
|
13096
|
+
}),
|
|
13097
|
+
internal: kitInternals2
|
|
13082
13098
|
}).strict();
|
|
13083
13099
|
var tableSquashed2 = objectType({
|
|
13084
13100
|
name: stringType(),
|
|
@@ -13147,12 +13163,12 @@ var PgSquasher = {
|
|
|
13147
13163
|
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
|
13148
13164
|
},
|
|
13149
13165
|
unsquashUnique: (unq) => {
|
|
13150
|
-
const [
|
|
13166
|
+
const [name, columns, nullsNotDistinct] = unq.split(";");
|
|
13167
|
+
return {
|
|
13151
13168
|
name,
|
|
13152
|
-
columns,
|
|
13153
|
-
nullsNotDistinct
|
|
13154
|
-
|
|
13155
|
-
return { name, columns: columns.split(","), nullsNotDistinct: nullsNotDistinct === "true" };
|
|
13169
|
+
columns: columns.split(","),
|
|
13170
|
+
nullsNotDistinct: nullsNotDistinct === "true"
|
|
13171
|
+
};
|
|
13156
13172
|
},
|
|
13157
13173
|
unsquashFK: (input) => {
|
|
13158
13174
|
const [
|
|
@@ -13188,9 +13204,12 @@ var squashPgScheme = (json) => {
|
|
|
13188
13204
|
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
|
13189
13205
|
return PgSquasher.squashPK(pk);
|
|
13190
13206
|
});
|
|
13191
|
-
const squashedUniqueConstraints = mapValues(
|
|
13192
|
-
|
|
13193
|
-
|
|
13207
|
+
const squashedUniqueConstraints = mapValues(
|
|
13208
|
+
it[1].uniqueConstraints,
|
|
13209
|
+
(unq) => {
|
|
13210
|
+
return PgSquasher.squashUnique(unq);
|
|
13211
|
+
}
|
|
13212
|
+
);
|
|
13194
13213
|
return [
|
|
13195
13214
|
it[0],
|
|
13196
13215
|
{
|
|
@@ -16089,12 +16108,12 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
|
16089
16108
|
});
|
|
16090
16109
|
jsonStatements.push(...jsonMySqlCreateTables);
|
|
16091
16110
|
}
|
|
16092
|
-
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
|
16093
16111
|
jsonStatements.push(...jsonDropTables);
|
|
16094
16112
|
jsonStatements.push(...jsonRenameTables);
|
|
16095
16113
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
|
16096
16114
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
|
16097
16115
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
|
16116
|
+
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
|
16098
16117
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
|
16099
16118
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
|
16100
16119
|
jsonStatements.push(...jsonTableAlternations.createColumns);
|