drizzle-kit 0.16.9-9e3ed6f → 0.16.9-a7718d6
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.js +2419 -395
- package/package.json +4 -2
package/index.js
CHANGED
|
@@ -613,7 +613,7 @@ var require_command = __commonJS({
|
|
|
613
613
|
"node_modules/.pnpm/commander@9.5.0/node_modules/commander/lib/command.js"(exports) {
|
|
614
614
|
var EventEmitter = require("events").EventEmitter;
|
|
615
615
|
var childProcess = require("child_process");
|
|
616
|
-
var
|
|
616
|
+
var path4 = require("path");
|
|
617
617
|
var fs7 = require("fs");
|
|
618
618
|
var process3 = require("process");
|
|
619
619
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1053,10 +1053,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1053
1053
|
let launchWithNode = false;
|
|
1054
1054
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1055
1055
|
function findFile(baseDir, baseName) {
|
|
1056
|
-
const localBin =
|
|
1056
|
+
const localBin = path4.resolve(baseDir, baseName);
|
|
1057
1057
|
if (fs7.existsSync(localBin))
|
|
1058
1058
|
return localBin;
|
|
1059
|
-
if (sourceExt.includes(
|
|
1059
|
+
if (sourceExt.includes(path4.extname(baseName)))
|
|
1060
1060
|
return void 0;
|
|
1061
1061
|
const foundExt = sourceExt.find((ext) => fs7.existsSync(`${localBin}${ext}`));
|
|
1062
1062
|
if (foundExt)
|
|
@@ -1074,19 +1074,19 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1074
1074
|
} catch (err2) {
|
|
1075
1075
|
resolvedScriptPath = this._scriptPath;
|
|
1076
1076
|
}
|
|
1077
|
-
executableDir =
|
|
1077
|
+
executableDir = path4.resolve(path4.dirname(resolvedScriptPath), executableDir);
|
|
1078
1078
|
}
|
|
1079
1079
|
if (executableDir) {
|
|
1080
1080
|
let localFile = findFile(executableDir, executableFile);
|
|
1081
1081
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1082
|
-
const legacyName =
|
|
1082
|
+
const legacyName = path4.basename(this._scriptPath, path4.extname(this._scriptPath));
|
|
1083
1083
|
if (legacyName !== this._name) {
|
|
1084
1084
|
localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
1087
|
executableFile = localFile || executableFile;
|
|
1088
1088
|
}
|
|
1089
|
-
launchWithNode = sourceExt.includes(
|
|
1089
|
+
launchWithNode = sourceExt.includes(path4.extname(executableFile));
|
|
1090
1090
|
let proc;
|
|
1091
1091
|
if (process3.platform !== "win32") {
|
|
1092
1092
|
if (launchWithNode) {
|
|
@@ -1658,13 +1658,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1658
1658
|
return this;
|
|
1659
1659
|
}
|
|
1660
1660
|
nameFromFilename(filename) {
|
|
1661
|
-
this._name =
|
|
1661
|
+
this._name = path4.basename(filename, path4.extname(filename));
|
|
1662
1662
|
return this;
|
|
1663
1663
|
}
|
|
1664
|
-
executableDir(
|
|
1665
|
-
if (
|
|
1664
|
+
executableDir(path5) {
|
|
1665
|
+
if (path5 === void 0)
|
|
1666
1666
|
return this._executableDir;
|
|
1667
|
-
this._executableDir =
|
|
1667
|
+
this._executableDir = path5;
|
|
1668
1668
|
return this;
|
|
1669
1669
|
}
|
|
1670
1670
|
helpInformation(contextOptions) {
|
|
@@ -2252,8 +2252,8 @@ var init_lib = __esm({
|
|
|
2252
2252
|
};
|
|
2253
2253
|
overrideErrorMap = errorMap;
|
|
2254
2254
|
makeIssue = (params) => {
|
|
2255
|
-
const { data, path:
|
|
2256
|
-
const fullPath = [...
|
|
2255
|
+
const { data, path: path4, errorMaps, issueData } = params;
|
|
2256
|
+
const fullPath = [...path4, ...issueData.path || []];
|
|
2257
2257
|
const fullIssue = {
|
|
2258
2258
|
...issueData,
|
|
2259
2259
|
path: fullPath
|
|
@@ -2335,10 +2335,10 @@ var init_lib = __esm({
|
|
|
2335
2335
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
2336
2336
|
})(errorUtil || (errorUtil = {}));
|
|
2337
2337
|
ParseInputLazyPath = class {
|
|
2338
|
-
constructor(parent, value,
|
|
2338
|
+
constructor(parent, value, path4, key) {
|
|
2339
2339
|
this.parent = parent;
|
|
2340
2340
|
this.data = value;
|
|
2341
|
-
this._path =
|
|
2341
|
+
this._path = path4;
|
|
2342
2342
|
this._key = key;
|
|
2343
2343
|
}
|
|
2344
2344
|
get path() {
|
|
@@ -6232,29 +6232,30 @@ Is ${source_default.bold.blue(
|
|
|
6232
6232
|
this.requestLayout();
|
|
6233
6233
|
}
|
|
6234
6234
|
render() {
|
|
6235
|
-
let
|
|
6235
|
+
let info2 = "";
|
|
6236
6236
|
const spin = this.spinner.value();
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
return
|
|
6237
|
+
info2 += this.statusText(spin, this.state.tables);
|
|
6238
|
+
info2 += this.statusText(spin, this.state.columns);
|
|
6239
|
+
info2 += this.statusText(spin, this.state.enums);
|
|
6240
|
+
info2 += this.statusText(spin, this.state.indexes);
|
|
6241
|
+
info2 += this.statusText(spin, this.state.fks);
|
|
6242
|
+
return info2;
|
|
6243
6243
|
}
|
|
6244
6244
|
};
|
|
6245
6245
|
}
|
|
6246
6246
|
});
|
|
6247
6247
|
|
|
6248
6248
|
// src/global.ts
|
|
6249
|
-
var originUUID;
|
|
6249
|
+
var originUUID, snapshotVersion;
|
|
6250
6250
|
var init_global = __esm({
|
|
6251
6251
|
"src/global.ts"() {
|
|
6252
6252
|
originUUID = "00000000-0000-0000-0000-000000000000";
|
|
6253
|
+
snapshotVersion = "5";
|
|
6253
6254
|
}
|
|
6254
6255
|
});
|
|
6255
6256
|
|
|
6256
6257
|
// src/serializer/mysqlSchema.ts
|
|
6257
|
-
var index, fk, column, tableV3, table, dialect, schemaHash, schemaInternalV3, schemaInternal, schemaV3, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
|
|
6258
|
+
var index, fk, column, tableV3, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV4, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
|
|
6258
6259
|
var init_mysqlSchema = __esm({
|
|
6259
6260
|
"src/serializer/mysqlSchema.ts"() {
|
|
6260
6261
|
init_global();
|
|
@@ -6298,7 +6299,7 @@ var init_mysqlSchema = __esm({
|
|
|
6298
6299
|
indexes: recordType(stringType(), index),
|
|
6299
6300
|
foreignKeys: recordType(stringType(), fk)
|
|
6300
6301
|
}).strict();
|
|
6301
|
-
dialect =
|
|
6302
|
+
dialect = literalType("mysql");
|
|
6302
6303
|
schemaHash = objectType({
|
|
6303
6304
|
id: stringType(),
|
|
6304
6305
|
prevId: stringType()
|
|
@@ -6308,13 +6309,25 @@ var init_mysqlSchema = __esm({
|
|
|
6308
6309
|
dialect,
|
|
6309
6310
|
tables: recordType(stringType(), tableV3)
|
|
6310
6311
|
}).strict();
|
|
6311
|
-
|
|
6312
|
+
schemaInternalV4 = objectType({
|
|
6312
6313
|
version: literalType("4"),
|
|
6313
6314
|
dialect,
|
|
6314
6315
|
tables: recordType(stringType(), table),
|
|
6315
6316
|
schemas: recordType(stringType(), stringType())
|
|
6316
6317
|
}).strict();
|
|
6318
|
+
schemaInternal = objectType({
|
|
6319
|
+
version: literalType("5"),
|
|
6320
|
+
dialect,
|
|
6321
|
+
tables: recordType(stringType(), table),
|
|
6322
|
+
schemas: recordType(stringType(), stringType()),
|
|
6323
|
+
_meta: objectType({
|
|
6324
|
+
schemas: recordType(stringType(), stringType()),
|
|
6325
|
+
tables: recordType(stringType(), stringType()),
|
|
6326
|
+
columns: recordType(stringType(), stringType())
|
|
6327
|
+
})
|
|
6328
|
+
}).strict();
|
|
6317
6329
|
schemaV3 = schemaInternalV3.merge(schemaHash);
|
|
6330
|
+
schemaV4 = schemaInternalV4.merge(schemaHash);
|
|
6318
6331
|
schema2 = schemaInternal.merge(schemaHash);
|
|
6319
6332
|
tableSquashed = objectType({
|
|
6320
6333
|
name: stringType(),
|
|
@@ -6324,7 +6337,7 @@ var init_mysqlSchema = __esm({
|
|
|
6324
6337
|
foreignKeys: recordType(stringType(), stringType())
|
|
6325
6338
|
}).strict();
|
|
6326
6339
|
schemaSquashed = objectType({
|
|
6327
|
-
version: literalType("
|
|
6340
|
+
version: literalType("5"),
|
|
6328
6341
|
dialect,
|
|
6329
6342
|
tables: recordType(stringType(), tableSquashed),
|
|
6330
6343
|
schemas: recordType(stringType(), stringType())
|
|
@@ -6395,28 +6408,34 @@ var init_mysqlSchema = __esm({
|
|
|
6395
6408
|
})
|
|
6396
6409
|
);
|
|
6397
6410
|
return {
|
|
6398
|
-
version:
|
|
6411
|
+
version: "5",
|
|
6399
6412
|
dialect: json.dialect,
|
|
6400
6413
|
tables: mappedTables,
|
|
6401
6414
|
schemas: json.schemas
|
|
6402
6415
|
};
|
|
6403
6416
|
};
|
|
6404
6417
|
mysqlSchema = schema2;
|
|
6418
|
+
mysqlSchemaV4 = schemaV4;
|
|
6405
6419
|
mysqlSchemaV3 = schemaV3;
|
|
6406
|
-
backwardCompatibleMysqlSchema = unionType([schemaV3, schema2]);
|
|
6420
|
+
backwardCompatibleMysqlSchema = unionType([schemaV3, schemaV4, schema2]);
|
|
6407
6421
|
dryMySql = mysqlSchema.parse({
|
|
6408
|
-
version:
|
|
6422
|
+
version: snapshotVersion,
|
|
6409
6423
|
dialect: "mysql",
|
|
6410
6424
|
id: originUUID,
|
|
6411
6425
|
prevId: "",
|
|
6412
6426
|
tables: {},
|
|
6413
|
-
schemas: {}
|
|
6427
|
+
schemas: {},
|
|
6428
|
+
_meta: {
|
|
6429
|
+
schemas: {},
|
|
6430
|
+
tables: {},
|
|
6431
|
+
columns: {}
|
|
6432
|
+
}
|
|
6414
6433
|
});
|
|
6415
6434
|
}
|
|
6416
6435
|
});
|
|
6417
6436
|
|
|
6418
6437
|
// src/serializer/pgSchema.ts
|
|
6419
|
-
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternal, tableSquashed2, pgSchemaSquashed, pgSchemaV3, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
|
6438
|
+
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternal, tableSquashed2, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
|
6420
6439
|
var init_pgSchema = __esm({
|
|
6421
6440
|
"src/serializer/pgSchema.ts"() {
|
|
6422
6441
|
init_global();
|
|
@@ -6519,17 +6538,29 @@ var init_pgSchema = __esm({
|
|
|
6519
6538
|
});
|
|
6520
6539
|
pgSchemaInternalV3 = objectType({
|
|
6521
6540
|
version: literalType("3"),
|
|
6522
|
-
dialect:
|
|
6541
|
+
dialect: literalType("pg"),
|
|
6523
6542
|
tables: recordType(stringType(), tableV32),
|
|
6524
6543
|
enums: recordType(stringType(), enumSchema)
|
|
6525
6544
|
}).strict();
|
|
6526
|
-
|
|
6545
|
+
pgSchemaInternalV4 = objectType({
|
|
6527
6546
|
version: literalType("4"),
|
|
6528
|
-
dialect:
|
|
6547
|
+
dialect: literalType("pg"),
|
|
6529
6548
|
tables: recordType(stringType(), table2),
|
|
6530
6549
|
enums: recordType(stringType(), enumSchema),
|
|
6531
6550
|
schemas: recordType(stringType(), stringType())
|
|
6532
6551
|
}).strict();
|
|
6552
|
+
pgSchemaInternal = objectType({
|
|
6553
|
+
version: literalType("5"),
|
|
6554
|
+
dialect: literalType("pg"),
|
|
6555
|
+
tables: recordType(stringType(), table2),
|
|
6556
|
+
enums: recordType(stringType(), enumSchema),
|
|
6557
|
+
schemas: recordType(stringType(), stringType()),
|
|
6558
|
+
_meta: objectType({
|
|
6559
|
+
schemas: recordType(stringType(), stringType()),
|
|
6560
|
+
tables: recordType(stringType(), stringType()),
|
|
6561
|
+
columns: recordType(stringType(), stringType())
|
|
6562
|
+
})
|
|
6563
|
+
}).strict();
|
|
6533
6564
|
tableSquashed2 = objectType({
|
|
6534
6565
|
name: stringType(),
|
|
6535
6566
|
schema: stringType(),
|
|
@@ -6538,18 +6569,20 @@ var init_pgSchema = __esm({
|
|
|
6538
6569
|
foreignKeys: recordType(stringType(), stringType())
|
|
6539
6570
|
}).strict();
|
|
6540
6571
|
pgSchemaSquashed = objectType({
|
|
6541
|
-
version: literalType("
|
|
6572
|
+
version: literalType("5"),
|
|
6542
6573
|
dialect: enumType(["pg"]),
|
|
6543
6574
|
tables: recordType(stringType(), tableSquashed2),
|
|
6544
6575
|
enums: recordType(stringType(), enumSchema),
|
|
6545
6576
|
schemas: recordType(stringType(), stringType())
|
|
6546
6577
|
}).strict();
|
|
6547
6578
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
|
6579
|
+
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
|
6548
6580
|
pgSchema = pgSchemaInternal.merge(schemaHash2);
|
|
6549
6581
|
backwardCompatiblePgSchema = unionType([
|
|
6550
6582
|
pgSchemaV1,
|
|
6551
6583
|
pgSchemaV2,
|
|
6552
6584
|
pgSchemaV3,
|
|
6585
|
+
pgSchemaV4,
|
|
6553
6586
|
pgSchema
|
|
6554
6587
|
]);
|
|
6555
6588
|
PgSquasher = {
|
|
@@ -6614,7 +6647,7 @@ var init_pgSchema = __esm({
|
|
|
6614
6647
|
})
|
|
6615
6648
|
);
|
|
6616
6649
|
return {
|
|
6617
|
-
version:
|
|
6650
|
+
version: "5",
|
|
6618
6651
|
dialect: json.dialect,
|
|
6619
6652
|
tables: mappedTables,
|
|
6620
6653
|
enums: json.enums,
|
|
@@ -6622,19 +6655,24 @@ var init_pgSchema = __esm({
|
|
|
6622
6655
|
};
|
|
6623
6656
|
};
|
|
6624
6657
|
dryPg = pgSchema.parse({
|
|
6625
|
-
version:
|
|
6658
|
+
version: snapshotVersion,
|
|
6626
6659
|
dialect: "pg",
|
|
6627
6660
|
id: originUUID,
|
|
6628
6661
|
prevId: "",
|
|
6629
6662
|
tables: {},
|
|
6630
6663
|
enums: {},
|
|
6631
|
-
schemas: {}
|
|
6664
|
+
schemas: {},
|
|
6665
|
+
_meta: {
|
|
6666
|
+
schemas: {},
|
|
6667
|
+
tables: {},
|
|
6668
|
+
columns: {}
|
|
6669
|
+
}
|
|
6632
6670
|
});
|
|
6633
6671
|
}
|
|
6634
6672
|
});
|
|
6635
6673
|
|
|
6636
6674
|
// src/serializer/sqliteSchema.ts
|
|
6637
|
-
var index3, fk3, compositePK, column3, tableV33, table3, dialect2, schemaHash3, schemaInternalV32, latestVersion, schemaInternal2, schemaV32, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV3, sqliteSchema, backwardCompatibleSqliteSchema;
|
|
6675
|
+
var index3, fk3, compositePK, column3, tableV33, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV3, sqliteSchemaV4, sqliteSchema, backwardCompatibleSqliteSchema;
|
|
6638
6676
|
var init_sqliteSchema = __esm({
|
|
6639
6677
|
"src/serializer/sqliteSchema.ts"() {
|
|
6640
6678
|
init_global();
|
|
@@ -6690,14 +6728,25 @@ var init_sqliteSchema = __esm({
|
|
|
6690
6728
|
tables: recordType(stringType(), tableV33),
|
|
6691
6729
|
enums: objectType({})
|
|
6692
6730
|
}).strict();
|
|
6693
|
-
|
|
6731
|
+
schemaInternalV42 = objectType({
|
|
6732
|
+
version: literalType("4"),
|
|
6733
|
+
dialect: dialect2,
|
|
6734
|
+
tables: recordType(stringType(), table3),
|
|
6735
|
+
enums: objectType({})
|
|
6736
|
+
}).strict();
|
|
6737
|
+
latestVersion = literalType("5");
|
|
6694
6738
|
schemaInternal2 = objectType({
|
|
6695
6739
|
version: latestVersion,
|
|
6696
6740
|
dialect: dialect2,
|
|
6697
6741
|
tables: recordType(stringType(), table3),
|
|
6698
|
-
enums: objectType({})
|
|
6742
|
+
enums: objectType({}),
|
|
6743
|
+
_meta: objectType({
|
|
6744
|
+
tables: recordType(stringType(), stringType()),
|
|
6745
|
+
columns: recordType(stringType(), stringType())
|
|
6746
|
+
})
|
|
6699
6747
|
}).strict();
|
|
6700
6748
|
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
|
6749
|
+
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
|
6701
6750
|
schema3 = schemaInternal2.merge(schemaHash3).strict();
|
|
6702
6751
|
tableSquashed3 = objectType({
|
|
6703
6752
|
name: stringType(),
|
|
@@ -6792,21 +6841,26 @@ var init_sqliteSchema = __esm({
|
|
|
6792
6841
|
};
|
|
6793
6842
|
};
|
|
6794
6843
|
drySQLite = schema3.parse({
|
|
6795
|
-
version:
|
|
6844
|
+
version: snapshotVersion,
|
|
6796
6845
|
dialect: "sqlite",
|
|
6797
6846
|
id: originUUID,
|
|
6798
6847
|
prevId: "",
|
|
6799
6848
|
tables: {},
|
|
6800
|
-
enums: {}
|
|
6849
|
+
enums: {},
|
|
6850
|
+
_meta: {
|
|
6851
|
+
tables: {},
|
|
6852
|
+
columns: {}
|
|
6853
|
+
}
|
|
6801
6854
|
});
|
|
6802
6855
|
sqliteSchemaV3 = schemaV32;
|
|
6856
|
+
sqliteSchemaV4 = schemaV42;
|
|
6803
6857
|
sqliteSchema = schema3;
|
|
6804
|
-
backwardCompatibleSqliteSchema = unionType([schemaV32, schema3]);
|
|
6858
|
+
backwardCompatibleSqliteSchema = unionType([schemaV32, schemaV42, schema3]);
|
|
6805
6859
|
}
|
|
6806
6860
|
});
|
|
6807
6861
|
|
|
6808
6862
|
// src/utils.ts
|
|
6809
|
-
var import_fs,
|
|
6863
|
+
var import_fs, import_path, assertV1OutFolder, dryJournal, snapshotsPriorV4, prepareOutFolder, mapValues, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
|
6810
6864
|
var init_utils = __esm({
|
|
6811
6865
|
"src/utils.ts"() {
|
|
6812
6866
|
import_fs = require("fs");
|
|
@@ -6815,16 +6869,54 @@ var init_utils = __esm({
|
|
|
6815
6869
|
init_pgSchema();
|
|
6816
6870
|
init_sqliteSchema();
|
|
6817
6871
|
init_source();
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6872
|
+
import_path = require("path");
|
|
6873
|
+
init_global();
|
|
6874
|
+
assertV1OutFolder = (out, dialect6) => {
|
|
6875
|
+
if (!(0, import_fs.existsSync)(out))
|
|
6876
|
+
return;
|
|
6877
|
+
const oldMigrationFolders = (0, import_fs.readdirSync)(out).filter(
|
|
6878
|
+
(it) => it.length === 14 && /^\d+$/.test(it)
|
|
6879
|
+
);
|
|
6880
|
+
if (oldMigrationFolders.length > 0) {
|
|
6881
|
+
console.log(
|
|
6882
|
+
`Your migrations folder format is outdated, please run ${source_default.green.bold(
|
|
6883
|
+
`drizzle-kit up:${dialect6}`
|
|
6884
|
+
)}`
|
|
6885
|
+
);
|
|
6886
|
+
process.exit(1);
|
|
6822
6887
|
}
|
|
6823
|
-
|
|
6888
|
+
};
|
|
6889
|
+
dryJournal = (dialect6) => {
|
|
6890
|
+
return {
|
|
6891
|
+
version: snapshotVersion,
|
|
6892
|
+
dialect: dialect6,
|
|
6893
|
+
entries: []
|
|
6894
|
+
};
|
|
6895
|
+
};
|
|
6896
|
+
snapshotsPriorV4 = (out) => {
|
|
6897
|
+
const oldMigrationFolders = (0, import_fs.readdirSync)(out).filter(
|
|
6824
6898
|
(it) => it.length === 14 && /^\d+$/.test(it)
|
|
6825
6899
|
);
|
|
6826
|
-
|
|
6827
|
-
return
|
|
6900
|
+
oldMigrationFolders.sort();
|
|
6901
|
+
return oldMigrationFolders.map(
|
|
6902
|
+
(it) => {
|
|
6903
|
+
const pathJson = (0, import_path.join)(out, it, "snapshot.json");
|
|
6904
|
+
console.log(pathJson);
|
|
6905
|
+
return pathJson;
|
|
6906
|
+
}
|
|
6907
|
+
);
|
|
6908
|
+
};
|
|
6909
|
+
prepareOutFolder = (out, dialect6) => {
|
|
6910
|
+
const meta = (0, import_path.join)(out, "meta");
|
|
6911
|
+
const journalPath = (0, import_path.join)(meta, "_journal.json");
|
|
6912
|
+
if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta"))) {
|
|
6913
|
+
(0, import_fs.mkdirSync)(meta, { recursive: true });
|
|
6914
|
+
(0, import_fs.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect6)));
|
|
6915
|
+
}
|
|
6916
|
+
const journal = JSON.parse((0, import_fs.readFileSync)(journalPath).toString());
|
|
6917
|
+
const snapshots = (0, import_fs.readdirSync)(meta).filter((it) => !it.startsWith("_")).map((it) => (0, import_path.join)(meta, it));
|
|
6918
|
+
snapshots.sort();
|
|
6919
|
+
return { meta, snapshots, journal };
|
|
6828
6920
|
};
|
|
6829
6921
|
mapValues = (obj, map) => {
|
|
6830
6922
|
const result = Object.keys(obj).reduce(function(result2, key) {
|
|
@@ -6836,46 +6928,43 @@ var init_utils = __esm({
|
|
|
6836
6928
|
validatorForDialect = (dialect6) => {
|
|
6837
6929
|
switch (dialect6) {
|
|
6838
6930
|
case "pg":
|
|
6839
|
-
return { validator: backwardCompatiblePgSchema, version:
|
|
6931
|
+
return { validator: backwardCompatiblePgSchema, version: 5 };
|
|
6840
6932
|
case "sqlite":
|
|
6841
6933
|
return { validator: backwardCompatibleSqliteSchema, version: 4 };
|
|
6842
6934
|
case "mysql":
|
|
6843
|
-
return { validator: backwardCompatibleMysqlSchema, version:
|
|
6935
|
+
return { validator: backwardCompatibleMysqlSchema, version: 5 };
|
|
6844
6936
|
}
|
|
6845
6937
|
};
|
|
6846
|
-
validateWithReport = (
|
|
6938
|
+
validateWithReport = (snapshots, dialect6) => {
|
|
6847
6939
|
const { validator, version } = validatorForDialect(dialect6);
|
|
6848
|
-
const result =
|
|
6849
|
-
(accum,
|
|
6940
|
+
const result = snapshots.reduce(
|
|
6941
|
+
(accum, it) => {
|
|
6850
6942
|
var _a;
|
|
6851
|
-
const
|
|
6852
|
-
|
|
6853
|
-
(0, import_fs.readFileSync)(`./${root}/${folder}/snapshot.json`).toString()
|
|
6854
|
-
);
|
|
6855
|
-
accum.rawMap[folder] = raw;
|
|
6943
|
+
const raw = JSON.parse((0, import_fs.readFileSync)(`./${it}`).toString());
|
|
6944
|
+
accum.rawMap[it] = raw;
|
|
6856
6945
|
if (raw["version"] && Number(raw["version"]) > version) {
|
|
6857
6946
|
console.log(
|
|
6858
6947
|
info(
|
|
6859
|
-
`${
|
|
6948
|
+
`${it} snapshot is of unsupported version, please update drizzle-kit`
|
|
6860
6949
|
)
|
|
6861
6950
|
);
|
|
6862
6951
|
process.exit(0);
|
|
6863
6952
|
}
|
|
6864
6953
|
const result2 = validator.safeParse(raw);
|
|
6865
6954
|
if (!result2.success) {
|
|
6866
|
-
accum.malformed.push(
|
|
6955
|
+
accum.malformed.push(it);
|
|
6867
6956
|
return accum;
|
|
6868
6957
|
}
|
|
6869
6958
|
const snapshot = result2.data;
|
|
6870
6959
|
if (snapshot.version !== String(version)) {
|
|
6871
|
-
accum.nonLatest.push(
|
|
6960
|
+
accum.nonLatest.push(it);
|
|
6872
6961
|
return accum;
|
|
6873
6962
|
}
|
|
6874
6963
|
const idEntry = (_a = accum.idsMap[snapshot["prevId"]]) != null ? _a : {
|
|
6875
|
-
parent:
|
|
6964
|
+
parent: it,
|
|
6876
6965
|
snapshots: []
|
|
6877
6966
|
};
|
|
6878
|
-
idEntry.snapshots.push(
|
|
6967
|
+
idEntry.snapshots.push(it);
|
|
6879
6968
|
accum.idsMap[snapshot["prevId"]] = idEntry;
|
|
6880
6969
|
return accum;
|
|
6881
6970
|
},
|
|
@@ -6890,9 +6979,8 @@ var init_utils = __esm({
|
|
|
6890
6979
|
return result;
|
|
6891
6980
|
};
|
|
6892
6981
|
prepareMigrationFolder = (outFolder = "drizzle", dialect6) => {
|
|
6893
|
-
const
|
|
6894
|
-
const
|
|
6895
|
-
const report = validateWithReport(root, migrationFolders, dialect6);
|
|
6982
|
+
const { snapshots, journal } = prepareOutFolder(outFolder, dialect6);
|
|
6983
|
+
const report = validateWithReport(snapshots, dialect6);
|
|
6896
6984
|
if (report.nonLatest.length > 0) {
|
|
6897
6985
|
console.log(
|
|
6898
6986
|
report.nonLatest.map((it) => {
|
|
@@ -6923,7 +7011,41 @@ var init_utils = __esm({
|
|
|
6923
7011
|
if (abort) {
|
|
6924
7012
|
process.exit(0);
|
|
6925
7013
|
}
|
|
6926
|
-
return {
|
|
7014
|
+
return { snapshots, journal };
|
|
7015
|
+
};
|
|
7016
|
+
prepareMigrationMeta = (schemas, tables, columns) => {
|
|
7017
|
+
const _meta = {
|
|
7018
|
+
schemas: {},
|
|
7019
|
+
tables: {},
|
|
7020
|
+
columns: {}
|
|
7021
|
+
};
|
|
7022
|
+
schemas.forEach((it) => {
|
|
7023
|
+
const from = schemaRenameKey(it.from);
|
|
7024
|
+
const to = schemaRenameKey(it.to);
|
|
7025
|
+
_meta.schemas[from] = to;
|
|
7026
|
+
});
|
|
7027
|
+
tables.forEach((it) => {
|
|
7028
|
+
const from = tableRenameKey(it.from);
|
|
7029
|
+
const to = tableRenameKey(it.to);
|
|
7030
|
+
_meta.tables[from] = to;
|
|
7031
|
+
});
|
|
7032
|
+
columns.forEach((it) => {
|
|
7033
|
+
const from = columnRenameKey(it.from.table, it.from.schema, it.from.column);
|
|
7034
|
+
const to = columnRenameKey(it.to.table, it.to.schema, it.to.column);
|
|
7035
|
+
_meta.columns[from] = to;
|
|
7036
|
+
});
|
|
7037
|
+
return _meta;
|
|
7038
|
+
};
|
|
7039
|
+
schemaRenameKey = (it) => {
|
|
7040
|
+
return it;
|
|
7041
|
+
};
|
|
7042
|
+
tableRenameKey = (it) => {
|
|
7043
|
+
const out = it.schema ? `"${it.schema}"."${it.name}"` : `"${it.name}"`;
|
|
7044
|
+
return out;
|
|
7045
|
+
};
|
|
7046
|
+
columnRenameKey = (table4, schema4, column6) => {
|
|
7047
|
+
const out = schema4 ? `"${schema4}"."${table4}"."${column6}"` : `"${table4}"."${column6}"`;
|
|
7048
|
+
return out;
|
|
6927
7049
|
};
|
|
6928
7050
|
}
|
|
6929
7051
|
});
|
|
@@ -7841,16 +7963,16 @@ var require_node2 = __commonJS({
|
|
|
7841
7963
|
}
|
|
7842
7964
|
exports2.urlGenerate = urlGenerate;
|
|
7843
7965
|
function normalize(aPath) {
|
|
7844
|
-
var
|
|
7966
|
+
var path4 = aPath;
|
|
7845
7967
|
var url = urlParse(aPath);
|
|
7846
7968
|
if (url) {
|
|
7847
7969
|
if (!url.path) {
|
|
7848
7970
|
return aPath;
|
|
7849
7971
|
}
|
|
7850
|
-
|
|
7972
|
+
path4 = url.path;
|
|
7851
7973
|
}
|
|
7852
|
-
var isAbsolute = exports2.isAbsolute(
|
|
7853
|
-
var parts =
|
|
7974
|
+
var isAbsolute = exports2.isAbsolute(path4);
|
|
7975
|
+
var parts = path4.split(/\/+/);
|
|
7854
7976
|
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
|
7855
7977
|
part = parts[i];
|
|
7856
7978
|
if (part === ".") {
|
|
@@ -7867,18 +7989,18 @@ var require_node2 = __commonJS({
|
|
|
7867
7989
|
}
|
|
7868
7990
|
}
|
|
7869
7991
|
}
|
|
7870
|
-
|
|
7871
|
-
if (
|
|
7872
|
-
|
|
7992
|
+
path4 = parts.join("/");
|
|
7993
|
+
if (path4 === "") {
|
|
7994
|
+
path4 = isAbsolute ? "/" : ".";
|
|
7873
7995
|
}
|
|
7874
7996
|
if (url) {
|
|
7875
|
-
url.path =
|
|
7997
|
+
url.path = path4;
|
|
7876
7998
|
return urlGenerate(url);
|
|
7877
7999
|
}
|
|
7878
|
-
return
|
|
8000
|
+
return path4;
|
|
7879
8001
|
}
|
|
7880
8002
|
exports2.normalize = normalize;
|
|
7881
|
-
function
|
|
8003
|
+
function join22(aRoot, aPath) {
|
|
7882
8004
|
if (aRoot === "") {
|
|
7883
8005
|
aRoot = ".";
|
|
7884
8006
|
}
|
|
@@ -7910,7 +8032,7 @@ var require_node2 = __commonJS({
|
|
|
7910
8032
|
}
|
|
7911
8033
|
return joined;
|
|
7912
8034
|
}
|
|
7913
|
-
exports2.join =
|
|
8035
|
+
exports2.join = join22;
|
|
7914
8036
|
exports2.isAbsolute = function(aPath) {
|
|
7915
8037
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
7916
8038
|
};
|
|
@@ -8083,7 +8205,7 @@ var require_node2 = __commonJS({
|
|
|
8083
8205
|
parsed.path = parsed.path.substring(0, index4 + 1);
|
|
8084
8206
|
}
|
|
8085
8207
|
}
|
|
8086
|
-
sourceURL =
|
|
8208
|
+
sourceURL = join22(urlGenerate(parsed), sourceURL);
|
|
8087
8209
|
}
|
|
8088
8210
|
return normalize(sourceURL);
|
|
8089
8211
|
}
|
|
@@ -9405,7 +9527,7 @@ var require_node2 = __commonJS({
|
|
|
9405
9527
|
});
|
|
9406
9528
|
var require_source_map_support = __commonJS2((exports2, module22) => {
|
|
9407
9529
|
var SourceMapConsumer = require_source_map().SourceMapConsumer;
|
|
9408
|
-
var
|
|
9530
|
+
var path4 = require("path");
|
|
9409
9531
|
var fs32;
|
|
9410
9532
|
try {
|
|
9411
9533
|
fs32 = require("fs");
|
|
@@ -9478,15 +9600,15 @@ var require_node2 = __commonJS({
|
|
|
9478
9600
|
function supportRelativeURL(file, url) {
|
|
9479
9601
|
if (!file)
|
|
9480
9602
|
return url;
|
|
9481
|
-
var dir =
|
|
9603
|
+
var dir = path4.dirname(file);
|
|
9482
9604
|
var match = /^\w+:\/\/[^\/]*/.exec(dir);
|
|
9483
9605
|
var protocol = match ? match[0] : "";
|
|
9484
9606
|
var startPath = dir.slice(protocol.length);
|
|
9485
9607
|
if (protocol && /^\/\w\:/.test(startPath)) {
|
|
9486
9608
|
protocol += "/";
|
|
9487
|
-
return protocol +
|
|
9609
|
+
return protocol + path4.resolve(dir.slice(protocol.length), url).replace(/\\/g, "/");
|
|
9488
9610
|
}
|
|
9489
|
-
return protocol +
|
|
9611
|
+
return protocol + path4.resolve(dir.slice(protocol.length), url);
|
|
9490
9612
|
}
|
|
9491
9613
|
function retrieveSourceMapURL(source) {
|
|
9492
9614
|
var fileData;
|
|
@@ -9939,13 +10061,13 @@ var require_node2 = __commonJS({
|
|
|
9939
10061
|
}
|
|
9940
10062
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9941
10063
|
try {
|
|
9942
|
-
var
|
|
9943
|
-
var value =
|
|
10064
|
+
var info2 = gen[key](arg);
|
|
10065
|
+
var value = info2.value;
|
|
9944
10066
|
} catch (error2) {
|
|
9945
10067
|
reject(error2);
|
|
9946
10068
|
return;
|
|
9947
10069
|
}
|
|
9948
|
-
if (
|
|
10070
|
+
if (info2.done) {
|
|
9949
10071
|
resolve(value);
|
|
9950
10072
|
} else {
|
|
9951
10073
|
Promise.resolve(value).then(_next, _throw);
|
|
@@ -9973,7 +10095,7 @@ var require_node2 = __commonJS({
|
|
|
9973
10095
|
resolve(data);
|
|
9974
10096
|
});
|
|
9975
10097
|
});
|
|
9976
|
-
var
|
|
10098
|
+
var readFileSync3 = (fp) => {
|
|
9977
10099
|
return _fs.default.readFileSync(fp, "utf8");
|
|
9978
10100
|
};
|
|
9979
10101
|
var pathExists = (fp) => new Promise((resolve) => {
|
|
@@ -10204,7 +10326,7 @@ var require_node2 = __commonJS({
|
|
|
10204
10326
|
data: this.packageJsonCache.get(filepath)[options.packageKey]
|
|
10205
10327
|
};
|
|
10206
10328
|
}
|
|
10207
|
-
const data = this.options.parseJSON(
|
|
10329
|
+
const data = this.options.parseJSON(readFileSync3(filepath));
|
|
10208
10330
|
return {
|
|
10209
10331
|
path: filepath,
|
|
10210
10332
|
data
|
|
@@ -10212,7 +10334,7 @@ var require_node2 = __commonJS({
|
|
|
10212
10334
|
}
|
|
10213
10335
|
return {
|
|
10214
10336
|
path: filepath,
|
|
10215
|
-
data:
|
|
10337
|
+
data: readFileSync3(filepath)
|
|
10216
10338
|
};
|
|
10217
10339
|
}
|
|
10218
10340
|
return {};
|
|
@@ -10281,9 +10403,9 @@ var require_node2 = __commonJS({
|
|
|
10281
10403
|
"use strict";
|
|
10282
10404
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10283
10405
|
var fs32 = require("fs");
|
|
10284
|
-
function fileExistsSync(
|
|
10406
|
+
function fileExistsSync(path4) {
|
|
10285
10407
|
try {
|
|
10286
|
-
var stats = fs32.statSync(
|
|
10408
|
+
var stats = fs32.statSync(path4);
|
|
10287
10409
|
return stats.isFile();
|
|
10288
10410
|
} catch (err2) {
|
|
10289
10411
|
return false;
|
|
@@ -10297,8 +10419,8 @@ var require_node2 = __commonJS({
|
|
|
10297
10419
|
return require(packageJsonPath);
|
|
10298
10420
|
}
|
|
10299
10421
|
exports2.readJsonFromDiskSync = readJsonFromDiskSync;
|
|
10300
|
-
function readJsonFromDiskAsync(
|
|
10301
|
-
fs32.readFile(
|
|
10422
|
+
function readJsonFromDiskAsync(path4, callback) {
|
|
10423
|
+
fs32.readFile(path4, "utf8", function(err2, result) {
|
|
10302
10424
|
if (err2 || !result) {
|
|
10303
10425
|
return callback();
|
|
10304
10426
|
}
|
|
@@ -10316,15 +10438,15 @@ var require_node2 = __commonJS({
|
|
|
10316
10438
|
});
|
|
10317
10439
|
}
|
|
10318
10440
|
exports2.fileExistsAsync = fileExistsAsync;
|
|
10319
|
-
function removeExtension(
|
|
10320
|
-
return
|
|
10441
|
+
function removeExtension(path4) {
|
|
10442
|
+
return path4.substring(0, path4.lastIndexOf(".")) || path4;
|
|
10321
10443
|
}
|
|
10322
10444
|
exports2.removeExtension = removeExtension;
|
|
10323
10445
|
});
|
|
10324
10446
|
var require_mapping_entry = __commonJS2((exports2) => {
|
|
10325
10447
|
"use strict";
|
|
10326
10448
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10327
|
-
var
|
|
10449
|
+
var path4 = require("path");
|
|
10328
10450
|
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
|
|
10329
10451
|
var sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
10330
10452
|
var absolutePaths = [];
|
|
@@ -10333,7 +10455,7 @@ var require_node2 = __commonJS({
|
|
|
10333
10455
|
absolutePaths.push({
|
|
10334
10456
|
pattern: key,
|
|
10335
10457
|
paths: paths[key].map(function(pathToResolve) {
|
|
10336
|
-
return
|
|
10458
|
+
return path4.join(absoluteBaseUrl, pathToResolve);
|
|
10337
10459
|
})
|
|
10338
10460
|
});
|
|
10339
10461
|
}
|
|
@@ -10359,11 +10481,11 @@ var require_node2 = __commonJS({
|
|
|
10359
10481
|
var require_try_path = __commonJS2((exports2) => {
|
|
10360
10482
|
"use strict";
|
|
10361
10483
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10362
|
-
var
|
|
10484
|
+
var path4 = require("path");
|
|
10363
10485
|
var path_1 = require("path");
|
|
10364
10486
|
var filesystem_1 = require_filesystem();
|
|
10365
10487
|
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
|
|
10366
|
-
if (!absolutePathMappings || !requestedModule || requestedModule[0] === "." || requestedModule[0] ===
|
|
10488
|
+
if (!absolutePathMappings || !requestedModule || requestedModule[0] === "." || requestedModule[0] === path4.sep) {
|
|
10367
10489
|
return void 0;
|
|
10368
10490
|
}
|
|
10369
10491
|
var pathsToTry = [];
|
|
@@ -10379,9 +10501,9 @@ var require_node2 = __commonJS({
|
|
|
10379
10501
|
}));
|
|
10380
10502
|
pathsToTry.push({
|
|
10381
10503
|
type: "package",
|
|
10382
|
-
path:
|
|
10504
|
+
path: path4.join(physicalPath, "/package.json")
|
|
10383
10505
|
});
|
|
10384
|
-
var indexPath =
|
|
10506
|
+
var indexPath = path4.join(physicalPath, "/index");
|
|
10385
10507
|
pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
|
|
10386
10508
|
return { type: "index", path: indexPath + e };
|
|
10387
10509
|
}));
|
|
@@ -10428,7 +10550,7 @@ var require_node2 = __commonJS({
|
|
|
10428
10550
|
var require_match_path_sync = __commonJS2((exports2) => {
|
|
10429
10551
|
"use strict";
|
|
10430
10552
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10431
|
-
var
|
|
10553
|
+
var path4 = require("path");
|
|
10432
10554
|
var Filesystem = require_filesystem();
|
|
10433
10555
|
var MappingEntry = require_mapping_entry();
|
|
10434
10556
|
var TryPath = require_try_path();
|
|
@@ -10470,7 +10592,7 @@ var require_node2 = __commonJS({
|
|
|
10470
10592
|
var mainFieldName = mainFields[index4];
|
|
10471
10593
|
var candidateMapping = packageJson[mainFieldName];
|
|
10472
10594
|
if (candidateMapping && typeof candidateMapping === "string") {
|
|
10473
|
-
var candidateFilePath =
|
|
10595
|
+
var candidateFilePath = path4.join(path4.dirname(packageJsonPath), candidateMapping);
|
|
10474
10596
|
if (fileExists(candidateFilePath)) {
|
|
10475
10597
|
return candidateFilePath;
|
|
10476
10598
|
}
|
|
@@ -10509,7 +10631,7 @@ var require_node2 = __commonJS({
|
|
|
10509
10631
|
var require_match_path_async = __commonJS2((exports2) => {
|
|
10510
10632
|
"use strict";
|
|
10511
10633
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
10512
|
-
var
|
|
10634
|
+
var path4 = require("path");
|
|
10513
10635
|
var TryPath = require_try_path();
|
|
10514
10636
|
var MappingEntry = require_mapping_entry();
|
|
10515
10637
|
var Filesystem = require_filesystem();
|
|
@@ -10560,7 +10682,7 @@ var require_node2 = __commonJS({
|
|
|
10560
10682
|
if (typeof mainFieldMapping !== "string") {
|
|
10561
10683
|
return tryNext();
|
|
10562
10684
|
}
|
|
10563
|
-
var mappedFilePath =
|
|
10685
|
+
var mappedFilePath = path4.join(path4.dirname(packageJsonPath), mainFieldMapping);
|
|
10564
10686
|
fileExistsAsync(mappedFilePath, function(err2, exists) {
|
|
10565
10687
|
if (err2) {
|
|
10566
10688
|
return doneCallback(err2);
|
|
@@ -11780,7 +11902,7 @@ var require_node2 = __commonJS({
|
|
|
11780
11902
|
return t;
|
|
11781
11903
|
};
|
|
11782
11904
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
11783
|
-
var
|
|
11905
|
+
var path4 = require("path");
|
|
11784
11906
|
var fs32 = require("fs");
|
|
11785
11907
|
var JSON5 = require_lib32();
|
|
11786
11908
|
var StripBom = require_strip_bom();
|
|
@@ -11810,43 +11932,43 @@ var require_node2 = __commonJS({
|
|
|
11810
11932
|
}
|
|
11811
11933
|
function resolveConfigPath(cwd, filename) {
|
|
11812
11934
|
if (filename) {
|
|
11813
|
-
var absolutePath = fs32.lstatSync(filename).isDirectory() ?
|
|
11935
|
+
var absolutePath = fs32.lstatSync(filename).isDirectory() ? path4.resolve(filename, "./tsconfig.json") : path4.resolve(cwd, filename);
|
|
11814
11936
|
return absolutePath;
|
|
11815
11937
|
}
|
|
11816
11938
|
if (fs32.statSync(cwd).isFile()) {
|
|
11817
|
-
return
|
|
11939
|
+
return path4.resolve(cwd);
|
|
11818
11940
|
}
|
|
11819
11941
|
var configAbsolutePath = walkForTsConfig(cwd);
|
|
11820
|
-
return configAbsolutePath ?
|
|
11942
|
+
return configAbsolutePath ? path4.resolve(configAbsolutePath) : void 0;
|
|
11821
11943
|
}
|
|
11822
|
-
function walkForTsConfig(directory,
|
|
11823
|
-
if (
|
|
11824
|
-
|
|
11944
|
+
function walkForTsConfig(directory, existsSync4) {
|
|
11945
|
+
if (existsSync4 === void 0) {
|
|
11946
|
+
existsSync4 = fs32.existsSync;
|
|
11825
11947
|
}
|
|
11826
|
-
var configPath =
|
|
11827
|
-
if (
|
|
11948
|
+
var configPath = path4.join(directory, "./tsconfig.json");
|
|
11949
|
+
if (existsSync4(configPath)) {
|
|
11828
11950
|
return configPath;
|
|
11829
11951
|
}
|
|
11830
|
-
var parentDirectory =
|
|
11952
|
+
var parentDirectory = path4.join(directory, "../");
|
|
11831
11953
|
if (directory === parentDirectory) {
|
|
11832
11954
|
return void 0;
|
|
11833
11955
|
}
|
|
11834
|
-
return walkForTsConfig(parentDirectory,
|
|
11956
|
+
return walkForTsConfig(parentDirectory, existsSync4);
|
|
11835
11957
|
}
|
|
11836
11958
|
exports2.walkForTsConfig = walkForTsConfig;
|
|
11837
|
-
function loadTsconfig(configFilePath,
|
|
11838
|
-
if (
|
|
11839
|
-
|
|
11959
|
+
function loadTsconfig(configFilePath, existsSync4, readFileSync3) {
|
|
11960
|
+
if (existsSync4 === void 0) {
|
|
11961
|
+
existsSync4 = fs32.existsSync;
|
|
11840
11962
|
}
|
|
11841
|
-
if (
|
|
11842
|
-
|
|
11963
|
+
if (readFileSync3 === void 0) {
|
|
11964
|
+
readFileSync3 = function(filename) {
|
|
11843
11965
|
return fs32.readFileSync(filename, "utf8");
|
|
11844
11966
|
};
|
|
11845
11967
|
}
|
|
11846
|
-
if (!
|
|
11968
|
+
if (!existsSync4(configFilePath)) {
|
|
11847
11969
|
return void 0;
|
|
11848
11970
|
}
|
|
11849
|
-
var configString =
|
|
11971
|
+
var configString = readFileSync3(configFilePath);
|
|
11850
11972
|
var cleanedJson = StripBom(configString);
|
|
11851
11973
|
var config = JSON5.parse(cleanedJson);
|
|
11852
11974
|
var extendedConfig = config.extends;
|
|
@@ -11854,15 +11976,15 @@ var require_node2 = __commonJS({
|
|
|
11854
11976
|
if (typeof extendedConfig === "string" && extendedConfig.indexOf(".json") === -1) {
|
|
11855
11977
|
extendedConfig += ".json";
|
|
11856
11978
|
}
|
|
11857
|
-
var currentDir =
|
|
11858
|
-
var extendedConfigPath =
|
|
11859
|
-
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !
|
|
11860
|
-
extendedConfigPath =
|
|
11979
|
+
var currentDir = path4.dirname(configFilePath);
|
|
11980
|
+
var extendedConfigPath = path4.join(currentDir, extendedConfig);
|
|
11981
|
+
if (extendedConfig.indexOf("/") !== -1 && extendedConfig.indexOf(".") !== -1 && !existsSync4(extendedConfigPath)) {
|
|
11982
|
+
extendedConfigPath = path4.join(currentDir, "node_modules", extendedConfig);
|
|
11861
11983
|
}
|
|
11862
|
-
var base = loadTsconfig(extendedConfigPath,
|
|
11984
|
+
var base = loadTsconfig(extendedConfigPath, existsSync4, readFileSync3) || {};
|
|
11863
11985
|
if (base.compilerOptions && base.compilerOptions.baseUrl) {
|
|
11864
|
-
var extendsDir =
|
|
11865
|
-
base.compilerOptions.baseUrl =
|
|
11986
|
+
var extendsDir = path4.dirname(extendedConfig);
|
|
11987
|
+
base.compilerOptions.baseUrl = path4.join(extendsDir, base.compilerOptions.baseUrl);
|
|
11866
11988
|
}
|
|
11867
11989
|
return __assign({}, base, config, { compilerOptions: __assign({}, base.compilerOptions, config.compilerOptions) });
|
|
11868
11990
|
}
|
|
@@ -12087,7 +12209,7 @@ var require_node2 = __commonJS({
|
|
|
12087
12209
|
"use strict";
|
|
12088
12210
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12089
12211
|
var TsConfigLoader = require_tsconfig_loader();
|
|
12090
|
-
var
|
|
12212
|
+
var path4 = require("path");
|
|
12091
12213
|
var options_1 = require_options();
|
|
12092
12214
|
function loadConfig2(cwd) {
|
|
12093
12215
|
if (cwd === void 0) {
|
|
@@ -12099,7 +12221,7 @@ var require_node2 = __commonJS({
|
|
|
12099
12221
|
function configLoader(_a) {
|
|
12100
12222
|
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader.tsConfigLoader : _b;
|
|
12101
12223
|
if (explicitParams) {
|
|
12102
|
-
var absoluteBaseUrl_1 =
|
|
12224
|
+
var absoluteBaseUrl_1 = path4.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path4.join(cwd, explicitParams.baseUrl);
|
|
12103
12225
|
return {
|
|
12104
12226
|
resultType: "success",
|
|
12105
12227
|
configFileAbsolutePath: "",
|
|
@@ -12128,8 +12250,8 @@ var require_node2 = __commonJS({
|
|
|
12128
12250
|
message: "Missing baseUrl in compilerOptions"
|
|
12129
12251
|
};
|
|
12130
12252
|
}
|
|
12131
|
-
var tsConfigDir =
|
|
12132
|
-
var absoluteBaseUrl =
|
|
12253
|
+
var tsConfigDir = path4.dirname(loadResult.tsConfigPath);
|
|
12254
|
+
var absoluteBaseUrl = path4.join(tsConfigDir, loadResult.baseUrl);
|
|
12133
12255
|
return {
|
|
12134
12256
|
resultType: "success",
|
|
12135
12257
|
configFileAbsolutePath: loadResult.tsConfigPath,
|
|
@@ -12330,8 +12452,8 @@ var require_node2 = __commonJS({
|
|
|
12330
12452
|
});
|
|
12331
12453
|
var getOptions = (cwd) => {
|
|
12332
12454
|
var _a, _b, _c, _d;
|
|
12333
|
-
const { data, path:
|
|
12334
|
-
if (
|
|
12455
|
+
const { data, path: path4 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
|
12456
|
+
if (path4 && data) {
|
|
12335
12457
|
return {
|
|
12336
12458
|
jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
|
|
12337
12459
|
jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
|
|
@@ -12539,7 +12661,6 @@ function clearDefaults(defaultValue, collate) {
|
|
|
12539
12661
|
if (typeof collate === "undefined" || collate === null) {
|
|
12540
12662
|
collate = `utf8mb4`;
|
|
12541
12663
|
}
|
|
12542
|
-
;
|
|
12543
12664
|
let resultDefault = defaultValue;
|
|
12544
12665
|
collate = `_${collate}`;
|
|
12545
12666
|
if (defaultValue.startsWith(collate)) {
|
|
@@ -12659,7 +12780,17 @@ var init_mysqlSerializer = __esm({
|
|
|
12659
12780
|
const schemas = Object.fromEntries(
|
|
12660
12781
|
mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
|
|
12661
12782
|
);
|
|
12662
|
-
return {
|
|
12783
|
+
return {
|
|
12784
|
+
version: "5",
|
|
12785
|
+
dialect: "mysql",
|
|
12786
|
+
tables: result,
|
|
12787
|
+
schemas,
|
|
12788
|
+
_meta: {
|
|
12789
|
+
schemas: {},
|
|
12790
|
+
tables: {},
|
|
12791
|
+
columns: {}
|
|
12792
|
+
}
|
|
12793
|
+
};
|
|
12663
12794
|
};
|
|
12664
12795
|
fromDatabase = async (db, schema4, progressCallback) => {
|
|
12665
12796
|
const result = {};
|
|
@@ -12793,10 +12924,15 @@ var init_mysqlSerializer = __esm({
|
|
|
12793
12924
|
progressCallback("enums", 0, "done");
|
|
12794
12925
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
|
12795
12926
|
return {
|
|
12796
|
-
version: "
|
|
12927
|
+
version: "5",
|
|
12797
12928
|
dialect: "mysql",
|
|
12798
12929
|
tables: result,
|
|
12799
|
-
schemas: schemasObject
|
|
12930
|
+
schemas: schemasObject,
|
|
12931
|
+
_meta: {
|
|
12932
|
+
schemas: {},
|
|
12933
|
+
tables: {},
|
|
12934
|
+
columns: {}
|
|
12935
|
+
}
|
|
12800
12936
|
};
|
|
12801
12937
|
};
|
|
12802
12938
|
}
|
|
@@ -12845,7 +12981,7 @@ __export(pgSerializer_exports, {
|
|
|
12845
12981
|
generatePgSnapshot: () => generatePgSnapshot,
|
|
12846
12982
|
indexName: () => indexName2
|
|
12847
12983
|
});
|
|
12848
|
-
var import_pg_core2, import_utils6, import_sql2, import_table2, dialect4, indexName2, generatePgSnapshot, fromDatabase2;
|
|
12984
|
+
var import_pg_core2, import_utils6, import_sql2, import_table2, dialect4, indexName2, generatePgSnapshot, fromDatabase2, defaultForColumn;
|
|
12849
12985
|
var init_pgSerializer = __esm({
|
|
12850
12986
|
"src/serializer/pgSerializer.ts"() {
|
|
12851
12987
|
import_pg_core2 = require("drizzle-orm/pg-core");
|
|
@@ -12967,14 +13103,19 @@ var init_pgSerializer = __esm({
|
|
|
12967
13103
|
return map;
|
|
12968
13104
|
}, {});
|
|
12969
13105
|
const schemasObject = Object.fromEntries(
|
|
12970
|
-
schemas.map((it) => [it.schemaName, it.schemaName])
|
|
13106
|
+
schemas.filter((it) => it.schemaName !== "public").map((it) => [it.schemaName, it.schemaName])
|
|
12971
13107
|
);
|
|
12972
13108
|
return {
|
|
12973
|
-
version: "
|
|
13109
|
+
version: "5",
|
|
12974
13110
|
dialect: "pg",
|
|
12975
13111
|
tables: result,
|
|
12976
13112
|
enums: enumsToReturn,
|
|
12977
|
-
schemas: schemasObject
|
|
13113
|
+
schemas: schemasObject,
|
|
13114
|
+
_meta: {
|
|
13115
|
+
schemas: {},
|
|
13116
|
+
tables: {},
|
|
13117
|
+
columns: {}
|
|
13118
|
+
}
|
|
12978
13119
|
};
|
|
12979
13120
|
};
|
|
12980
13121
|
fromDatabase2 = async (db, progressCallback) => {
|
|
@@ -12982,7 +13123,10 @@ var init_pgSerializer = __esm({
|
|
|
12982
13123
|
const allTables = await db.query(
|
|
12983
13124
|
`SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema = 'public';`
|
|
12984
13125
|
);
|
|
12985
|
-
const schemas = new Set(
|
|
13126
|
+
const schemas = new Set(
|
|
13127
|
+
allTables.rows.map((it) => it.table_schema)
|
|
13128
|
+
);
|
|
13129
|
+
schemas.delete("public");
|
|
12986
13130
|
progressCallback("tables", allTables.rows.length, "done");
|
|
12987
13131
|
let columnsCount = 0;
|
|
12988
13132
|
let indexesCount = 0;
|
|
@@ -13093,7 +13237,7 @@ var init_pgSerializer = __esm({
|
|
|
13093
13237
|
const uniqueKey = tableConstraints.rows.filter(
|
|
13094
13238
|
(mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "UNIQUE"
|
|
13095
13239
|
);
|
|
13096
|
-
const defaultValue = columnResponse
|
|
13240
|
+
const defaultValue = defaultForColumn(columnResponse);
|
|
13097
13241
|
const isSerial = columnType === "serial";
|
|
13098
13242
|
columnToReturn[columnName] = {
|
|
13099
13243
|
name: columnName,
|
|
@@ -13146,7 +13290,7 @@ var init_pgSerializer = __esm({
|
|
|
13146
13290
|
progressCallback("indexes", indexesCount, "fetching");
|
|
13147
13291
|
result[tableName] = {
|
|
13148
13292
|
name: tableName,
|
|
13149
|
-
schema: tableSchema,
|
|
13293
|
+
schema: tableSchema !== "public" ? tableSchema : "",
|
|
13150
13294
|
columns: columnToReturn,
|
|
13151
13295
|
indexes: indexToReturn,
|
|
13152
13296
|
foreignKeys: foreignKeysToReturn
|
|
@@ -13187,13 +13331,25 @@ var init_pgSerializer = __esm({
|
|
|
13187
13331
|
progressCallback("enums", Object.keys(enumsToReturn).length, "done");
|
|
13188
13332
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
|
13189
13333
|
return {
|
|
13190
|
-
version: "
|
|
13334
|
+
version: "5",
|
|
13191
13335
|
dialect: "pg",
|
|
13192
13336
|
tables: result,
|
|
13193
13337
|
enums: enumsToReturn,
|
|
13194
|
-
schemas: schemasObject
|
|
13338
|
+
schemas: schemasObject,
|
|
13339
|
+
_meta: {
|
|
13340
|
+
schemas: {},
|
|
13341
|
+
tables: {},
|
|
13342
|
+
columns: {}
|
|
13343
|
+
}
|
|
13195
13344
|
};
|
|
13196
13345
|
};
|
|
13346
|
+
defaultForColumn = (column6) => {
|
|
13347
|
+
if (column6.data_type === "serial" || column6.data_type === "smallserial" || column6.data_type === "bigserial") {
|
|
13348
|
+
return void 0;
|
|
13349
|
+
}
|
|
13350
|
+
const defaultValue = column6.column_default === null ? void 0 : column6.column_default;
|
|
13351
|
+
return defaultValue;
|
|
13352
|
+
};
|
|
13197
13353
|
}
|
|
13198
13354
|
});
|
|
13199
13355
|
|
|
@@ -13319,7 +13475,9 @@ var init_sqliteSerializer = __esm({
|
|
|
13319
13475
|
};
|
|
13320
13476
|
});
|
|
13321
13477
|
(0, import_utils7.getTableCompositePrimaryKeys)(table4).forEach((it) => {
|
|
13322
|
-
primaryKeysObject[it.getName()] = {
|
|
13478
|
+
primaryKeysObject[it.getName()] = {
|
|
13479
|
+
columns: it.columns.map((it2) => it2.name)
|
|
13480
|
+
};
|
|
13323
13481
|
});
|
|
13324
13482
|
result[tableName] = {
|
|
13325
13483
|
name: tableName,
|
|
@@ -13329,18 +13487,27 @@ var init_sqliteSerializer = __esm({
|
|
|
13329
13487
|
compositePrimaryKeys: primaryKeysObject
|
|
13330
13488
|
};
|
|
13331
13489
|
}
|
|
13332
|
-
return {
|
|
13490
|
+
return {
|
|
13491
|
+
version: "5",
|
|
13492
|
+
dialect: "sqlite",
|
|
13493
|
+
tables: result,
|
|
13494
|
+
enums: {},
|
|
13495
|
+
_meta: {
|
|
13496
|
+
tables: {},
|
|
13497
|
+
columns: {}
|
|
13498
|
+
}
|
|
13499
|
+
};
|
|
13333
13500
|
};
|
|
13334
13501
|
}
|
|
13335
13502
|
});
|
|
13336
13503
|
|
|
13337
13504
|
// src/serializer/index.ts
|
|
13338
|
-
var import_fs2, import_node,
|
|
13505
|
+
var import_fs2, import_node, import_path2, safeRegister, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
|
13339
13506
|
var init_serializer = __esm({
|
|
13340
13507
|
"src/serializer/index.ts"() {
|
|
13341
13508
|
import_fs2 = __toESM(require("fs"));
|
|
13342
13509
|
import_node = __toESM(require_node2());
|
|
13343
|
-
|
|
13510
|
+
import_path2 = __toESM(require("path"));
|
|
13344
13511
|
safeRegister = () => {
|
|
13345
13512
|
try {
|
|
13346
13513
|
const { unregister } = (0, import_node.register)({
|
|
@@ -13353,8 +13520,8 @@ var init_serializer = __esm({
|
|
|
13353
13520
|
} };
|
|
13354
13521
|
}
|
|
13355
13522
|
};
|
|
13356
|
-
serializeMySql = (
|
|
13357
|
-
const filenames = prepareFilenames(
|
|
13523
|
+
serializeMySql = (path4) => {
|
|
13524
|
+
const filenames = prepareFilenames(path4);
|
|
13358
13525
|
const { unregister } = safeRegister();
|
|
13359
13526
|
const { prepareFromMySqlImports: prepareFromMySqlImports2 } = (init_mysqlImports(), __toCommonJS(mysqlImports_exports));
|
|
13360
13527
|
const { generateMySqlSnapshot: generateMySqlSnapshot2 } = (init_mysqlSerializer(), __toCommonJS(mysqlSerializer_exports));
|
|
@@ -13362,8 +13529,8 @@ var init_serializer = __esm({
|
|
|
13362
13529
|
unregister();
|
|
13363
13530
|
return generateMySqlSnapshot2(tables, enums, schemas);
|
|
13364
13531
|
};
|
|
13365
|
-
serializePg = (
|
|
13366
|
-
const filenames = prepareFilenames(
|
|
13532
|
+
serializePg = (path4) => {
|
|
13533
|
+
const filenames = prepareFilenames(path4);
|
|
13367
13534
|
const { unregister } = safeRegister();
|
|
13368
13535
|
const { prepareFromPgImports: prepareFromPgImports2 } = (init_pgImports(), __toCommonJS(pgImports_exports));
|
|
13369
13536
|
const { generatePgSnapshot: generatePgSnapshot2 } = (init_pgSerializer(), __toCommonJS(pgSerializer_exports));
|
|
@@ -13371,8 +13538,8 @@ var init_serializer = __esm({
|
|
|
13371
13538
|
unregister();
|
|
13372
13539
|
return generatePgSnapshot2(tables, enums, schemas);
|
|
13373
13540
|
};
|
|
13374
|
-
serializeSQLite = (
|
|
13375
|
-
const filenames = prepareFilenames(
|
|
13541
|
+
serializeSQLite = (path4) => {
|
|
13542
|
+
const filenames = prepareFilenames(path4);
|
|
13376
13543
|
const { unregister } = safeRegister();
|
|
13377
13544
|
const { prepareFromSqliteImports: prepareFromSqliteImports2 } = (init_sqliteImports(), __toCommonJS(sqliteImports_exports));
|
|
13378
13545
|
const { generateSqliteSnapshot: generateSqliteSnapshot2 } = (init_sqliteSerializer(), __toCommonJS(sqliteSerializer_exports));
|
|
@@ -13380,9 +13547,9 @@ var init_serializer = __esm({
|
|
|
13380
13547
|
unregister();
|
|
13381
13548
|
return generateSqliteSnapshot2(tables, enums);
|
|
13382
13549
|
};
|
|
13383
|
-
prepareFilenames = (
|
|
13384
|
-
const fileName = import_fs2.default.lstatSync(
|
|
13385
|
-
const filenames = fileName ? [fileName] : import_fs2.default.readdirSync(
|
|
13550
|
+
prepareFilenames = (path4) => {
|
|
13551
|
+
const fileName = import_fs2.default.lstatSync(path4).isDirectory() ? null : import_path2.default.resolve(path4);
|
|
13552
|
+
const filenames = fileName ? [fileName] : import_fs2.default.readdirSync(path4).map((it) => import_path2.default.join(import_path2.default.resolve(path4), it));
|
|
13386
13553
|
return filenames;
|
|
13387
13554
|
};
|
|
13388
13555
|
}
|
|
@@ -13398,9 +13565,9 @@ var init_migrationPreparator = __esm({
|
|
|
13398
13565
|
init_pgSchema();
|
|
13399
13566
|
init_sqliteSchema();
|
|
13400
13567
|
init_mysqlSchema();
|
|
13401
|
-
prepareMySqlMigrationSnapshot = (migrationFolders,
|
|
13568
|
+
prepareMySqlMigrationSnapshot = (migrationFolders, schemaPath) => {
|
|
13402
13569
|
const prevSnapshot = mysqlSchema.parse(
|
|
13403
|
-
preparePrevSnapshot(
|
|
13570
|
+
preparePrevSnapshot(migrationFolders, dryMySql)
|
|
13404
13571
|
);
|
|
13405
13572
|
const serialized = serializeMySql(schemaPath);
|
|
13406
13573
|
const id = (0, import_crypto.randomUUID)();
|
|
@@ -13409,9 +13576,9 @@ var init_migrationPreparator = __esm({
|
|
|
13409
13576
|
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
|
13410
13577
|
return { prev: prevSnapshot, cur: result };
|
|
13411
13578
|
};
|
|
13412
|
-
prepareSqliteMigrationSnapshot = (
|
|
13579
|
+
prepareSqliteMigrationSnapshot = (snapshots, schemaPath) => {
|
|
13413
13580
|
const prevSnapshot = sqliteSchema.parse(
|
|
13414
|
-
preparePrevSnapshot(
|
|
13581
|
+
preparePrevSnapshot(snapshots, drySQLite)
|
|
13415
13582
|
);
|
|
13416
13583
|
const serialized = serializeSQLite(schemaPath);
|
|
13417
13584
|
const id = (0, import_crypto.randomUUID)();
|
|
@@ -13426,10 +13593,8 @@ var init_migrationPreparator = __esm({
|
|
|
13426
13593
|
};
|
|
13427
13594
|
return { prev: prevSnapshot, cur: result };
|
|
13428
13595
|
};
|
|
13429
|
-
preparePgMigrationSnapshot = (
|
|
13430
|
-
const prevSnapshot = pgSchema.parse(
|
|
13431
|
-
preparePrevSnapshot(outFolder, migrationFolders, dryPg)
|
|
13432
|
-
);
|
|
13596
|
+
preparePgMigrationSnapshot = (snapshots, schemaPath) => {
|
|
13597
|
+
const prevSnapshot = pgSchema.parse(preparePrevSnapshot(snapshots, dryPg));
|
|
13433
13598
|
const serialized = serializePg(schemaPath);
|
|
13434
13599
|
const id = (0, import_crypto.randomUUID)();
|
|
13435
13600
|
const idPrev = prevSnapshot.id;
|
|
@@ -13437,16 +13602,13 @@ var init_migrationPreparator = __esm({
|
|
|
13437
13602
|
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
|
13438
13603
|
return { prev: prevSnapshot, cur: result };
|
|
13439
13604
|
};
|
|
13440
|
-
preparePrevSnapshot = (
|
|
13441
|
-
const root = outFolder;
|
|
13605
|
+
preparePrevSnapshot = (snapshots, defaultPrev) => {
|
|
13442
13606
|
let prevSnapshot;
|
|
13443
|
-
if (
|
|
13607
|
+
if (snapshots.length === 0) {
|
|
13444
13608
|
prevSnapshot = defaultPrev;
|
|
13445
13609
|
} else {
|
|
13446
|
-
const
|
|
13447
|
-
prevSnapshot = JSON.parse(
|
|
13448
|
-
import_fs3.default.readFileSync(`${root}/${lastSnapshotFolder}/snapshot.json`).toString()
|
|
13449
|
-
);
|
|
13610
|
+
const lastSnapshot = snapshots[snapshots.length - 1];
|
|
13611
|
+
prevSnapshot = JSON.parse(import_fs3.default.readFileSync(lastSnapshot).toString());
|
|
13450
13612
|
}
|
|
13451
13613
|
return prevSnapshot;
|
|
13452
13614
|
};
|
|
@@ -13491,7 +13653,8 @@ var init_sqlgenerator = __esm({
|
|
|
13491
13653
|
isPgNativeType = (it) => {
|
|
13492
13654
|
if (pgNativeTypes.has(it))
|
|
13493
13655
|
return true;
|
|
13494
|
-
|
|
13656
|
+
const toCheck = it.replace(/ /g, "");
|
|
13657
|
+
return toCheck.startsWith("varchar(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(");
|
|
13495
13658
|
};
|
|
13496
13659
|
Convertor = class {
|
|
13497
13660
|
};
|
|
@@ -17306,7 +17469,7 @@ var require_get = __commonJS({
|
|
|
17306
17469
|
return lastId;
|
|
17307
17470
|
},
|
|
17308
17471
|
delete: function(id) {
|
|
17309
|
-
var index4 = 0, set = map, i, args = cache[id], length = args.length,
|
|
17472
|
+
var index4 = 0, set = map, i, args = cache[id], length = args.length, path4 = [];
|
|
17310
17473
|
if (length === 0) {
|
|
17311
17474
|
delete set[length];
|
|
17312
17475
|
} else if (set = set[length]) {
|
|
@@ -17315,7 +17478,7 @@ var require_get = __commonJS({
|
|
|
17315
17478
|
if (i === -1) {
|
|
17316
17479
|
return;
|
|
17317
17480
|
}
|
|
17318
|
-
|
|
17481
|
+
path4.push(set, i);
|
|
17319
17482
|
set = set[1][i];
|
|
17320
17483
|
++index4;
|
|
17321
17484
|
}
|
|
@@ -17326,9 +17489,9 @@ var require_get = __commonJS({
|
|
|
17326
17489
|
id = set[1][i];
|
|
17327
17490
|
set[0].splice(i, 1);
|
|
17328
17491
|
set[1].splice(i, 1);
|
|
17329
|
-
while (!set[0].length &&
|
|
17330
|
-
i =
|
|
17331
|
-
set =
|
|
17492
|
+
while (!set[0].length && path4.length) {
|
|
17493
|
+
i = path4.pop();
|
|
17494
|
+
set = path4.pop();
|
|
17332
17495
|
set[0].splice(i, 1);
|
|
17333
17496
|
set[1].splice(i, 1);
|
|
17334
17497
|
}
|
|
@@ -17420,13 +17583,13 @@ var require_get_fixed = __commonJS({
|
|
|
17420
17583
|
return lastId;
|
|
17421
17584
|
},
|
|
17422
17585
|
delete: function(id) {
|
|
17423
|
-
var index4 = 0, set = map, i,
|
|
17586
|
+
var index4 = 0, set = map, i, path4 = [], args = cache[id];
|
|
17424
17587
|
while (index4 < length - 1) {
|
|
17425
17588
|
i = indexOf.call(set[0], args[index4]);
|
|
17426
17589
|
if (i === -1) {
|
|
17427
17590
|
return;
|
|
17428
17591
|
}
|
|
17429
|
-
|
|
17592
|
+
path4.push(set, i);
|
|
17430
17593
|
set = set[1][i];
|
|
17431
17594
|
++index4;
|
|
17432
17595
|
}
|
|
@@ -17437,9 +17600,9 @@ var require_get_fixed = __commonJS({
|
|
|
17437
17600
|
id = set[1][i];
|
|
17438
17601
|
set[0].splice(i, 1);
|
|
17439
17602
|
set[1].splice(i, 1);
|
|
17440
|
-
while (!set[0].length &&
|
|
17441
|
-
i =
|
|
17442
|
-
set =
|
|
17603
|
+
while (!set[0].length && path4.length) {
|
|
17604
|
+
i = path4.pop();
|
|
17605
|
+
set = path4.pop();
|
|
17443
17606
|
set[0].splice(i, 1);
|
|
17444
17607
|
set[1].splice(i, 1);
|
|
17445
17608
|
}
|
|
@@ -19004,7 +19167,7 @@ var require_bare = __commonJS({
|
|
|
19004
19167
|
var sgr = require_sgr();
|
|
19005
19168
|
var supportsColor2 = require_supports_color2();
|
|
19006
19169
|
var mods = sgr.mods;
|
|
19007
|
-
var
|
|
19170
|
+
var join4 = Array.prototype.join;
|
|
19008
19171
|
var defineProperty = Object.defineProperty;
|
|
19009
19172
|
var max = Math.max;
|
|
19010
19173
|
var min = Math.min;
|
|
@@ -19058,7 +19221,7 @@ var require_bare = __commonJS({
|
|
|
19058
19221
|
getFn = function() {
|
|
19059
19222
|
return setPrototypeOf(
|
|
19060
19223
|
function self2() {
|
|
19061
|
-
var start = "", end = "", msg =
|
|
19224
|
+
var start = "", end = "", msg = join4.call(arguments, " "), conf = self2._cliColorData, hasAnsi = sgr.hasCSI(msg);
|
|
19062
19225
|
forEach(
|
|
19063
19226
|
conf,
|
|
19064
19227
|
function(mod, key) {
|
|
@@ -20489,7 +20652,7 @@ function diffForRenamedTable(t1, t2) {
|
|
|
20489
20652
|
t1.name = t2.name;
|
|
20490
20653
|
const diffed = (0, import_json_diff.diff)(t1, t2) || {};
|
|
20491
20654
|
diffed.name = t2.name;
|
|
20492
|
-
return findAlternationsInTable(diffed);
|
|
20655
|
+
return findAlternationsInTable(diffed, t2.schema);
|
|
20493
20656
|
}
|
|
20494
20657
|
function diffForRenamedColumn(t1, t2) {
|
|
20495
20658
|
const renamed = { ...t1, name: t2.name };
|
|
@@ -20503,6 +20666,10 @@ function applyJsonDiff(json1, json2) {
|
|
|
20503
20666
|
json2 = JSON.parse(JSON.stringify(json2));
|
|
20504
20667
|
const rawDiff = (0, import_json_diff.diff)(json1, json2);
|
|
20505
20668
|
const difference = rawDiff;
|
|
20669
|
+
const tableToSchema = Object.entries(json2.tables).reduce((res, it) => {
|
|
20670
|
+
res[it[0]] = it[1].schema;
|
|
20671
|
+
return res;
|
|
20672
|
+
}, {});
|
|
20506
20673
|
if (!difference)
|
|
20507
20674
|
return {};
|
|
20508
20675
|
difference.tables = (_a = difference.tables) != null ? _a : {};
|
|
@@ -20532,7 +20699,7 @@ function applyJsonDiff(json1, json2) {
|
|
|
20532
20699
|
const schemasEntries = Object.entries(difference.schemas);
|
|
20533
20700
|
const addedSchemas = schemasEntries.filter((it) => it[0].endsWith("__added")).map((it) => it[1]);
|
|
20534
20701
|
const deletedSchemas = schemasEntries.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
|
|
20535
|
-
const alteredTablesWithColumns = alteredTables.map((table4) => findAlternationsInTable(table4));
|
|
20702
|
+
const alteredTablesWithColumns = alteredTables.map((table4) => findAlternationsInTable(table4, tableToSchema[table4.name]));
|
|
20536
20703
|
return {
|
|
20537
20704
|
addedTables,
|
|
20538
20705
|
deletedTables,
|
|
@@ -20549,10 +20716,13 @@ var init_jsonDiffer = __esm({
|
|
|
20549
20716
|
"src/jsonDiffer.js"() {
|
|
20550
20717
|
import_json_diff = __toESM(require_lib());
|
|
20551
20718
|
"use-strict";
|
|
20552
|
-
findAlternationsInTable = (table4) => {
|
|
20719
|
+
findAlternationsInTable = (table4, tableSchema) => {
|
|
20553
20720
|
var _a;
|
|
20554
20721
|
const columns = (_a = table4.columns) != null ? _a : {};
|
|
20555
|
-
let schema4
|
|
20722
|
+
let schema4 = {
|
|
20723
|
+
type: "none",
|
|
20724
|
+
value: tableSchema
|
|
20725
|
+
};
|
|
20556
20726
|
if ("schema" in table4) {
|
|
20557
20727
|
if (table4.schema.__new) {
|
|
20558
20728
|
schema4 = { type: "changed", old: table4.schema.__old, new: table4.schema.__new };
|
|
@@ -20689,7 +20859,8 @@ var init_jsonStatements = __esm({
|
|
|
20689
20859
|
prepareDropTableJson = (table4) => {
|
|
20690
20860
|
return {
|
|
20691
20861
|
type: "drop_table",
|
|
20692
|
-
tableName: table4.name
|
|
20862
|
+
tableName: table4.name,
|
|
20863
|
+
schema: table4.schema
|
|
20693
20864
|
};
|
|
20694
20865
|
};
|
|
20695
20866
|
prepareRenameTableJson = (tableFrom, tableTo) => {
|
|
@@ -20742,20 +20913,21 @@ var init_jsonStatements = __esm({
|
|
|
20742
20913
|
};
|
|
20743
20914
|
});
|
|
20744
20915
|
};
|
|
20745
|
-
prepareRenameColumns = (tableName, pairs) => {
|
|
20916
|
+
prepareRenameColumns = (tableName, schema4, pairs) => {
|
|
20746
20917
|
return pairs.map((it) => {
|
|
20747
20918
|
return {
|
|
20748
20919
|
type: "alter_table_rename_column",
|
|
20749
20920
|
tableName,
|
|
20750
20921
|
oldColumnName: it.from.name,
|
|
20751
|
-
newColumnName: it.to.name
|
|
20922
|
+
newColumnName: it.to.name,
|
|
20923
|
+
schema: schema4
|
|
20752
20924
|
};
|
|
20753
20925
|
});
|
|
20754
20926
|
};
|
|
20755
|
-
prepareAlterTableColumnsJson = (tableName, deleted, added, altered, addedFk, dialect6) => {
|
|
20927
|
+
prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, dialect6) => {
|
|
20756
20928
|
const addColumns = [];
|
|
20757
|
-
const dropColumns = _prepareDropColumns(tableName, deleted);
|
|
20758
|
-
const alterColumns = _prepareAlterColumns(tableName, altered);
|
|
20929
|
+
const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
|
|
20930
|
+
const alterColumns = _prepareAlterColumns(tableName, schema4, altered);
|
|
20759
20931
|
if (dialect6 === "sqlite") {
|
|
20760
20932
|
let jsonCreateFKStatements = Object.values(addedFk);
|
|
20761
20933
|
const sqliteAddColumns = _prepareSQLiteAddColumns(
|
|
@@ -20765,25 +20937,27 @@ var init_jsonStatements = __esm({
|
|
|
20765
20937
|
);
|
|
20766
20938
|
addColumns.push(...sqliteAddColumns);
|
|
20767
20939
|
} else {
|
|
20768
|
-
addColumns.push(..._prepareAddColumns(tableName, added));
|
|
20940
|
+
addColumns.push(..._prepareAddColumns(tableName, schema4, added));
|
|
20769
20941
|
}
|
|
20770
20942
|
return { addColumns, dropColumns, alterColumns };
|
|
20771
20943
|
};
|
|
20772
|
-
_prepareDropColumns = (taleName, columns) => {
|
|
20944
|
+
_prepareDropColumns = (taleName, schema4, columns) => {
|
|
20773
20945
|
return columns.map((it) => {
|
|
20774
20946
|
return {
|
|
20775
20947
|
type: "alter_table_drop_column",
|
|
20776
20948
|
tableName: taleName,
|
|
20777
|
-
columnName: it.name
|
|
20949
|
+
columnName: it.name,
|
|
20950
|
+
schema: schema4
|
|
20778
20951
|
};
|
|
20779
20952
|
});
|
|
20780
20953
|
};
|
|
20781
|
-
_prepareAddColumns = (tableName, columns) => {
|
|
20954
|
+
_prepareAddColumns = (tableName, schema4, columns) => {
|
|
20782
20955
|
return columns.map((it) => {
|
|
20783
20956
|
return {
|
|
20784
20957
|
type: "alter_table_add_column",
|
|
20785
20958
|
tableName,
|
|
20786
|
-
column: it
|
|
20959
|
+
column: it,
|
|
20960
|
+
schema: schema4
|
|
20787
20961
|
};
|
|
20788
20962
|
});
|
|
20789
20963
|
};
|
|
@@ -20803,7 +20977,7 @@ var init_jsonStatements = __esm({
|
|
|
20803
20977
|
};
|
|
20804
20978
|
});
|
|
20805
20979
|
};
|
|
20806
|
-
_prepareAlterColumns = (tableName, columns) => {
|
|
20980
|
+
_prepareAlterColumns = (tableName, schema4, columns) => {
|
|
20807
20981
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
20808
20982
|
let statements = [];
|
|
20809
20983
|
for (const column6 of columns) {
|
|
@@ -20813,7 +20987,8 @@ var init_jsonStatements = __esm({
|
|
|
20813
20987
|
type: "alter_table_rename_column",
|
|
20814
20988
|
tableName,
|
|
20815
20989
|
oldColumnName: column6.name.old,
|
|
20816
|
-
newColumnName: column6.name.new
|
|
20990
|
+
newColumnName: column6.name.new,
|
|
20991
|
+
schema: schema4
|
|
20817
20992
|
});
|
|
20818
20993
|
}
|
|
20819
20994
|
if (((_a = column6.type) == null ? void 0 : _a.type) === "changed") {
|
|
@@ -20821,7 +20996,8 @@ var init_jsonStatements = __esm({
|
|
|
20821
20996
|
type: "alter_table_alter_column_set_type",
|
|
20822
20997
|
tableName,
|
|
20823
20998
|
columnName,
|
|
20824
|
-
newDataType: column6.type.new
|
|
20999
|
+
newDataType: column6.type.new,
|
|
21000
|
+
schema: schema4
|
|
20825
21001
|
});
|
|
20826
21002
|
}
|
|
20827
21003
|
if (((_b = column6.default) == null ? void 0 : _b.type) === "added") {
|
|
@@ -20829,7 +21005,8 @@ var init_jsonStatements = __esm({
|
|
|
20829
21005
|
type: "alter_table_alter_column_set_default",
|
|
20830
21006
|
tableName,
|
|
20831
21007
|
columnName,
|
|
20832
|
-
newDefaultValue: column6.default.value
|
|
21008
|
+
newDefaultValue: column6.default.value,
|
|
21009
|
+
schema: schema4
|
|
20833
21010
|
});
|
|
20834
21011
|
}
|
|
20835
21012
|
if (((_c = column6.default) == null ? void 0 : _c.type) === "changed") {
|
|
@@ -20837,21 +21014,24 @@ var init_jsonStatements = __esm({
|
|
|
20837
21014
|
type: "alter_table_alter_column_set_default",
|
|
20838
21015
|
tableName,
|
|
20839
21016
|
columnName,
|
|
20840
|
-
newDefaultValue: column6.default.new
|
|
21017
|
+
newDefaultValue: column6.default.new,
|
|
21018
|
+
schema: schema4
|
|
20841
21019
|
});
|
|
20842
21020
|
}
|
|
20843
21021
|
if (((_d = column6.default) == null ? void 0 : _d.type) === "deleted") {
|
|
20844
21022
|
statements.push({
|
|
20845
21023
|
type: "alter_table_alter_column_drop_default",
|
|
20846
21024
|
tableName,
|
|
20847
|
-
columnName
|
|
21025
|
+
columnName,
|
|
21026
|
+
schema: schema4
|
|
20848
21027
|
});
|
|
20849
21028
|
}
|
|
20850
21029
|
if (((_e = column6.notNull) == null ? void 0 : _e.type) === "added") {
|
|
20851
21030
|
statements.push({
|
|
20852
21031
|
type: "alter_table_alter_column_set_notnull",
|
|
20853
21032
|
tableName,
|
|
20854
|
-
columnName
|
|
21033
|
+
columnName,
|
|
21034
|
+
schema: schema4
|
|
20855
21035
|
});
|
|
20856
21036
|
}
|
|
20857
21037
|
if (((_f = column6.notNull) == null ? void 0 : _f.type) === "changed") {
|
|
@@ -20859,62 +21039,69 @@ var init_jsonStatements = __esm({
|
|
|
20859
21039
|
statements.push({
|
|
20860
21040
|
type,
|
|
20861
21041
|
tableName,
|
|
20862
|
-
columnName
|
|
21042
|
+
columnName,
|
|
21043
|
+
schema: schema4
|
|
20863
21044
|
});
|
|
20864
21045
|
}
|
|
20865
21046
|
if (((_g = column6.notNull) == null ? void 0 : _g.type) === "deleted") {
|
|
20866
21047
|
statements.push({
|
|
20867
21048
|
type: "alter_table_alter_column_drop_notnull",
|
|
20868
21049
|
tableName,
|
|
20869
|
-
columnName
|
|
21050
|
+
columnName,
|
|
21051
|
+
schema: schema4
|
|
20870
21052
|
});
|
|
20871
21053
|
}
|
|
20872
21054
|
}
|
|
20873
21055
|
return statements;
|
|
20874
21056
|
};
|
|
20875
|
-
prepareCreateIndexesJson = (tableName, indexes) => {
|
|
21057
|
+
prepareCreateIndexesJson = (tableName, schema4, indexes) => {
|
|
20876
21058
|
return Object.values(indexes).map((indexData) => {
|
|
20877
21059
|
return {
|
|
20878
21060
|
type: "create_index",
|
|
20879
21061
|
tableName,
|
|
20880
|
-
data: indexData
|
|
21062
|
+
data: indexData,
|
|
21063
|
+
schema: schema4
|
|
20881
21064
|
};
|
|
20882
21065
|
});
|
|
20883
21066
|
};
|
|
20884
|
-
prepareCreateReferencesJson = (tableName, foreignKeys) => {
|
|
21067
|
+
prepareCreateReferencesJson = (tableName, schema4, foreignKeys) => {
|
|
20885
21068
|
return Object.values(foreignKeys).map((fkData) => {
|
|
20886
21069
|
return {
|
|
20887
21070
|
type: "create_reference",
|
|
20888
21071
|
tableName,
|
|
20889
|
-
data: fkData
|
|
21072
|
+
data: fkData,
|
|
21073
|
+
schema: schema4
|
|
20890
21074
|
};
|
|
20891
21075
|
});
|
|
20892
21076
|
};
|
|
20893
|
-
prepareDropReferencesJson = (tableName, foreignKeys) => {
|
|
21077
|
+
prepareDropReferencesJson = (tableName, schema4, foreignKeys) => {
|
|
20894
21078
|
return Object.values(foreignKeys).map((fkData) => {
|
|
20895
21079
|
return {
|
|
20896
21080
|
type: "delete_reference",
|
|
20897
21081
|
tableName,
|
|
20898
|
-
data: fkData
|
|
21082
|
+
data: fkData,
|
|
21083
|
+
schema: schema4
|
|
20899
21084
|
};
|
|
20900
21085
|
});
|
|
20901
21086
|
};
|
|
20902
|
-
prepareAlterReferencesJson = (tableName, foreignKeys) => {
|
|
21087
|
+
prepareAlterReferencesJson = (tableName, schema4, foreignKeys) => {
|
|
20903
21088
|
return Object.values(foreignKeys).map((fkData) => {
|
|
20904
21089
|
return {
|
|
20905
21090
|
type: "alter_reference",
|
|
20906
21091
|
tableName,
|
|
20907
21092
|
data: fkData.__new,
|
|
20908
|
-
oldFkey: fkData.__old
|
|
21093
|
+
oldFkey: fkData.__old,
|
|
21094
|
+
schema: schema4
|
|
20909
21095
|
};
|
|
20910
21096
|
});
|
|
20911
21097
|
};
|
|
20912
|
-
prepareDropIndexesJson = (tableName, indexes) => {
|
|
21098
|
+
prepareDropIndexesJson = (tableName, schema4, indexes) => {
|
|
20913
21099
|
return Object.values(indexes).map((indexData) => {
|
|
20914
21100
|
return {
|
|
20915
21101
|
type: "drop_index",
|
|
20916
21102
|
tableName,
|
|
20917
|
-
data: indexData
|
|
21103
|
+
data: indexData,
|
|
21104
|
+
schema: schema4
|
|
20918
21105
|
};
|
|
20919
21106
|
});
|
|
20920
21107
|
};
|
|
@@ -20950,13 +21137,14 @@ var init_jsonStatements = __esm({
|
|
|
20950
21137
|
});
|
|
20951
21138
|
|
|
20952
21139
|
// src/snapshotsDiffer.ts
|
|
20953
|
-
var makeChanged, makeSelfOrChanged, makePatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
|
|
21140
|
+
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, valueFromSelfOrPatchedNew, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
|
|
20954
21141
|
var init_snapshotsDiffer = __esm({
|
|
20955
21142
|
"src/snapshotsDiffer.ts"() {
|
|
20956
21143
|
init_sqlgenerator();
|
|
20957
21144
|
init_lib();
|
|
20958
21145
|
init_jsonDiffer();
|
|
20959
21146
|
init_jsonStatements();
|
|
21147
|
+
init_utils();
|
|
20960
21148
|
makeChanged = (schema4) => {
|
|
20961
21149
|
return objectType({
|
|
20962
21150
|
type: enumType(["changed"]),
|
|
@@ -20977,20 +21165,53 @@ var init_snapshotsDiffer = __esm({
|
|
|
20977
21165
|
makePatched = (schema4) => {
|
|
20978
21166
|
return unionType([
|
|
20979
21167
|
objectType({
|
|
20980
|
-
type:
|
|
21168
|
+
type: literalType("added"),
|
|
20981
21169
|
value: schema4
|
|
20982
21170
|
}),
|
|
20983
21171
|
objectType({
|
|
20984
|
-
type:
|
|
21172
|
+
type: literalType("deleted"),
|
|
20985
21173
|
value: schema4
|
|
20986
21174
|
}),
|
|
20987
21175
|
objectType({
|
|
20988
|
-
type:
|
|
21176
|
+
type: literalType("changed"),
|
|
20989
21177
|
old: schema4,
|
|
20990
21178
|
new: schema4
|
|
20991
21179
|
})
|
|
20992
21180
|
]);
|
|
20993
21181
|
};
|
|
21182
|
+
makeSelfOrPatched = (schema4) => {
|
|
21183
|
+
return unionType([
|
|
21184
|
+
objectType({
|
|
21185
|
+
type: literalType("none"),
|
|
21186
|
+
value: schema4.optional()
|
|
21187
|
+
}),
|
|
21188
|
+
objectType({
|
|
21189
|
+
type: literalType("added"),
|
|
21190
|
+
value: schema4
|
|
21191
|
+
}),
|
|
21192
|
+
objectType({
|
|
21193
|
+
type: literalType("deleted"),
|
|
21194
|
+
value: schema4
|
|
21195
|
+
}),
|
|
21196
|
+
objectType({
|
|
21197
|
+
type: literalType("changed"),
|
|
21198
|
+
old: schema4,
|
|
21199
|
+
new: schema4
|
|
21200
|
+
})
|
|
21201
|
+
]);
|
|
21202
|
+
};
|
|
21203
|
+
valueFromSelfOrPatchedNew = (it) => {
|
|
21204
|
+
switch (it.type) {
|
|
21205
|
+
case "none":
|
|
21206
|
+
return it.value;
|
|
21207
|
+
case "added":
|
|
21208
|
+
return it.value;
|
|
21209
|
+
case "deleted":
|
|
21210
|
+
return it.value;
|
|
21211
|
+
case "changed":
|
|
21212
|
+
return it.new;
|
|
21213
|
+
}
|
|
21214
|
+
};
|
|
20994
21215
|
columnSchema = objectType({
|
|
20995
21216
|
name: stringType(),
|
|
20996
21217
|
type: stringType(),
|
|
@@ -21003,7 +21224,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
21003
21224
|
alteredColumnSchema = objectType({
|
|
21004
21225
|
name: makeSelfOrChanged(stringType()),
|
|
21005
21226
|
type: makeChanged(stringType()).optional(),
|
|
21006
|
-
default: makePatched(
|
|
21227
|
+
default: makePatched(anyType()).optional(),
|
|
21007
21228
|
notNull: makePatched(booleanType()).optional()
|
|
21008
21229
|
}).strict();
|
|
21009
21230
|
enumSchema2 = objectType({
|
|
@@ -21025,7 +21246,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
21025
21246
|
}).strict();
|
|
21026
21247
|
alteredTableScheme = objectType({
|
|
21027
21248
|
name: stringType(),
|
|
21028
|
-
schema:
|
|
21249
|
+
schema: makeSelfOrPatched(stringType()),
|
|
21029
21250
|
deleted: columnSchema.array(),
|
|
21030
21251
|
added: columnSchema.array(),
|
|
21031
21252
|
altered: alteredColumnSchema.array(),
|
|
@@ -21060,7 +21281,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
21060
21281
|
addedSchemas: stringType().array(),
|
|
21061
21282
|
deletedSchemas: stringType().array()
|
|
21062
21283
|
}).strict();
|
|
21063
|
-
applySnapshotsDiff = async (json1, json2, dialect6,
|
|
21284
|
+
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver2, tablesResolver2, columnsResolver2) => {
|
|
21064
21285
|
var _a, _b, _c, _d;
|
|
21065
21286
|
const diffResult = applyJsonDiff(json1, json2);
|
|
21066
21287
|
if (Object.keys(diffResult).length === 0) {
|
|
@@ -21071,14 +21292,21 @@ var init_snapshotsDiffer = __esm({
|
|
|
21071
21292
|
created: createdSchemas,
|
|
21072
21293
|
deleted: deletedSchemas,
|
|
21073
21294
|
renamed: renamedSchemas
|
|
21074
|
-
} = await
|
|
21295
|
+
} = await schemasResolver2({
|
|
21075
21296
|
created: typedResult.addedSchemas.map((it) => ({ name: it })),
|
|
21076
21297
|
deleted: typedResult.deletedSchemas.map((it) => ({ name: it }))
|
|
21077
21298
|
});
|
|
21078
|
-
const { created, deleted, renamed } = await
|
|
21299
|
+
const { created, deleted, renamed } = await tablesResolver2({
|
|
21079
21300
|
created: typedResult.addedTables,
|
|
21080
21301
|
deleted: typedResult.deletedTables
|
|
21081
21302
|
});
|
|
21303
|
+
const rSchemas = renamedSchemas.map((it) => ({
|
|
21304
|
+
from: it.from.name,
|
|
21305
|
+
to: it.to.name
|
|
21306
|
+
}));
|
|
21307
|
+
const rTables = renamed.map((it) => {
|
|
21308
|
+
return { from: it.from, to: it.to };
|
|
21309
|
+
});
|
|
21082
21310
|
const jsonStatements = [];
|
|
21083
21311
|
const jsonSQLiteCreateTables = created.map((it) => {
|
|
21084
21312
|
return prepareSQLiteCreateTable(it);
|
|
@@ -21087,7 +21315,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
21087
21315
|
return prepareCreateTableJson(it);
|
|
21088
21316
|
});
|
|
21089
21317
|
const jsonCreateIndexesForCreatedTables = created.map((it) => {
|
|
21090
|
-
return prepareCreateIndexesJson(it.name, it.indexes);
|
|
21318
|
+
return prepareCreateIndexesJson(it.name, it.schema, it.indexes);
|
|
21091
21319
|
}).flat();
|
|
21092
21320
|
const jsonDropTables = deleted.map((it) => {
|
|
21093
21321
|
return prepareDropTableJson(it);
|
|
@@ -21104,13 +21332,14 @@ var init_snapshotsDiffer = __esm({
|
|
|
21104
21332
|
const jsonRenameColumnsStatements = [];
|
|
21105
21333
|
const allAlteredResolved = [];
|
|
21106
21334
|
for (const table4 of allAltered) {
|
|
21107
|
-
const result = await
|
|
21335
|
+
const result = await columnsResolver2({
|
|
21108
21336
|
tableName: table4.name,
|
|
21109
21337
|
created: table4.added,
|
|
21110
21338
|
deleted: table4.deleted
|
|
21111
21339
|
});
|
|
21340
|
+
const schema4 = valueFromSelfOrPatchedNew(table4.schema);
|
|
21112
21341
|
jsonRenameColumnsStatements.push(
|
|
21113
|
-
...prepareRenameColumns(table4.name, result.renamed)
|
|
21342
|
+
...prepareRenameColumns(table4.name, schema4, result.renamed)
|
|
21114
21343
|
);
|
|
21115
21344
|
const renamedColumnsAltered = result.renamed.map(
|
|
21116
21345
|
(it) => alteredColumnSchema.parse(diffForRenamedColumn(it.from, it.to))
|
|
@@ -21152,7 +21381,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
21152
21381
|
it.name,
|
|
21153
21382
|
it.alteredCompositePKs
|
|
21154
21383
|
);
|
|
21155
|
-
if (it.schema) {
|
|
21384
|
+
if (it.schema && typeof it.schema !== "string") {
|
|
21156
21385
|
switch (it.schema.type) {
|
|
21157
21386
|
case "added": {
|
|
21158
21387
|
jsonSetTableSchemas.push({
|
|
@@ -21185,9 +21414,19 @@ var init_snapshotsDiffer = __esm({
|
|
|
21185
21414
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
|
21186
21415
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
|
21187
21416
|
});
|
|
21417
|
+
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
|
21418
|
+
const tableName = it.tableName;
|
|
21419
|
+
const schema4 = it.schema;
|
|
21420
|
+
return {
|
|
21421
|
+
from: { schema: schema4, table: tableName, column: it.oldColumnName },
|
|
21422
|
+
to: { schema: schema4, table: tableName, column: it.newColumnName }
|
|
21423
|
+
};
|
|
21424
|
+
});
|
|
21188
21425
|
const jsonTableAlternations = allAlteredResolved.map((it) => {
|
|
21426
|
+
const schema4 = valueFromSelfOrPatchedNew(it.schema);
|
|
21189
21427
|
return prepareAlterTableColumnsJson(
|
|
21190
21428
|
it.name,
|
|
21429
|
+
schema4,
|
|
21191
21430
|
it.deleted,
|
|
21192
21431
|
it.added,
|
|
21193
21432
|
it.altered,
|
|
@@ -21204,22 +21443,27 @@ var init_snapshotsDiffer = __esm({
|
|
|
21204
21443
|
{ createColumns: [], dropColumns: [], alterColumns: [] }
|
|
21205
21444
|
);
|
|
21206
21445
|
const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
|
|
21207
|
-
|
|
21446
|
+
const schema4 = valueFromSelfOrPatchedNew(it.schema);
|
|
21447
|
+
return prepareCreateIndexesJson(it.name, schema4, it.addedIndexes || {});
|
|
21208
21448
|
}).flat();
|
|
21209
21449
|
const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
|
|
21210
|
-
|
|
21450
|
+
const schema4 = valueFromSelfOrPatchedNew(it.schema);
|
|
21451
|
+
return prepareDropIndexesJson(it.name, schema4, it.deletedIndexes || {});
|
|
21211
21452
|
}).flat();
|
|
21212
21453
|
const jsonCreateReferencesForCreatedTables = created.map((it) => {
|
|
21213
|
-
return prepareCreateReferencesJson(it.name, it.foreignKeys);
|
|
21454
|
+
return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
|
|
21214
21455
|
}).flat();
|
|
21215
21456
|
const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
|
|
21216
|
-
const
|
|
21457
|
+
const schema4 = valueFromSelfOrPatchedNew(it.schema);
|
|
21458
|
+
const forAdded = dialect6 !== "sqlite" ? prepareCreateReferencesJson(it.name, schema4, it.addedForeignKeys) : [];
|
|
21217
21459
|
const forAltered = prepareDropReferencesJson(
|
|
21218
21460
|
it.name,
|
|
21461
|
+
schema4,
|
|
21219
21462
|
it.deletedForeignKeys
|
|
21220
21463
|
);
|
|
21221
21464
|
const alteredFKs = prepareAlterReferencesJson(
|
|
21222
21465
|
it.name,
|
|
21466
|
+
schema4,
|
|
21223
21467
|
it.alteredForeignKeys
|
|
21224
21468
|
);
|
|
21225
21469
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
|
@@ -21281,8 +21525,1330 @@ var init_snapshotsDiffer = __esm({
|
|
|
21281
21525
|
jsonStatements.push(...jsonRemoveTableFromSchemas);
|
|
21282
21526
|
jsonStatements.push(...dropSchemas);
|
|
21283
21527
|
const sqlStatements = fromJson(jsonStatements, dialect6);
|
|
21284
|
-
|
|
21285
|
-
|
|
21528
|
+
const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
|
|
21529
|
+
return { statements: jsonStatements, sql: sqlStatements.join("\n"), _meta };
|
|
21530
|
+
};
|
|
21531
|
+
}
|
|
21532
|
+
});
|
|
21533
|
+
|
|
21534
|
+
// src/utils/words.ts
|
|
21535
|
+
var prepareMigrationMetadata, adjectives, heroes;
|
|
21536
|
+
var init_words = __esm({
|
|
21537
|
+
"src/utils/words.ts"() {
|
|
21538
|
+
prepareMigrationMetadata = (idx) => {
|
|
21539
|
+
const prefix = idx.toFixed(0).padStart(4, "0");
|
|
21540
|
+
const suffix = `${adjectives.random()}_${heroes.random()}`;
|
|
21541
|
+
const tag = `${prefix}_${suffix}`;
|
|
21542
|
+
return { prefix, suffix, tag };
|
|
21543
|
+
};
|
|
21544
|
+
adjectives = [
|
|
21545
|
+
"abandoned",
|
|
21546
|
+
"aberrant",
|
|
21547
|
+
"abnormal",
|
|
21548
|
+
"absent",
|
|
21549
|
+
"absurd",
|
|
21550
|
+
"acoustic",
|
|
21551
|
+
"adorable",
|
|
21552
|
+
"amazing",
|
|
21553
|
+
"ambiguous",
|
|
21554
|
+
"ambitious",
|
|
21555
|
+
"amused",
|
|
21556
|
+
"amusing",
|
|
21557
|
+
"ancient",
|
|
21558
|
+
"aromatic",
|
|
21559
|
+
"aspiring",
|
|
21560
|
+
"awesome",
|
|
21561
|
+
"bent",
|
|
21562
|
+
"big",
|
|
21563
|
+
"bitter",
|
|
21564
|
+
"bizarre",
|
|
21565
|
+
"black",
|
|
21566
|
+
"blue",
|
|
21567
|
+
"blushing",
|
|
21568
|
+
"bored",
|
|
21569
|
+
"boring",
|
|
21570
|
+
"bouncy",
|
|
21571
|
+
"brainy",
|
|
21572
|
+
"brave",
|
|
21573
|
+
"breezy",
|
|
21574
|
+
"brief",
|
|
21575
|
+
"bright",
|
|
21576
|
+
"broad",
|
|
21577
|
+
"broken",
|
|
21578
|
+
"brown",
|
|
21579
|
+
"bumpy",
|
|
21580
|
+
"burly",
|
|
21581
|
+
"busy",
|
|
21582
|
+
"calm",
|
|
21583
|
+
"careful",
|
|
21584
|
+
"careless",
|
|
21585
|
+
"certain",
|
|
21586
|
+
"charming",
|
|
21587
|
+
"cheerful",
|
|
21588
|
+
"chemical",
|
|
21589
|
+
"chief",
|
|
21590
|
+
"chilly",
|
|
21591
|
+
"chubby",
|
|
21592
|
+
"chunky",
|
|
21593
|
+
"clammy",
|
|
21594
|
+
"classy",
|
|
21595
|
+
"clean",
|
|
21596
|
+
"clear",
|
|
21597
|
+
"clever",
|
|
21598
|
+
"cloudy",
|
|
21599
|
+
"closed",
|
|
21600
|
+
"clumsy",
|
|
21601
|
+
"cold",
|
|
21602
|
+
"colorful",
|
|
21603
|
+
"colossal",
|
|
21604
|
+
"common",
|
|
21605
|
+
"complete",
|
|
21606
|
+
"complex",
|
|
21607
|
+
"concerned",
|
|
21608
|
+
"condemned",
|
|
21609
|
+
"confused",
|
|
21610
|
+
"conscious",
|
|
21611
|
+
"cooing",
|
|
21612
|
+
"cool",
|
|
21613
|
+
"crazy",
|
|
21614
|
+
"cuddly",
|
|
21615
|
+
"cultured",
|
|
21616
|
+
"curious",
|
|
21617
|
+
"curly",
|
|
21618
|
+
"curved",
|
|
21619
|
+
"curvy",
|
|
21620
|
+
"cute",
|
|
21621
|
+
"cynical",
|
|
21622
|
+
"daffy",
|
|
21623
|
+
"daily",
|
|
21624
|
+
"damp",
|
|
21625
|
+
"dapper",
|
|
21626
|
+
"dark",
|
|
21627
|
+
"dashing",
|
|
21628
|
+
"dazzling",
|
|
21629
|
+
"dear",
|
|
21630
|
+
"deep",
|
|
21631
|
+
"demonic",
|
|
21632
|
+
"dizzy",
|
|
21633
|
+
"dry",
|
|
21634
|
+
"dusty",
|
|
21635
|
+
"eager",
|
|
21636
|
+
"early",
|
|
21637
|
+
"easy",
|
|
21638
|
+
"elite",
|
|
21639
|
+
"eminent",
|
|
21640
|
+
"empty",
|
|
21641
|
+
"equal",
|
|
21642
|
+
"even",
|
|
21643
|
+
"exotic",
|
|
21644
|
+
"fair",
|
|
21645
|
+
"faithful",
|
|
21646
|
+
"familiar",
|
|
21647
|
+
"famous",
|
|
21648
|
+
"fancy",
|
|
21649
|
+
"fantastic",
|
|
21650
|
+
"far",
|
|
21651
|
+
"fast",
|
|
21652
|
+
"fat",
|
|
21653
|
+
"faulty",
|
|
21654
|
+
"fearless",
|
|
21655
|
+
"fine",
|
|
21656
|
+
"first",
|
|
21657
|
+
"fixed",
|
|
21658
|
+
"flaky",
|
|
21659
|
+
"flashy",
|
|
21660
|
+
"flat",
|
|
21661
|
+
"flawless",
|
|
21662
|
+
"flimsy",
|
|
21663
|
+
"flippant",
|
|
21664
|
+
"flowery",
|
|
21665
|
+
"fluffy",
|
|
21666
|
+
"foamy",
|
|
21667
|
+
"free",
|
|
21668
|
+
"freezing",
|
|
21669
|
+
"fresh",
|
|
21670
|
+
"friendly",
|
|
21671
|
+
"funny",
|
|
21672
|
+
"furry",
|
|
21673
|
+
"futuristic",
|
|
21674
|
+
"fuzzy",
|
|
21675
|
+
"giant",
|
|
21676
|
+
"gifted",
|
|
21677
|
+
"gigantic",
|
|
21678
|
+
"glamorous",
|
|
21679
|
+
"glorious",
|
|
21680
|
+
"glossy",
|
|
21681
|
+
"good",
|
|
21682
|
+
"goofy",
|
|
21683
|
+
"gorgeous",
|
|
21684
|
+
"graceful",
|
|
21685
|
+
"gray",
|
|
21686
|
+
"great",
|
|
21687
|
+
"greedy",
|
|
21688
|
+
"green",
|
|
21689
|
+
"grey",
|
|
21690
|
+
"groovy",
|
|
21691
|
+
"handy",
|
|
21692
|
+
"happy",
|
|
21693
|
+
"hard",
|
|
21694
|
+
"harsh",
|
|
21695
|
+
"heavy",
|
|
21696
|
+
"hesitant",
|
|
21697
|
+
"high",
|
|
21698
|
+
"hot",
|
|
21699
|
+
"huge",
|
|
21700
|
+
"icy",
|
|
21701
|
+
"illegal",
|
|
21702
|
+
"jazzy",
|
|
21703
|
+
"jittery",
|
|
21704
|
+
"keen",
|
|
21705
|
+
"kind",
|
|
21706
|
+
"known",
|
|
21707
|
+
"lame",
|
|
21708
|
+
"large",
|
|
21709
|
+
"last",
|
|
21710
|
+
"late",
|
|
21711
|
+
"lazy",
|
|
21712
|
+
"lean",
|
|
21713
|
+
"left",
|
|
21714
|
+
"legal",
|
|
21715
|
+
"lethal",
|
|
21716
|
+
"light",
|
|
21717
|
+
"little",
|
|
21718
|
+
"lively",
|
|
21719
|
+
"living",
|
|
21720
|
+
"lonely",
|
|
21721
|
+
"long",
|
|
21722
|
+
"loose",
|
|
21723
|
+
"loud",
|
|
21724
|
+
"lovely",
|
|
21725
|
+
"loving",
|
|
21726
|
+
"low",
|
|
21727
|
+
"lowly",
|
|
21728
|
+
"lucky",
|
|
21729
|
+
"lumpy",
|
|
21730
|
+
"lush",
|
|
21731
|
+
"luxuriant",
|
|
21732
|
+
"lying",
|
|
21733
|
+
"lyrical",
|
|
21734
|
+
"magenta",
|
|
21735
|
+
"magical",
|
|
21736
|
+
"majestic",
|
|
21737
|
+
"many",
|
|
21738
|
+
"massive",
|
|
21739
|
+
"married",
|
|
21740
|
+
"marvelous",
|
|
21741
|
+
"material",
|
|
21742
|
+
"mature",
|
|
21743
|
+
"mean",
|
|
21744
|
+
"medical",
|
|
21745
|
+
"melodic",
|
|
21746
|
+
"melted",
|
|
21747
|
+
"messy",
|
|
21748
|
+
"mighty",
|
|
21749
|
+
"military",
|
|
21750
|
+
"milky",
|
|
21751
|
+
"minor",
|
|
21752
|
+
"misty",
|
|
21753
|
+
"mixed",
|
|
21754
|
+
"moaning",
|
|
21755
|
+
"modern",
|
|
21756
|
+
"motionless",
|
|
21757
|
+
"mushy",
|
|
21758
|
+
"mute",
|
|
21759
|
+
"mysterious",
|
|
21760
|
+
"naive",
|
|
21761
|
+
"nappy",
|
|
21762
|
+
"narrow",
|
|
21763
|
+
"nasty",
|
|
21764
|
+
"natural",
|
|
21765
|
+
"neat",
|
|
21766
|
+
"nebulous",
|
|
21767
|
+
"needy",
|
|
21768
|
+
"nervous",
|
|
21769
|
+
"new",
|
|
21770
|
+
"next",
|
|
21771
|
+
"nice",
|
|
21772
|
+
"nifty",
|
|
21773
|
+
"noisy",
|
|
21774
|
+
"normal",
|
|
21775
|
+
"nostalgic",
|
|
21776
|
+
"nosy",
|
|
21777
|
+
"numerous",
|
|
21778
|
+
"odd",
|
|
21779
|
+
"old",
|
|
21780
|
+
"omniscient",
|
|
21781
|
+
"open",
|
|
21782
|
+
"opposite",
|
|
21783
|
+
"optimal",
|
|
21784
|
+
"orange",
|
|
21785
|
+
"ordinary",
|
|
21786
|
+
"organic",
|
|
21787
|
+
"outgoing",
|
|
21788
|
+
"outstanding",
|
|
21789
|
+
"oval",
|
|
21790
|
+
"overconfident",
|
|
21791
|
+
"overjoyed",
|
|
21792
|
+
"overrated",
|
|
21793
|
+
"pale",
|
|
21794
|
+
"panoramic",
|
|
21795
|
+
"parallel",
|
|
21796
|
+
"parched",
|
|
21797
|
+
"past",
|
|
21798
|
+
"peaceful",
|
|
21799
|
+
"perfect",
|
|
21800
|
+
"perpetual",
|
|
21801
|
+
"petite",
|
|
21802
|
+
"pink",
|
|
21803
|
+
"plain",
|
|
21804
|
+
"polite",
|
|
21805
|
+
"powerful",
|
|
21806
|
+
"premium",
|
|
21807
|
+
"pretty",
|
|
21808
|
+
"previous",
|
|
21809
|
+
"productive",
|
|
21810
|
+
"public",
|
|
21811
|
+
"purple",
|
|
21812
|
+
"puzzling",
|
|
21813
|
+
"quick",
|
|
21814
|
+
"quiet",
|
|
21815
|
+
"rainy",
|
|
21816
|
+
"rapid",
|
|
21817
|
+
"rare",
|
|
21818
|
+
"real",
|
|
21819
|
+
"red",
|
|
21820
|
+
"redundant",
|
|
21821
|
+
"reflective",
|
|
21822
|
+
"regular",
|
|
21823
|
+
"remarkable",
|
|
21824
|
+
"rich",
|
|
21825
|
+
"right",
|
|
21826
|
+
"robust",
|
|
21827
|
+
"romantic",
|
|
21828
|
+
"round",
|
|
21829
|
+
"sad",
|
|
21830
|
+
"safe",
|
|
21831
|
+
"salty",
|
|
21832
|
+
"same",
|
|
21833
|
+
"secret",
|
|
21834
|
+
"serious",
|
|
21835
|
+
"shallow",
|
|
21836
|
+
"sharp",
|
|
21837
|
+
"shiny",
|
|
21838
|
+
"shocking",
|
|
21839
|
+
"short",
|
|
21840
|
+
"silent",
|
|
21841
|
+
"silky",
|
|
21842
|
+
"silly",
|
|
21843
|
+
"simple",
|
|
21844
|
+
"skinny",
|
|
21845
|
+
"sleepy",
|
|
21846
|
+
"slim",
|
|
21847
|
+
"slimy",
|
|
21848
|
+
"slippery",
|
|
21849
|
+
"sloppy",
|
|
21850
|
+
"slow",
|
|
21851
|
+
"small",
|
|
21852
|
+
"smart",
|
|
21853
|
+
"smiling",
|
|
21854
|
+
"smooth",
|
|
21855
|
+
"soft",
|
|
21856
|
+
"solid",
|
|
21857
|
+
"sour",
|
|
21858
|
+
"sparkling",
|
|
21859
|
+
"special",
|
|
21860
|
+
"spicy",
|
|
21861
|
+
"spooky",
|
|
21862
|
+
"spotty",
|
|
21863
|
+
"square",
|
|
21864
|
+
"stale",
|
|
21865
|
+
"steady",
|
|
21866
|
+
"steep",
|
|
21867
|
+
"sticky",
|
|
21868
|
+
"stiff",
|
|
21869
|
+
"stormy",
|
|
21870
|
+
"strange",
|
|
21871
|
+
"striped",
|
|
21872
|
+
"strong",
|
|
21873
|
+
"sturdy",
|
|
21874
|
+
"sudden",
|
|
21875
|
+
"superb",
|
|
21876
|
+
"supreme",
|
|
21877
|
+
"sweet",
|
|
21878
|
+
"swift",
|
|
21879
|
+
"talented",
|
|
21880
|
+
"tan",
|
|
21881
|
+
"tearful",
|
|
21882
|
+
"tense",
|
|
21883
|
+
"thankful",
|
|
21884
|
+
"thick",
|
|
21885
|
+
"thin",
|
|
21886
|
+
"third",
|
|
21887
|
+
"tidy",
|
|
21888
|
+
"tiny",
|
|
21889
|
+
"tired",
|
|
21890
|
+
"tiresome",
|
|
21891
|
+
"tough",
|
|
21892
|
+
"tranquil",
|
|
21893
|
+
"tricky",
|
|
21894
|
+
"true",
|
|
21895
|
+
"typical",
|
|
21896
|
+
"uneven",
|
|
21897
|
+
"unique",
|
|
21898
|
+
"unknown",
|
|
21899
|
+
"unusual",
|
|
21900
|
+
"useful",
|
|
21901
|
+
"vengeful",
|
|
21902
|
+
"violet",
|
|
21903
|
+
"volatile",
|
|
21904
|
+
"wakeful",
|
|
21905
|
+
"wandering",
|
|
21906
|
+
"warm",
|
|
21907
|
+
"watery",
|
|
21908
|
+
"wealthy",
|
|
21909
|
+
"wet",
|
|
21910
|
+
"white",
|
|
21911
|
+
"whole",
|
|
21912
|
+
"wide",
|
|
21913
|
+
"wild",
|
|
21914
|
+
"windy",
|
|
21915
|
+
"wise",
|
|
21916
|
+
"wonderful",
|
|
21917
|
+
"wooden",
|
|
21918
|
+
"woozy",
|
|
21919
|
+
"workable",
|
|
21920
|
+
"worried",
|
|
21921
|
+
"worthless",
|
|
21922
|
+
"yellow",
|
|
21923
|
+
"yielding",
|
|
21924
|
+
"young",
|
|
21925
|
+
"youthful",
|
|
21926
|
+
"yummy",
|
|
21927
|
+
"zippy"
|
|
21928
|
+
];
|
|
21929
|
+
heroes = [
|
|
21930
|
+
"aaron_stack",
|
|
21931
|
+
"abomination",
|
|
21932
|
+
"absorbing_man",
|
|
21933
|
+
"adam_destine",
|
|
21934
|
+
"adam_warlock",
|
|
21935
|
+
"agent_brand",
|
|
21936
|
+
"agent_zero",
|
|
21937
|
+
"albert_cleary",
|
|
21938
|
+
"alex_power",
|
|
21939
|
+
"alex_wilder",
|
|
21940
|
+
"alice",
|
|
21941
|
+
"amazoness",
|
|
21942
|
+
"amphibian",
|
|
21943
|
+
"angel",
|
|
21944
|
+
"anita_blake",
|
|
21945
|
+
"annihilus",
|
|
21946
|
+
"anthem",
|
|
21947
|
+
"apocalypse",
|
|
21948
|
+
"aqueduct",
|
|
21949
|
+
"arachne",
|
|
21950
|
+
"archangel",
|
|
21951
|
+
"arclight",
|
|
21952
|
+
"ares",
|
|
21953
|
+
"argent",
|
|
21954
|
+
"avengers",
|
|
21955
|
+
"azazel",
|
|
21956
|
+
"banshee",
|
|
21957
|
+
"baron_strucker",
|
|
21958
|
+
"baron_zemo",
|
|
21959
|
+
"barracuda",
|
|
21960
|
+
"bastion",
|
|
21961
|
+
"beast",
|
|
21962
|
+
"bedlam",
|
|
21963
|
+
"ben_grimm",
|
|
21964
|
+
"ben_parker",
|
|
21965
|
+
"ben_urich",
|
|
21966
|
+
"betty_brant",
|
|
21967
|
+
"betty_ross",
|
|
21968
|
+
"beyonder",
|
|
21969
|
+
"big_bertha",
|
|
21970
|
+
"bill_hollister",
|
|
21971
|
+
"bishop",
|
|
21972
|
+
"black_bird",
|
|
21973
|
+
"black_bolt",
|
|
21974
|
+
"black_cat",
|
|
21975
|
+
"black_crow",
|
|
21976
|
+
"black_knight",
|
|
21977
|
+
"black_panther",
|
|
21978
|
+
"black_queen",
|
|
21979
|
+
"black_tarantula",
|
|
21980
|
+
"black_tom",
|
|
21981
|
+
"black_widow",
|
|
21982
|
+
"blackheart",
|
|
21983
|
+
"blacklash",
|
|
21984
|
+
"blade",
|
|
21985
|
+
"blazing_skull",
|
|
21986
|
+
"blindfold",
|
|
21987
|
+
"blink",
|
|
21988
|
+
"blizzard",
|
|
21989
|
+
"blob",
|
|
21990
|
+
"blockbuster",
|
|
21991
|
+
"blonde_phantom",
|
|
21992
|
+
"bloodaxe",
|
|
21993
|
+
"bloodscream",
|
|
21994
|
+
"bloodstorm",
|
|
21995
|
+
"bloodstrike",
|
|
21996
|
+
"blue_blade",
|
|
21997
|
+
"blue_marvel",
|
|
21998
|
+
"blue_shield",
|
|
21999
|
+
"blur",
|
|
22000
|
+
"boom_boom",
|
|
22001
|
+
"boomer",
|
|
22002
|
+
"boomerang",
|
|
22003
|
+
"bromley",
|
|
22004
|
+
"brood",
|
|
22005
|
+
"brother_voodoo",
|
|
22006
|
+
"bruce_banner",
|
|
22007
|
+
"bucky",
|
|
22008
|
+
"bug",
|
|
22009
|
+
"bulldozer",
|
|
22010
|
+
"bullseye",
|
|
22011
|
+
"bushwacker",
|
|
22012
|
+
"butterfly",
|
|
22013
|
+
"cable",
|
|
22014
|
+
"callisto",
|
|
22015
|
+
"calypso",
|
|
22016
|
+
"cammi",
|
|
22017
|
+
"cannonball",
|
|
22018
|
+
"captain_america",
|
|
22019
|
+
"captain_britain",
|
|
22020
|
+
"captain_cross",
|
|
22021
|
+
"captain_flint",
|
|
22022
|
+
"captain_marvel",
|
|
22023
|
+
"captain_midlands",
|
|
22024
|
+
"captain_stacy",
|
|
22025
|
+
"captain_universe",
|
|
22026
|
+
"cardiac",
|
|
22027
|
+
"caretaker",
|
|
22028
|
+
"cargill",
|
|
22029
|
+
"carlie_cooper",
|
|
22030
|
+
"carmella_unuscione",
|
|
22031
|
+
"carnage",
|
|
22032
|
+
"cassandra_nova",
|
|
22033
|
+
"catseye",
|
|
22034
|
+
"celestials",
|
|
22035
|
+
"centennial",
|
|
22036
|
+
"cerebro",
|
|
22037
|
+
"cerise",
|
|
22038
|
+
"chamber",
|
|
22039
|
+
"chameleon",
|
|
22040
|
+
"champions",
|
|
22041
|
+
"changeling",
|
|
22042
|
+
"charles_xavier",
|
|
22043
|
+
"chat",
|
|
22044
|
+
"chimera",
|
|
22045
|
+
"christian_walker",
|
|
22046
|
+
"chronomancer",
|
|
22047
|
+
"clea",
|
|
22048
|
+
"clint_barton",
|
|
22049
|
+
"cloak",
|
|
22050
|
+
"cobalt_man",
|
|
22051
|
+
"colleen_wing",
|
|
22052
|
+
"colonel_america",
|
|
22053
|
+
"colossus",
|
|
22054
|
+
"corsair",
|
|
22055
|
+
"crusher_hogan",
|
|
22056
|
+
"crystal",
|
|
22057
|
+
"cyclops",
|
|
22058
|
+
"dagger",
|
|
22059
|
+
"daimon_hellstrom",
|
|
22060
|
+
"dakota_north",
|
|
22061
|
+
"daredevil",
|
|
22062
|
+
"dark_beast",
|
|
22063
|
+
"dark_phoenix",
|
|
22064
|
+
"darkhawk",
|
|
22065
|
+
"darkstar",
|
|
22066
|
+
"darwin",
|
|
22067
|
+
"dazzler",
|
|
22068
|
+
"deadpool",
|
|
22069
|
+
"deathbird",
|
|
22070
|
+
"deathstrike",
|
|
22071
|
+
"demogoblin",
|
|
22072
|
+
"devos",
|
|
22073
|
+
"dexter_bennett",
|
|
22074
|
+
"diamondback",
|
|
22075
|
+
"doctor_doom",
|
|
22076
|
+
"doctor_faustus",
|
|
22077
|
+
"doctor_octopus",
|
|
22078
|
+
"doctor_spectrum",
|
|
22079
|
+
"doctor_strange",
|
|
22080
|
+
"domino",
|
|
22081
|
+
"donald_blake",
|
|
22082
|
+
"doomsday",
|
|
22083
|
+
"doorman",
|
|
22084
|
+
"dorian_gray",
|
|
22085
|
+
"dormammu",
|
|
22086
|
+
"dracula",
|
|
22087
|
+
"dragon_lord",
|
|
22088
|
+
"dragon_man",
|
|
22089
|
+
"drax",
|
|
22090
|
+
"dreadnoughts",
|
|
22091
|
+
"dreaming_celestial",
|
|
22092
|
+
"dust",
|
|
22093
|
+
"earthquake",
|
|
22094
|
+
"echo",
|
|
22095
|
+
"eddie_brock",
|
|
22096
|
+
"edwin_jarvis",
|
|
22097
|
+
"ego",
|
|
22098
|
+
"electro",
|
|
22099
|
+
"elektra",
|
|
22100
|
+
"emma_frost",
|
|
22101
|
+
"enchantress",
|
|
22102
|
+
"ender_wiggin",
|
|
22103
|
+
"energizer",
|
|
22104
|
+
"epoch",
|
|
22105
|
+
"eternals",
|
|
22106
|
+
"eternity",
|
|
22107
|
+
"excalibur",
|
|
22108
|
+
"exiles",
|
|
22109
|
+
"exodus",
|
|
22110
|
+
"expediter",
|
|
22111
|
+
"ezekiel",
|
|
22112
|
+
"ezekiel_stane",
|
|
22113
|
+
"fabian_cortez",
|
|
22114
|
+
"falcon",
|
|
22115
|
+
"fallen_one",
|
|
22116
|
+
"famine",
|
|
22117
|
+
"fantastic_four",
|
|
22118
|
+
"fat_cobra",
|
|
22119
|
+
"felicia_hardy",
|
|
22120
|
+
"fenris",
|
|
22121
|
+
"firebird",
|
|
22122
|
+
"firebrand",
|
|
22123
|
+
"firedrake",
|
|
22124
|
+
"firelord",
|
|
22125
|
+
"firestar",
|
|
22126
|
+
"fixer",
|
|
22127
|
+
"flatman",
|
|
22128
|
+
"forge",
|
|
22129
|
+
"forgotten_one",
|
|
22130
|
+
"frank_castle",
|
|
22131
|
+
"franklin_richards",
|
|
22132
|
+
"franklin_storm",
|
|
22133
|
+
"freak",
|
|
22134
|
+
"frightful_four",
|
|
22135
|
+
"frog_thor",
|
|
22136
|
+
"gabe_jones",
|
|
22137
|
+
"galactus",
|
|
22138
|
+
"gambit",
|
|
22139
|
+
"gamma_corps",
|
|
22140
|
+
"gamora",
|
|
22141
|
+
"gargoyle",
|
|
22142
|
+
"garia",
|
|
22143
|
+
"gateway",
|
|
22144
|
+
"gauntlet",
|
|
22145
|
+
"genesis",
|
|
22146
|
+
"george_stacy",
|
|
22147
|
+
"gertrude_yorkes",
|
|
22148
|
+
"ghost_rider",
|
|
22149
|
+
"giant_girl",
|
|
22150
|
+
"giant_man",
|
|
22151
|
+
"gideon",
|
|
22152
|
+
"gladiator",
|
|
22153
|
+
"glorian",
|
|
22154
|
+
"goblin_queen",
|
|
22155
|
+
"golden_guardian",
|
|
22156
|
+
"goliath",
|
|
22157
|
+
"gorgon",
|
|
22158
|
+
"gorilla_man",
|
|
22159
|
+
"grandmaster",
|
|
22160
|
+
"gravity",
|
|
22161
|
+
"green_goblin",
|
|
22162
|
+
"gressill",
|
|
22163
|
+
"grey_gargoyle",
|
|
22164
|
+
"greymalkin",
|
|
22165
|
+
"grim_reaper",
|
|
22166
|
+
"groot",
|
|
22167
|
+
"guardian",
|
|
22168
|
+
"guardsmen",
|
|
22169
|
+
"gunslinger",
|
|
22170
|
+
"gwen_stacy",
|
|
22171
|
+
"hairball",
|
|
22172
|
+
"hammerhead",
|
|
22173
|
+
"hannibal_king",
|
|
22174
|
+
"hardball",
|
|
22175
|
+
"harpoon",
|
|
22176
|
+
"harrier",
|
|
22177
|
+
"harry_osborn",
|
|
22178
|
+
"havok",
|
|
22179
|
+
"hawkeye",
|
|
22180
|
+
"hedge_knight",
|
|
22181
|
+
"hellcat",
|
|
22182
|
+
"hellfire_club",
|
|
22183
|
+
"hellion",
|
|
22184
|
+
"hemingway",
|
|
22185
|
+
"hercules",
|
|
22186
|
+
"hex",
|
|
22187
|
+
"hiroim",
|
|
22188
|
+
"hitman",
|
|
22189
|
+
"hobgoblin",
|
|
22190
|
+
"hulk",
|
|
22191
|
+
"human_cannonball",
|
|
22192
|
+
"human_fly",
|
|
22193
|
+
"human_robot",
|
|
22194
|
+
"human_torch",
|
|
22195
|
+
"husk",
|
|
22196
|
+
"hydra",
|
|
22197
|
+
"iceman",
|
|
22198
|
+
"ikaris",
|
|
22199
|
+
"imperial_guard",
|
|
22200
|
+
"impossible_man",
|
|
22201
|
+
"inertia",
|
|
22202
|
+
"infant_terrible",
|
|
22203
|
+
"inhumans",
|
|
22204
|
+
"ink",
|
|
22205
|
+
"invaders",
|
|
22206
|
+
"invisible_woman",
|
|
22207
|
+
"iron_fist",
|
|
22208
|
+
"iron_lad",
|
|
22209
|
+
"iron_man",
|
|
22210
|
+
"iron_monger",
|
|
22211
|
+
"iron_patriot",
|
|
22212
|
+
"ironclad",
|
|
22213
|
+
"jack_flag",
|
|
22214
|
+
"jack_murdock",
|
|
22215
|
+
"jack_power",
|
|
22216
|
+
"jackal",
|
|
22217
|
+
"jackpot",
|
|
22218
|
+
"james_howlett",
|
|
22219
|
+
"jamie_braddock",
|
|
22220
|
+
"jane_foster",
|
|
22221
|
+
"jasper_sitwell",
|
|
22222
|
+
"jazinda",
|
|
22223
|
+
"jean_grey",
|
|
22224
|
+
"jetstream",
|
|
22225
|
+
"jigsaw",
|
|
22226
|
+
"jimmy_woo",
|
|
22227
|
+
"jocasta",
|
|
22228
|
+
"johnny_blaze",
|
|
22229
|
+
"johnny_storm",
|
|
22230
|
+
"joseph",
|
|
22231
|
+
"joshua_kane",
|
|
22232
|
+
"joystick",
|
|
22233
|
+
"jubilee",
|
|
22234
|
+
"juggernaut",
|
|
22235
|
+
"junta",
|
|
22236
|
+
"justice",
|
|
22237
|
+
"justin_hammer",
|
|
22238
|
+
"kabuki",
|
|
22239
|
+
"kang",
|
|
22240
|
+
"karen_page",
|
|
22241
|
+
"karma",
|
|
22242
|
+
"karnak",
|
|
22243
|
+
"kat_farrell",
|
|
22244
|
+
"kate_bishop",
|
|
22245
|
+
"katie_power",
|
|
22246
|
+
"ken_ellis",
|
|
22247
|
+
"khan",
|
|
22248
|
+
"kid_colt",
|
|
22249
|
+
"killer_shrike",
|
|
22250
|
+
"killmonger",
|
|
22251
|
+
"killraven",
|
|
22252
|
+
"king_bedlam",
|
|
22253
|
+
"king_cobra",
|
|
22254
|
+
"kingpin",
|
|
22255
|
+
"kinsey_walden",
|
|
22256
|
+
"kitty_pryde",
|
|
22257
|
+
"klaw",
|
|
22258
|
+
"komodo",
|
|
22259
|
+
"korath",
|
|
22260
|
+
"korg",
|
|
22261
|
+
"korvac",
|
|
22262
|
+
"kree",
|
|
22263
|
+
"krista_starr",
|
|
22264
|
+
"kronos",
|
|
22265
|
+
"kulan_gath",
|
|
22266
|
+
"kylun",
|
|
22267
|
+
"la_nuit",
|
|
22268
|
+
"lady_bullseye",
|
|
22269
|
+
"lady_deathstrike",
|
|
22270
|
+
"lady_mastermind",
|
|
22271
|
+
"lady_ursula",
|
|
22272
|
+
"lady_vermin",
|
|
22273
|
+
"lake",
|
|
22274
|
+
"landau",
|
|
22275
|
+
"layla_miller",
|
|
22276
|
+
"leader",
|
|
22277
|
+
"leech",
|
|
22278
|
+
"legion",
|
|
22279
|
+
"lenny_balinger",
|
|
22280
|
+
"leo",
|
|
22281
|
+
"leopardon",
|
|
22282
|
+
"leper_queen",
|
|
22283
|
+
"lester",
|
|
22284
|
+
"lethal_legion",
|
|
22285
|
+
"lifeguard",
|
|
22286
|
+
"lightspeed",
|
|
22287
|
+
"lila_cheney",
|
|
22288
|
+
"lilandra",
|
|
22289
|
+
"lilith",
|
|
22290
|
+
"lily_hollister",
|
|
22291
|
+
"lionheart",
|
|
22292
|
+
"living_lightning",
|
|
22293
|
+
"living_mummy",
|
|
22294
|
+
"living_tribunal",
|
|
22295
|
+
"liz_osborn",
|
|
22296
|
+
"lizard",
|
|
22297
|
+
"loa",
|
|
22298
|
+
"lockheed",
|
|
22299
|
+
"lockjaw",
|
|
22300
|
+
"logan",
|
|
22301
|
+
"loki",
|
|
22302
|
+
"loners",
|
|
22303
|
+
"longshot",
|
|
22304
|
+
"lord_hawal",
|
|
22305
|
+
"lord_tyger",
|
|
22306
|
+
"lorna_dane",
|
|
22307
|
+
"luckman",
|
|
22308
|
+
"lucky_pierre",
|
|
22309
|
+
"luke_cage",
|
|
22310
|
+
"luminals",
|
|
22311
|
+
"lyja",
|
|
22312
|
+
"ma_gnuci",
|
|
22313
|
+
"mac_gargan",
|
|
22314
|
+
"mach_iv",
|
|
22315
|
+
"machine_man",
|
|
22316
|
+
"mad_thinker",
|
|
22317
|
+
"madame_hydra",
|
|
22318
|
+
"madame_masque",
|
|
22319
|
+
"madame_web",
|
|
22320
|
+
"maddog",
|
|
22321
|
+
"madelyne_pryor",
|
|
22322
|
+
"madripoor",
|
|
22323
|
+
"madrox",
|
|
22324
|
+
"maelstrom",
|
|
22325
|
+
"maestro",
|
|
22326
|
+
"magdalene",
|
|
22327
|
+
"maggott",
|
|
22328
|
+
"magik",
|
|
22329
|
+
"maginty",
|
|
22330
|
+
"magma",
|
|
22331
|
+
"magneto",
|
|
22332
|
+
"magus",
|
|
22333
|
+
"major_mapleleaf",
|
|
22334
|
+
"makkari",
|
|
22335
|
+
"malcolm_colcord",
|
|
22336
|
+
"malice",
|
|
22337
|
+
"mandarin",
|
|
22338
|
+
"mandrill",
|
|
22339
|
+
"mandroid",
|
|
22340
|
+
"manta",
|
|
22341
|
+
"mantis",
|
|
22342
|
+
"marauders",
|
|
22343
|
+
"maria_hill",
|
|
22344
|
+
"mariko_yashida",
|
|
22345
|
+
"marrow",
|
|
22346
|
+
"marten_broadcloak",
|
|
22347
|
+
"martin_li",
|
|
22348
|
+
"marvel_apes",
|
|
22349
|
+
"marvel_boy",
|
|
22350
|
+
"marvel_zombies",
|
|
22351
|
+
"marvex",
|
|
22352
|
+
"masked_marvel",
|
|
22353
|
+
"masque",
|
|
22354
|
+
"master_chief",
|
|
22355
|
+
"master_mold",
|
|
22356
|
+
"mastermind",
|
|
22357
|
+
"mathemanic",
|
|
22358
|
+
"matthew_murdock",
|
|
22359
|
+
"mattie_franklin",
|
|
22360
|
+
"mauler",
|
|
22361
|
+
"maverick",
|
|
22362
|
+
"maximus",
|
|
22363
|
+
"may_parker",
|
|
22364
|
+
"medusa",
|
|
22365
|
+
"meggan",
|
|
22366
|
+
"meltdown",
|
|
22367
|
+
"menace",
|
|
22368
|
+
"mentallo",
|
|
22369
|
+
"mentor",
|
|
22370
|
+
"mephisto",
|
|
22371
|
+
"mephistopheles",
|
|
22372
|
+
"mercury",
|
|
22373
|
+
"mesmero",
|
|
22374
|
+
"metal_master",
|
|
22375
|
+
"meteorite",
|
|
22376
|
+
"micro/macro",
|
|
22377
|
+
"microbe",
|
|
22378
|
+
"microchip",
|
|
22379
|
+
"micromax",
|
|
22380
|
+
"midnight",
|
|
22381
|
+
"miek",
|
|
22382
|
+
"mikhail_rasputin",
|
|
22383
|
+
"millenium_guard",
|
|
22384
|
+
"mimic",
|
|
22385
|
+
"mindworm",
|
|
22386
|
+
"miracleman",
|
|
22387
|
+
"miss_america",
|
|
22388
|
+
"mister_fear",
|
|
22389
|
+
"mister_sinister",
|
|
22390
|
+
"misty_knight",
|
|
22391
|
+
"mockingbird",
|
|
22392
|
+
"moira_mactaggert",
|
|
22393
|
+
"mojo",
|
|
22394
|
+
"mole_man",
|
|
22395
|
+
"molecule_man",
|
|
22396
|
+
"molly_hayes",
|
|
22397
|
+
"molten_man",
|
|
22398
|
+
"mongoose",
|
|
22399
|
+
"mongu",
|
|
22400
|
+
"monster_badoon",
|
|
22401
|
+
"moon_knight",
|
|
22402
|
+
"moondragon",
|
|
22403
|
+
"moonstone",
|
|
22404
|
+
"morbius",
|
|
22405
|
+
"mordo",
|
|
22406
|
+
"morg",
|
|
22407
|
+
"morgan_stark",
|
|
22408
|
+
"morlocks",
|
|
22409
|
+
"morlun",
|
|
22410
|
+
"morph",
|
|
22411
|
+
"mother_askani",
|
|
22412
|
+
"mulholland_black",
|
|
22413
|
+
"multiple_man",
|
|
22414
|
+
"mysterio",
|
|
22415
|
+
"mystique",
|
|
22416
|
+
"namor",
|
|
22417
|
+
"namora",
|
|
22418
|
+
"namorita",
|
|
22419
|
+
"naoko",
|
|
22420
|
+
"natasha_romanoff",
|
|
22421
|
+
"nebula",
|
|
22422
|
+
"nehzno",
|
|
22423
|
+
"nekra",
|
|
22424
|
+
"nemesis",
|
|
22425
|
+
"network",
|
|
22426
|
+
"newton_destine",
|
|
22427
|
+
"next_avengers",
|
|
22428
|
+
"nextwave",
|
|
22429
|
+
"nick_fury",
|
|
22430
|
+
"nico_minoru",
|
|
22431
|
+
"nicolaos",
|
|
22432
|
+
"night_nurse",
|
|
22433
|
+
"night_thrasher",
|
|
22434
|
+
"nightcrawler",
|
|
22435
|
+
"nighthawk",
|
|
22436
|
+
"nightmare",
|
|
22437
|
+
"nightshade",
|
|
22438
|
+
"nitro",
|
|
22439
|
+
"nocturne",
|
|
22440
|
+
"nomad",
|
|
22441
|
+
"norman_osborn",
|
|
22442
|
+
"norrin_radd",
|
|
22443
|
+
"northstar",
|
|
22444
|
+
"nova",
|
|
22445
|
+
"nuke",
|
|
22446
|
+
"obadiah_stane",
|
|
22447
|
+
"odin",
|
|
22448
|
+
"ogun",
|
|
22449
|
+
"old_lace",
|
|
22450
|
+
"omega_flight",
|
|
22451
|
+
"omega_red",
|
|
22452
|
+
"omega_sentinel",
|
|
22453
|
+
"onslaught",
|
|
22454
|
+
"oracle",
|
|
22455
|
+
"orphan",
|
|
22456
|
+
"otto_octavius",
|
|
22457
|
+
"outlaw_kid",
|
|
22458
|
+
"overlord",
|
|
22459
|
+
"owl",
|
|
22460
|
+
"ozymandias",
|
|
22461
|
+
"paibok",
|
|
22462
|
+
"paladin",
|
|
22463
|
+
"pandemic",
|
|
22464
|
+
"paper_doll",
|
|
22465
|
+
"patch",
|
|
22466
|
+
"patriot",
|
|
22467
|
+
"payback",
|
|
22468
|
+
"penance",
|
|
22469
|
+
"pepper_potts",
|
|
22470
|
+
"pestilence",
|
|
22471
|
+
"pet_avengers",
|
|
22472
|
+
"pete_wisdom",
|
|
22473
|
+
"peter_parker",
|
|
22474
|
+
"peter_quill",
|
|
22475
|
+
"phalanx",
|
|
22476
|
+
"phantom_reporter",
|
|
22477
|
+
"phil_sheldon",
|
|
22478
|
+
"photon",
|
|
22479
|
+
"piledriver",
|
|
22480
|
+
"pixie",
|
|
22481
|
+
"plazm",
|
|
22482
|
+
"polaris",
|
|
22483
|
+
"post",
|
|
22484
|
+
"power_man",
|
|
22485
|
+
"power_pack",
|
|
22486
|
+
"praxagora",
|
|
22487
|
+
"preak",
|
|
22488
|
+
"pretty_boy",
|
|
22489
|
+
"pride",
|
|
22490
|
+
"prima",
|
|
22491
|
+
"princess_powerful",
|
|
22492
|
+
"prism",
|
|
22493
|
+
"prodigy",
|
|
22494
|
+
"proemial_gods",
|
|
22495
|
+
"professor_monster",
|
|
22496
|
+
"proteus",
|
|
22497
|
+
"proudstar",
|
|
22498
|
+
"prowler",
|
|
22499
|
+
"psylocke",
|
|
22500
|
+
"psynapse",
|
|
22501
|
+
"puck",
|
|
22502
|
+
"puff_adder",
|
|
22503
|
+
"puma",
|
|
22504
|
+
"punisher",
|
|
22505
|
+
"puppet_master",
|
|
22506
|
+
"purifiers",
|
|
22507
|
+
"purple_man",
|
|
22508
|
+
"pyro",
|
|
22509
|
+
"quasar",
|
|
22510
|
+
"quasimodo",
|
|
22511
|
+
"queen_noir",
|
|
22512
|
+
"quentin_quire",
|
|
22513
|
+
"quicksilver",
|
|
22514
|
+
"rachel_grey",
|
|
22515
|
+
"radioactive_man",
|
|
22516
|
+
"rafael_vega",
|
|
22517
|
+
"rage",
|
|
22518
|
+
"raider",
|
|
22519
|
+
"randall",
|
|
22520
|
+
"randall_flagg",
|
|
22521
|
+
"random",
|
|
22522
|
+
"rattler",
|
|
22523
|
+
"ravenous",
|
|
22524
|
+
"rawhide_kid",
|
|
22525
|
+
"raza",
|
|
22526
|
+
"reaper",
|
|
22527
|
+
"reavers",
|
|
22528
|
+
"red_ghost",
|
|
22529
|
+
"red_hulk",
|
|
22530
|
+
"red_shift",
|
|
22531
|
+
"red_skull",
|
|
22532
|
+
"red_wolf",
|
|
22533
|
+
"redwing",
|
|
22534
|
+
"reptil",
|
|
22535
|
+
"retro_girl",
|
|
22536
|
+
"revanche",
|
|
22537
|
+
"rhino",
|
|
22538
|
+
"rhodey",
|
|
22539
|
+
"richard_fisk",
|
|
22540
|
+
"rick_jones",
|
|
22541
|
+
"ricochet",
|
|
22542
|
+
"rictor",
|
|
22543
|
+
"riptide",
|
|
22544
|
+
"risque",
|
|
22545
|
+
"robbie_robertson",
|
|
22546
|
+
"robin_chapel",
|
|
22547
|
+
"rocket_raccoon",
|
|
22548
|
+
"rocket_racer",
|
|
22549
|
+
"rockslide",
|
|
22550
|
+
"rogue",
|
|
22551
|
+
"roland_deschain",
|
|
22552
|
+
"romulus",
|
|
22553
|
+
"ronan",
|
|
22554
|
+
"roughhouse",
|
|
22555
|
+
"roulette",
|
|
22556
|
+
"roxanne_simpson",
|
|
22557
|
+
"rumiko_fujikawa",
|
|
22558
|
+
"runaways",
|
|
22559
|
+
"russian",
|
|
22560
|
+
"sabra",
|
|
22561
|
+
"sabretooth",
|
|
22562
|
+
"sage",
|
|
22563
|
+
"sally_floyd",
|
|
22564
|
+
"salo",
|
|
22565
|
+
"sandman",
|
|
22566
|
+
"santa_claus",
|
|
22567
|
+
"saracen",
|
|
22568
|
+
"sasquatch",
|
|
22569
|
+
"satana",
|
|
22570
|
+
"sauron",
|
|
22571
|
+
"scalphunter",
|
|
22572
|
+
"scarecrow",
|
|
22573
|
+
"scarlet_spider",
|
|
22574
|
+
"scarlet_witch",
|
|
22575
|
+
"scorpion",
|
|
22576
|
+
"scourge",
|
|
22577
|
+
"scrambler",
|
|
22578
|
+
"scream",
|
|
22579
|
+
"screwball",
|
|
22580
|
+
"sebastian_shaw",
|
|
22581
|
+
"secret_warriors",
|
|
22582
|
+
"selene",
|
|
22583
|
+
"senator_kelly",
|
|
22584
|
+
"sentinel",
|
|
22585
|
+
"sentinels",
|
|
22586
|
+
"sentry",
|
|
22587
|
+
"ser_duncan",
|
|
22588
|
+
"serpent_society",
|
|
22589
|
+
"sersi",
|
|
22590
|
+
"shadow_king",
|
|
22591
|
+
"shadowcat",
|
|
22592
|
+
"shaman",
|
|
22593
|
+
"shape",
|
|
22594
|
+
"shard",
|
|
22595
|
+
"sharon_carter",
|
|
22596
|
+
"sharon_ventura",
|
|
22597
|
+
"shatterstar",
|
|
22598
|
+
"shen",
|
|
22599
|
+
"sheva_callister",
|
|
22600
|
+
"shinko_yamashiro",
|
|
22601
|
+
"shinobi_shaw",
|
|
22602
|
+
"shiva",
|
|
22603
|
+
"shiver_man",
|
|
22604
|
+
"shocker",
|
|
22605
|
+
"shockwave",
|
|
22606
|
+
"shooting_star",
|
|
22607
|
+
"shotgun",
|
|
22608
|
+
"shriek",
|
|
22609
|
+
"silhouette",
|
|
22610
|
+
"silk_fever",
|
|
22611
|
+
"silver_centurion",
|
|
22612
|
+
"silver_fox",
|
|
22613
|
+
"silver_sable",
|
|
22614
|
+
"silver_samurai",
|
|
22615
|
+
"silver_surfer",
|
|
22616
|
+
"silverclaw",
|
|
22617
|
+
"silvermane",
|
|
22618
|
+
"sinister_six",
|
|
22619
|
+
"sir_ram",
|
|
22620
|
+
"siren",
|
|
22621
|
+
"sister_grimm",
|
|
22622
|
+
"skaar",
|
|
22623
|
+
"skin",
|
|
22624
|
+
"skreet",
|
|
22625
|
+
"skrulls",
|
|
22626
|
+
"skullbuster",
|
|
22627
|
+
"slapstick",
|
|
22628
|
+
"slayback",
|
|
22629
|
+
"sleeper",
|
|
22630
|
+
"sleepwalker",
|
|
22631
|
+
"slipstream",
|
|
22632
|
+
"slyde",
|
|
22633
|
+
"smasher",
|
|
22634
|
+
"smiling_tiger",
|
|
22635
|
+
"snowbird",
|
|
22636
|
+
"solo",
|
|
22637
|
+
"songbird",
|
|
22638
|
+
"spacker_dave",
|
|
22639
|
+
"spectrum",
|
|
22640
|
+
"speed",
|
|
22641
|
+
"speed_demon",
|
|
22642
|
+
"speedball",
|
|
22643
|
+
"spencer_smythe",
|
|
22644
|
+
"sphinx",
|
|
22645
|
+
"spiral",
|
|
22646
|
+
"spirit",
|
|
22647
|
+
"spitfire",
|
|
22648
|
+
"spot",
|
|
22649
|
+
"sprite",
|
|
22650
|
+
"spyke",
|
|
22651
|
+
"squadron_sinister",
|
|
22652
|
+
"squadron_supreme",
|
|
22653
|
+
"squirrel_girl",
|
|
22654
|
+
"star_brand",
|
|
22655
|
+
"starbolt",
|
|
22656
|
+
"stardust",
|
|
22657
|
+
"starfox",
|
|
22658
|
+
"starhawk",
|
|
22659
|
+
"starjammers",
|
|
22660
|
+
"stark_industries",
|
|
22661
|
+
"stature",
|
|
22662
|
+
"steel_serpent",
|
|
22663
|
+
"stellaris",
|
|
22664
|
+
"stepford_cuckoos",
|
|
22665
|
+
"stephen_strange",
|
|
22666
|
+
"steve_rogers",
|
|
22667
|
+
"stick",
|
|
22668
|
+
"stingray",
|
|
22669
|
+
"stone_men",
|
|
22670
|
+
"storm",
|
|
22671
|
+
"stranger",
|
|
22672
|
+
"strong_guy",
|
|
22673
|
+
"stryfe",
|
|
22674
|
+
"sue_storm",
|
|
22675
|
+
"sugar_man",
|
|
22676
|
+
"sumo",
|
|
22677
|
+
"sunfire",
|
|
22678
|
+
"sunset_bain",
|
|
22679
|
+
"sunspot",
|
|
22680
|
+
"supernaut",
|
|
22681
|
+
"supreme_intelligence",
|
|
22682
|
+
"surge",
|
|
22683
|
+
"susan_delgado",
|
|
22684
|
+
"swarm",
|
|
22685
|
+
"sway",
|
|
22686
|
+
"switch",
|
|
22687
|
+
"swordsman",
|
|
22688
|
+
"synch",
|
|
22689
|
+
"tag",
|
|
22690
|
+
"talisman",
|
|
22691
|
+
"talkback",
|
|
22692
|
+
"talon",
|
|
22693
|
+
"talos",
|
|
22694
|
+
"tana_nile",
|
|
22695
|
+
"tarantula",
|
|
22696
|
+
"tarot",
|
|
22697
|
+
"taskmaster",
|
|
22698
|
+
"tattoo",
|
|
22699
|
+
"ted_forrester",
|
|
22700
|
+
"tempest",
|
|
22701
|
+
"tenebrous",
|
|
22702
|
+
"terrax",
|
|
22703
|
+
"terror",
|
|
22704
|
+
"texas_twister",
|
|
22705
|
+
"thaddeus_ross",
|
|
22706
|
+
"thanos",
|
|
22707
|
+
"the_anarchist",
|
|
22708
|
+
"the_call",
|
|
22709
|
+
"the_captain",
|
|
22710
|
+
"the_enforcers",
|
|
22711
|
+
"the_executioner",
|
|
22712
|
+
"the_fallen",
|
|
22713
|
+
"the_fury",
|
|
22714
|
+
"the_hand",
|
|
22715
|
+
"the_hood",
|
|
22716
|
+
"the_hunter",
|
|
22717
|
+
"the_initiative",
|
|
22718
|
+
"the_leader",
|
|
22719
|
+
"the_liberteens",
|
|
22720
|
+
"the_order",
|
|
22721
|
+
"the_phantom",
|
|
22722
|
+
"the_professor",
|
|
22723
|
+
"the_renegades",
|
|
22724
|
+
"the_santerians",
|
|
22725
|
+
"the_spike",
|
|
22726
|
+
"the_stranger",
|
|
22727
|
+
"the_twelve",
|
|
22728
|
+
"the_watchers",
|
|
22729
|
+
"thena",
|
|
22730
|
+
"thing",
|
|
22731
|
+
"thor",
|
|
22732
|
+
"thor_girl",
|
|
22733
|
+
"thunderball",
|
|
22734
|
+
"thunderbird",
|
|
22735
|
+
"thunderbolt",
|
|
22736
|
+
"thunderbolt_ross",
|
|
22737
|
+
"thunderbolts",
|
|
22738
|
+
"thundra",
|
|
22739
|
+
"tiger_shark",
|
|
22740
|
+
"tigra",
|
|
22741
|
+
"timeslip",
|
|
22742
|
+
"tinkerer",
|
|
22743
|
+
"titania",
|
|
22744
|
+
"titanium_man",
|
|
22745
|
+
"toad",
|
|
22746
|
+
"toad_men",
|
|
22747
|
+
"tomas",
|
|
22748
|
+
"tombstone",
|
|
22749
|
+
"tomorrow_man",
|
|
22750
|
+
"tony_stark",
|
|
22751
|
+
"toro",
|
|
22752
|
+
"toxin",
|
|
22753
|
+
"trauma",
|
|
22754
|
+
"triathlon",
|
|
22755
|
+
"trish_tilby",
|
|
22756
|
+
"triton",
|
|
22757
|
+
"true_believers",
|
|
22758
|
+
"turbo",
|
|
22759
|
+
"tusk",
|
|
22760
|
+
"tyger_tiger",
|
|
22761
|
+
"typhoid_mary",
|
|
22762
|
+
"tyrannus",
|
|
22763
|
+
"ulik",
|
|
22764
|
+
"ultimates",
|
|
22765
|
+
"ultimatum",
|
|
22766
|
+
"ultimo",
|
|
22767
|
+
"ultragirl",
|
|
22768
|
+
"ultron",
|
|
22769
|
+
"umar",
|
|
22770
|
+
"unicorn",
|
|
22771
|
+
"union_jack",
|
|
22772
|
+
"unus",
|
|
22773
|
+
"valeria_richards",
|
|
22774
|
+
"valkyrie",
|
|
22775
|
+
"vampiro",
|
|
22776
|
+
"vance_astro",
|
|
22777
|
+
"vanisher",
|
|
22778
|
+
"vapor",
|
|
22779
|
+
"vargas",
|
|
22780
|
+
"vector",
|
|
22781
|
+
"veda",
|
|
22782
|
+
"vengeance",
|
|
22783
|
+
"venom",
|
|
22784
|
+
"venus",
|
|
22785
|
+
"vermin",
|
|
22786
|
+
"vertigo",
|
|
22787
|
+
"victor_mancha",
|
|
22788
|
+
"vin_gonzales",
|
|
22789
|
+
"vindicator",
|
|
22790
|
+
"violations",
|
|
22791
|
+
"viper",
|
|
22792
|
+
"virginia_dare",
|
|
22793
|
+
"vision",
|
|
22794
|
+
"vivisector",
|
|
22795
|
+
"vulcan",
|
|
22796
|
+
"vulture",
|
|
22797
|
+
"wallflower",
|
|
22798
|
+
"wallop",
|
|
22799
|
+
"wallow",
|
|
22800
|
+
"war_machine",
|
|
22801
|
+
"warbird",
|
|
22802
|
+
"warbound",
|
|
22803
|
+
"warhawk",
|
|
22804
|
+
"warlock",
|
|
22805
|
+
"warpath",
|
|
22806
|
+
"warstar",
|
|
22807
|
+
"wasp",
|
|
22808
|
+
"weapon_omega",
|
|
22809
|
+
"wendell_rand",
|
|
22810
|
+
"wendell_vaughn",
|
|
22811
|
+
"wendigo",
|
|
22812
|
+
"whiplash",
|
|
22813
|
+
"whirlwind",
|
|
22814
|
+
"whistler",
|
|
22815
|
+
"white_queen",
|
|
22816
|
+
"white_tiger",
|
|
22817
|
+
"whizzer",
|
|
22818
|
+
"wiccan",
|
|
22819
|
+
"wild_child",
|
|
22820
|
+
"wild_pack",
|
|
22821
|
+
"wildside",
|
|
22822
|
+
"william_stryker",
|
|
22823
|
+
"wilson_fisk",
|
|
22824
|
+
"wind_dancer",
|
|
22825
|
+
"winter_soldier",
|
|
22826
|
+
"wither",
|
|
22827
|
+
"wolf_cub",
|
|
22828
|
+
"wolfpack",
|
|
22829
|
+
"wolfsbane",
|
|
22830
|
+
"wolverine",
|
|
22831
|
+
"wonder_man",
|
|
22832
|
+
"wong",
|
|
22833
|
+
"wraith",
|
|
22834
|
+
"wrecker",
|
|
22835
|
+
"wrecking_crew",
|
|
22836
|
+
"xavin",
|
|
22837
|
+
"xorn",
|
|
22838
|
+
"yellow_claw",
|
|
22839
|
+
"yellowjacket",
|
|
22840
|
+
"young_avengers",
|
|
22841
|
+
"zaladane",
|
|
22842
|
+
"zaran",
|
|
22843
|
+
"zarda",
|
|
22844
|
+
"zarek",
|
|
22845
|
+
"zeigeist",
|
|
22846
|
+
"zemo",
|
|
22847
|
+
"zodiak",
|
|
22848
|
+
"zombie",
|
|
22849
|
+
"zuras",
|
|
22850
|
+
"zzzax"
|
|
22851
|
+
];
|
|
21286
22852
|
}
|
|
21287
22853
|
});
|
|
21288
22854
|
|
|
@@ -21293,15 +22859,16 @@ __export(migrate_exports, {
|
|
|
21293
22859
|
prepareAndMigratePg: () => prepareAndMigratePg,
|
|
21294
22860
|
prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
|
|
21295
22861
|
prepareSQL: () => prepareSQL,
|
|
21296
|
-
prepareSnapshotFolderName: () => prepareSnapshotFolderName
|
|
22862
|
+
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
|
22863
|
+
writeResult: () => writeResult
|
|
21297
22864
|
});
|
|
21298
|
-
var import_fs4,
|
|
22865
|
+
var import_fs4, import_path3, import_hanji2, prepareAndMigratePg, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, writeResult, prepareSnapshotFolderName, two;
|
|
21299
22866
|
var init_migrate = __esm({
|
|
21300
22867
|
"src/cli/commands/migrate.ts"() {
|
|
21301
22868
|
import_fs4 = __toESM(require("fs"));
|
|
21302
22869
|
init_migrationPreparator();
|
|
21303
22870
|
init_snapshotsDiffer();
|
|
21304
|
-
|
|
22871
|
+
import_path3 = __toESM(require("path"));
|
|
21305
22872
|
import_hanji2 = __toESM(require_hanji());
|
|
21306
22873
|
init_views();
|
|
21307
22874
|
init_source();
|
|
@@ -21309,80 +22876,68 @@ var init_migrate = __esm({
|
|
|
21309
22876
|
init_sqliteSchema();
|
|
21310
22877
|
init_mysqlSchema();
|
|
21311
22878
|
init_utils();
|
|
22879
|
+
init_words();
|
|
21312
22880
|
prepareAndMigratePg = async (config) => {
|
|
21313
22881
|
const outFolder = config.out;
|
|
21314
22882
|
const schemaPath = config.schema;
|
|
21315
22883
|
try {
|
|
21316
|
-
|
|
21317
|
-
const {
|
|
21318
|
-
|
|
21319
|
-
outFolder,
|
|
21320
|
-
schemaPath
|
|
21321
|
-
);
|
|
22884
|
+
assertV1OutFolder(outFolder, "pg");
|
|
22885
|
+
const { snapshots, journal } = prepareMigrationFolder(outFolder, "pg");
|
|
22886
|
+
const { prev, cur } = preparePgMigrationSnapshot(snapshots, schemaPath);
|
|
21322
22887
|
const validatedPrev = pgSchema.parse(prev);
|
|
21323
22888
|
const validatedCur = pgSchema.parse(cur);
|
|
21324
22889
|
const squashedPrev = squashPgScheme(validatedPrev);
|
|
21325
22890
|
const squashedCur = squashPgScheme(validatedCur);
|
|
21326
|
-
const { statements, sql } = await prepareSQL(
|
|
22891
|
+
const { statements, sql, _meta } = await prepareSQL(
|
|
21327
22892
|
squashedPrev,
|
|
21328
22893
|
squashedCur,
|
|
21329
22894
|
"pg"
|
|
21330
22895
|
);
|
|
21331
|
-
writeResult(cur, sql,
|
|
22896
|
+
writeResult(cur, sql, snapshots.length, journal, _meta, outFolder);
|
|
21332
22897
|
} catch (e) {
|
|
21333
22898
|
console.error(e);
|
|
21334
22899
|
}
|
|
21335
22900
|
};
|
|
21336
|
-
|
|
22901
|
+
prepareAndMigrateMySql = async (config) => {
|
|
21337
22902
|
const outFolder = config.out;
|
|
21338
22903
|
const schemaPath = config.schema;
|
|
21339
22904
|
try {
|
|
21340
|
-
|
|
21341
|
-
const {
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
);
|
|
21346
|
-
const
|
|
21347
|
-
const
|
|
21348
|
-
const squashedPrev = squashSqliteScheme(validatedPrev);
|
|
21349
|
-
const squashedCur = squashSqliteScheme(validatedCur);
|
|
21350
|
-
const { statements, sql } = await prepareSQL(
|
|
22905
|
+
assertV1OutFolder(outFolder, "mysql");
|
|
22906
|
+
const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
|
|
22907
|
+
const { prev, cur } = prepareMySqlMigrationSnapshot(snapshots, schemaPath);
|
|
22908
|
+
const validatedPrev = mysqlSchema.parse(prev);
|
|
22909
|
+
const validatedCur = mysqlSchema.parse(cur);
|
|
22910
|
+
const squashedPrev = squashMysqlScheme(validatedPrev);
|
|
22911
|
+
const squashedCur = squashMysqlScheme(validatedCur);
|
|
22912
|
+
const { sql, _meta } = await prepareSQL(
|
|
21351
22913
|
squashedPrev,
|
|
21352
22914
|
squashedCur,
|
|
21353
|
-
"
|
|
22915
|
+
"mysql"
|
|
21354
22916
|
);
|
|
21355
|
-
writeResult(cur, sql,
|
|
22917
|
+
writeResult(cur, sql, snapshots.length, journal, _meta, outFolder);
|
|
21356
22918
|
} catch (e) {
|
|
21357
22919
|
console.error(e);
|
|
21358
22920
|
}
|
|
21359
22921
|
};
|
|
21360
|
-
|
|
22922
|
+
prepareAndMigrateSqlite = async (config) => {
|
|
21361
22923
|
const outFolder = config.out;
|
|
21362
22924
|
const schemaPath = config.schema;
|
|
21363
22925
|
try {
|
|
21364
|
-
|
|
21365
|
-
const {
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
);
|
|
21370
|
-
const
|
|
21371
|
-
const
|
|
21372
|
-
|
|
21373
|
-
const squashedCur = squashMysqlScheme(validatedCur);
|
|
21374
|
-
const { statements, sql } = await prepareSQL(
|
|
21375
|
-
squashedPrev,
|
|
21376
|
-
squashedCur,
|
|
21377
|
-
"mysql"
|
|
21378
|
-
);
|
|
21379
|
-
writeResult(cur, sql, statements, outFolder);
|
|
22926
|
+
assertV1OutFolder(outFolder, "sqlite");
|
|
22927
|
+
const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
|
|
22928
|
+
const { prev, cur } = prepareSqliteMigrationSnapshot(snapshots, schemaPath);
|
|
22929
|
+
const validatedPrev = sqliteSchema.parse(prev);
|
|
22930
|
+
const validatedCur = sqliteSchema.parse(cur);
|
|
22931
|
+
const squashedPrev = squashSqliteScheme(validatedPrev);
|
|
22932
|
+
const squashedCur = squashSqliteScheme(validatedCur);
|
|
22933
|
+
const { sql, _meta } = await prepareSQL(squashedPrev, squashedCur, "mysql");
|
|
22934
|
+
writeResult(cur, sql, snapshots.length, journal, _meta, outFolder);
|
|
21380
22935
|
} catch (e) {
|
|
21381
22936
|
console.error(e);
|
|
21382
22937
|
}
|
|
21383
22938
|
};
|
|
21384
22939
|
prepareSQL = async (prev, cur, dialect6) => {
|
|
21385
|
-
const
|
|
22940
|
+
const schemasResolver2 = async (input) => {
|
|
21386
22941
|
try {
|
|
21387
22942
|
const { created, deleted, renamed } = await promptSchemasConflict(
|
|
21388
22943
|
input.created,
|
|
@@ -21394,7 +22949,7 @@ var init_migrate = __esm({
|
|
|
21394
22949
|
throw e;
|
|
21395
22950
|
}
|
|
21396
22951
|
};
|
|
21397
|
-
const
|
|
22952
|
+
const tablesResolver2 = async (input) => {
|
|
21398
22953
|
try {
|
|
21399
22954
|
const { created, deleted, renamed } = await promptTablesConflict(
|
|
21400
22955
|
input.created,
|
|
@@ -21406,7 +22961,7 @@ var init_migrate = __esm({
|
|
|
21406
22961
|
throw e;
|
|
21407
22962
|
}
|
|
21408
22963
|
};
|
|
21409
|
-
const
|
|
22964
|
+
const columnsResolver2 = async (input) => {
|
|
21410
22965
|
const result = await promptColumnsConflicts(
|
|
21411
22966
|
input.tableName,
|
|
21412
22967
|
input.created,
|
|
@@ -21423,9 +22978,9 @@ var init_migrate = __esm({
|
|
|
21423
22978
|
prev,
|
|
21424
22979
|
cur,
|
|
21425
22980
|
dialect6,
|
|
21426
|
-
|
|
21427
|
-
|
|
21428
|
-
|
|
22981
|
+
schemasResolver2,
|
|
22982
|
+
tablesResolver2,
|
|
22983
|
+
columnsResolver2
|
|
21429
22984
|
);
|
|
21430
22985
|
};
|
|
21431
22986
|
promptColumnsConflicts = async (tableName, newColumns, missingColumns) => {
|
|
@@ -21560,24 +23115,34 @@ var init_migrate = __esm({
|
|
|
21560
23115
|
result.deleted.push(...leftMissing);
|
|
21561
23116
|
return result;
|
|
21562
23117
|
};
|
|
21563
|
-
writeResult = (cur, sql,
|
|
23118
|
+
writeResult = (cur, sql, idx, journal, _meta, outFolder) => {
|
|
21564
23119
|
console.log(schema(cur));
|
|
21565
23120
|
if (sql.length === 0) {
|
|
21566
23121
|
console.log("No schema changes, nothing to migrate \u{1F634}");
|
|
21567
23122
|
return;
|
|
21568
23123
|
}
|
|
23124
|
+
const { prefix, tag } = prepareMigrationMetadata(idx);
|
|
21569
23125
|
const toSave = JSON.parse(JSON.stringify(cur));
|
|
21570
|
-
|
|
21571
|
-
const
|
|
21572
|
-
|
|
23126
|
+
toSave["_meta"] = _meta;
|
|
23127
|
+
const metaFolderPath = (0, import_path3.join)(outFolder, "meta");
|
|
23128
|
+
const metaJournal = (0, import_path3.join)(metaFolderPath, "_journal.json");
|
|
21573
23129
|
import_fs4.default.writeFileSync(
|
|
21574
|
-
`${
|
|
23130
|
+
(0, import_path3.join)(metaFolderPath, `${prefix}_snapshot.json`),
|
|
21575
23131
|
JSON.stringify(toSave, null, 2)
|
|
21576
23132
|
);
|
|
21577
|
-
|
|
21578
|
-
|
|
21579
|
-
|
|
21580
|
-
|
|
23133
|
+
journal.entries.push({
|
|
23134
|
+
idx,
|
|
23135
|
+
when: +new Date(),
|
|
23136
|
+
tag
|
|
23137
|
+
});
|
|
23138
|
+
import_fs4.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
|
|
23139
|
+
import_fs4.default.writeFileSync(`${outFolder}/${tag}.sql`, sql);
|
|
23140
|
+
(0, import_hanji2.render)(
|
|
23141
|
+
`[${source_default.green(
|
|
23142
|
+
"\u2713"
|
|
23143
|
+
)}] Your SQL migration file \u279C ${source_default.bold.underline.blue(
|
|
23144
|
+
import_path3.default.join(`${outFolder}/${tag}.sql`)
|
|
23145
|
+
)} \u{1F680}`
|
|
21581
23146
|
);
|
|
21582
23147
|
};
|
|
21583
23148
|
prepareSnapshotFolderName = () => {
|
|
@@ -21594,9 +23159,97 @@ var init_migrate = __esm({
|
|
|
21594
23159
|
}
|
|
21595
23160
|
});
|
|
21596
23161
|
|
|
23162
|
+
// node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
|
|
23163
|
+
function camelCase(input, options) {
|
|
23164
|
+
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
23165
|
+
throw new TypeError("Expected the input to be `string | string[]`");
|
|
23166
|
+
}
|
|
23167
|
+
options = {
|
|
23168
|
+
pascalCase: false,
|
|
23169
|
+
preserveConsecutiveUppercase: false,
|
|
23170
|
+
...options
|
|
23171
|
+
};
|
|
23172
|
+
if (Array.isArray(input)) {
|
|
23173
|
+
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
23174
|
+
} else {
|
|
23175
|
+
input = input.trim();
|
|
23176
|
+
}
|
|
23177
|
+
if (input.length === 0) {
|
|
23178
|
+
return "";
|
|
23179
|
+
}
|
|
23180
|
+
const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
|
|
23181
|
+
const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
|
|
23182
|
+
if (input.length === 1) {
|
|
23183
|
+
if (SEPARATORS.test(input)) {
|
|
23184
|
+
return "";
|
|
23185
|
+
}
|
|
23186
|
+
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
|
23187
|
+
}
|
|
23188
|
+
const hasUpperCase = input !== toLowerCase(input);
|
|
23189
|
+
if (hasUpperCase) {
|
|
23190
|
+
input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
|
|
23191
|
+
}
|
|
23192
|
+
input = input.replace(LEADING_SEPARATORS, "");
|
|
23193
|
+
input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
|
|
23194
|
+
if (options.pascalCase) {
|
|
23195
|
+
input = toUpperCase(input.charAt(0)) + input.slice(1);
|
|
23196
|
+
}
|
|
23197
|
+
return postProcess(input, toUpperCase);
|
|
23198
|
+
}
|
|
23199
|
+
var UPPERCASE, LOWERCASE, LEADING_CAPITAL, IDENTIFIER, SEPARATORS, LEADING_SEPARATORS, SEPARATORS_AND_IDENTIFIER, NUMBERS_AND_IDENTIFIER, preserveCamelCase, preserveConsecutiveUppercase, postProcess;
|
|
23200
|
+
var init_camelcase = __esm({
|
|
23201
|
+
"node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js"() {
|
|
23202
|
+
UPPERCASE = /[\p{Lu}]/u;
|
|
23203
|
+
LOWERCASE = /[\p{Ll}]/u;
|
|
23204
|
+
LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
|
|
23205
|
+
IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
|
23206
|
+
SEPARATORS = /[_.\- ]+/;
|
|
23207
|
+
LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
|
|
23208
|
+
SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
|
|
23209
|
+
NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
|
|
23210
|
+
preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
|
|
23211
|
+
let isLastCharLower = false;
|
|
23212
|
+
let isLastCharUpper = false;
|
|
23213
|
+
let isLastLastCharUpper = false;
|
|
23214
|
+
let isLastLastCharPreserved = false;
|
|
23215
|
+
for (let index4 = 0; index4 < string.length; index4++) {
|
|
23216
|
+
const character = string[index4];
|
|
23217
|
+
isLastLastCharPreserved = index4 > 2 ? string[index4 - 3] === "-" : true;
|
|
23218
|
+
if (isLastCharLower && UPPERCASE.test(character)) {
|
|
23219
|
+
string = string.slice(0, index4) + "-" + string.slice(index4);
|
|
23220
|
+
isLastCharLower = false;
|
|
23221
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
23222
|
+
isLastCharUpper = true;
|
|
23223
|
+
index4++;
|
|
23224
|
+
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
|
|
23225
|
+
string = string.slice(0, index4 - 1) + "-" + string.slice(index4 - 1);
|
|
23226
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
23227
|
+
isLastCharUpper = false;
|
|
23228
|
+
isLastCharLower = true;
|
|
23229
|
+
} else {
|
|
23230
|
+
isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
|
|
23231
|
+
isLastLastCharUpper = isLastCharUpper;
|
|
23232
|
+
isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
|
|
23233
|
+
}
|
|
23234
|
+
}
|
|
23235
|
+
return string;
|
|
23236
|
+
};
|
|
23237
|
+
preserveConsecutiveUppercase = (input, toLowerCase) => {
|
|
23238
|
+
LEADING_CAPITAL.lastIndex = 0;
|
|
23239
|
+
return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
|
|
23240
|
+
};
|
|
23241
|
+
postProcess = (input, toUpperCase) => {
|
|
23242
|
+
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
23243
|
+
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
23244
|
+
return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m) => toUpperCase(m));
|
|
23245
|
+
};
|
|
23246
|
+
}
|
|
23247
|
+
});
|
|
23248
|
+
|
|
21597
23249
|
// src/@types/utils.ts
|
|
21598
23250
|
var init_utils2 = __esm({
|
|
21599
23251
|
"src/@types/utils.ts"() {
|
|
23252
|
+
init_camelcase();
|
|
21600
23253
|
String.prototype.trimChar = function(char) {
|
|
21601
23254
|
let start = 0;
|
|
21602
23255
|
let end = this.length;
|
|
@@ -21610,9 +23263,13 @@ var init_utils2 = __esm({
|
|
|
21610
23263
|
return this.replace(/ +/g, " ").trim();
|
|
21611
23264
|
};
|
|
21612
23265
|
String.prototype.camelCase = function() {
|
|
21613
|
-
return
|
|
21614
|
-
|
|
21615
|
-
|
|
23266
|
+
return camelCase(String(this));
|
|
23267
|
+
};
|
|
23268
|
+
String.prototype.concatIf = function(it, condition) {
|
|
23269
|
+
return condition ? `${this}${it}` : this;
|
|
23270
|
+
};
|
|
23271
|
+
Array.prototype.random = function() {
|
|
23272
|
+
return this[~~(Math.random() * this.length)];
|
|
21616
23273
|
};
|
|
21617
23274
|
}
|
|
21618
23275
|
});
|
|
@@ -23003,7 +24660,7 @@ var require_split2 = __commonJS({
|
|
|
23003
24660
|
var require_helper = __commonJS({
|
|
23004
24661
|
"node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js"(exports, module2) {
|
|
23005
24662
|
"use strict";
|
|
23006
|
-
var
|
|
24663
|
+
var path4 = require("path");
|
|
23007
24664
|
var Stream = require("stream").Stream;
|
|
23008
24665
|
var split = require_split2();
|
|
23009
24666
|
var util2 = require("util");
|
|
@@ -23042,7 +24699,7 @@ var require_helper = __commonJS({
|
|
|
23042
24699
|
};
|
|
23043
24700
|
module2.exports.getFileName = function(rawEnv) {
|
|
23044
24701
|
var env2 = rawEnv || process.env;
|
|
23045
|
-
var file = env2.PGPASSFILE || (isWin ?
|
|
24702
|
+
var file = env2.PGPASSFILE || (isWin ? path4.join(env2.APPDATA || "./", "postgresql", "pgpass.conf") : path4.join(env2.HOME || "./", ".pgpass"));
|
|
23046
24703
|
return file;
|
|
23047
24704
|
};
|
|
23048
24705
|
module2.exports.usePgPass = function(stats, fname) {
|
|
@@ -23169,7 +24826,7 @@ var require_helper = __commonJS({
|
|
|
23169
24826
|
var require_lib2 = __commonJS({
|
|
23170
24827
|
"node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js"(exports, module2) {
|
|
23171
24828
|
"use strict";
|
|
23172
|
-
var
|
|
24829
|
+
var path4 = require("path");
|
|
23173
24830
|
var fs7 = require("fs");
|
|
23174
24831
|
var helper = require_helper();
|
|
23175
24832
|
module2.exports = function(connInfo, cb) {
|
|
@@ -26019,7 +27676,8 @@ var init_introspect = __esm({
|
|
|
26019
27676
|
"interval",
|
|
26020
27677
|
"bigint",
|
|
26021
27678
|
"bigserial",
|
|
26022
|
-
"doublePrecision"
|
|
27679
|
+
"doublePrecision",
|
|
27680
|
+
"uuid"
|
|
26023
27681
|
]);
|
|
26024
27682
|
objToStatement = (json) => {
|
|
26025
27683
|
json = Object.fromEntries(Object.entries(json).filter((it) => it[1]));
|
|
@@ -26096,13 +27754,13 @@ var init_introspect = __esm({
|
|
|
26096
27754
|
return `export const ${it.name.camelCase()} = pgEnum("${it.name}", [${values}])
|
|
26097
27755
|
`;
|
|
26098
27756
|
}).join("").concat("\n");
|
|
26099
|
-
const schemaStatements = Object.entries(schemas).
|
|
27757
|
+
const schemaStatements = Object.entries(schemas).map((it) => {
|
|
26100
27758
|
return `export const ${it[1]} = pgSchema("${it[0]}");
|
|
26101
27759
|
`;
|
|
26102
27760
|
}).join();
|
|
26103
27761
|
const tableStatements = Object.values(schema4.tables).map((table4) => {
|
|
26104
27762
|
const schema5 = schemas[table4.schema];
|
|
26105
|
-
const func = schema5
|
|
27763
|
+
const func = schema5 ? schema5 : "pgTable";
|
|
26106
27764
|
let statement = `export const ${table4.name.camelCase()} = ${func}("${table4.name}", {
|
|
26107
27765
|
`;
|
|
26108
27766
|
statement += createTableColumns(
|
|
@@ -26140,6 +27798,8 @@ var init_introspect = __esm({
|
|
|
26140
27798
|
`;
|
|
26141
27799
|
result += enumStatements;
|
|
26142
27800
|
result += schemaStatements;
|
|
27801
|
+
result += `import { sql } from "drizzle-orm/sql"
|
|
27802
|
+
`;
|
|
26143
27803
|
result += "\n";
|
|
26144
27804
|
result += tableStatements.join("\n\n");
|
|
26145
27805
|
return result;
|
|
@@ -26190,6 +27850,11 @@ var init_introspect = __esm({
|
|
|
26190
27850
|
out += defaultValue ? `.default(${defaultValue})` : "";
|
|
26191
27851
|
return out;
|
|
26192
27852
|
}
|
|
27853
|
+
if (lowered === "uuid") {
|
|
27854
|
+
let out = `${name.camelCase()}: uuid("${name}")`;
|
|
27855
|
+
out += defaultValue === "gen_random_uuid()" ? ".defaultRandom()" : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
|
27856
|
+
return out;
|
|
27857
|
+
}
|
|
26193
27858
|
if (lowered.startsWith("numeric")) {
|
|
26194
27859
|
let params;
|
|
26195
27860
|
if (lowered.length > 7) {
|
|
@@ -26273,7 +27938,10 @@ var init_introspect = __esm({
|
|
|
26273
27938
|
if (enumTypes.has(type)) {
|
|
26274
27939
|
return `${name.camelCase()}: ${type.camelCase()}("${name}")`;
|
|
26275
27940
|
}
|
|
26276
|
-
|
|
27941
|
+
let unknown = `// TODO: failed to parse database type '${type}'
|
|
27942
|
+
`;
|
|
27943
|
+
unknown += ` ${name.camelCase()}: unknown("${name}")`;
|
|
27944
|
+
return unknown;
|
|
26277
27945
|
};
|
|
26278
27946
|
createTableColumns = (columns, fks, enumTypes) => {
|
|
26279
27947
|
let statement = "";
|
|
@@ -26287,8 +27955,9 @@ var init_introspect = __esm({
|
|
|
26287
27955
|
return res;
|
|
26288
27956
|
}, {});
|
|
26289
27957
|
columns.forEach((it) => {
|
|
27958
|
+
const columnStatement = column4(it.type, it.name, enumTypes, it.default);
|
|
26290
27959
|
statement += " ";
|
|
26291
|
-
statement +=
|
|
27960
|
+
statement += columnStatement;
|
|
26292
27961
|
statement += it.primaryKey ? ".primaryKey()" : "";
|
|
26293
27962
|
statement += it.notNull ? ".notNull()" : "";
|
|
26294
27963
|
const fks2 = fkByColumnName[it.name];
|
|
@@ -38521,12 +40190,12 @@ var require_query4 = __commonJS({
|
|
|
38521
40190
|
this._fields.push([]);
|
|
38522
40191
|
return this.readField;
|
|
38523
40192
|
}
|
|
38524
|
-
_streamLocalInfile(connection,
|
|
40193
|
+
_streamLocalInfile(connection, path4) {
|
|
38525
40194
|
if (this._streamFactory) {
|
|
38526
|
-
this._localStream = this._streamFactory(
|
|
40195
|
+
this._localStream = this._streamFactory(path4);
|
|
38527
40196
|
} else {
|
|
38528
40197
|
this._localStreamError = new Error(
|
|
38529
|
-
`As a result of LOCAL INFILE command server wants to read ${
|
|
40198
|
+
`As a result of LOCAL INFILE command server wants to read ${path4} file, but as of v2.0 you must provide streamFactory option returning ReadStream.`
|
|
38530
40199
|
);
|
|
38531
40200
|
connection.writePacket(EmptyPacket);
|
|
38532
40201
|
return this.infileOk;
|
|
@@ -40680,7 +42349,7 @@ var require_named_placeholders = __commonJS({
|
|
|
40680
42349
|
}
|
|
40681
42350
|
return s;
|
|
40682
42351
|
}
|
|
40683
|
-
function
|
|
42352
|
+
function join4(tree) {
|
|
40684
42353
|
if (tree.length == 1) {
|
|
40685
42354
|
return tree;
|
|
40686
42355
|
}
|
|
@@ -40706,7 +42375,7 @@ var require_named_placeholders = __commonJS({
|
|
|
40706
42375
|
if (cache && (tree = cache.get(query))) {
|
|
40707
42376
|
return toArrayParams(tree, paramsObj);
|
|
40708
42377
|
}
|
|
40709
|
-
tree =
|
|
42378
|
+
tree = join4(parse(query));
|
|
40710
42379
|
if (cache) {
|
|
40711
42380
|
cache.set(query, tree);
|
|
40712
42381
|
}
|
|
@@ -43088,14 +44757,14 @@ var {
|
|
|
43088
44757
|
} = import_index.default;
|
|
43089
44758
|
|
|
43090
44759
|
// src/cli/index.ts
|
|
43091
|
-
var
|
|
44760
|
+
var import_fs9 = __toESM(require("fs"));
|
|
43092
44761
|
init_lib();
|
|
43093
44762
|
|
|
43094
44763
|
// src/cli/commands/check.ts
|
|
43095
44764
|
init_utils();
|
|
43096
44765
|
var checkHandler = (out, dialect6) => {
|
|
43097
|
-
const
|
|
43098
|
-
const report = validateWithReport(
|
|
44766
|
+
const { snapshots } = prepareOutFolder(out, dialect6);
|
|
44767
|
+
const report = validateWithReport(snapshots, dialect6);
|
|
43099
44768
|
if (report.nonLatest.length > 0) {
|
|
43100
44769
|
console.log(
|
|
43101
44770
|
report.nonLatest.map((it) => {
|
|
@@ -43131,7 +44800,7 @@ var checkHandler = (out, dialect6) => {
|
|
|
43131
44800
|
// src/cli/index.ts
|
|
43132
44801
|
var import_hanji5 = __toESM(require_hanji());
|
|
43133
44802
|
init_views();
|
|
43134
|
-
var
|
|
44803
|
+
var import_path7 = __toESM(require("path"));
|
|
43135
44804
|
|
|
43136
44805
|
// src/cli/utils.ts
|
|
43137
44806
|
init_views();
|
|
@@ -43148,7 +44817,7 @@ var assertPackages = (...pkgs) => {
|
|
|
43148
44817
|
}
|
|
43149
44818
|
};
|
|
43150
44819
|
var requiredApiVersion = 2;
|
|
43151
|
-
var
|
|
44820
|
+
var assertOrmCoreVersion = () => {
|
|
43152
44821
|
const { compatibilityVersion } = require("drizzle-orm/version");
|
|
43153
44822
|
if (compatibilityVersion && compatibilityVersion === requiredApiVersion)
|
|
43154
44823
|
return;
|
|
@@ -43163,10 +44832,10 @@ var assertPgVersion = () => {
|
|
|
43163
44832
|
}
|
|
43164
44833
|
process.exit(1);
|
|
43165
44834
|
};
|
|
43166
|
-
var
|
|
44835
|
+
var ormCoreVersions = () => {
|
|
43167
44836
|
try {
|
|
43168
|
-
const {
|
|
43169
|
-
return {
|
|
44837
|
+
const { compatibilityVersion, npmVersion } = require("drizzle-orm/version");
|
|
44838
|
+
return { compatibilityVersion, npmVersion };
|
|
43170
44839
|
} catch (e) {
|
|
43171
44840
|
return {};
|
|
43172
44841
|
}
|
|
@@ -43217,6 +44886,7 @@ var package_default = {
|
|
|
43217
44886
|
]
|
|
43218
44887
|
},
|
|
43219
44888
|
dependencies: {
|
|
44889
|
+
camelcase: "^7.0.1",
|
|
43220
44890
|
chalk: "^5.2.0",
|
|
43221
44891
|
commander: "^9.4.1",
|
|
43222
44892
|
esbuild: "^0.15.18",
|
|
@@ -43233,7 +44903,8 @@ var package_default = {
|
|
|
43233
44903
|
"@typescript-eslint/parser": "^5.46.1",
|
|
43234
44904
|
ava: "^5.1.0",
|
|
43235
44905
|
dockerode: "^3.3.4",
|
|
43236
|
-
"drizzle-
|
|
44906
|
+
"drizzle-kit": "^0.16.8",
|
|
44907
|
+
"drizzle-orm": "0.17.6",
|
|
43237
44908
|
esbuild: "^0.15.7",
|
|
43238
44909
|
"esbuild-register": "^3.3.3",
|
|
43239
44910
|
eslint: "^8.29.0",
|
|
@@ -43259,32 +44930,28 @@ init_utils();
|
|
|
43259
44930
|
init_source();
|
|
43260
44931
|
var import_crypto2 = require("crypto");
|
|
43261
44932
|
var import_fs5 = require("fs");
|
|
43262
|
-
var import_path3 = __toESM(require("path"));
|
|
43263
44933
|
init_global();
|
|
43264
44934
|
init_pgSchema();
|
|
43265
44935
|
init_utils();
|
|
43266
44936
|
var upPgHandler = (out) => {
|
|
43267
|
-
|
|
43268
|
-
|
|
44937
|
+
};
|
|
44938
|
+
var upPgHandlerV4 = (out) => {
|
|
44939
|
+
const snapshots = snapshotsPriorV4(out);
|
|
44940
|
+
const report = validateWithReport(snapshots, "pg");
|
|
43269
44941
|
let prevId = originUUID;
|
|
43270
44942
|
report.nonLatest.map((it) => ({
|
|
43271
|
-
|
|
44943
|
+
path: it,
|
|
43272
44944
|
raw: report.rawMap[it]
|
|
43273
44945
|
})).forEach((it) => {
|
|
43274
|
-
const
|
|
43275
|
-
const result =
|
|
44946
|
+
const path4 = it.path;
|
|
44947
|
+
const result = updateUpToV4(it.raw, prevId);
|
|
43276
44948
|
prevId = result.id;
|
|
43277
|
-
console.log(
|
|
43278
|
-
|
|
43279
|
-
);
|
|
43280
|
-
(0, import_fs5.writeFileSync)(
|
|
43281
|
-
import_path3.default.join(out, folder, "snapshot.json"),
|
|
43282
|
-
JSON.stringify(result, null, 2)
|
|
43283
|
-
);
|
|
44949
|
+
console.log(`[${source_default.green("\u2713")}] ${path4}`);
|
|
44950
|
+
(0, import_fs5.writeFileSync)(path4, JSON.stringify(result, null, 2));
|
|
43284
44951
|
});
|
|
43285
44952
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
43286
44953
|
};
|
|
43287
|
-
var
|
|
44954
|
+
var updateUpToV4 = (json, prevId) => {
|
|
43288
44955
|
const version = Number(json["version"]);
|
|
43289
44956
|
if (version === 1) {
|
|
43290
44957
|
const v1 = pgSchemaV1.parse(json);
|
|
@@ -43302,7 +44969,7 @@ var updateToLatest = (json, prevId) => {
|
|
|
43302
44969
|
if (version === 3) {
|
|
43303
44970
|
return update3to4(pgSchemaV3.parse(json));
|
|
43304
44971
|
}
|
|
43305
|
-
return
|
|
44972
|
+
return pgSchemaV4.parse(json);
|
|
43306
44973
|
};
|
|
43307
44974
|
var update1to2 = (json) => {
|
|
43308
44975
|
const tables = Object.fromEntries(
|
|
@@ -43452,14 +45119,14 @@ var import_path4 = __toESM(require("path"));
|
|
|
43452
45119
|
init_sqliteSchema();
|
|
43453
45120
|
init_utils();
|
|
43454
45121
|
var upSqliteHandler = (out) => {
|
|
43455
|
-
const
|
|
43456
|
-
const report = validateWithReport(
|
|
45122
|
+
const { snapshots } = prepareOutFolder(out, "sqlite");
|
|
45123
|
+
const report = validateWithReport(snapshots, "sqlite");
|
|
43457
45124
|
report.nonLatest.map((it) => ({
|
|
43458
45125
|
folder: it,
|
|
43459
45126
|
raw: report.rawMap[it]
|
|
43460
45127
|
})).forEach((it) => {
|
|
43461
45128
|
const folder = it.folder;
|
|
43462
|
-
const result =
|
|
45129
|
+
const result = updateToLatest(it.raw);
|
|
43463
45130
|
console.log(
|
|
43464
45131
|
`[${source_default.green("\u2713")}] ${import_path4.default.join(out, folder, "snapshot.json")}`
|
|
43465
45132
|
);
|
|
@@ -43470,14 +45137,14 @@ var upSqliteHandler = (out) => {
|
|
|
43470
45137
|
});
|
|
43471
45138
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
43472
45139
|
};
|
|
43473
|
-
var
|
|
45140
|
+
var updateToLatest = (json) => {
|
|
43474
45141
|
const version = Number(json["version"]);
|
|
43475
45142
|
if (version === 3) {
|
|
43476
45143
|
const v3 = sqliteSchemaV3.parse(json);
|
|
43477
45144
|
const v4 = updateV3toV4(v3);
|
|
43478
45145
|
return v4;
|
|
43479
45146
|
}
|
|
43480
|
-
return
|
|
45147
|
+
return sqliteSchemaV4.parse(json);
|
|
43481
45148
|
};
|
|
43482
45149
|
var updateV3toV4 = (old) => {
|
|
43483
45150
|
const mappedTables = Object.fromEntries(
|
|
@@ -43500,14 +45167,16 @@ var import_path5 = __toESM(require("path"));
|
|
|
43500
45167
|
init_mysqlSchema();
|
|
43501
45168
|
init_utils();
|
|
43502
45169
|
var upMysqlHandler = (out) => {
|
|
43503
|
-
|
|
43504
|
-
|
|
45170
|
+
};
|
|
45171
|
+
var upMysqlHandlerV4 = (out) => {
|
|
45172
|
+
const { snapshots } = prepareOutFolder(out, "mysql");
|
|
45173
|
+
const report = validateWithReport(snapshots, "mysql");
|
|
43505
45174
|
report.nonLatest.map((it) => ({
|
|
43506
45175
|
folder: it,
|
|
43507
45176
|
raw: report.rawMap[it]
|
|
43508
45177
|
})).forEach((it) => {
|
|
43509
45178
|
const folder = it.folder;
|
|
43510
|
-
const result =
|
|
45179
|
+
const result = updateToLatestV4(it.raw);
|
|
43511
45180
|
console.log(
|
|
43512
45181
|
`[${source_default.green("\u2713")}] ${import_path5.default.join(out, folder, "snapshot.json")}`
|
|
43513
45182
|
);
|
|
@@ -43518,14 +45187,14 @@ var upMysqlHandler = (out) => {
|
|
|
43518
45187
|
});
|
|
43519
45188
|
console.log("Everything's fine \u{1F436}\u{1F525}");
|
|
43520
45189
|
};
|
|
43521
|
-
var
|
|
45190
|
+
var updateToLatestV4 = (json) => {
|
|
43522
45191
|
const version = Number(json["version"]);
|
|
43523
45192
|
if (version === 3) {
|
|
43524
45193
|
const v3 = mysqlSchemaV3.parse(json);
|
|
43525
45194
|
const v4 = updateV3toV42(v3);
|
|
43526
45195
|
return v4;
|
|
43527
45196
|
}
|
|
43528
|
-
return
|
|
45197
|
+
return mysqlSchemaV4.parse(json);
|
|
43529
45198
|
};
|
|
43530
45199
|
var updateV3toV42 = (old) => {
|
|
43531
45200
|
return {
|
|
@@ -43535,6 +45204,378 @@ var updateV3toV42 = (old) => {
|
|
|
43535
45204
|
};
|
|
43536
45205
|
};
|
|
43537
45206
|
|
|
45207
|
+
// src/cli/commands/upFolders.ts
|
|
45208
|
+
var import_fs8 = require("fs");
|
|
45209
|
+
var import_path6 = require("path");
|
|
45210
|
+
init_jsonDiffer();
|
|
45211
|
+
init_mysqlSchema();
|
|
45212
|
+
init_snapshotsDiffer();
|
|
45213
|
+
init_utils();
|
|
45214
|
+
init_words();
|
|
45215
|
+
init_pgSchema();
|
|
45216
|
+
var schemasResolver = (missingSchemas, newSchemas, sql) => {
|
|
45217
|
+
try {
|
|
45218
|
+
if (missingSchemas.length === 0 || newSchemas.length === 0) {
|
|
45219
|
+
return { created: newSchemas, renamed: [], deleted: missingSchemas };
|
|
45220
|
+
}
|
|
45221
|
+
const result = { created: [], renamed: [], deleted: [] };
|
|
45222
|
+
let index4 = 0;
|
|
45223
|
+
let leftMissing = [...missingSchemas];
|
|
45224
|
+
do {
|
|
45225
|
+
const created = newSchemas[index4];
|
|
45226
|
+
index4 += 1;
|
|
45227
|
+
const possibleRenames = leftMissing.map((it) => {
|
|
45228
|
+
return {
|
|
45229
|
+
value: it,
|
|
45230
|
+
sql: `ALTER SCHEMA "${it.name}" RENAME TO "${created.name}"`
|
|
45231
|
+
};
|
|
45232
|
+
});
|
|
45233
|
+
const renames = possibleRenames.filter((it) => {
|
|
45234
|
+
return sql.includes(it.sql);
|
|
45235
|
+
});
|
|
45236
|
+
if (renames.length > 1)
|
|
45237
|
+
throw new Error("wtf");
|
|
45238
|
+
if (renames.length === 0) {
|
|
45239
|
+
result.created.push(created);
|
|
45240
|
+
} else {
|
|
45241
|
+
const it = renames[0];
|
|
45242
|
+
result.renamed.push({ from: it.value, to: created });
|
|
45243
|
+
delete leftMissing[leftMissing.indexOf(it.value)];
|
|
45244
|
+
leftMissing = leftMissing.filter(Boolean);
|
|
45245
|
+
}
|
|
45246
|
+
} while (index4 < newSchemas.length);
|
|
45247
|
+
result.deleted.push(...leftMissing);
|
|
45248
|
+
return result;
|
|
45249
|
+
} catch (e) {
|
|
45250
|
+
console.error(e);
|
|
45251
|
+
throw e;
|
|
45252
|
+
}
|
|
45253
|
+
};
|
|
45254
|
+
var tablesResolver = (missingTables, newTables, sql) => {
|
|
45255
|
+
try {
|
|
45256
|
+
if (missingTables.length === 0 || newTables.length === 0) {
|
|
45257
|
+
return { created: newTables, renamed: [], deleted: missingTables };
|
|
45258
|
+
}
|
|
45259
|
+
const result = { created: [], renamed: [], deleted: [] };
|
|
45260
|
+
let index4 = 0;
|
|
45261
|
+
let leftMissing = [...missingTables];
|
|
45262
|
+
do {
|
|
45263
|
+
const created = newTables[index4];
|
|
45264
|
+
index4 += 1;
|
|
45265
|
+
const possibleRenames = leftMissing.map((it) => {
|
|
45266
|
+
const pgSchemaPrefix = created.schema ? `"${created.schema}".` : "";
|
|
45267
|
+
const mysqlSchemaPrefix = created.schema ? `\`${created.schema}\`.` : "";
|
|
45268
|
+
return [{
|
|
45269
|
+
value: it,
|
|
45270
|
+
sql: `ALTER TABLE ${pgSchemaPrefix}"${it.name}" RENAME TO ${pgSchemaPrefix}"${created.name}"`
|
|
45271
|
+
}, {
|
|
45272
|
+
value: it,
|
|
45273
|
+
sql: `RENAME TABLE ${mysqlSchemaPrefix}\`${it.name}\` TO ${mysqlSchemaPrefix}\`${created.name}\`;`
|
|
45274
|
+
}];
|
|
45275
|
+
}).flat();
|
|
45276
|
+
const renames = possibleRenames.filter((it) => {
|
|
45277
|
+
return sql.includes(it.sql);
|
|
45278
|
+
});
|
|
45279
|
+
if (renames.length > 1)
|
|
45280
|
+
throw new Error("wtf");
|
|
45281
|
+
if (renames.length === 0) {
|
|
45282
|
+
result.created.push(created);
|
|
45283
|
+
} else {
|
|
45284
|
+
const it = renames[0];
|
|
45285
|
+
result.renamed.push({ from: it.value, to: created });
|
|
45286
|
+
delete leftMissing[leftMissing.indexOf(it.value)];
|
|
45287
|
+
leftMissing = leftMissing.filter(Boolean);
|
|
45288
|
+
}
|
|
45289
|
+
} while (index4 < newTables.length);
|
|
45290
|
+
result.deleted.push(...leftMissing);
|
|
45291
|
+
return result;
|
|
45292
|
+
} catch (e) {
|
|
45293
|
+
console.error(e);
|
|
45294
|
+
throw e;
|
|
45295
|
+
}
|
|
45296
|
+
};
|
|
45297
|
+
var columnsResolver = (tableName, missingColumns, newColumns, sql) => {
|
|
45298
|
+
try {
|
|
45299
|
+
if (missingColumns.length === 0 || newColumns.length === 0) {
|
|
45300
|
+
return { created: newColumns, renamed: [], deleted: missingColumns };
|
|
45301
|
+
}
|
|
45302
|
+
const result = { created: [], renamed: [], deleted: [] };
|
|
45303
|
+
let index4 = 0;
|
|
45304
|
+
let leftMissing = [...missingColumns];
|
|
45305
|
+
do {
|
|
45306
|
+
const created = newColumns[index4];
|
|
45307
|
+
index4 += 1;
|
|
45308
|
+
const possibleRenames = leftMissing.map((it) => {
|
|
45309
|
+
return [{
|
|
45310
|
+
value: it,
|
|
45311
|
+
sql: `ALTER TABLE ${tableName} RENAME COLUMN "${it.name}" TO "${created.name}"`
|
|
45312
|
+
}, {
|
|
45313
|
+
value: it,
|
|
45314
|
+
sql: `ALTER TABLE ${tableName} RENAME COLUMN \`${it.name}\` TO \`${created.name}\``
|
|
45315
|
+
}];
|
|
45316
|
+
}).flat();
|
|
45317
|
+
const renames = possibleRenames.filter((it) => {
|
|
45318
|
+
return sql.includes(it.sql);
|
|
45319
|
+
});
|
|
45320
|
+
if (renames.length > 1)
|
|
45321
|
+
throw new Error("wtf");
|
|
45322
|
+
if (renames.length === 0) {
|
|
45323
|
+
result.created.push(created);
|
|
45324
|
+
} else {
|
|
45325
|
+
const it = renames[0];
|
|
45326
|
+
result.renamed.push({ from: it.value, to: created });
|
|
45327
|
+
delete leftMissing[leftMissing.indexOf(it.value)];
|
|
45328
|
+
leftMissing = leftMissing.filter(Boolean);
|
|
45329
|
+
}
|
|
45330
|
+
} while (index4 < newColumns.length);
|
|
45331
|
+
result.deleted.push(...leftMissing);
|
|
45332
|
+
return result;
|
|
45333
|
+
} catch (e) {
|
|
45334
|
+
console.error(e);
|
|
45335
|
+
throw e;
|
|
45336
|
+
}
|
|
45337
|
+
};
|
|
45338
|
+
var fullfill = (prev, cur, sql, dialect6) => {
|
|
45339
|
+
if (dialect6 === "pg") {
|
|
45340
|
+
return fullfillpg(prev, cur, sql);
|
|
45341
|
+
}
|
|
45342
|
+
if (dialect6 === "mysql") {
|
|
45343
|
+
return fullfillmysql(prev, cur, sql);
|
|
45344
|
+
}
|
|
45345
|
+
throw new Error("");
|
|
45346
|
+
};
|
|
45347
|
+
var fullfillpg = (prev, cur, sql) => {
|
|
45348
|
+
const b = pgSchemaV4.parse(cur);
|
|
45349
|
+
if (!prev) {
|
|
45350
|
+
return {
|
|
45351
|
+
version: "5",
|
|
45352
|
+
dialect: b.dialect,
|
|
45353
|
+
id: b.id,
|
|
45354
|
+
prevId: b.prevId,
|
|
45355
|
+
tables: b.tables,
|
|
45356
|
+
enums: b.enums,
|
|
45357
|
+
schemas: b.schemas,
|
|
45358
|
+
_meta: {
|
|
45359
|
+
schemas: {},
|
|
45360
|
+
tables: {},
|
|
45361
|
+
columns: {}
|
|
45362
|
+
}
|
|
45363
|
+
};
|
|
45364
|
+
}
|
|
45365
|
+
const a = pgSchemaV4.parse(prev);
|
|
45366
|
+
const json1 = squashPgScheme(a);
|
|
45367
|
+
const json2 = squashPgScheme(b);
|
|
45368
|
+
const diffResult = applyJsonDiff(json1, json2);
|
|
45369
|
+
const parseResult = diffResultScheme.safeParse(diffResult);
|
|
45370
|
+
if (!parseResult.success) {
|
|
45371
|
+
parseResult.error.errors.forEach((it) => {
|
|
45372
|
+
console.error(it);
|
|
45373
|
+
});
|
|
45374
|
+
throw new Error();
|
|
45375
|
+
}
|
|
45376
|
+
const typedResult = parseResult.data;
|
|
45377
|
+
const { renamed: renamedSchemas } = schemasResolver(
|
|
45378
|
+
typedResult.deletedSchemas.map((it) => ({ name: it })),
|
|
45379
|
+
typedResult.addedSchemas.map((it) => ({ name: it })),
|
|
45380
|
+
sql
|
|
45381
|
+
);
|
|
45382
|
+
const { renamed } = tablesResolver(
|
|
45383
|
+
typedResult.deletedTables,
|
|
45384
|
+
typedResult.addedTables,
|
|
45385
|
+
sql
|
|
45386
|
+
);
|
|
45387
|
+
const renamedWithAlternations = Object.values(
|
|
45388
|
+
alteredTableScheme.array().parse(diffForRenamedTables(renamed))
|
|
45389
|
+
);
|
|
45390
|
+
const allAltered = typedResult.alteredTablesWithColumns.concat(
|
|
45391
|
+
renamedWithAlternations
|
|
45392
|
+
);
|
|
45393
|
+
const rSchemas = renamedSchemas.map((it) => ({
|
|
45394
|
+
from: it.from.name,
|
|
45395
|
+
to: it.to.name
|
|
45396
|
+
}));
|
|
45397
|
+
const rTables = renamed.map((it) => {
|
|
45398
|
+
return { from: it.from, to: it.to };
|
|
45399
|
+
});
|
|
45400
|
+
const rColumns = allAltered.map((table4) => {
|
|
45401
|
+
const name = table4.name;
|
|
45402
|
+
const result = columnsResolver(name, table4.deleted, table4.added, sql);
|
|
45403
|
+
const tableName = table4.name;
|
|
45404
|
+
const schema4 = typeof table4.schema === "string" ? table4.schema : "";
|
|
45405
|
+
return result.renamed.map((it) => {
|
|
45406
|
+
return {
|
|
45407
|
+
from: { schema: schema4, table: tableName, column: it.from.name },
|
|
45408
|
+
to: { schema: schema4, table: tableName, column: it.to.name }
|
|
45409
|
+
};
|
|
45410
|
+
});
|
|
45411
|
+
}).flat();
|
|
45412
|
+
const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
|
|
45413
|
+
const bpatched = {
|
|
45414
|
+
version: "5",
|
|
45415
|
+
dialect: b.dialect,
|
|
45416
|
+
id: b.id,
|
|
45417
|
+
prevId: b.prevId,
|
|
45418
|
+
tables: b.tables,
|
|
45419
|
+
enums: b.enums,
|
|
45420
|
+
schemas: b.schemas,
|
|
45421
|
+
_meta
|
|
45422
|
+
};
|
|
45423
|
+
pgSchema.parse(bpatched);
|
|
45424
|
+
return {
|
|
45425
|
+
version: "5",
|
|
45426
|
+
dialect: b.dialect,
|
|
45427
|
+
id: b.id,
|
|
45428
|
+
prevId: b.prevId,
|
|
45429
|
+
tables: b.tables,
|
|
45430
|
+
enums: b.enums,
|
|
45431
|
+
schemas: b.schemas,
|
|
45432
|
+
_meta
|
|
45433
|
+
};
|
|
45434
|
+
};
|
|
45435
|
+
var fullfillmysql = (prev, cur, sql) => {
|
|
45436
|
+
const b = mysqlSchemaV4.parse(cur);
|
|
45437
|
+
if (!prev) {
|
|
45438
|
+
return {
|
|
45439
|
+
version: "5",
|
|
45440
|
+
dialect: b.dialect,
|
|
45441
|
+
id: b.id,
|
|
45442
|
+
prevId: b.prevId,
|
|
45443
|
+
tables: b.tables,
|
|
45444
|
+
schemas: b.schemas,
|
|
45445
|
+
_meta: {
|
|
45446
|
+
schemas: {},
|
|
45447
|
+
tables: {},
|
|
45448
|
+
columns: {}
|
|
45449
|
+
}
|
|
45450
|
+
};
|
|
45451
|
+
}
|
|
45452
|
+
const a = mysqlSchemaV4.parse(prev);
|
|
45453
|
+
const json1 = squashMysqlScheme(a);
|
|
45454
|
+
const json2 = squashMysqlScheme(b);
|
|
45455
|
+
const diffResult = applyJsonDiff(json1, json2);
|
|
45456
|
+
const parseResult = diffResultScheme.safeParse(diffResult);
|
|
45457
|
+
if (!parseResult.success) {
|
|
45458
|
+
parseResult.error.errors.forEach((it) => {
|
|
45459
|
+
console.error(it);
|
|
45460
|
+
});
|
|
45461
|
+
throw new Error();
|
|
45462
|
+
}
|
|
45463
|
+
const typedResult = parseResult.data;
|
|
45464
|
+
const { renamed: renamedSchemas } = schemasResolver(
|
|
45465
|
+
typedResult.deletedSchemas.map((it) => ({ name: it })),
|
|
45466
|
+
typedResult.addedSchemas.map((it) => ({ name: it })),
|
|
45467
|
+
sql
|
|
45468
|
+
);
|
|
45469
|
+
const { renamed } = tablesResolver(
|
|
45470
|
+
typedResult.deletedTables,
|
|
45471
|
+
typedResult.addedTables,
|
|
45472
|
+
sql
|
|
45473
|
+
);
|
|
45474
|
+
const renamedWithAlternations = Object.values(
|
|
45475
|
+
alteredTableScheme.array().parse(diffForRenamedTables(renamed))
|
|
45476
|
+
);
|
|
45477
|
+
const allAltered = typedResult.alteredTablesWithColumns.concat(
|
|
45478
|
+
renamedWithAlternations
|
|
45479
|
+
);
|
|
45480
|
+
const rSchemas = renamedSchemas.map((it) => ({
|
|
45481
|
+
from: it.from.name,
|
|
45482
|
+
to: it.to.name
|
|
45483
|
+
}));
|
|
45484
|
+
const rTables = renamed.map((it) => {
|
|
45485
|
+
return { from: it.from, to: it.to };
|
|
45486
|
+
});
|
|
45487
|
+
const rColumns = allAltered.map((table4) => {
|
|
45488
|
+
const name = table4.name;
|
|
45489
|
+
const result = columnsResolver(name, table4.deleted, table4.added, sql);
|
|
45490
|
+
const tableName = table4.name;
|
|
45491
|
+
const schema4 = typeof table4.schema === "string" ? table4.schema : "";
|
|
45492
|
+
return result.renamed.map((it) => {
|
|
45493
|
+
return {
|
|
45494
|
+
from: { schema: schema4, table: tableName, column: it.from.name },
|
|
45495
|
+
to: { schema: schema4, table: tableName, column: it.to.name }
|
|
45496
|
+
};
|
|
45497
|
+
});
|
|
45498
|
+
}).flat();
|
|
45499
|
+
const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
|
|
45500
|
+
const bpatched = {
|
|
45501
|
+
version: "5",
|
|
45502
|
+
dialect: b.dialect,
|
|
45503
|
+
id: b.id,
|
|
45504
|
+
prevId: b.prevId,
|
|
45505
|
+
tables: b.tables,
|
|
45506
|
+
schemas: b.schemas,
|
|
45507
|
+
_meta
|
|
45508
|
+
};
|
|
45509
|
+
mysqlSchema.parse(bpatched);
|
|
45510
|
+
return {
|
|
45511
|
+
version: "5",
|
|
45512
|
+
dialect: b.dialect,
|
|
45513
|
+
id: b.id,
|
|
45514
|
+
prevId: b.prevId,
|
|
45515
|
+
tables: b.tables,
|
|
45516
|
+
schemas: b.schemas,
|
|
45517
|
+
_meta
|
|
45518
|
+
};
|
|
45519
|
+
};
|
|
45520
|
+
var upgradeFolders = (dialect6, out) => {
|
|
45521
|
+
const oldMigrationFolders = (0, import_fs8.readdirSync)(out).filter(
|
|
45522
|
+
(it) => it.length === 14 && /^\d+$/.test(it)
|
|
45523
|
+
);
|
|
45524
|
+
oldMigrationFolders.sort();
|
|
45525
|
+
const res = oldMigrationFolders.reduce(
|
|
45526
|
+
(res2, it) => {
|
|
45527
|
+
const date = new Date();
|
|
45528
|
+
date.setUTCFullYear(Number(it.substring(0, 4)));
|
|
45529
|
+
date.setUTCMonth(Number(it.substring(4, 6)) - 1);
|
|
45530
|
+
date.setUTCDate(Number(it.substring(6, 8)));
|
|
45531
|
+
date.setUTCHours(Number(it.substring(8, 10)));
|
|
45532
|
+
date.setUTCMinutes(Number(it.substring(10, 12)));
|
|
45533
|
+
date.setUTCSeconds(Number(it.substring(12, 14)));
|
|
45534
|
+
const path4 = (0, import_path6.join)(out, it);
|
|
45535
|
+
const pathJson = (0, import_path6.join)(out, it, "snapshot.json");
|
|
45536
|
+
const pathSQL = (0, import_path6.join)(out, it, "migration.sql");
|
|
45537
|
+
const snapshot = JSON.parse((0, import_fs8.readFileSync)(pathJson).toString());
|
|
45538
|
+
const sql = (0, import_fs8.readFileSync)(pathSQL).toString();
|
|
45539
|
+
res2.entries.push({
|
|
45540
|
+
idx: res2.idx,
|
|
45541
|
+
json: snapshot,
|
|
45542
|
+
date,
|
|
45543
|
+
sql,
|
|
45544
|
+
path: path4
|
|
45545
|
+
});
|
|
45546
|
+
res2.idx += 1;
|
|
45547
|
+
return res2;
|
|
45548
|
+
},
|
|
45549
|
+
{
|
|
45550
|
+
entries: [],
|
|
45551
|
+
idx: 0
|
|
45552
|
+
}
|
|
45553
|
+
);
|
|
45554
|
+
const metaFolder = (0, import_path6.join)(`${out}`, "meta");
|
|
45555
|
+
if (!(0, import_fs8.existsSync)(metaFolder)) {
|
|
45556
|
+
(0, import_fs8.mkdirSync)(metaFolder, { recursive: true });
|
|
45557
|
+
}
|
|
45558
|
+
const journal = dryJournal(dialect6);
|
|
45559
|
+
let prev = void 0;
|
|
45560
|
+
res.entries.forEach((it) => {
|
|
45561
|
+
const { prefix, suffix, tag } = prepareMigrationMetadata(it.idx);
|
|
45562
|
+
journal.entries.push({
|
|
45563
|
+
idx: it.idx,
|
|
45564
|
+
when: +it.date,
|
|
45565
|
+
tag
|
|
45566
|
+
});
|
|
45567
|
+
const patchedJSON = fullfill(prev, it.json, it.sql, dialect6);
|
|
45568
|
+
(0, import_fs8.writeFileSync)(
|
|
45569
|
+
(0, import_path6.join)(`${out}`, "meta", `${prefix}_snapshot.json`),
|
|
45570
|
+
JSON.stringify(patchedJSON)
|
|
45571
|
+
);
|
|
45572
|
+
(0, import_fs8.writeFileSync)((0, import_path6.join)(`${out}`, `${tag}.sql`), it.sql);
|
|
45573
|
+
(0, import_fs8.rmSync)(it.path, { recursive: true });
|
|
45574
|
+
prev = it.json;
|
|
45575
|
+
});
|
|
45576
|
+
(0, import_fs8.writeFileSync)((0, import_path6.join)(metaFolder, "_journal.json"), JSON.stringify(journal));
|
|
45577
|
+
};
|
|
45578
|
+
|
|
43538
45579
|
// src/cli/index.ts
|
|
43539
45580
|
init_mysqlSchema();
|
|
43540
45581
|
var printVersions = () => {
|
|
@@ -43544,18 +45585,18 @@ var printVersions = () => {
|
|
|
43544
45585
|
var assertEitherConfigOrOut = (config, out) => {
|
|
43545
45586
|
if (out)
|
|
43546
45587
|
return out;
|
|
43547
|
-
if (!(0,
|
|
45588
|
+
if (!(0, import_fs9.existsSync)(import_path7.default.join(import_path7.default.resolve(config)))) {
|
|
43548
45589
|
console.log(`${config} file does not exist`);
|
|
43549
45590
|
process.exit(1);
|
|
43550
45591
|
}
|
|
43551
45592
|
console.log(`Reading ${config}`);
|
|
43552
45593
|
const drizzleConfig = JSON.parse(
|
|
43553
|
-
|
|
45594
|
+
import_fs9.default.readFileSync(import_path7.default.join(import_path7.default.resolve(config))).toString()
|
|
43554
45595
|
);
|
|
43555
45596
|
return drizzleConfig.out;
|
|
43556
45597
|
};
|
|
43557
45598
|
var versions = () => {
|
|
43558
|
-
const { npmVersion } =
|
|
45599
|
+
const { npmVersion } = ormCoreVersions();
|
|
43559
45600
|
const ormVersion = npmVersion ? `
|
|
43560
45601
|
drizzle-orm: v${npmVersion}` : "";
|
|
43561
45602
|
const versions2 = `drizzle-kit: v${package_default.version}${ormVersion}`;
|
|
@@ -43618,9 +45659,9 @@ var generateSqliteCommand = new Command("generate:sqlite").option("--schema <sch
|
|
|
43618
45659
|
var prepareGenerateConfig = (options) => {
|
|
43619
45660
|
const { schema: schema4, out, config } = options;
|
|
43620
45661
|
if (!(schema4 || out)) {
|
|
43621
|
-
const
|
|
45662
|
+
const path4 = config != null ? config : "drizzle.config.json";
|
|
43622
45663
|
const drizzleConfig = JSON.parse(
|
|
43623
|
-
|
|
45664
|
+
import_fs9.default.readFileSync(import_path7.default.join(import_path7.default.resolve(path4))).toString()
|
|
43624
45665
|
);
|
|
43625
45666
|
return drizzleConfig;
|
|
43626
45667
|
}
|
|
@@ -43668,6 +45709,8 @@ var upPgCommand = new Command("up:pg").option("--out <out>", `Output folder`).op
|
|
|
43668
45709
|
process.exit(0);
|
|
43669
45710
|
}
|
|
43670
45711
|
assertPackages("drizzle-orm");
|
|
45712
|
+
upPgHandlerV4(out);
|
|
45713
|
+
upgradeFolders("pg", out);
|
|
43671
45714
|
upPgHandler(out);
|
|
43672
45715
|
});
|
|
43673
45716
|
var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
@@ -43686,6 +45729,9 @@ var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folde
|
|
|
43686
45729
|
console.log(error(`'out' folder param must be set`));
|
|
43687
45730
|
process.exit(0);
|
|
43688
45731
|
}
|
|
45732
|
+
assertPackages("drizzle-orm");
|
|
45733
|
+
upMysqlHandlerV4(out);
|
|
45734
|
+
upgradeFolders("mysql", out);
|
|
43689
45735
|
upMysqlHandler(out);
|
|
43690
45736
|
});
|
|
43691
45737
|
var upSqliteCommand = new Command("up:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
|
|
@@ -43704,7 +45750,7 @@ var pt1 = objectType({
|
|
|
43704
45750
|
var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Migrations folder`).option("--connectionString <connectionString>", "Postgres connection string").option("--host <host>", "Postgres host").option("--port <port>", "Postgres port").option("--user <user>", "Postgres user").option("--password <password>", "Postgres password").option("--database <database>", "Postgres database name").option("--ssl <ssl>", "Postgres ssl").action(async (options) => {
|
|
43705
45751
|
printVersions();
|
|
43706
45752
|
assertPackages("drizzle-orm");
|
|
43707
|
-
|
|
45753
|
+
assertOrmCoreVersion();
|
|
43708
45754
|
const { pgIntrospect: pgIntrospect2, PgConfig2: PgConfig22, PgConfig1: PgConfig12 } = (init_pgIntrospect(), __toCommonJS(pgIntrospect_exports));
|
|
43709
45755
|
const pgIntrospectConfig = unionType([
|
|
43710
45756
|
pt1.extend(PgConfig22.shape),
|
|
@@ -43715,29 +45761,18 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
|
|
|
43715
45761
|
console.log("Missing required params");
|
|
43716
45762
|
return;
|
|
43717
45763
|
}
|
|
43718
|
-
const
|
|
43719
|
-
const folderName = prepareSnapshotFolderName();
|
|
43720
|
-
const migrationFolderPath = `./${res.data.out}/${folderName}`;
|
|
45764
|
+
const { snapshots, journal } = prepareOutFolder(res.data.out, "pg");
|
|
43721
45765
|
const { schema: schema4, ts } = await pgIntrospect2(res.data);
|
|
43722
|
-
const schemaFile =
|
|
43723
|
-
(0,
|
|
45766
|
+
const schemaFile = import_path7.default.join(res.data.out, "schema.ts");
|
|
45767
|
+
(0, import_fs9.writeFileSync)(schemaFile, ts);
|
|
43724
45768
|
console.log();
|
|
43725
|
-
if (
|
|
43726
|
-
|
|
43727
|
-
const snapshotFile = import_path6.default.join(migrationFolderPath, "snapshot.json");
|
|
43728
|
-
(0, import_fs8.writeFileSync)(snapshotFile, JSON.stringify(schema4));
|
|
43729
|
-
const sql = await prepareSQL(
|
|
45769
|
+
if (snapshots.length === 0) {
|
|
45770
|
+
const { sql, _meta } = await prepareSQL(
|
|
43730
45771
|
squashPgScheme(dryPg),
|
|
43731
45772
|
squashPgScheme(schema4),
|
|
43732
45773
|
"pg"
|
|
43733
45774
|
);
|
|
43734
|
-
|
|
43735
|
-
(0, import_fs8.writeFileSync)(sqlFile, sql);
|
|
43736
|
-
(0, import_hanji5.render)(
|
|
43737
|
-
`[${source_default.green(
|
|
43738
|
-
"\u2713"
|
|
43739
|
-
)}] Your SQL migration file \u279C ${source_default.bold.underline.blue(sqlFile)} \u{1F680}`
|
|
43740
|
-
);
|
|
45775
|
+
writeResult(schema4, sql, 0, journal, _meta, res.data.out);
|
|
43741
45776
|
} else {
|
|
43742
45777
|
(0, import_hanji5.render)(
|
|
43743
45778
|
`[${source_default.blue(
|
|
@@ -43757,7 +45792,7 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
|
|
|
43757
45792
|
var introspectMySqlCommand = new Command("introspect:mysql").option("--out <out>", `Migrations folder`).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").action(async (options) => {
|
|
43758
45793
|
printVersions();
|
|
43759
45794
|
assertPackages("drizzle-orm");
|
|
43760
|
-
|
|
45795
|
+
assertOrmCoreVersion();
|
|
43761
45796
|
const { mysqlIntrospect: mysqlIntrospect2, MySQLConfig1: MySQLConfig12, MySQLConfig2: MySQLConfig22 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
|
|
43762
45797
|
const mysqlIntrospectConfig = unionType([
|
|
43763
45798
|
pt1.extend(MySQLConfig22.shape),
|
|
@@ -43768,29 +45803,18 @@ var introspectMySqlCommand = new Command("introspect:mysql").option("--out <out>
|
|
|
43768
45803
|
console.log("Missing required params");
|
|
43769
45804
|
return;
|
|
43770
45805
|
}
|
|
43771
|
-
const
|
|
43772
|
-
const folderName = prepareSnapshotFolderName();
|
|
43773
|
-
const migrationFolderPath = `./${res.data.out}/${folderName}`;
|
|
45806
|
+
const { snapshots, journal } = prepareOutFolder(res.data.out, "mysql");
|
|
43774
45807
|
const { schema: schema4, ts } = await mysqlIntrospect2(res.data);
|
|
43775
|
-
const schemaFile =
|
|
43776
|
-
(0,
|
|
45808
|
+
const schemaFile = import_path7.default.join(res.data.out, "schema.ts");
|
|
45809
|
+
(0, import_fs9.writeFileSync)(schemaFile, ts);
|
|
43777
45810
|
console.log();
|
|
43778
|
-
if (
|
|
43779
|
-
|
|
43780
|
-
const snapshotFile = import_path6.default.join(migrationFolderPath, "snapshot.json");
|
|
43781
|
-
(0, import_fs8.writeFileSync)(snapshotFile, JSON.stringify(schema4));
|
|
43782
|
-
const sql = await prepareSQL(
|
|
45811
|
+
if (snapshots.length === 0) {
|
|
45812
|
+
const { sql, _meta } = await prepareSQL(
|
|
43783
45813
|
squashMysqlScheme(dryMySql),
|
|
43784
45814
|
squashMysqlScheme(schema4),
|
|
43785
45815
|
"mysql"
|
|
43786
45816
|
);
|
|
43787
|
-
|
|
43788
|
-
(0, import_fs8.writeFileSync)(sqlFile, sql.sql);
|
|
43789
|
-
(0, import_hanji5.render)(
|
|
43790
|
-
`[${source_default.green(
|
|
43791
|
-
"\u2713"
|
|
43792
|
-
)}] Your SQL migration file \u279C ${source_default.bold.underline.blue(sqlFile)} \u{1F680}`
|
|
43793
|
-
);
|
|
45817
|
+
writeResult(schema4, sql, 0, journal, _meta, res.data.out);
|
|
43794
45818
|
} else {
|
|
43795
45819
|
(0, import_hanji5.render)(
|
|
43796
45820
|
`[${source_default.blue(
|