drizzle-kit 0.20.14-c82ab68 → 0.20.14-dc0459e
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +36904 -34432
- package/cli/commands/migrate.d.ts +24 -24
- package/cli/commands/mysqlIntrospect.d.ts +8 -8
- package/cli/commands/mysqlPushUtils.d.ts +2 -2
- package/cli/commands/mysqlUp.d.ts +2 -2
- package/cli/commands/pgConnect.d.ts +1 -1
- package/cli/commands/pgIntrospect.d.ts +9 -12
- package/cli/commands/pgPushUtils.d.ts +2 -2
- package/cli/commands/pgUp.d.ts +2 -2
- package/cli/commands/sqliteIntrospect.d.ts +9 -9
- package/cli/commands/sqlitePushUtils.d.ts +3 -3
- package/cli/commands/sqliteUtils.d.ts +162 -0
- package/cli/commands/upFolders.d.ts +1 -1
- package/cli/commands/utils.d.ts +259 -14
- package/cli/validations/common.d.ts +7 -205
- package/cli/validations/mysql.d.ts +1 -6
- package/cli/validations/pg.d.ts +1 -6
- package/cli/views.d.ts +1 -1
- package/global.d.ts +1 -1
- package/index.d.mts +6 -8
- package/index.d.ts +6 -8
- package/index.js +0 -1
- package/introspect-mysql.d.ts +1 -1
- package/introspect-pg.d.ts +2 -5
- package/introspect-sqlite.d.ts +1 -1
- package/jsonStatements.d.ts +1 -1
- package/package.json +8 -7
- package/payload.js +1534 -2210
- package/payload.mjs +1538 -2213
- package/schemaValidator.d.ts +40 -40
- package/serializer/mysqlSchema.d.ts +616 -1854
- package/serializer/mysqlSerializer.d.ts +2 -2
- package/serializer/pgSchema.d.ts +684 -1009
- package/serializer/sqliteSchema.d.ts +570 -144
- package/serializer/sqliteSerializer.d.ts +2 -2
- package/snapshotsDiffer.d.ts +20 -24
- package/utils-studio.js +15 -390
- package/utils-studio.mjs +15 -389
- package/utils.d.ts +12 -12
- package/utils.js +735 -849
- package/utils.mjs +736 -849
- package/cli/validations/cli.d.ts +0 -104
- package/cli/validations/sqlite.d.ts +0 -382
package/payload.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
2
|
var __create = Object.create;
|
4
3
|
var __defProp = Object.defineProperty;
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
@@ -1079,7 +1078,6 @@ var require_hanji = __commonJS({
|
|
1079
1078
|
var import_hanji, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, ResolveSchemasSelect;
|
1080
1079
|
var init_views = __esm({
|
1081
1080
|
"src/cli/views.ts"() {
|
1082
|
-
"use strict";
|
1083
1081
|
init_source();
|
1084
1082
|
import_hanji = __toESM(require_hanji());
|
1085
1083
|
info = (msg, greyMsg = "") => {
|
@@ -1101,7 +1099,7 @@ var init_views = __esm({
|
|
1101
1099
|
)}`;
|
1102
1100
|
}).join("\n");
|
1103
1101
|
msg += "\n";
|
1104
|
-
const enums = Object.values(
|
1102
|
+
const enums = Object.values(schema4["enums"] || {});
|
1105
1103
|
if (enums.length > 0) {
|
1106
1104
|
msg += "\n";
|
1107
1105
|
msg += source_default.bold(`${enums.length} enums
|
@@ -1116,7 +1114,7 @@ var init_views = __esm({
|
|
1116
1114
|
return msg;
|
1117
1115
|
};
|
1118
1116
|
isRenamePromptItem = (item) => {
|
1119
|
-
return "from"
|
1117
|
+
return item["from"] && item["to"];
|
1120
1118
|
};
|
1121
1119
|
ResolveColumnSelect = class extends import_hanji.Prompt {
|
1122
1120
|
constructor(tableName, base, data) {
|
@@ -1264,7 +1262,6 @@ __export(mysqlImports_exports, {
|
|
1264
1262
|
var import_mysql_core, import_drizzle_orm, prepareFromExports, prepareFromMySqlImports;
|
1265
1263
|
var init_mysqlImports = __esm({
|
1266
1264
|
"src/serializer/mysqlImports.ts"() {
|
1267
|
-
"use strict";
|
1268
1265
|
import_mysql_core = require("drizzle-orm/mysql-core");
|
1269
1266
|
import_drizzle_orm = require("drizzle-orm");
|
1270
1267
|
init_utils();
|
@@ -1306,7 +1303,6 @@ var init_mysqlImports = __esm({
|
|
1306
1303
|
var withStyle;
|
1307
1304
|
var init_outputs = __esm({
|
1308
1305
|
"src/cli/validations/outputs.ts"() {
|
1309
|
-
"use strict";
|
1310
1306
|
init_source();
|
1311
1307
|
withStyle = {
|
1312
1308
|
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
@@ -1345,7 +1341,6 @@ function clearDefaults(defaultValue, collate) {
|
|
1345
1341
|
var import_mysql_core2, import_drizzle_orm2, import_mysql_core3, import_drizzle_orm3, dialect, indexName, generateMySqlSnapshot, fromDatabase;
|
1346
1342
|
var init_mysqlSerializer = __esm({
|
1347
1343
|
"src/serializer/mysqlSerializer.ts"() {
|
1348
|
-
"use strict";
|
1349
1344
|
import_mysql_core2 = require("drizzle-orm/mysql-core");
|
1350
1345
|
import_drizzle_orm2 = require("drizzle-orm");
|
1351
1346
|
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
@@ -1561,8 +1556,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1561
1556
|
lock: value.config.lock
|
1562
1557
|
};
|
1563
1558
|
});
|
1564
|
-
|
1565
|
-
result[tableKey] = {
|
1559
|
+
result[tableName] = {
|
1566
1560
|
name: tableName,
|
1567
1561
|
schema: schema4,
|
1568
1562
|
columns: columnsObject,
|
@@ -1576,7 +1570,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1576
1570
|
mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
|
1577
1571
|
);
|
1578
1572
|
return {
|
1579
|
-
version: "
|
1573
|
+
version: "5",
|
1580
1574
|
dialect: "mysql",
|
1581
1575
|
tables: result,
|
1582
1576
|
schemas,
|
@@ -1831,7 +1825,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1831
1825
|
}
|
1832
1826
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
1833
1827
|
return {
|
1834
|
-
version: "
|
1828
|
+
version: "5",
|
1835
1829
|
dialect: "mysql",
|
1836
1830
|
tables: result,
|
1837
1831
|
schemas: schemasObject,
|
@@ -1856,7 +1850,6 @@ __export(pgSerializer_exports, {
|
|
1856
1850
|
var import_pg_core, import_pg_core2, import_drizzle_orm4, dialect2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
1857
1851
|
var init_pgSerializer = __esm({
|
1858
1852
|
"src/serializer/pgSerializer.ts"() {
|
1859
|
-
"use strict";
|
1860
1853
|
import_pg_core = require("drizzle-orm/pg-core");
|
1861
1854
|
import_pg_core2 = require("drizzle-orm/pg-core");
|
1862
1855
|
import_drizzle_orm4 = require("drizzle-orm");
|
@@ -2047,8 +2040,7 @@ ${withStyle.errorWarning(
|
|
2047
2040
|
isUnique: value.config.unique ?? false
|
2048
2041
|
};
|
2049
2042
|
});
|
2050
|
-
|
2051
|
-
result[tableKey] = {
|
2043
|
+
result[tableName] = {
|
2052
2044
|
name: tableName,
|
2053
2045
|
schema: schema4 ?? "",
|
2054
2046
|
columns: columnsObject,
|
@@ -2077,7 +2069,7 @@ ${withStyle.errorWarning(
|
|
2077
2069
|
}).map((it) => [it.schemaName, it.schemaName])
|
2078
2070
|
);
|
2079
2071
|
return {
|
2080
|
-
version: "
|
2072
|
+
version: "5",
|
2081
2073
|
dialect: "pg",
|
2082
2074
|
tables: result,
|
2083
2075
|
enums: enumsToReturn,
|
@@ -2098,7 +2090,7 @@ ${withStyle.errorWarning(
|
|
2098
2090
|
--end;
|
2099
2091
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
2100
2092
|
};
|
2101
|
-
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
|
2093
|
+
fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
|
2102
2094
|
const result = {};
|
2103
2095
|
const internals = { tables: {} };
|
2104
2096
|
const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
|
@@ -2425,7 +2417,7 @@ ${withStyle.errorWarning(
|
|
2425
2417
|
}
|
2426
2418
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
2427
2419
|
return {
|
2428
|
-
version: "
|
2420
|
+
version: "5",
|
2429
2421
|
dialect: "pg",
|
2430
2422
|
tables: result,
|
2431
2423
|
enums: enumsToReturn,
|
@@ -2506,7 +2498,6 @@ __export(sqliteImports_exports, {
|
|
2506
2498
|
var import_sqlite_core, import_drizzle_orm5, prepareFromExports2, prepareFromSqliteImports;
|
2507
2499
|
var init_sqliteImports = __esm({
|
2508
2500
|
"src/serializer/sqliteImports.ts"() {
|
2509
|
-
"use strict";
|
2510
2501
|
import_sqlite_core = require("drizzle-orm/sqlite-core");
|
2511
2502
|
import_drizzle_orm5 = require("drizzle-orm");
|
2512
2503
|
init_utils();
|
@@ -2545,7 +2536,6 @@ __export(sqliteSerializer_exports, {
|
|
2545
2536
|
generateSqliteSnapshot: () => generateSqliteSnapshot
|
2546
2537
|
});
|
2547
2538
|
function mapSqlToSqliteType(sqlType) {
|
2548
|
-
const lowered = sqlType.toLowerCase();
|
2549
2539
|
if ([
|
2550
2540
|
"int",
|
2551
2541
|
"integer",
|
@@ -2557,27 +2547,24 @@ function mapSqlToSqliteType(sqlType) {
|
|
2557
2547
|
"unsigned big int",
|
2558
2548
|
"int2",
|
2559
2549
|
"int8"
|
2560
|
-
].
|
2550
|
+
].includes(sqlType.toLowerCase())) {
|
2561
2551
|
return "integer";
|
2562
2552
|
} else if ([
|
2563
2553
|
"character",
|
2564
2554
|
"varchar",
|
2565
|
-
"
|
2566
|
-
"national varying character",
|
2555
|
+
"vatying character",
|
2567
2556
|
"nchar",
|
2568
2557
|
"native character",
|
2569
2558
|
"nvarchar",
|
2570
2559
|
"text",
|
2571
2560
|
"clob"
|
2572
|
-
].some((it) =>
|
2573
|
-
const match2 = lowered.match(/\d+/);
|
2574
|
-
if (match2) {
|
2575
|
-
return `text(${match2[0]})`;
|
2576
|
-
}
|
2561
|
+
].some((it) => it.startsWith(sqlType.toLowerCase()))) {
|
2577
2562
|
return "text";
|
2578
|
-
} else if (
|
2563
|
+
} else if (sqlType.toLowerCase() === "blob") {
|
2579
2564
|
return "blob";
|
2580
|
-
} else if (["real", "double", "double precision", "float"].
|
2565
|
+
} else if (["real", "double", "double precision", "float"].includes(
|
2566
|
+
sqlType.toLowerCase()
|
2567
|
+
)) {
|
2581
2568
|
return "real";
|
2582
2569
|
} else {
|
2583
2570
|
return "numeric";
|
@@ -2586,7 +2573,6 @@ function mapSqlToSqliteType(sqlType) {
|
|
2586
2573
|
var import_drizzle_orm6, import_sqlite_core2, dialect3, generateSqliteSnapshot, fromDatabase3;
|
2587
2574
|
var init_sqliteSerializer = __esm({
|
2588
2575
|
"src/serializer/sqliteSerializer.ts"() {
|
2589
|
-
"use strict";
|
2590
2576
|
import_drizzle_orm6 = require("drizzle-orm");
|
2591
2577
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
2592
2578
|
init_serializer();
|
@@ -2959,7 +2945,6 @@ WHERE
|
|
2959
2945
|
var import_fs, import_path, glob, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
2960
2946
|
var init_serializer = __esm({
|
2961
2947
|
"src/serializer/index.ts"() {
|
2962
|
-
"use strict";
|
2963
2948
|
import_fs = __toESM(require("fs"));
|
2964
2949
|
import_path = __toESM(require("path"));
|
2965
2950
|
glob = __toESM(require("glob"));
|
@@ -3029,26 +3014,6 @@ ${filenames.join("\n")}
|
|
3029
3014
|
}
|
3030
3015
|
});
|
3031
3016
|
|
3032
|
-
// src/global.ts
|
3033
|
-
function assertUnreachable(x) {
|
3034
|
-
throw new Error("Didn't expect to get here");
|
3035
|
-
}
|
3036
|
-
var originUUID, snapshotVersion, mapValues;
|
3037
|
-
var init_global = __esm({
|
3038
|
-
"src/global.ts"() {
|
3039
|
-
"use strict";
|
3040
|
-
originUUID = "00000000-0000-0000-0000-000000000000";
|
3041
|
-
snapshotVersion = "6";
|
3042
|
-
mapValues = (obj, map) => {
|
3043
|
-
const result = Object.keys(obj).reduce(function(result2, key) {
|
3044
|
-
result2[key] = map(obj[key]);
|
3045
|
-
return result2;
|
3046
|
-
}, {});
|
3047
|
-
return result;
|
3048
|
-
};
|
3049
|
-
}
|
3050
|
-
});
|
3051
|
-
|
3052
3017
|
// node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
|
3053
3018
|
function getErrorMap() {
|
3054
3019
|
return overrideErrorMap;
|
@@ -6195,1250 +6160,132 @@ var init_lib = __esm({
|
|
6195
6160
|
}
|
6196
6161
|
});
|
6197
6162
|
|
6198
|
-
// src/
|
6199
|
-
var
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6203
|
-
|
6204
|
-
|
6205
|
-
|
6206
|
-
|
6207
|
-
|
6208
|
-
|
6209
|
-
|
6210
|
-
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6214
|
-
|
6215
|
-
|
6216
|
-
|
6217
|
-
|
6218
|
-
|
6219
|
-
|
6220
|
-
|
6221
|
-
|
6222
|
-
|
6223
|
-
|
6224
|
-
|
6225
|
-
|
6226
|
-
|
6227
|
-
autoincrement: booleanType().optional(),
|
6228
|
-
default: anyType().optional(),
|
6229
|
-
onUpdate: anyType().optional()
|
6230
|
-
}).strict();
|
6231
|
-
tableV3 = objectType({
|
6232
|
-
name: stringType(),
|
6233
|
-
columns: recordType(stringType(), column),
|
6234
|
-
indexes: recordType(stringType(), index),
|
6235
|
-
foreignKeys: recordType(stringType(), fk)
|
6236
|
-
}).strict();
|
6237
|
-
compositePK = objectType({
|
6238
|
-
name: stringType(),
|
6239
|
-
columns: stringType().array()
|
6240
|
-
}).strict();
|
6241
|
-
uniqueConstraint = objectType({
|
6242
|
-
name: stringType(),
|
6243
|
-
columns: stringType().array()
|
6244
|
-
}).strict();
|
6245
|
-
tableV4 = objectType({
|
6246
|
-
name: stringType(),
|
6247
|
-
schema: stringType().optional(),
|
6248
|
-
columns: recordType(stringType(), column),
|
6249
|
-
indexes: recordType(stringType(), index),
|
6250
|
-
foreignKeys: recordType(stringType(), fk)
|
6251
|
-
}).strict();
|
6252
|
-
table = objectType({
|
6253
|
-
name: stringType(),
|
6254
|
-
schema: stringType().optional(),
|
6255
|
-
columns: recordType(stringType(), column),
|
6256
|
-
indexes: recordType(stringType(), index),
|
6257
|
-
foreignKeys: recordType(stringType(), fk),
|
6258
|
-
compositePrimaryKeys: recordType(stringType(), compositePK),
|
6259
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
6260
|
-
}).strict();
|
6261
|
-
kitInternals = objectType({
|
6262
|
-
tables: recordType(
|
6263
|
-
stringType(),
|
6264
|
-
objectType({
|
6265
|
-
columns: recordType(
|
6266
|
-
stringType(),
|
6267
|
-
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
6268
|
-
)
|
6269
|
-
}).optional()
|
6270
|
-
)
|
6271
|
-
}).optional();
|
6272
|
-
dialect4 = literalType("mysql");
|
6273
|
-
schemaHash = objectType({
|
6274
|
-
id: stringType(),
|
6275
|
-
prevId: stringType()
|
6276
|
-
});
|
6277
|
-
schemaInternalV3 = objectType({
|
6278
|
-
version: literalType("3"),
|
6279
|
-
dialect: dialect4,
|
6280
|
-
tables: recordType(stringType(), tableV3)
|
6281
|
-
}).strict();
|
6282
|
-
schemaInternalV4 = objectType({
|
6283
|
-
version: literalType("4"),
|
6284
|
-
dialect: dialect4,
|
6285
|
-
tables: recordType(stringType(), tableV4),
|
6286
|
-
schemas: recordType(stringType(), stringType())
|
6287
|
-
}).strict();
|
6288
|
-
schemaInternalV5 = objectType({
|
6289
|
-
version: literalType("5"),
|
6290
|
-
dialect: dialect4,
|
6291
|
-
tables: recordType(stringType(), table),
|
6292
|
-
schemas: recordType(stringType(), stringType()),
|
6293
|
-
_meta: objectType({
|
6294
|
-
schemas: recordType(stringType(), stringType()),
|
6295
|
-
tables: recordType(stringType(), stringType()),
|
6296
|
-
columns: recordType(stringType(), stringType())
|
6297
|
-
}),
|
6298
|
-
internal: kitInternals
|
6299
|
-
}).strict();
|
6300
|
-
schemaInternalV6 = objectType({
|
6301
|
-
version: literalType("6"),
|
6302
|
-
dialect: dialect4,
|
6303
|
-
tables: recordType(stringType(), table),
|
6304
|
-
schemas: recordType(stringType(), stringType()),
|
6305
|
-
_meta: objectType({
|
6306
|
-
schemas: recordType(stringType(), stringType()),
|
6307
|
-
tables: recordType(stringType(), stringType()),
|
6308
|
-
columns: recordType(stringType(), stringType())
|
6309
|
-
}),
|
6310
|
-
internal: kitInternals
|
6311
|
-
}).strict();
|
6312
|
-
schemaInternal = objectType({
|
6313
|
-
version: literalType("6"),
|
6314
|
-
dialect: dialect4,
|
6315
|
-
tables: recordType(stringType(), table),
|
6316
|
-
schemas: recordType(stringType(), stringType()),
|
6317
|
-
_meta: objectType({
|
6318
|
-
schemas: recordType(stringType(), stringType()),
|
6319
|
-
tables: recordType(stringType(), stringType()),
|
6320
|
-
columns: recordType(stringType(), stringType())
|
6321
|
-
}),
|
6322
|
-
internal: kitInternals
|
6323
|
-
}).strict();
|
6324
|
-
schemaV3 = schemaInternalV3.merge(schemaHash);
|
6325
|
-
schemaV4 = schemaInternalV4.merge(schemaHash);
|
6326
|
-
schemaV5 = schemaInternalV5.merge(schemaHash);
|
6327
|
-
schema2 = schemaInternal.merge(schemaHash);
|
6328
|
-
tableSquashedV4 = objectType({
|
6329
|
-
name: stringType(),
|
6330
|
-
schema: stringType().optional(),
|
6331
|
-
columns: recordType(stringType(), column),
|
6332
|
-
indexes: recordType(stringType(), stringType()),
|
6333
|
-
foreignKeys: recordType(stringType(), stringType())
|
6334
|
-
}).strict();
|
6335
|
-
tableSquashed = objectType({
|
6336
|
-
name: stringType(),
|
6337
|
-
schema: stringType().optional(),
|
6338
|
-
columns: recordType(stringType(), column),
|
6339
|
-
indexes: recordType(stringType(), stringType()),
|
6340
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6341
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6342
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6343
|
-
}).strict();
|
6344
|
-
schemaSquashed = objectType({
|
6345
|
-
version: literalType("5"),
|
6346
|
-
dialect: dialect4,
|
6347
|
-
tables: recordType(stringType(), tableSquashed),
|
6348
|
-
schemas: recordType(stringType(), stringType())
|
6349
|
-
}).strict();
|
6350
|
-
schemaSquashedV4 = objectType({
|
6351
|
-
version: literalType("4"),
|
6352
|
-
dialect: dialect4,
|
6353
|
-
tables: recordType(stringType(), tableSquashedV4),
|
6354
|
-
schemas: recordType(stringType(), stringType())
|
6355
|
-
}).strict();
|
6356
|
-
MySqlSquasher = {
|
6357
|
-
squashIdx: (idx) => {
|
6358
|
-
index.parse(idx);
|
6359
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
|
6360
|
-
},
|
6361
|
-
unsquashIdx: (input) => {
|
6362
|
-
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
6363
|
-
const destructed = {
|
6364
|
-
name,
|
6365
|
-
columns: columnsString.split(","),
|
6366
|
-
isUnique: isUnique === "true",
|
6367
|
-
using: using ? using : void 0,
|
6368
|
-
algorithm: algorithm ? algorithm : void 0,
|
6369
|
-
lock: lock ? lock : void 0
|
6370
|
-
};
|
6371
|
-
return index.parse(destructed);
|
6372
|
-
},
|
6373
|
-
squashPK: (pk) => {
|
6374
|
-
return `${pk.name};${pk.columns.join(",")}`;
|
6375
|
-
},
|
6376
|
-
unsquashPK: (pk) => {
|
6377
|
-
const splitted = pk.split(";");
|
6378
|
-
return { name: splitted[0], columns: splitted[1].split(",") };
|
6379
|
-
},
|
6380
|
-
squashUnique: (unq) => {
|
6381
|
-
return `${unq.name};${unq.columns.join(",")}`;
|
6382
|
-
},
|
6383
|
-
unsquashUnique: (unq) => {
|
6384
|
-
const [name, columns] = unq.split(";");
|
6385
|
-
return { name, columns: columns.split(",") };
|
6386
|
-
},
|
6387
|
-
squashFK: (fk4) => {
|
6388
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
6389
|
-
},
|
6390
|
-
unsquashFK: (input) => {
|
6391
|
-
const [
|
6392
|
-
name,
|
6393
|
-
tableFrom,
|
6394
|
-
columnsFromStr,
|
6395
|
-
tableTo,
|
6396
|
-
columnsToStr,
|
6397
|
-
onUpdate,
|
6398
|
-
onDelete
|
6399
|
-
] = input.split(";");
|
6400
|
-
const result = fk.parse({
|
6401
|
-
name,
|
6402
|
-
tableFrom,
|
6403
|
-
columnsFrom: columnsFromStr.split(","),
|
6404
|
-
tableTo,
|
6405
|
-
columnsTo: columnsToStr.split(","),
|
6406
|
-
onUpdate,
|
6407
|
-
onDelete
|
6408
|
-
});
|
6409
|
-
return result;
|
6163
|
+
// src/cli/commands/_es5.ts
|
6164
|
+
var es5_exports = {};
|
6165
|
+
__export(es5_exports, {
|
6166
|
+
default: () => es5_default
|
6167
|
+
});
|
6168
|
+
var _, es5_default;
|
6169
|
+
var init_es5 = __esm({
|
6170
|
+
"src/cli/commands/_es5.ts"() {
|
6171
|
+
_ = "";
|
6172
|
+
es5_default = _;
|
6173
|
+
}
|
6174
|
+
});
|
6175
|
+
|
6176
|
+
// node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
6177
|
+
var require_ms = __commonJS({
|
6178
|
+
"node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
|
6179
|
+
var s = 1e3;
|
6180
|
+
var m = s * 60;
|
6181
|
+
var h = m * 60;
|
6182
|
+
var d = h * 24;
|
6183
|
+
var w = d * 7;
|
6184
|
+
var y = d * 365.25;
|
6185
|
+
module2.exports = function(val, options) {
|
6186
|
+
options = options || {};
|
6187
|
+
var type = typeof val;
|
6188
|
+
if (type === "string" && val.length > 0) {
|
6189
|
+
return parse(val);
|
6190
|
+
} else if (type === "number" && isFinite(val)) {
|
6191
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
6410
6192
|
}
|
6411
|
-
|
6412
|
-
|
6413
|
-
const mappedTables = Object.fromEntries(
|
6414
|
-
Object.entries(json.tables).map((it) => {
|
6415
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6416
|
-
return MySqlSquasher.squashIdx(index4);
|
6417
|
-
});
|
6418
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6419
|
-
return MySqlSquasher.squashFK(fk4);
|
6420
|
-
});
|
6421
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6422
|
-
return MySqlSquasher.squashPK(pk);
|
6423
|
-
});
|
6424
|
-
const squashedUniqueConstraints = mapValues(
|
6425
|
-
it[1].uniqueConstraints,
|
6426
|
-
(unq) => {
|
6427
|
-
return MySqlSquasher.squashUnique(unq);
|
6428
|
-
}
|
6429
|
-
);
|
6430
|
-
return [
|
6431
|
-
it[0],
|
6432
|
-
{
|
6433
|
-
name: it[1].name,
|
6434
|
-
schema: it[1].schema,
|
6435
|
-
columns: it[1].columns,
|
6436
|
-
indexes: squashedIndexes,
|
6437
|
-
foreignKeys: squashedFKs,
|
6438
|
-
compositePrimaryKeys: squashedPKs,
|
6439
|
-
uniqueConstraints: squashedUniqueConstraints
|
6440
|
-
}
|
6441
|
-
];
|
6442
|
-
})
|
6193
|
+
throw new Error(
|
6194
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
6443
6195
|
);
|
6444
|
-
return {
|
6445
|
-
version: "5",
|
6446
|
-
dialect: json.dialect,
|
6447
|
-
tables: mappedTables,
|
6448
|
-
schemas: json.schemas
|
6449
|
-
};
|
6450
6196
|
};
|
6451
|
-
|
6452
|
-
|
6453
|
-
|
6454
|
-
|
6455
|
-
dryMySql = mysqlSchema.parse({
|
6456
|
-
version: snapshotVersion,
|
6457
|
-
dialect: "mysql",
|
6458
|
-
id: originUUID,
|
6459
|
-
prevId: "",
|
6460
|
-
tables: {},
|
6461
|
-
schemas: {},
|
6462
|
-
_meta: {
|
6463
|
-
schemas: {},
|
6464
|
-
tables: {},
|
6465
|
-
columns: {}
|
6197
|
+
function parse(str) {
|
6198
|
+
str = String(str);
|
6199
|
+
if (str.length > 100) {
|
6200
|
+
return;
|
6466
6201
|
}
|
6467
|
-
|
6468
|
-
|
6469
|
-
|
6470
|
-
|
6471
|
-
|
6472
|
-
|
6473
|
-
var
|
6474
|
-
|
6475
|
-
|
6476
|
-
|
6477
|
-
|
6478
|
-
|
6479
|
-
|
6480
|
-
|
6481
|
-
|
6482
|
-
|
6483
|
-
|
6484
|
-
|
6485
|
-
|
6486
|
-
|
6487
|
-
|
6488
|
-
|
6489
|
-
|
6490
|
-
|
6491
|
-
|
6492
|
-
|
6493
|
-
|
6494
|
-
|
6495
|
-
|
6496
|
-
|
6497
|
-
|
6498
|
-
|
6499
|
-
|
6500
|
-
|
6501
|
-
|
6502
|
-
|
6503
|
-
|
6504
|
-
|
6505
|
-
|
6506
|
-
|
6507
|
-
|
6508
|
-
|
6509
|
-
|
6510
|
-
|
6511
|
-
|
6512
|
-
|
6513
|
-
|
6514
|
-
|
6515
|
-
|
6516
|
-
|
6517
|
-
|
6518
|
-
|
6519
|
-
|
6520
|
-
|
6521
|
-
|
6522
|
-
|
6523
|
-
|
6524
|
-
|
6525
|
-
|
6526
|
-
|
6527
|
-
|
6528
|
-
|
6529
|
-
|
6530
|
-
|
6531
|
-
|
6532
|
-
|
6533
|
-
|
6534
|
-
|
6535
|
-
|
6536
|
-
|
6537
|
-
|
6538
|
-
|
6539
|
-
|
6540
|
-
|
6541
|
-
|
6542
|
-
|
6543
|
-
|
6544
|
-
|
6545
|
-
|
6546
|
-
|
6547
|
-
|
6548
|
-
|
6549
|
-
}
|
6550
|
-
|
6551
|
-
|
6552
|
-
|
6553
|
-
|
6554
|
-
notNull: booleanType(),
|
6555
|
-
default: anyType().optional(),
|
6556
|
-
isUnique: anyType().optional(),
|
6557
|
-
uniqueName: stringType().optional(),
|
6558
|
-
nullsNotDistinct: booleanType().optional()
|
6559
|
-
}).strict();
|
6560
|
-
tableV32 = objectType({
|
6561
|
-
name: stringType(),
|
6562
|
-
columns: recordType(stringType(), column2),
|
6563
|
-
indexes: recordType(stringType(), index2),
|
6564
|
-
foreignKeys: recordType(stringType(), fk2)
|
6565
|
-
}).strict();
|
6566
|
-
compositePK2 = objectType({
|
6567
|
-
name: stringType(),
|
6568
|
-
columns: stringType().array()
|
6569
|
-
}).strict();
|
6570
|
-
uniqueConstraint2 = objectType({
|
6571
|
-
name: stringType(),
|
6572
|
-
columns: stringType().array(),
|
6573
|
-
nullsNotDistinct: booleanType()
|
6574
|
-
}).strict();
|
6575
|
-
tableV42 = objectType({
|
6576
|
-
name: stringType(),
|
6577
|
-
schema: stringType(),
|
6578
|
-
columns: recordType(stringType(), column2),
|
6579
|
-
indexes: recordType(stringType(), index2),
|
6580
|
-
foreignKeys: recordType(stringType(), fk2)
|
6581
|
-
}).strict();
|
6582
|
-
table2 = objectType({
|
6583
|
-
name: stringType(),
|
6584
|
-
schema: stringType(),
|
6585
|
-
columns: recordType(stringType(), column2),
|
6586
|
-
indexes: recordType(stringType(), index2),
|
6587
|
-
foreignKeys: recordType(stringType(), fk2),
|
6588
|
-
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
6589
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
6590
|
-
}).strict();
|
6591
|
-
schemaHash2 = objectType({
|
6592
|
-
id: stringType(),
|
6593
|
-
prevId: stringType()
|
6594
|
-
});
|
6595
|
-
kitInternals2 = objectType({
|
6596
|
-
tables: recordType(
|
6597
|
-
stringType(),
|
6598
|
-
objectType({
|
6599
|
-
columns: recordType(
|
6600
|
-
stringType(),
|
6601
|
-
objectType({
|
6602
|
-
isArray: booleanType().optional(),
|
6603
|
-
dimensions: numberType().optional(),
|
6604
|
-
rawType: stringType().optional()
|
6605
|
-
}).optional()
|
6606
|
-
)
|
6607
|
-
}).optional()
|
6608
|
-
)
|
6609
|
-
}).optional();
|
6610
|
-
pgSchemaInternalV3 = objectType({
|
6611
|
-
version: literalType("3"),
|
6612
|
-
dialect: literalType("pg"),
|
6613
|
-
tables: recordType(stringType(), tableV32),
|
6614
|
-
enums: recordType(stringType(), enumSchema)
|
6615
|
-
}).strict();
|
6616
|
-
pgSchemaInternalV4 = objectType({
|
6617
|
-
version: literalType("4"),
|
6618
|
-
dialect: literalType("pg"),
|
6619
|
-
tables: recordType(stringType(), tableV42),
|
6620
|
-
enums: recordType(stringType(), enumSchema),
|
6621
|
-
schemas: recordType(stringType(), stringType())
|
6622
|
-
}).strict();
|
6623
|
-
pgSchemaInternalV5 = objectType({
|
6624
|
-
version: literalType("5"),
|
6625
|
-
dialect: literalType("pg"),
|
6626
|
-
tables: recordType(stringType(), table2),
|
6627
|
-
enums: recordType(stringType(), enumSchema),
|
6628
|
-
schemas: recordType(stringType(), stringType()),
|
6629
|
-
_meta: objectType({
|
6630
|
-
schemas: recordType(stringType(), stringType()),
|
6631
|
-
tables: recordType(stringType(), stringType()),
|
6632
|
-
columns: recordType(stringType(), stringType())
|
6633
|
-
}),
|
6634
|
-
internal: kitInternals2
|
6635
|
-
}).strict();
|
6636
|
-
pgSchemaExternal = objectType({
|
6637
|
-
version: literalType("5"),
|
6638
|
-
dialect: literalType("pg"),
|
6639
|
-
tables: arrayType(table2),
|
6640
|
-
enums: arrayType(enumSchema),
|
6641
|
-
schemas: arrayType(objectType({ name: stringType() })),
|
6642
|
-
_meta: objectType({
|
6643
|
-
schemas: recordType(stringType(), stringType()),
|
6644
|
-
tables: recordType(stringType(), stringType()),
|
6645
|
-
columns: recordType(stringType(), stringType())
|
6646
|
-
})
|
6647
|
-
}).strict();
|
6648
|
-
pgSchemaInternal = objectType({
|
6649
|
-
version: literalType("6"),
|
6650
|
-
dialect: literalType("pg"),
|
6651
|
-
tables: recordType(stringType(), table2),
|
6652
|
-
enums: recordType(stringType(), enumSchema),
|
6653
|
-
schemas: recordType(stringType(), stringType()),
|
6654
|
-
_meta: objectType({
|
6655
|
-
schemas: recordType(stringType(), stringType()),
|
6656
|
-
tables: recordType(stringType(), stringType()),
|
6657
|
-
columns: recordType(stringType(), stringType())
|
6658
|
-
}),
|
6659
|
-
internal: kitInternals2
|
6660
|
-
}).strict();
|
6661
|
-
tableSquashed2 = objectType({
|
6662
|
-
name: stringType(),
|
6663
|
-
schema: stringType(),
|
6664
|
-
columns: recordType(stringType(), column2),
|
6665
|
-
indexes: recordType(stringType(), stringType()),
|
6666
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6667
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6668
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
6669
|
-
}).strict();
|
6670
|
-
tableSquashedV42 = objectType({
|
6671
|
-
name: stringType(),
|
6672
|
-
schema: stringType(),
|
6673
|
-
columns: recordType(stringType(), column2),
|
6674
|
-
indexes: recordType(stringType(), stringType()),
|
6675
|
-
foreignKeys: recordType(stringType(), stringType())
|
6676
|
-
}).strict();
|
6677
|
-
pgSchemaSquashedV4 = objectType({
|
6678
|
-
version: literalType("4"),
|
6679
|
-
dialect: enumType(["pg"]),
|
6680
|
-
tables: recordType(stringType(), tableSquashedV42),
|
6681
|
-
enums: recordType(stringType(), enumSchema),
|
6682
|
-
schemas: recordType(stringType(), stringType())
|
6683
|
-
}).strict();
|
6684
|
-
pgSchemaSquashed = objectType({
|
6685
|
-
version: literalType("6"),
|
6686
|
-
dialect: enumType(["pg"]),
|
6687
|
-
tables: recordType(stringType(), tableSquashed2),
|
6688
|
-
enums: recordType(stringType(), enumSchema),
|
6689
|
-
schemas: recordType(stringType(), stringType())
|
6690
|
-
}).strict();
|
6691
|
-
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
6692
|
-
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
6693
|
-
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
6694
|
-
pgSchema = pgSchemaInternal.merge(schemaHash2);
|
6695
|
-
backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
|
6696
|
-
PgSquasher = {
|
6697
|
-
squashIdx: (idx) => {
|
6698
|
-
index2.parse(idx);
|
6699
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
|
6700
|
-
},
|
6701
|
-
unsquashIdx: (input) => {
|
6702
|
-
const [name, columnsString, isUnique] = input.split(";");
|
6703
|
-
const result = index2.parse({
|
6704
|
-
name,
|
6705
|
-
columns: columnsString.split(","),
|
6706
|
-
isUnique: isUnique === "true"
|
6707
|
-
});
|
6708
|
-
return result;
|
6709
|
-
},
|
6710
|
-
squashFK: (fk4) => {
|
6711
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6712
|
-
},
|
6713
|
-
squashPK: (pk) => {
|
6714
|
-
return `${pk.columns.join(",")};${pk.name}`;
|
6715
|
-
},
|
6716
|
-
unsquashPK: (pk) => {
|
6717
|
-
const splitted = pk.split(";");
|
6718
|
-
return { name: splitted[1], columns: splitted[0].split(",") };
|
6719
|
-
},
|
6720
|
-
squashUnique: (unq) => {
|
6721
|
-
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
6722
|
-
},
|
6723
|
-
unsquashUnique: (unq) => {
|
6724
|
-
const [name, columns, nullsNotDistinct] = unq.split(";");
|
6725
|
-
return {
|
6726
|
-
name,
|
6727
|
-
columns: columns.split(","),
|
6728
|
-
nullsNotDistinct: nullsNotDistinct === "true"
|
6729
|
-
};
|
6730
|
-
},
|
6731
|
-
unsquashFK: (input) => {
|
6732
|
-
const [
|
6733
|
-
name,
|
6734
|
-
tableFrom,
|
6735
|
-
columnsFromStr,
|
6736
|
-
tableTo,
|
6737
|
-
columnsToStr,
|
6738
|
-
onUpdate,
|
6739
|
-
onDelete,
|
6740
|
-
schemaTo
|
6741
|
-
] = input.split(";");
|
6742
|
-
const result = fk2.parse({
|
6743
|
-
name,
|
6744
|
-
tableFrom,
|
6745
|
-
columnsFrom: columnsFromStr.split(","),
|
6746
|
-
schemaTo,
|
6747
|
-
tableTo,
|
6748
|
-
columnsTo: columnsToStr.split(","),
|
6749
|
-
onUpdate,
|
6750
|
-
onDelete
|
6751
|
-
});
|
6752
|
-
return result;
|
6753
|
-
}
|
6754
|
-
};
|
6755
|
-
squashPgScheme = (json) => {
|
6756
|
-
const mappedTables = Object.fromEntries(
|
6757
|
-
Object.entries(json.tables).map((it) => {
|
6758
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6759
|
-
return PgSquasher.squashIdx(index4);
|
6760
|
-
});
|
6761
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6762
|
-
return PgSquasher.squashFK(fk4);
|
6763
|
-
});
|
6764
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6765
|
-
return PgSquasher.squashPK(pk);
|
6766
|
-
});
|
6767
|
-
const squashedUniqueConstraints = mapValues(
|
6768
|
-
it[1].uniqueConstraints,
|
6769
|
-
(unq) => {
|
6770
|
-
return PgSquasher.squashUnique(unq);
|
6771
|
-
}
|
6772
|
-
);
|
6773
|
-
return [
|
6774
|
-
it[0],
|
6775
|
-
{
|
6776
|
-
name: it[1].name,
|
6777
|
-
schema: it[1].schema,
|
6778
|
-
columns: it[1].columns,
|
6779
|
-
indexes: squashedIndexes,
|
6780
|
-
foreignKeys: squashedFKs,
|
6781
|
-
compositePrimaryKeys: squashedPKs,
|
6782
|
-
uniqueConstraints: squashedUniqueConstraints
|
6783
|
-
}
|
6784
|
-
];
|
6785
|
-
})
|
6786
|
-
);
|
6787
|
-
return {
|
6788
|
-
version: "6",
|
6789
|
-
dialect: json.dialect,
|
6790
|
-
tables: mappedTables,
|
6791
|
-
enums: json.enums,
|
6792
|
-
schemas: json.schemas
|
6793
|
-
};
|
6794
|
-
};
|
6795
|
-
dryPg = pgSchema.parse({
|
6796
|
-
version: snapshotVersion,
|
6797
|
-
dialect: "pg",
|
6798
|
-
id: originUUID,
|
6799
|
-
prevId: "",
|
6800
|
-
tables: {},
|
6801
|
-
enums: {},
|
6802
|
-
schemas: {},
|
6803
|
-
_meta: {
|
6804
|
-
schemas: {},
|
6805
|
-
tables: {},
|
6806
|
-
columns: {}
|
6807
|
-
}
|
6808
|
-
});
|
6809
|
-
}
|
6810
|
-
});
|
6811
|
-
|
6812
|
-
// src/serializer/sqliteSchema.ts
|
6813
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect5, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
6814
|
-
var init_sqliteSchema = __esm({
|
6815
|
-
"src/serializer/sqliteSchema.ts"() {
|
6816
|
-
"use strict";
|
6817
|
-
init_global();
|
6818
|
-
init_lib();
|
6819
|
-
index3 = objectType({
|
6820
|
-
name: stringType(),
|
6821
|
-
columns: stringType().array(),
|
6822
|
-
where: stringType().optional(),
|
6823
|
-
isUnique: booleanType()
|
6824
|
-
}).strict();
|
6825
|
-
fk3 = objectType({
|
6826
|
-
name: stringType(),
|
6827
|
-
tableFrom: stringType(),
|
6828
|
-
columnsFrom: stringType().array(),
|
6829
|
-
tableTo: stringType(),
|
6830
|
-
columnsTo: stringType().array(),
|
6831
|
-
onUpdate: stringType().optional(),
|
6832
|
-
onDelete: stringType().optional()
|
6833
|
-
}).strict();
|
6834
|
-
compositePK3 = objectType({
|
6835
|
-
columns: stringType().array(),
|
6836
|
-
name: stringType().optional()
|
6837
|
-
}).strict();
|
6838
|
-
column3 = objectType({
|
6839
|
-
name: stringType(),
|
6840
|
-
type: stringType(),
|
6841
|
-
primaryKey: booleanType(),
|
6842
|
-
notNull: booleanType(),
|
6843
|
-
autoincrement: booleanType().optional(),
|
6844
|
-
default: anyType().optional()
|
6845
|
-
}).strict();
|
6846
|
-
tableV33 = objectType({
|
6847
|
-
name: stringType(),
|
6848
|
-
columns: recordType(stringType(), column3),
|
6849
|
-
indexes: recordType(stringType(), index3),
|
6850
|
-
foreignKeys: recordType(stringType(), fk3)
|
6851
|
-
}).strict();
|
6852
|
-
uniqueConstraint3 = objectType({
|
6853
|
-
name: stringType(),
|
6854
|
-
columns: stringType().array()
|
6855
|
-
}).strict();
|
6856
|
-
table3 = objectType({
|
6857
|
-
name: stringType(),
|
6858
|
-
columns: recordType(stringType(), column3),
|
6859
|
-
indexes: recordType(stringType(), index3),
|
6860
|
-
foreignKeys: recordType(stringType(), fk3),
|
6861
|
-
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
6862
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
6863
|
-
}).strict();
|
6864
|
-
dialect5 = enumType(["sqlite"]);
|
6865
|
-
schemaHash3 = objectType({
|
6866
|
-
id: stringType(),
|
6867
|
-
prevId: stringType()
|
6868
|
-
}).strict();
|
6869
|
-
schemaInternalV32 = objectType({
|
6870
|
-
version: literalType("3"),
|
6871
|
-
dialect: dialect5,
|
6872
|
-
tables: recordType(stringType(), tableV33),
|
6873
|
-
enums: objectType({})
|
6874
|
-
}).strict();
|
6875
|
-
schemaInternalV42 = objectType({
|
6876
|
-
version: literalType("4"),
|
6877
|
-
dialect: dialect5,
|
6878
|
-
tables: recordType(stringType(), table3),
|
6879
|
-
enums: objectType({})
|
6880
|
-
}).strict();
|
6881
|
-
latestVersion = literalType("5");
|
6882
|
-
schemaInternal2 = objectType({
|
6883
|
-
version: latestVersion,
|
6884
|
-
dialect: dialect5,
|
6885
|
-
tables: recordType(stringType(), table3),
|
6886
|
-
enums: objectType({}),
|
6887
|
-
_meta: objectType({
|
6888
|
-
tables: recordType(stringType(), stringType()),
|
6889
|
-
columns: recordType(stringType(), stringType())
|
6890
|
-
})
|
6891
|
-
}).strict();
|
6892
|
-
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
6893
|
-
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
6894
|
-
schema3 = schemaInternal2.merge(schemaHash3).strict();
|
6895
|
-
tableSquashed3 = objectType({
|
6896
|
-
name: stringType(),
|
6897
|
-
columns: recordType(stringType(), column3),
|
6898
|
-
indexes: recordType(stringType(), stringType()),
|
6899
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6900
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6901
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6902
|
-
}).strict();
|
6903
|
-
schemaSquashed2 = objectType({
|
6904
|
-
version: latestVersion,
|
6905
|
-
dialect: dialect5,
|
6906
|
-
tables: recordType(stringType(), tableSquashed3),
|
6907
|
-
enums: anyType()
|
6908
|
-
}).strict();
|
6909
|
-
SQLiteSquasher = {
|
6910
|
-
squashIdx: (idx) => {
|
6911
|
-
index3.parse(idx);
|
6912
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
|
6913
|
-
},
|
6914
|
-
unsquashIdx: (input) => {
|
6915
|
-
const [name, columnsString, isUnique, where] = input.split(";");
|
6916
|
-
const result = index3.parse({
|
6917
|
-
name,
|
6918
|
-
columns: columnsString.split(","),
|
6919
|
-
isUnique: isUnique === "true",
|
6920
|
-
where: where ?? void 0
|
6921
|
-
});
|
6922
|
-
return result;
|
6923
|
-
},
|
6924
|
-
squashUnique: (unq) => {
|
6925
|
-
return `${unq.name};${unq.columns.join(",")}`;
|
6926
|
-
},
|
6927
|
-
unsquashUnique: (unq) => {
|
6928
|
-
const [name, columns] = unq.split(";");
|
6929
|
-
return { name, columns: columns.split(",") };
|
6930
|
-
},
|
6931
|
-
squashFK: (fk4) => {
|
6932
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
6933
|
-
},
|
6934
|
-
unsquashFK: (input) => {
|
6935
|
-
const [
|
6936
|
-
name,
|
6937
|
-
tableFrom,
|
6938
|
-
columnsFromStr,
|
6939
|
-
tableTo,
|
6940
|
-
columnsToStr,
|
6941
|
-
onUpdate,
|
6942
|
-
onDelete
|
6943
|
-
] = input.split(";");
|
6944
|
-
const result = fk3.parse({
|
6945
|
-
name,
|
6946
|
-
tableFrom,
|
6947
|
-
columnsFrom: columnsFromStr.split(","),
|
6948
|
-
tableTo,
|
6949
|
-
columnsTo: columnsToStr.split(","),
|
6950
|
-
onUpdate,
|
6951
|
-
onDelete
|
6952
|
-
});
|
6953
|
-
return result;
|
6954
|
-
},
|
6955
|
-
squashPK: (pk) => {
|
6956
|
-
return pk.columns.join(",");
|
6957
|
-
},
|
6958
|
-
unsquashPK: (pk) => {
|
6959
|
-
return pk.split(",");
|
6960
|
-
}
|
6961
|
-
};
|
6962
|
-
squashSqliteScheme = (json) => {
|
6963
|
-
const mappedTables = Object.fromEntries(
|
6964
|
-
Object.entries(json.tables).map((it) => {
|
6965
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6966
|
-
return SQLiteSquasher.squashIdx(index4);
|
6967
|
-
});
|
6968
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6969
|
-
return SQLiteSquasher.squashFK(fk4);
|
6970
|
-
});
|
6971
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6972
|
-
return SQLiteSquasher.squashPK(pk);
|
6973
|
-
});
|
6974
|
-
const squashedUniqueConstraints = mapValues(
|
6975
|
-
it[1].uniqueConstraints,
|
6976
|
-
(unq) => {
|
6977
|
-
return SQLiteSquasher.squashUnique(unq);
|
6978
|
-
}
|
6979
|
-
);
|
6980
|
-
return [
|
6981
|
-
it[0],
|
6982
|
-
{
|
6983
|
-
name: it[1].name,
|
6984
|
-
columns: it[1].columns,
|
6985
|
-
indexes: squashedIndexes,
|
6986
|
-
foreignKeys: squashedFKs,
|
6987
|
-
compositePrimaryKeys: squashedPKs,
|
6988
|
-
uniqueConstraints: squashedUniqueConstraints
|
6989
|
-
}
|
6990
|
-
];
|
6991
|
-
})
|
6992
|
-
);
|
6993
|
-
return {
|
6994
|
-
version: "5",
|
6995
|
-
dialect: json.dialect,
|
6996
|
-
tables: mappedTables,
|
6997
|
-
enums: json.enums
|
6998
|
-
};
|
6999
|
-
};
|
7000
|
-
drySQLite = schema3.parse({
|
7001
|
-
version: "5",
|
7002
|
-
dialect: "sqlite",
|
7003
|
-
id: originUUID,
|
7004
|
-
prevId: "",
|
7005
|
-
tables: {},
|
7006
|
-
enums: {},
|
7007
|
-
_meta: {
|
7008
|
-
tables: {},
|
7009
|
-
columns: {}
|
7010
|
-
}
|
7011
|
-
});
|
7012
|
-
sqliteSchema = schema3;
|
7013
|
-
SQLiteSchemaSquashed = schemaSquashed2;
|
7014
|
-
backwardCompatibleSqliteSchema = schema3;
|
7015
|
-
}
|
7016
|
-
});
|
7017
|
-
|
7018
|
-
// src/schemaValidator.ts
|
7019
|
-
var dialect6, commonSquashedSchema, commonSchema;
|
7020
|
-
var init_schemaValidator = __esm({
|
7021
|
-
"src/schemaValidator.ts"() {
|
7022
|
-
"use strict";
|
7023
|
-
init_lib();
|
7024
|
-
init_mysqlSchema();
|
7025
|
-
init_pgSchema();
|
7026
|
-
init_sqliteSchema();
|
7027
|
-
dialect6 = enumType(["pg", "mysql", "sqlite"]);
|
7028
|
-
commonSquashedSchema = unionType([
|
7029
|
-
pgSchemaSquashed,
|
7030
|
-
mysqlSchemaSquashed,
|
7031
|
-
SQLiteSchemaSquashed
|
7032
|
-
]);
|
7033
|
-
commonSchema = unionType([
|
7034
|
-
pgSchema,
|
7035
|
-
mysqlSchema,
|
7036
|
-
sqliteSchema
|
7037
|
-
]);
|
7038
|
-
}
|
7039
|
-
});
|
7040
|
-
|
7041
|
-
// src/cli/validations/common.ts
|
7042
|
-
var driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema;
|
7043
|
-
var init_common = __esm({
|
7044
|
-
"src/cli/validations/common.ts"() {
|
7045
|
-
"use strict";
|
7046
|
-
init_outputs();
|
7047
|
-
init_lib();
|
7048
|
-
init_schemaValidator();
|
7049
|
-
driver = unionType([
|
7050
|
-
literalType("better-sqlite"),
|
7051
|
-
literalType("turso"),
|
7052
|
-
literalType("libsql"),
|
7053
|
-
literalType("d1"),
|
7054
|
-
literalType("expo"),
|
7055
|
-
literalType("pg"),
|
7056
|
-
literalType("mysql2")
|
7057
|
-
]);
|
7058
|
-
configCommonSchema = objectType({
|
7059
|
-
dialect: dialect6,
|
7060
|
-
schema: unionType([stringType(), stringType().array()]),
|
7061
|
-
out: stringType().optional(),
|
7062
|
-
breakpoints: booleanType().default(true),
|
7063
|
-
driver: driver.optional(),
|
7064
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7065
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
7066
|
-
});
|
7067
|
-
introspectCasing = objectType({
|
7068
|
-
casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
|
7069
|
-
}).default({ casing: "camel" });
|
7070
|
-
configIntrospectSchema = objectType({
|
7071
|
-
schema: unionType([stringType(), stringType().array()]).optional(),
|
7072
|
-
out: stringType().optional().default("./drizzle"),
|
7073
|
-
breakpoints: booleanType().default(true),
|
7074
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7075
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7076
|
-
introspect: introspectCasing
|
7077
|
-
});
|
7078
|
-
configIntrospectCliSchema = objectType({
|
7079
|
-
schema: unionType([stringType(), stringType().array()]).optional(),
|
7080
|
-
out: stringType().optional().default("./drizzle"),
|
7081
|
-
breakpoints: booleanType().default(true),
|
7082
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7083
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7084
|
-
introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
|
7085
|
-
"camel"
|
7086
|
-
)
|
7087
|
-
});
|
7088
|
-
configGenerateSchema = objectType({
|
7089
|
-
schema: unionType([stringType(), stringType().array()]),
|
7090
|
-
out: stringType().optional().default("./drizzle"),
|
7091
|
-
breakpoints: booleanType().default(true)
|
7092
|
-
});
|
7093
|
-
configPushSchema = objectType({
|
7094
|
-
dialect: dialect6,
|
7095
|
-
schema: unionType([stringType(), stringType().array()]),
|
7096
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7097
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7098
|
-
verbose: booleanType().default(false),
|
7099
|
-
strict: booleanType().default(false)
|
7100
|
-
});
|
7101
|
-
mysqlConnectionSchema = unionType([
|
7102
|
-
objectType({
|
7103
|
-
host: stringType(),
|
7104
|
-
port: coerce.number().optional(),
|
7105
|
-
user: stringType().default("mysql"),
|
7106
|
-
password: stringType().optional(),
|
7107
|
-
database: stringType()
|
7108
|
-
// ssl: boolean().optional(),
|
7109
|
-
}),
|
7110
|
-
objectType({
|
7111
|
-
connectionString: stringType()
|
7112
|
-
}),
|
7113
|
-
objectType({})
|
7114
|
-
]);
|
7115
|
-
mySqlCliConfigSchema = intersectionType(
|
7116
|
-
configCommonSchema,
|
7117
|
-
mysqlConnectionSchema
|
7118
|
-
);
|
7119
|
-
}
|
7120
|
-
});
|
7121
|
-
|
7122
|
-
// src/cli/validations/mysql.ts
|
7123
|
-
var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams;
|
7124
|
-
var init_mysql = __esm({
|
7125
|
-
"src/cli/validations/mysql.ts"() {
|
7126
|
-
"use strict";
|
7127
|
-
init_lib();
|
7128
|
-
init_utils();
|
7129
|
-
init_common();
|
7130
|
-
init_common();
|
7131
|
-
init_outputs();
|
7132
|
-
mysqlConnectionCli = unionType([
|
7133
|
-
objectType({
|
7134
|
-
driver: literalType("mysql2"),
|
7135
|
-
host: stringType(),
|
7136
|
-
port: coerce.number().optional(),
|
7137
|
-
user: stringType().default("mysql"),
|
7138
|
-
password: stringType().optional(),
|
7139
|
-
database: stringType()
|
7140
|
-
}),
|
7141
|
-
objectType({
|
7142
|
-
driver: literalType("mysql2"),
|
7143
|
-
uri: stringType()
|
7144
|
-
// TODO: change docs
|
7145
|
-
})
|
7146
|
-
]);
|
7147
|
-
mysql2credentials = unionType([
|
7148
|
-
objectType({
|
7149
|
-
host: stringType(),
|
7150
|
-
port: coerce.number().optional(),
|
7151
|
-
user: stringType().default("mysql"),
|
7152
|
-
password: stringType().optional(),
|
7153
|
-
database: stringType()
|
7154
|
-
}),
|
7155
|
-
objectType({
|
7156
|
-
uri: stringType()
|
7157
|
-
// TODO: change docs
|
7158
|
-
})
|
7159
|
-
]);
|
7160
|
-
mysqlConnectionConfig = objectType({
|
7161
|
-
driver: literalType("mysql2"),
|
7162
|
-
dbCredentials: mysql2credentials
|
7163
|
-
});
|
7164
|
-
mysqlConfigIntrospectSchema = intersectionType(
|
7165
|
-
configIntrospectSchema,
|
7166
|
-
mysqlConnectionConfig
|
7167
|
-
);
|
7168
|
-
mysqlCliIntrospectParams = intersectionType(
|
7169
|
-
configIntrospectCliSchema,
|
7170
|
-
mysqlConnectionCli
|
7171
|
-
);
|
7172
|
-
mysqlCliPushParams = intersectionType(
|
7173
|
-
configPushSchema,
|
7174
|
-
mysqlConnectionCli
|
7175
|
-
);
|
7176
|
-
mysqlConfigPushParams = intersectionType(
|
7177
|
-
configPushSchema,
|
7178
|
-
mysqlConnectionConfig
|
7179
|
-
);
|
7180
|
-
}
|
7181
|
-
});
|
7182
|
-
|
7183
|
-
// src/cli/validations/pg.ts
|
7184
|
-
var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, pgCliPushParams, pgConfigPushParams;
|
7185
|
-
var init_pg = __esm({
|
7186
|
-
"src/cli/validations/pg.ts"() {
|
7187
|
-
"use strict";
|
7188
|
-
init_lib();
|
7189
|
-
init_utils();
|
7190
|
-
init_common();
|
7191
|
-
init_common();
|
7192
|
-
init_outputs();
|
7193
|
-
pgConnectionCli = unionType([
|
7194
|
-
objectType({
|
7195
|
-
driver: literalType("pg"),
|
7196
|
-
host: stringType(),
|
7197
|
-
port: coerce.number().optional(),
|
7198
|
-
user: stringType().default("postgres"),
|
7199
|
-
password: stringType().optional(),
|
7200
|
-
database: stringType(),
|
7201
|
-
ssl: coerce.boolean().optional(),
|
7202
|
-
type: literalType("params").default("params")
|
7203
|
-
}),
|
7204
|
-
objectType({
|
7205
|
-
driver: literalType("pg"),
|
7206
|
-
connectionString: stringType(),
|
7207
|
-
type: literalType("url").default("url")
|
7208
|
-
})
|
7209
|
-
]);
|
7210
|
-
pgConnectionConfig = unionType([
|
7211
|
-
objectType({
|
7212
|
-
driver: literalType("pg"),
|
7213
|
-
dbCredentials: objectType({
|
7214
|
-
host: stringType(),
|
7215
|
-
port: coerce.number().optional(),
|
7216
|
-
user: stringType().default("postgres"),
|
7217
|
-
password: stringType().optional(),
|
7218
|
-
database: stringType(),
|
7219
|
-
ssl: coerce.boolean().optional(),
|
7220
|
-
type: literalType("params").default("params").optional()
|
7221
|
-
})
|
7222
|
-
}),
|
7223
|
-
objectType({
|
7224
|
-
driver: literalType("pg"),
|
7225
|
-
dbCredentials: objectType({
|
7226
|
-
connectionString: stringType(),
|
7227
|
-
type: literalType("url").default("url").optional()
|
7228
|
-
})
|
7229
|
-
})
|
7230
|
-
]);
|
7231
|
-
pgConfigIntrospectSchema = intersectionType(
|
7232
|
-
configIntrospectSchema,
|
7233
|
-
pgConnectionConfig
|
7234
|
-
);
|
7235
|
-
pgCliIntrospectParams = intersectionType(
|
7236
|
-
configIntrospectCliSchema,
|
7237
|
-
pgConnectionCli
|
7238
|
-
);
|
7239
|
-
pgCliPushParams = intersectionType(
|
7240
|
-
configPushSchema,
|
7241
|
-
pgConnectionCli
|
7242
|
-
);
|
7243
|
-
pgConfigPushParams = intersectionType(
|
7244
|
-
configPushSchema,
|
7245
|
-
pgConnectionConfig
|
7246
|
-
);
|
7247
|
-
}
|
7248
|
-
});
|
7249
|
-
|
7250
|
-
// src/cli/validations/sqlite.ts
|
7251
|
-
var sqliteConnectionCli, sqliteConnectionSchema, sqliteCliConfigSchema, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams;
|
7252
|
-
var init_sqlite = __esm({
|
7253
|
-
"src/cli/validations/sqlite.ts"() {
|
7254
|
-
"use strict";
|
7255
|
-
init_lib();
|
7256
|
-
init_utils();
|
7257
|
-
init_common();
|
7258
|
-
init_common();
|
7259
|
-
init_outputs();
|
7260
|
-
sqliteConnectionCli = unionType([
|
7261
|
-
objectType({
|
7262
|
-
driver: literalType("turso"),
|
7263
|
-
url: stringType(),
|
7264
|
-
authToken: stringType()
|
7265
|
-
}),
|
7266
|
-
objectType({
|
7267
|
-
driver: literalType("better-sqlite"),
|
7268
|
-
url: stringType()
|
7269
|
-
}),
|
7270
|
-
objectType({
|
7271
|
-
driver: literalType("libsql"),
|
7272
|
-
url: stringType()
|
7273
|
-
})
|
7274
|
-
]);
|
7275
|
-
sqliteConnectionSchema = unionType([
|
7276
|
-
objectType({
|
7277
|
-
driver: literalType("turso"),
|
7278
|
-
dbCredentials: objectType({
|
7279
|
-
url: stringType(),
|
7280
|
-
authToken: stringType().optional()
|
7281
|
-
})
|
7282
|
-
}),
|
7283
|
-
objectType({
|
7284
|
-
driver: literalType("libsql"),
|
7285
|
-
dbCredentials: objectType({
|
7286
|
-
url: stringType()
|
7287
|
-
})
|
7288
|
-
}),
|
7289
|
-
objectType({
|
7290
|
-
driver: literalType("better-sqlite"),
|
7291
|
-
dbCredentials: objectType({
|
7292
|
-
url: stringType()
|
7293
|
-
})
|
7294
|
-
})
|
7295
|
-
]);
|
7296
|
-
sqliteCliConfigSchema = intersectionType(
|
7297
|
-
configIntrospectSchema,
|
7298
|
-
sqliteConnectionSchema
|
7299
|
-
);
|
7300
|
-
sqliteCliIntrospectParams = intersectionType(
|
7301
|
-
configIntrospectCliSchema,
|
7302
|
-
sqliteConnectionCli
|
7303
|
-
);
|
7304
|
-
sqliteCliPushParams = intersectionType(
|
7305
|
-
configPushSchema,
|
7306
|
-
sqliteConnectionCli
|
7307
|
-
);
|
7308
|
-
sqliteConfigPushParams = intersectionType(
|
7309
|
-
configPushSchema,
|
7310
|
-
sqliteConnectionSchema
|
7311
|
-
);
|
7312
|
-
}
|
7313
|
-
});
|
7314
|
-
|
7315
|
-
// src/cli/commands/_es5.ts
|
7316
|
-
var es5_exports = {};
|
7317
|
-
__export(es5_exports, {
|
7318
|
-
default: () => es5_default
|
7319
|
-
});
|
7320
|
-
var _, es5_default;
|
7321
|
-
var init_es5 = __esm({
|
7322
|
-
"src/cli/commands/_es5.ts"() {
|
7323
|
-
"use strict";
|
7324
|
-
_ = "";
|
7325
|
-
es5_default = _;
|
7326
|
-
}
|
7327
|
-
});
|
7328
|
-
|
7329
|
-
// node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
7330
|
-
var require_ms = __commonJS({
|
7331
|
-
"node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
|
7332
|
-
var s = 1e3;
|
7333
|
-
var m = s * 60;
|
7334
|
-
var h = m * 60;
|
7335
|
-
var d = h * 24;
|
7336
|
-
var w = d * 7;
|
7337
|
-
var y = d * 365.25;
|
7338
|
-
module2.exports = function(val, options) {
|
7339
|
-
options = options || {};
|
7340
|
-
var type = typeof val;
|
7341
|
-
if (type === "string" && val.length > 0) {
|
7342
|
-
return parse(val);
|
7343
|
-
} else if (type === "number" && isFinite(val)) {
|
7344
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
7345
|
-
}
|
7346
|
-
throw new Error(
|
7347
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
7348
|
-
);
|
7349
|
-
};
|
7350
|
-
function parse(str) {
|
7351
|
-
str = String(str);
|
7352
|
-
if (str.length > 100) {
|
7353
|
-
return;
|
7354
|
-
}
|
7355
|
-
var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
7356
|
-
str
|
7357
|
-
);
|
7358
|
-
if (!match2) {
|
7359
|
-
return;
|
7360
|
-
}
|
7361
|
-
var n = parseFloat(match2[1]);
|
7362
|
-
var type = (match2[2] || "ms").toLowerCase();
|
7363
|
-
switch (type) {
|
7364
|
-
case "years":
|
7365
|
-
case "year":
|
7366
|
-
case "yrs":
|
7367
|
-
case "yr":
|
7368
|
-
case "y":
|
7369
|
-
return n * y;
|
7370
|
-
case "weeks":
|
7371
|
-
case "week":
|
7372
|
-
case "w":
|
7373
|
-
return n * w;
|
7374
|
-
case "days":
|
7375
|
-
case "day":
|
7376
|
-
case "d":
|
7377
|
-
return n * d;
|
7378
|
-
case "hours":
|
7379
|
-
case "hour":
|
7380
|
-
case "hrs":
|
7381
|
-
case "hr":
|
7382
|
-
case "h":
|
7383
|
-
return n * h;
|
7384
|
-
case "minutes":
|
7385
|
-
case "minute":
|
7386
|
-
case "mins":
|
7387
|
-
case "min":
|
7388
|
-
case "m":
|
7389
|
-
return n * m;
|
7390
|
-
case "seconds":
|
7391
|
-
case "second":
|
7392
|
-
case "secs":
|
7393
|
-
case "sec":
|
7394
|
-
case "s":
|
7395
|
-
return n * s;
|
7396
|
-
case "milliseconds":
|
7397
|
-
case "millisecond":
|
7398
|
-
case "msecs":
|
7399
|
-
case "msec":
|
7400
|
-
case "ms":
|
7401
|
-
return n;
|
7402
|
-
default:
|
7403
|
-
return void 0;
|
7404
|
-
}
|
7405
|
-
}
|
7406
|
-
function fmtShort(ms) {
|
7407
|
-
var msAbs = Math.abs(ms);
|
7408
|
-
if (msAbs >= d) {
|
7409
|
-
return Math.round(ms / d) + "d";
|
7410
|
-
}
|
7411
|
-
if (msAbs >= h) {
|
7412
|
-
return Math.round(ms / h) + "h";
|
7413
|
-
}
|
7414
|
-
if (msAbs >= m) {
|
7415
|
-
return Math.round(ms / m) + "m";
|
7416
|
-
}
|
7417
|
-
if (msAbs >= s) {
|
7418
|
-
return Math.round(ms / s) + "s";
|
7419
|
-
}
|
7420
|
-
return ms + "ms";
|
7421
|
-
}
|
7422
|
-
function fmtLong(ms) {
|
7423
|
-
var msAbs = Math.abs(ms);
|
7424
|
-
if (msAbs >= d) {
|
7425
|
-
return plural2(ms, msAbs, d, "day");
|
7426
|
-
}
|
7427
|
-
if (msAbs >= h) {
|
7428
|
-
return plural2(ms, msAbs, h, "hour");
|
7429
|
-
}
|
7430
|
-
if (msAbs >= m) {
|
7431
|
-
return plural2(ms, msAbs, m, "minute");
|
7432
|
-
}
|
7433
|
-
if (msAbs >= s) {
|
7434
|
-
return plural2(ms, msAbs, s, "second");
|
7435
|
-
}
|
7436
|
-
return ms + " ms";
|
7437
|
-
}
|
7438
|
-
function plural2(ms, msAbs, n, name) {
|
7439
|
-
var isPlural = msAbs >= n * 1.5;
|
7440
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
7441
|
-
}
|
6202
|
+
var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
6203
|
+
str
|
6204
|
+
);
|
6205
|
+
if (!match2) {
|
6206
|
+
return;
|
6207
|
+
}
|
6208
|
+
var n = parseFloat(match2[1]);
|
6209
|
+
var type = (match2[2] || "ms").toLowerCase();
|
6210
|
+
switch (type) {
|
6211
|
+
case "years":
|
6212
|
+
case "year":
|
6213
|
+
case "yrs":
|
6214
|
+
case "yr":
|
6215
|
+
case "y":
|
6216
|
+
return n * y;
|
6217
|
+
case "weeks":
|
6218
|
+
case "week":
|
6219
|
+
case "w":
|
6220
|
+
return n * w;
|
6221
|
+
case "days":
|
6222
|
+
case "day":
|
6223
|
+
case "d":
|
6224
|
+
return n * d;
|
6225
|
+
case "hours":
|
6226
|
+
case "hour":
|
6227
|
+
case "hrs":
|
6228
|
+
case "hr":
|
6229
|
+
case "h":
|
6230
|
+
return n * h;
|
6231
|
+
case "minutes":
|
6232
|
+
case "minute":
|
6233
|
+
case "mins":
|
6234
|
+
case "min":
|
6235
|
+
case "m":
|
6236
|
+
return n * m;
|
6237
|
+
case "seconds":
|
6238
|
+
case "second":
|
6239
|
+
case "secs":
|
6240
|
+
case "sec":
|
6241
|
+
case "s":
|
6242
|
+
return n * s;
|
6243
|
+
case "milliseconds":
|
6244
|
+
case "millisecond":
|
6245
|
+
case "msecs":
|
6246
|
+
case "msec":
|
6247
|
+
case "ms":
|
6248
|
+
return n;
|
6249
|
+
default:
|
6250
|
+
return void 0;
|
6251
|
+
}
|
6252
|
+
}
|
6253
|
+
function fmtShort(ms) {
|
6254
|
+
var msAbs = Math.abs(ms);
|
6255
|
+
if (msAbs >= d) {
|
6256
|
+
return Math.round(ms / d) + "d";
|
6257
|
+
}
|
6258
|
+
if (msAbs >= h) {
|
6259
|
+
return Math.round(ms / h) + "h";
|
6260
|
+
}
|
6261
|
+
if (msAbs >= m) {
|
6262
|
+
return Math.round(ms / m) + "m";
|
6263
|
+
}
|
6264
|
+
if (msAbs >= s) {
|
6265
|
+
return Math.round(ms / s) + "s";
|
6266
|
+
}
|
6267
|
+
return ms + "ms";
|
6268
|
+
}
|
6269
|
+
function fmtLong(ms) {
|
6270
|
+
var msAbs = Math.abs(ms);
|
6271
|
+
if (msAbs >= d) {
|
6272
|
+
return plural(ms, msAbs, d, "day");
|
6273
|
+
}
|
6274
|
+
if (msAbs >= h) {
|
6275
|
+
return plural(ms, msAbs, h, "hour");
|
6276
|
+
}
|
6277
|
+
if (msAbs >= m) {
|
6278
|
+
return plural(ms, msAbs, m, "minute");
|
6279
|
+
}
|
6280
|
+
if (msAbs >= s) {
|
6281
|
+
return plural(ms, msAbs, s, "second");
|
6282
|
+
}
|
6283
|
+
return ms + " ms";
|
6284
|
+
}
|
6285
|
+
function plural(ms, msAbs, n, name) {
|
6286
|
+
var isPlural = msAbs >= n * 1.5;
|
6287
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
6288
|
+
}
|
7442
6289
|
}
|
7443
6290
|
});
|
7444
6291
|
|
@@ -12763,281 +11610,1144 @@ var require_node2 = __commonJS({
|
|
12763
11610
|
return jsoncParse(content);
|
12764
11611
|
}
|
12765
11612
|
});
|
12766
|
-
var getOptions = (cwd) => {
|
12767
|
-
var _a, _b, _c, _d;
|
12768
|
-
const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
12769
|
-
if (path3 && data) {
|
11613
|
+
var getOptions = (cwd) => {
|
11614
|
+
var _a, _b, _c, _d;
|
11615
|
+
const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
11616
|
+
if (path3 && data) {
|
11617
|
+
return {
|
11618
|
+
jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
|
11619
|
+
jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
|
11620
|
+
target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
|
11621
|
+
};
|
11622
|
+
}
|
11623
|
+
return {};
|
11624
|
+
};
|
11625
|
+
var inferPackageFormat = (cwd, filename) => {
|
11626
|
+
if (filename.endsWith(".mjs")) {
|
11627
|
+
return "esm";
|
11628
|
+
}
|
11629
|
+
if (filename.endsWith(".cjs")) {
|
11630
|
+
return "cjs";
|
11631
|
+
}
|
11632
|
+
const { data } = joycon.loadSync(["package.json"], cwd);
|
11633
|
+
return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
|
11634
|
+
};
|
11635
|
+
var import_tsconfig_paths = __toModule(require_lib4());
|
11636
|
+
var noOp = () => {
|
11637
|
+
};
|
11638
|
+
function registerTsconfigPaths() {
|
11639
|
+
const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
|
11640
|
+
if (configLoaderResult.resultType === "failed") {
|
11641
|
+
return noOp;
|
11642
|
+
}
|
11643
|
+
const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
|
11644
|
+
const Module = require("module");
|
11645
|
+
const originalResolveFilename = Module._resolveFilename;
|
11646
|
+
Module._resolveFilename = function(request, _parent) {
|
11647
|
+
const isCoreModule = _module2.builtinModules.includes(request);
|
11648
|
+
if (!isCoreModule) {
|
11649
|
+
const found = matchPath(request);
|
11650
|
+
if (found) {
|
11651
|
+
const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
|
11652
|
+
return originalResolveFilename.apply(this, modifiedArguments);
|
11653
|
+
}
|
11654
|
+
}
|
11655
|
+
return originalResolveFilename.apply(this, arguments);
|
11656
|
+
};
|
11657
|
+
return () => {
|
11658
|
+
Module._resolveFilename = originalResolveFilename;
|
11659
|
+
};
|
11660
|
+
}
|
11661
|
+
var _debug = require_src2();
|
11662
|
+
var _debug2 = _interopRequireDefault2(_debug);
|
11663
|
+
var debug = _debug2.default.call(void 0, "esbuild-register");
|
11664
|
+
var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
|
11665
|
+
var map = {};
|
11666
|
+
function installSourceMapSupport() {
|
11667
|
+
if (_process2.default.setSourceMapsEnabled) {
|
11668
|
+
;
|
11669
|
+
_process2.default.setSourceMapsEnabled(true);
|
11670
|
+
} else {
|
11671
|
+
import_source_map_support.default.install({
|
11672
|
+
handleUncaughtExceptions: false,
|
11673
|
+
environment: "node",
|
11674
|
+
retrieveSourceMap(file) {
|
11675
|
+
if (map[file]) {
|
11676
|
+
return {
|
11677
|
+
url: file,
|
11678
|
+
map: map[file]
|
11679
|
+
};
|
11680
|
+
}
|
11681
|
+
return null;
|
11682
|
+
}
|
11683
|
+
});
|
11684
|
+
}
|
11685
|
+
}
|
11686
|
+
function patchCommonJsLoader(compile) {
|
11687
|
+
const extensions = _module3.default.Module._extensions;
|
11688
|
+
const jsHandler = extensions[".js"];
|
11689
|
+
extensions[".js"] = function(module22, filename) {
|
11690
|
+
try {
|
11691
|
+
return jsHandler.call(this, module22, filename);
|
11692
|
+
} catch (error2) {
|
11693
|
+
if (error2.code !== "ERR_REQUIRE_ESM") {
|
11694
|
+
throw error2;
|
11695
|
+
}
|
11696
|
+
let content = _fs3.default.readFileSync(filename, "utf8");
|
11697
|
+
content = compile(content, filename, "cjs");
|
11698
|
+
module22._compile(content, filename);
|
11699
|
+
}
|
11700
|
+
};
|
11701
|
+
return () => {
|
11702
|
+
extensions[".js"] = jsHandler;
|
11703
|
+
};
|
11704
|
+
}
|
11705
|
+
var FILE_LOADERS = {
|
11706
|
+
".js": "js",
|
11707
|
+
".jsx": "jsx",
|
11708
|
+
".ts": "ts",
|
11709
|
+
".tsx": "tsx",
|
11710
|
+
".mjs": "js",
|
11711
|
+
".mts": "ts",
|
11712
|
+
".cts": "ts"
|
11713
|
+
};
|
11714
|
+
var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
|
11715
|
+
var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
|
11716
|
+
function register(esbuildOptions = {}) {
|
11717
|
+
const {
|
11718
|
+
extensions = DEFAULT_EXTENSIONS,
|
11719
|
+
hookIgnoreNodeModules = true,
|
11720
|
+
hookMatcher,
|
11721
|
+
...overrides
|
11722
|
+
} = esbuildOptions;
|
11723
|
+
const compile = function compile2(code, filename, format) {
|
11724
|
+
const define = {
|
11725
|
+
"import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
|
11726
|
+
...overrides.define
|
11727
|
+
};
|
11728
|
+
const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
|
11729
|
+
if (code.includes(banner)) {
|
11730
|
+
return code;
|
11731
|
+
}
|
11732
|
+
const dir = _path2.dirname.call(void 0, filename);
|
11733
|
+
const options = getOptions(dir);
|
11734
|
+
format = format != null ? format : inferPackageFormat(dir, filename);
|
11735
|
+
const result = _esbuild.transformSync.call(void 0, code, {
|
11736
|
+
sourcefile: filename,
|
11737
|
+
loader: getLoader(filename),
|
11738
|
+
sourcemap: "both",
|
11739
|
+
target: options.target,
|
11740
|
+
jsxFactory: options.jsxFactory,
|
11741
|
+
jsxFragment: options.jsxFragment,
|
11742
|
+
format,
|
11743
|
+
define,
|
11744
|
+
banner,
|
11745
|
+
...overrides
|
11746
|
+
});
|
11747
|
+
const js = result.code;
|
11748
|
+
debug("compiled %s", filename);
|
11749
|
+
debug("%s", js);
|
11750
|
+
const warnings = result.warnings;
|
11751
|
+
if (warnings && warnings.length > 0) {
|
11752
|
+
for (const warning of warnings) {
|
11753
|
+
console.log(warning.location);
|
11754
|
+
console.log(warning.text);
|
11755
|
+
}
|
11756
|
+
}
|
11757
|
+
if (format === "esm")
|
11758
|
+
return js;
|
11759
|
+
return removeNodePrefix(js);
|
11760
|
+
};
|
11761
|
+
const revert = (0, import_pirates.addHook)(compile, {
|
11762
|
+
exts: extensions,
|
11763
|
+
ignoreNodeModules: hookIgnoreNodeModules,
|
11764
|
+
matcher: hookMatcher
|
11765
|
+
});
|
11766
|
+
installSourceMapSupport();
|
11767
|
+
const unpatchCommonJsLoader = patchCommonJsLoader(compile);
|
11768
|
+
const unregisterTsconfigPaths = registerTsconfigPaths();
|
11769
|
+
return {
|
11770
|
+
unregister() {
|
11771
|
+
revert();
|
11772
|
+
unpatchCommonJsLoader();
|
11773
|
+
unregisterTsconfigPaths();
|
11774
|
+
}
|
11775
|
+
};
|
11776
|
+
}
|
11777
|
+
exports.register = register;
|
11778
|
+
}
|
11779
|
+
});
|
11780
|
+
|
11781
|
+
// src/cli/commands/utils.ts
|
11782
|
+
var import_hanji2, assertES5, safeRegister, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
|
11783
|
+
var init_utils = __esm({
|
11784
|
+
"src/cli/commands/utils.ts"() {
|
11785
|
+
init_serializer();
|
11786
|
+
init_lib();
|
11787
|
+
init_source();
|
11788
|
+
init_views();
|
11789
|
+
import_hanji2 = __toESM(require_hanji());
|
11790
|
+
assertES5 = async (unregister) => {
|
11791
|
+
try {
|
11792
|
+
init_es5();
|
11793
|
+
} catch (e) {
|
11794
|
+
if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
|
11795
|
+
const es5Error = e.errors.filter(
|
11796
|
+
(it) => {
|
11797
|
+
var _a;
|
11798
|
+
return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
|
11799
|
+
}
|
11800
|
+
).length > 0;
|
11801
|
+
if (es5Error) {
|
11802
|
+
console.log(
|
11803
|
+
error(
|
11804
|
+
`Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
|
11805
|
+
)
|
11806
|
+
);
|
11807
|
+
process.exit(1);
|
11808
|
+
}
|
11809
|
+
}
|
11810
|
+
console.error(e);
|
11811
|
+
process.exit(1);
|
11812
|
+
}
|
11813
|
+
};
|
11814
|
+
safeRegister = async () => {
|
11815
|
+
const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
|
11816
|
+
let res;
|
11817
|
+
try {
|
11818
|
+
res = register({
|
11819
|
+
format: "cjs",
|
11820
|
+
loader: "ts"
|
11821
|
+
});
|
11822
|
+
} catch {
|
11823
|
+
res = {
|
11824
|
+
unregister: () => {
|
11825
|
+
}
|
11826
|
+
};
|
11827
|
+
}
|
11828
|
+
await assertES5(res.unregister);
|
11829
|
+
return res;
|
11830
|
+
};
|
11831
|
+
driver = unionType([
|
11832
|
+
literalType("better-sqlite"),
|
11833
|
+
literalType("turso"),
|
11834
|
+
literalType("libsql"),
|
11835
|
+
literalType("d1"),
|
11836
|
+
literalType("expo"),
|
11837
|
+
literalType("pg"),
|
11838
|
+
literalType("mysql2")
|
11839
|
+
]);
|
11840
|
+
configCommonSchema = objectType({
|
11841
|
+
schema: unionType([stringType(), stringType().array()]),
|
11842
|
+
out: stringType().optional(),
|
11843
|
+
breakpoints: booleanType().default(true),
|
11844
|
+
driver: driver.optional(),
|
11845
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11846
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
11847
|
+
});
|
11848
|
+
introspectCasing = objectType({
|
11849
|
+
casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
|
11850
|
+
}).default({ casing: "camel" });
|
11851
|
+
configIntrospectSchema = objectType({
|
11852
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
11853
|
+
out: stringType().optional().default("./drizzle"),
|
11854
|
+
breakpoints: booleanType().default(true),
|
11855
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11856
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11857
|
+
introspect: introspectCasing
|
11858
|
+
});
|
11859
|
+
configIntrospectCliSchema = objectType({
|
11860
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
11861
|
+
out: stringType().optional().default("./drizzle"),
|
11862
|
+
breakpoints: booleanType().default(true),
|
11863
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11864
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11865
|
+
introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
|
11866
|
+
"camel"
|
11867
|
+
)
|
11868
|
+
});
|
11869
|
+
configGenerateSchema = objectType({
|
11870
|
+
schema: unionType([stringType(), stringType().array()]),
|
11871
|
+
out: stringType().optional().default("./drizzle"),
|
11872
|
+
breakpoints: booleanType().default(true)
|
11873
|
+
});
|
11874
|
+
configPushSchema = objectType({
|
11875
|
+
schema: unionType([stringType(), stringType().array()]),
|
11876
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11877
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11878
|
+
verbose: booleanType().default(false),
|
11879
|
+
strict: booleanType().default(false)
|
11880
|
+
});
|
11881
|
+
mysqlConnectionSchema = unionType([
|
11882
|
+
objectType({
|
11883
|
+
host: stringType(),
|
11884
|
+
port: coerce.number().optional(),
|
11885
|
+
user: stringType().default("mysql"),
|
11886
|
+
password: stringType().optional(),
|
11887
|
+
database: stringType()
|
11888
|
+
// ssl: boolean().optional(),
|
11889
|
+
}),
|
11890
|
+
objectType({
|
11891
|
+
connectionString: stringType()
|
11892
|
+
}),
|
11893
|
+
objectType({})
|
11894
|
+
]);
|
11895
|
+
mySqlCliConfigSchema = intersectionType(
|
11896
|
+
configCommonSchema,
|
11897
|
+
mysqlConnectionSchema
|
11898
|
+
);
|
11899
|
+
mySqlIntrospectConfigSchema = intersectionType(
|
11900
|
+
configIntrospectSchema,
|
11901
|
+
mysqlConnectionSchema
|
11902
|
+
);
|
11903
|
+
}
|
11904
|
+
});
|
11905
|
+
|
11906
|
+
// src/serializer/pgImports.ts
|
11907
|
+
var pgImports_exports = {};
|
11908
|
+
__export(pgImports_exports, {
|
11909
|
+
prepareFromExports: () => prepareFromExports3,
|
11910
|
+
prepareFromPgImports: () => prepareFromPgImports
|
11911
|
+
});
|
11912
|
+
var import_pg_core3, import_drizzle_orm7, prepareFromExports3, prepareFromPgImports;
|
11913
|
+
var init_pgImports = __esm({
|
11914
|
+
"src/serializer/pgImports.ts"() {
|
11915
|
+
import_pg_core3 = require("drizzle-orm/pg-core");
|
11916
|
+
import_drizzle_orm7 = require("drizzle-orm");
|
11917
|
+
init_utils();
|
11918
|
+
prepareFromExports3 = (exports) => {
|
11919
|
+
const tables = [];
|
11920
|
+
const enums = [];
|
11921
|
+
const schemas = [];
|
11922
|
+
const i0values = Object.values(exports);
|
11923
|
+
i0values.forEach((t) => {
|
11924
|
+
if ((0, import_pg_core3.isPgEnum)(t)) {
|
11925
|
+
enums.push(t);
|
11926
|
+
return;
|
11927
|
+
}
|
11928
|
+
if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgTable)) {
|
11929
|
+
tables.push(t);
|
11930
|
+
}
|
11931
|
+
if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgSchema)) {
|
11932
|
+
schemas.push(t);
|
11933
|
+
}
|
11934
|
+
});
|
11935
|
+
return { tables, enums, schemas };
|
11936
|
+
};
|
11937
|
+
prepareFromPgImports = async (imports) => {
|
11938
|
+
let tables = [];
|
11939
|
+
let enums = [];
|
11940
|
+
let schemas = [];
|
11941
|
+
const { unregister } = await safeRegister();
|
11942
|
+
for (let i = 0; i < imports.length; i++) {
|
11943
|
+
const it = imports[i];
|
11944
|
+
const i0 = require(`${it}`);
|
11945
|
+
const prepared = prepareFromExports3(i0);
|
11946
|
+
tables.push(...prepared.tables);
|
11947
|
+
enums.push(...prepared.enums);
|
11948
|
+
schemas.push(...prepared.schemas);
|
11949
|
+
}
|
11950
|
+
unregister();
|
11951
|
+
return { tables: Array.from(new Set(tables)), enums, schemas };
|
11952
|
+
};
|
11953
|
+
}
|
11954
|
+
});
|
11955
|
+
|
11956
|
+
// src/global.ts
|
11957
|
+
var originUUID, snapshotVersion, mapValues;
|
11958
|
+
var init_global = __esm({
|
11959
|
+
"src/global.ts"() {
|
11960
|
+
originUUID = "00000000-0000-0000-0000-000000000000";
|
11961
|
+
snapshotVersion = "5";
|
11962
|
+
mapValues = (obj, map) => {
|
11963
|
+
const result = Object.keys(obj).reduce(function(result2, key) {
|
11964
|
+
result2[key] = map(obj[key]);
|
11965
|
+
return result2;
|
11966
|
+
}, {});
|
11967
|
+
return result;
|
11968
|
+
};
|
11969
|
+
}
|
11970
|
+
});
|
11971
|
+
|
11972
|
+
// src/serializer/pgSchema.ts
|
11973
|
+
var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, schemaHash, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals, pgSchemaInternal, tableSquashed, tableSquashedV4, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
11974
|
+
var init_pgSchema = __esm({
|
11975
|
+
"src/serializer/pgSchema.ts"() {
|
11976
|
+
init_global();
|
11977
|
+
init_lib();
|
11978
|
+
indexV2 = objectType({
|
11979
|
+
name: stringType(),
|
11980
|
+
columns: recordType(
|
11981
|
+
stringType(),
|
11982
|
+
objectType({
|
11983
|
+
name: stringType()
|
11984
|
+
})
|
11985
|
+
),
|
11986
|
+
isUnique: booleanType()
|
11987
|
+
}).strict();
|
11988
|
+
columnV2 = objectType({
|
11989
|
+
name: stringType(),
|
11990
|
+
type: stringType(),
|
11991
|
+
primaryKey: booleanType(),
|
11992
|
+
notNull: booleanType(),
|
11993
|
+
default: anyType().optional(),
|
11994
|
+
references: stringType().optional()
|
11995
|
+
}).strict();
|
11996
|
+
tableV2 = objectType({
|
11997
|
+
name: stringType(),
|
11998
|
+
columns: recordType(stringType(), columnV2),
|
11999
|
+
indexes: recordType(stringType(), indexV2)
|
12000
|
+
}).strict();
|
12001
|
+
enumSchema = objectType({
|
12002
|
+
name: stringType(),
|
12003
|
+
values: recordType(stringType(), stringType())
|
12004
|
+
}).strict();
|
12005
|
+
pgSchemaV2 = objectType({
|
12006
|
+
version: literalType("2"),
|
12007
|
+
tables: recordType(stringType(), tableV2),
|
12008
|
+
enums: recordType(stringType(), enumSchema)
|
12009
|
+
}).strict();
|
12010
|
+
references = objectType({
|
12011
|
+
foreignKeyName: stringType(),
|
12012
|
+
table: stringType(),
|
12013
|
+
column: stringType(),
|
12014
|
+
onDelete: stringType().optional(),
|
12015
|
+
onUpdate: stringType().optional()
|
12016
|
+
}).strict();
|
12017
|
+
columnV1 = objectType({
|
12018
|
+
name: stringType(),
|
12019
|
+
type: stringType(),
|
12020
|
+
primaryKey: booleanType(),
|
12021
|
+
notNull: booleanType(),
|
12022
|
+
default: anyType().optional(),
|
12023
|
+
references: references.optional()
|
12024
|
+
}).strict();
|
12025
|
+
tableV1 = objectType({
|
12026
|
+
name: stringType(),
|
12027
|
+
columns: recordType(stringType(), columnV1),
|
12028
|
+
indexes: recordType(stringType(), indexV2)
|
12029
|
+
}).strict();
|
12030
|
+
pgSchemaV1 = objectType({
|
12031
|
+
version: literalType("1"),
|
12032
|
+
tables: recordType(stringType(), tableV1),
|
12033
|
+
enums: recordType(stringType(), enumSchema)
|
12034
|
+
}).strict();
|
12035
|
+
index = objectType({
|
12036
|
+
name: stringType(),
|
12037
|
+
columns: stringType().array(),
|
12038
|
+
isUnique: booleanType()
|
12039
|
+
}).strict();
|
12040
|
+
fk = objectType({
|
12041
|
+
name: stringType(),
|
12042
|
+
tableFrom: stringType(),
|
12043
|
+
columnsFrom: stringType().array(),
|
12044
|
+
tableTo: stringType(),
|
12045
|
+
schemaTo: stringType().optional(),
|
12046
|
+
columnsTo: stringType().array(),
|
12047
|
+
onUpdate: stringType().optional(),
|
12048
|
+
onDelete: stringType().optional()
|
12049
|
+
}).strict();
|
12050
|
+
column = objectType({
|
12051
|
+
name: stringType(),
|
12052
|
+
type: stringType(),
|
12053
|
+
primaryKey: booleanType(),
|
12054
|
+
notNull: booleanType(),
|
12055
|
+
default: anyType().optional(),
|
12056
|
+
isUnique: anyType().optional(),
|
12057
|
+
uniqueName: stringType().optional(),
|
12058
|
+
nullsNotDistinct: booleanType().optional()
|
12059
|
+
}).strict();
|
12060
|
+
tableV3 = objectType({
|
12061
|
+
name: stringType(),
|
12062
|
+
columns: recordType(stringType(), column),
|
12063
|
+
indexes: recordType(stringType(), index),
|
12064
|
+
foreignKeys: recordType(stringType(), fk)
|
12065
|
+
}).strict();
|
12066
|
+
compositePK = objectType({
|
12067
|
+
name: stringType(),
|
12068
|
+
columns: stringType().array()
|
12069
|
+
}).strict();
|
12070
|
+
uniqueConstraint = objectType({
|
12071
|
+
name: stringType(),
|
12072
|
+
columns: stringType().array(),
|
12073
|
+
nullsNotDistinct: booleanType()
|
12074
|
+
}).strict();
|
12075
|
+
tableV4 = objectType({
|
12076
|
+
name: stringType(),
|
12077
|
+
schema: stringType(),
|
12078
|
+
columns: recordType(stringType(), column),
|
12079
|
+
indexes: recordType(stringType(), index),
|
12080
|
+
foreignKeys: recordType(stringType(), fk)
|
12081
|
+
}).strict();
|
12082
|
+
table = objectType({
|
12083
|
+
name: stringType(),
|
12084
|
+
schema: stringType(),
|
12085
|
+
columns: recordType(stringType(), column),
|
12086
|
+
indexes: recordType(stringType(), index),
|
12087
|
+
foreignKeys: recordType(stringType(), fk),
|
12088
|
+
compositePrimaryKeys: recordType(stringType(), compositePK),
|
12089
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
12090
|
+
}).strict();
|
12091
|
+
schemaHash = objectType({
|
12092
|
+
id: stringType(),
|
12093
|
+
prevId: stringType()
|
12094
|
+
});
|
12095
|
+
pgSchemaInternalV3 = objectType({
|
12096
|
+
version: literalType("3"),
|
12097
|
+
dialect: literalType("pg"),
|
12098
|
+
tables: recordType(stringType(), tableV3),
|
12099
|
+
enums: recordType(stringType(), enumSchema)
|
12100
|
+
}).strict();
|
12101
|
+
pgSchemaInternalV4 = objectType({
|
12102
|
+
version: literalType("4"),
|
12103
|
+
dialect: literalType("pg"),
|
12104
|
+
tables: recordType(stringType(), tableV4),
|
12105
|
+
enums: recordType(stringType(), enumSchema),
|
12106
|
+
schemas: recordType(stringType(), stringType())
|
12107
|
+
}).strict();
|
12108
|
+
pgSchemaExternal = objectType({
|
12109
|
+
version: literalType("5"),
|
12110
|
+
dialect: literalType("pg"),
|
12111
|
+
tables: arrayType(table),
|
12112
|
+
enums: arrayType(enumSchema),
|
12113
|
+
schemas: arrayType(objectType({ name: stringType() })),
|
12114
|
+
_meta: objectType({
|
12115
|
+
schemas: recordType(stringType(), stringType()),
|
12116
|
+
tables: recordType(stringType(), stringType()),
|
12117
|
+
columns: recordType(stringType(), stringType())
|
12118
|
+
})
|
12119
|
+
}).strict();
|
12120
|
+
kitInternals = objectType({
|
12121
|
+
tables: recordType(
|
12122
|
+
stringType(),
|
12123
|
+
objectType({
|
12124
|
+
columns: recordType(
|
12125
|
+
stringType(),
|
12126
|
+
objectType({
|
12127
|
+
isArray: booleanType().optional(),
|
12128
|
+
dimensions: numberType().optional(),
|
12129
|
+
rawType: stringType().optional()
|
12130
|
+
}).optional()
|
12131
|
+
)
|
12132
|
+
}).optional()
|
12133
|
+
)
|
12134
|
+
}).optional();
|
12135
|
+
pgSchemaInternal = objectType({
|
12136
|
+
version: literalType("5"),
|
12137
|
+
dialect: literalType("pg"),
|
12138
|
+
tables: recordType(stringType(), table),
|
12139
|
+
enums: recordType(stringType(), enumSchema),
|
12140
|
+
schemas: recordType(stringType(), stringType()),
|
12141
|
+
_meta: objectType({
|
12142
|
+
schemas: recordType(stringType(), stringType()),
|
12143
|
+
tables: recordType(stringType(), stringType()),
|
12144
|
+
columns: recordType(stringType(), stringType())
|
12145
|
+
}),
|
12146
|
+
internal: kitInternals
|
12147
|
+
}).strict();
|
12148
|
+
tableSquashed = objectType({
|
12149
|
+
name: stringType(),
|
12150
|
+
schema: stringType(),
|
12151
|
+
columns: recordType(stringType(), column),
|
12152
|
+
indexes: recordType(stringType(), stringType()),
|
12153
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12154
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12155
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
12156
|
+
}).strict();
|
12157
|
+
tableSquashedV4 = objectType({
|
12158
|
+
name: stringType(),
|
12159
|
+
schema: stringType(),
|
12160
|
+
columns: recordType(stringType(), column),
|
12161
|
+
indexes: recordType(stringType(), stringType()),
|
12162
|
+
foreignKeys: recordType(stringType(), stringType())
|
12163
|
+
}).strict();
|
12164
|
+
pgSchemaSquashedV4 = objectType({
|
12165
|
+
version: literalType("4"),
|
12166
|
+
dialect: enumType(["pg"]),
|
12167
|
+
tables: recordType(stringType(), tableSquashedV4),
|
12168
|
+
enums: recordType(stringType(), enumSchema),
|
12169
|
+
schemas: recordType(stringType(), stringType())
|
12170
|
+
}).strict();
|
12171
|
+
pgSchemaSquashed = objectType({
|
12172
|
+
version: literalType("5"),
|
12173
|
+
dialect: enumType(["pg"]),
|
12174
|
+
tables: recordType(stringType(), tableSquashed),
|
12175
|
+
enums: recordType(stringType(), enumSchema),
|
12176
|
+
schemas: recordType(stringType(), stringType())
|
12177
|
+
}).strict();
|
12178
|
+
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash);
|
12179
|
+
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash);
|
12180
|
+
pgSchema = pgSchemaInternal.merge(schemaHash);
|
12181
|
+
backwardCompatiblePgSchema = unionType([
|
12182
|
+
pgSchemaV1,
|
12183
|
+
pgSchemaV2,
|
12184
|
+
pgSchemaV3,
|
12185
|
+
pgSchemaV4,
|
12186
|
+
pgSchema
|
12187
|
+
]);
|
12188
|
+
PgSquasher = {
|
12189
|
+
squashIdx: (idx) => {
|
12190
|
+
index.parse(idx);
|
12191
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
|
12192
|
+
},
|
12193
|
+
unsquashIdx: (input) => {
|
12194
|
+
const [name, columnsString, isUnique] = input.split(";");
|
12195
|
+
const result = index.parse({
|
12196
|
+
name,
|
12197
|
+
columns: columnsString.split(","),
|
12198
|
+
isUnique: isUnique === "true"
|
12199
|
+
});
|
12200
|
+
return result;
|
12201
|
+
},
|
12202
|
+
squashFK: (fk4) => {
|
12203
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
|
12204
|
+
},
|
12205
|
+
squashPK: (pk) => {
|
12206
|
+
return `${pk.columns.join(",")};${pk.name}`;
|
12207
|
+
},
|
12208
|
+
unsquashPK: (pk) => {
|
12209
|
+
const splitted = pk.split(";");
|
12210
|
+
return { name: splitted[1], columns: splitted[0].split(",") };
|
12211
|
+
},
|
12212
|
+
squashUnique: (unq) => {
|
12213
|
+
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
12214
|
+
},
|
12215
|
+
unsquashUnique: (unq) => {
|
12216
|
+
const [name, columns, nullsNotDistinct] = unq.split(";");
|
12770
12217
|
return {
|
12771
|
-
|
12772
|
-
|
12773
|
-
|
12218
|
+
name,
|
12219
|
+
columns: columns.split(","),
|
12220
|
+
nullsNotDistinct: nullsNotDistinct === "true"
|
12774
12221
|
};
|
12222
|
+
},
|
12223
|
+
unsquashFK: (input) => {
|
12224
|
+
const [
|
12225
|
+
name,
|
12226
|
+
tableFrom,
|
12227
|
+
columnsFromStr,
|
12228
|
+
tableTo,
|
12229
|
+
columnsToStr,
|
12230
|
+
onUpdate,
|
12231
|
+
onDelete,
|
12232
|
+
schemaTo
|
12233
|
+
] = input.split(";");
|
12234
|
+
const result = fk.parse({
|
12235
|
+
name,
|
12236
|
+
tableFrom,
|
12237
|
+
columnsFrom: columnsFromStr.split(","),
|
12238
|
+
schemaTo,
|
12239
|
+
tableTo,
|
12240
|
+
columnsTo: columnsToStr.split(","),
|
12241
|
+
onUpdate,
|
12242
|
+
onDelete
|
12243
|
+
});
|
12244
|
+
return result;
|
12775
12245
|
}
|
12776
|
-
return {};
|
12777
|
-
};
|
12778
|
-
var inferPackageFormat = (cwd, filename) => {
|
12779
|
-
if (filename.endsWith(".mjs")) {
|
12780
|
-
return "esm";
|
12781
|
-
}
|
12782
|
-
if (filename.endsWith(".cjs")) {
|
12783
|
-
return "cjs";
|
12784
|
-
}
|
12785
|
-
const { data } = joycon.loadSync(["package.json"], cwd);
|
12786
|
-
return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
|
12787
|
-
};
|
12788
|
-
var import_tsconfig_paths = __toModule(require_lib4());
|
12789
|
-
var noOp = () => {
|
12790
12246
|
};
|
12791
|
-
|
12792
|
-
const
|
12793
|
-
|
12794
|
-
|
12795
|
-
|
12796
|
-
|
12797
|
-
|
12798
|
-
|
12799
|
-
|
12800
|
-
|
12801
|
-
|
12802
|
-
|
12803
|
-
|
12804
|
-
|
12805
|
-
|
12806
|
-
|
12807
|
-
}
|
12808
|
-
return originalResolveFilename.apply(this, arguments);
|
12809
|
-
};
|
12810
|
-
return () => {
|
12811
|
-
Module._resolveFilename = originalResolveFilename;
|
12812
|
-
};
|
12813
|
-
}
|
12814
|
-
var _debug = require_src2();
|
12815
|
-
var _debug2 = _interopRequireDefault2(_debug);
|
12816
|
-
var debug = _debug2.default.call(void 0, "esbuild-register");
|
12817
|
-
var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
|
12818
|
-
var map = {};
|
12819
|
-
function installSourceMapSupport() {
|
12820
|
-
if (_process2.default.setSourceMapsEnabled) {
|
12821
|
-
;
|
12822
|
-
_process2.default.setSourceMapsEnabled(true);
|
12823
|
-
} else {
|
12824
|
-
import_source_map_support.default.install({
|
12825
|
-
handleUncaughtExceptions: false,
|
12826
|
-
environment: "node",
|
12827
|
-
retrieveSourceMap(file) {
|
12828
|
-
if (map[file]) {
|
12829
|
-
return {
|
12830
|
-
url: file,
|
12831
|
-
map: map[file]
|
12832
|
-
};
|
12247
|
+
squashPgScheme = (json) => {
|
12248
|
+
const mappedTables = Object.fromEntries(
|
12249
|
+
Object.entries(json.tables).map((it) => {
|
12250
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12251
|
+
return PgSquasher.squashIdx(index4);
|
12252
|
+
});
|
12253
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12254
|
+
return PgSquasher.squashFK(fk4);
|
12255
|
+
});
|
12256
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12257
|
+
return PgSquasher.squashPK(pk);
|
12258
|
+
});
|
12259
|
+
const squashedUniqueConstraints = mapValues(
|
12260
|
+
it[1].uniqueConstraints,
|
12261
|
+
(unq) => {
|
12262
|
+
return PgSquasher.squashUnique(unq);
|
12833
12263
|
}
|
12834
|
-
|
12835
|
-
|
12836
|
-
|
12837
|
-
|
12838
|
-
|
12839
|
-
|
12840
|
-
|
12841
|
-
|
12842
|
-
|
12843
|
-
|
12844
|
-
|
12845
|
-
|
12846
|
-
|
12847
|
-
|
12848
|
-
|
12849
|
-
|
12850
|
-
|
12851
|
-
|
12852
|
-
|
12853
|
-
|
12854
|
-
|
12855
|
-
extensions[".js"] = jsHandler;
|
12264
|
+
);
|
12265
|
+
return [
|
12266
|
+
it[0],
|
12267
|
+
{
|
12268
|
+
name: it[1].name,
|
12269
|
+
schema: it[1].schema,
|
12270
|
+
columns: it[1].columns,
|
12271
|
+
indexes: squashedIndexes,
|
12272
|
+
foreignKeys: squashedFKs,
|
12273
|
+
compositePrimaryKeys: squashedPKs,
|
12274
|
+
uniqueConstraints: squashedUniqueConstraints
|
12275
|
+
}
|
12276
|
+
];
|
12277
|
+
})
|
12278
|
+
);
|
12279
|
+
return {
|
12280
|
+
version: "5",
|
12281
|
+
dialect: json.dialect,
|
12282
|
+
tables: mappedTables,
|
12283
|
+
enums: json.enums,
|
12284
|
+
schemas: json.schemas
|
12856
12285
|
};
|
12857
|
-
}
|
12858
|
-
var FILE_LOADERS = {
|
12859
|
-
".js": "js",
|
12860
|
-
".jsx": "jsx",
|
12861
|
-
".ts": "ts",
|
12862
|
-
".tsx": "tsx",
|
12863
|
-
".mjs": "js",
|
12864
|
-
".mts": "ts",
|
12865
|
-
".cts": "ts"
|
12866
12286
|
};
|
12867
|
-
|
12868
|
-
|
12869
|
-
|
12870
|
-
|
12871
|
-
|
12872
|
-
|
12873
|
-
|
12874
|
-
|
12875
|
-
|
12876
|
-
|
12877
|
-
|
12878
|
-
|
12879
|
-
|
12880
|
-
|
12881
|
-
|
12882
|
-
|
12883
|
-
|
12884
|
-
|
12885
|
-
|
12886
|
-
|
12887
|
-
|
12888
|
-
|
12889
|
-
|
12890
|
-
|
12891
|
-
|
12892
|
-
|
12893
|
-
|
12894
|
-
|
12895
|
-
|
12896
|
-
|
12897
|
-
|
12898
|
-
|
12287
|
+
dryPg = pgSchema.parse({
|
12288
|
+
version: snapshotVersion,
|
12289
|
+
dialect: "pg",
|
12290
|
+
id: originUUID,
|
12291
|
+
prevId: "",
|
12292
|
+
tables: {},
|
12293
|
+
enums: {},
|
12294
|
+
schemas: {},
|
12295
|
+
_meta: {
|
12296
|
+
schemas: {},
|
12297
|
+
tables: {},
|
12298
|
+
columns: {}
|
12299
|
+
}
|
12300
|
+
});
|
12301
|
+
}
|
12302
|
+
});
|
12303
|
+
|
12304
|
+
// src/serializer/sqliteSchema.ts
|
12305
|
+
var index2, fk2, compositePK2, column2, tableV32, uniqueConstraint2, table2, dialect4, schemaHash2, schemaInternalV3, schemaInternalV4, latestVersion, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed2, schemaSquashed, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, backwardCompatibleSqliteSchema;
|
12306
|
+
var init_sqliteSchema = __esm({
|
12307
|
+
"src/serializer/sqliteSchema.ts"() {
|
12308
|
+
init_global();
|
12309
|
+
init_lib();
|
12310
|
+
index2 = objectType({
|
12311
|
+
name: stringType(),
|
12312
|
+
columns: stringType().array(),
|
12313
|
+
where: stringType().optional(),
|
12314
|
+
isUnique: booleanType()
|
12315
|
+
}).strict();
|
12316
|
+
fk2 = objectType({
|
12317
|
+
name: stringType(),
|
12318
|
+
tableFrom: stringType(),
|
12319
|
+
columnsFrom: stringType().array(),
|
12320
|
+
tableTo: stringType(),
|
12321
|
+
columnsTo: stringType().array(),
|
12322
|
+
onUpdate: stringType().optional(),
|
12323
|
+
onDelete: stringType().optional()
|
12324
|
+
}).strict();
|
12325
|
+
compositePK2 = objectType({
|
12326
|
+
columns: stringType().array(),
|
12327
|
+
name: stringType().optional()
|
12328
|
+
}).strict();
|
12329
|
+
column2 = objectType({
|
12330
|
+
name: stringType(),
|
12331
|
+
type: stringType(),
|
12332
|
+
primaryKey: booleanType(),
|
12333
|
+
notNull: booleanType(),
|
12334
|
+
autoincrement: booleanType().optional(),
|
12335
|
+
default: anyType().optional()
|
12336
|
+
}).strict();
|
12337
|
+
tableV32 = objectType({
|
12338
|
+
name: stringType(),
|
12339
|
+
columns: recordType(stringType(), column2),
|
12340
|
+
indexes: recordType(stringType(), index2),
|
12341
|
+
foreignKeys: recordType(stringType(), fk2)
|
12342
|
+
}).strict();
|
12343
|
+
uniqueConstraint2 = objectType({
|
12344
|
+
name: stringType(),
|
12345
|
+
columns: stringType().array()
|
12346
|
+
}).strict();
|
12347
|
+
table2 = objectType({
|
12348
|
+
name: stringType(),
|
12349
|
+
columns: recordType(stringType(), column2),
|
12350
|
+
indexes: recordType(stringType(), index2),
|
12351
|
+
foreignKeys: recordType(stringType(), fk2),
|
12352
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
12353
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
12354
|
+
}).strict();
|
12355
|
+
dialect4 = enumType(["sqlite"]);
|
12356
|
+
schemaHash2 = objectType({
|
12357
|
+
id: stringType(),
|
12358
|
+
prevId: stringType()
|
12359
|
+
}).strict();
|
12360
|
+
schemaInternalV3 = objectType({
|
12361
|
+
version: literalType("3"),
|
12362
|
+
dialect: dialect4,
|
12363
|
+
tables: recordType(stringType(), tableV32),
|
12364
|
+
enums: objectType({})
|
12365
|
+
}).strict();
|
12366
|
+
schemaInternalV4 = objectType({
|
12367
|
+
version: literalType("4"),
|
12368
|
+
dialect: dialect4,
|
12369
|
+
tables: recordType(stringType(), table2),
|
12370
|
+
enums: objectType({})
|
12371
|
+
}).strict();
|
12372
|
+
latestVersion = literalType("5");
|
12373
|
+
schemaInternal = objectType({
|
12374
|
+
version: latestVersion,
|
12375
|
+
dialect: dialect4,
|
12376
|
+
tables: recordType(stringType(), table2),
|
12377
|
+
enums: objectType({}),
|
12378
|
+
_meta: objectType({
|
12379
|
+
tables: recordType(stringType(), stringType()),
|
12380
|
+
columns: recordType(stringType(), stringType())
|
12381
|
+
})
|
12382
|
+
}).strict();
|
12383
|
+
schemaV3 = schemaInternalV3.merge(schemaHash2).strict();
|
12384
|
+
schemaV4 = schemaInternalV4.merge(schemaHash2).strict();
|
12385
|
+
schema2 = schemaInternal.merge(schemaHash2).strict();
|
12386
|
+
tableSquashed2 = objectType({
|
12387
|
+
name: stringType(),
|
12388
|
+
columns: recordType(stringType(), column2),
|
12389
|
+
indexes: recordType(stringType(), stringType()),
|
12390
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12391
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12392
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
12393
|
+
}).strict();
|
12394
|
+
schemaSquashed = objectType({
|
12395
|
+
version: latestVersion,
|
12396
|
+
dialect: dialect4,
|
12397
|
+
tables: recordType(stringType(), tableSquashed2),
|
12398
|
+
enums: anyType()
|
12399
|
+
}).strict();
|
12400
|
+
SQLiteSquasher = {
|
12401
|
+
squashIdx: (idx) => {
|
12402
|
+
index2.parse(idx);
|
12403
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
|
12404
|
+
},
|
12405
|
+
unsquashIdx: (input) => {
|
12406
|
+
const [name, columnsString, isUnique, where] = input.split(";");
|
12407
|
+
const result = index2.parse({
|
12408
|
+
name,
|
12409
|
+
columns: columnsString.split(","),
|
12410
|
+
isUnique: isUnique === "true",
|
12411
|
+
where: where ?? void 0
|
12412
|
+
});
|
12413
|
+
return result;
|
12414
|
+
},
|
12415
|
+
squashUnique: (unq) => {
|
12416
|
+
return `${unq.name};${unq.columns.join(",")}`;
|
12417
|
+
},
|
12418
|
+
unsquashUnique: (unq) => {
|
12419
|
+
const [name, columns] = unq.split(";");
|
12420
|
+
return { name, columns: columns.split(",") };
|
12421
|
+
},
|
12422
|
+
squashFK: (fk4) => {
|
12423
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
12424
|
+
},
|
12425
|
+
unsquashFK: (input) => {
|
12426
|
+
const [
|
12427
|
+
name,
|
12428
|
+
tableFrom,
|
12429
|
+
columnsFromStr,
|
12430
|
+
tableTo,
|
12431
|
+
columnsToStr,
|
12432
|
+
onUpdate,
|
12433
|
+
onDelete
|
12434
|
+
] = input.split(";");
|
12435
|
+
const result = fk2.parse({
|
12436
|
+
name,
|
12437
|
+
tableFrom,
|
12438
|
+
columnsFrom: columnsFromStr.split(","),
|
12439
|
+
tableTo,
|
12440
|
+
columnsTo: columnsToStr.split(","),
|
12441
|
+
onUpdate,
|
12442
|
+
onDelete
|
12899
12443
|
});
|
12900
|
-
|
12901
|
-
|
12902
|
-
|
12903
|
-
|
12904
|
-
|
12905
|
-
|
12906
|
-
|
12907
|
-
|
12908
|
-
|
12909
|
-
|
12910
|
-
|
12911
|
-
|
12912
|
-
|
12913
|
-
|
12914
|
-
|
12915
|
-
|
12916
|
-
|
12917
|
-
|
12918
|
-
|
12919
|
-
|
12920
|
-
|
12921
|
-
|
12444
|
+
return result;
|
12445
|
+
},
|
12446
|
+
squashPK: (pk) => {
|
12447
|
+
return pk.columns.join(",");
|
12448
|
+
},
|
12449
|
+
unsquashPK: (pk) => {
|
12450
|
+
return pk.split(",");
|
12451
|
+
}
|
12452
|
+
};
|
12453
|
+
squashSqliteScheme = (json) => {
|
12454
|
+
const mappedTables = Object.fromEntries(
|
12455
|
+
Object.entries(json.tables).map((it) => {
|
12456
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12457
|
+
return SQLiteSquasher.squashIdx(index4);
|
12458
|
+
});
|
12459
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12460
|
+
return SQLiteSquasher.squashFK(fk4);
|
12461
|
+
});
|
12462
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12463
|
+
return SQLiteSquasher.squashPK(pk);
|
12464
|
+
});
|
12465
|
+
const squashedUniqueConstraints = mapValues(it[1].uniqueConstraints, (unq) => {
|
12466
|
+
return SQLiteSquasher.squashUnique(unq);
|
12467
|
+
});
|
12468
|
+
return [
|
12469
|
+
it[0],
|
12470
|
+
{
|
12471
|
+
name: it[1].name,
|
12472
|
+
columns: it[1].columns,
|
12473
|
+
indexes: squashedIndexes,
|
12474
|
+
foreignKeys: squashedFKs,
|
12475
|
+
compositePrimaryKeys: squashedPKs,
|
12476
|
+
uniqueConstraints: squashedUniqueConstraints
|
12477
|
+
}
|
12478
|
+
];
|
12479
|
+
})
|
12480
|
+
);
|
12922
12481
|
return {
|
12923
|
-
|
12924
|
-
|
12925
|
-
|
12926
|
-
|
12927
|
-
}
|
12482
|
+
version: "5",
|
12483
|
+
dialect: json.dialect,
|
12484
|
+
tables: mappedTables,
|
12485
|
+
enums: json.enums
|
12928
12486
|
};
|
12929
|
-
}
|
12930
|
-
|
12487
|
+
};
|
12488
|
+
drySQLite = schema2.parse({
|
12489
|
+
version: snapshotVersion,
|
12490
|
+
dialect: "sqlite",
|
12491
|
+
id: originUUID,
|
12492
|
+
prevId: "",
|
12493
|
+
tables: {},
|
12494
|
+
enums: {},
|
12495
|
+
_meta: {
|
12496
|
+
tables: {},
|
12497
|
+
columns: {}
|
12498
|
+
}
|
12499
|
+
});
|
12500
|
+
sqliteSchema = schema2;
|
12501
|
+
backwardCompatibleSqliteSchema = unionType([schemaV3, schemaV4, schema2]);
|
12931
12502
|
}
|
12932
12503
|
});
|
12933
12504
|
|
12934
|
-
// src/
|
12935
|
-
var
|
12936
|
-
var
|
12937
|
-
"src/
|
12938
|
-
"use strict";
|
12939
|
-
init_serializer();
|
12940
|
-
init_source();
|
12941
|
-
init_views();
|
12942
|
-
import_hanji2 = __toESM(require_hanji());
|
12943
|
-
init_outputs();
|
12505
|
+
// src/serializer/mysqlSchema.ts
|
12506
|
+
var index3, fk3, column3, tableV33, compositePK3, uniqueConstraint3, tableV42, table3, dialect5, schemaHash3, schemaInternalV32, schemaInternalV42, kitInternals2, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashedV42, tableSquashed3, schemaSquashed2, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, backwardCompatibleMysqlSchema, dryMySql;
|
12507
|
+
var init_mysqlSchema = __esm({
|
12508
|
+
"src/serializer/mysqlSchema.ts"() {
|
12944
12509
|
init_global();
|
12945
|
-
|
12946
|
-
|
12947
|
-
|
12948
|
-
|
12949
|
-
|
12950
|
-
|
12951
|
-
|
12952
|
-
|
12953
|
-
|
12954
|
-
|
12955
|
-
|
12956
|
-
|
12957
|
-
|
12958
|
-
|
12959
|
-
|
12960
|
-
|
12961
|
-
|
12962
|
-
|
12963
|
-
|
12964
|
-
|
12965
|
-
|
12966
|
-
|
12967
|
-
|
12968
|
-
|
12969
|
-
|
12970
|
-
|
12971
|
-
|
12972
|
-
|
12973
|
-
|
12974
|
-
|
12975
|
-
|
12976
|
-
|
12977
|
-
|
12978
|
-
|
12979
|
-
|
12980
|
-
|
12981
|
-
|
12982
|
-
|
12983
|
-
|
12984
|
-
|
12510
|
+
init_lib();
|
12511
|
+
index3 = objectType({
|
12512
|
+
name: stringType(),
|
12513
|
+
columns: stringType().array(),
|
12514
|
+
isUnique: booleanType(),
|
12515
|
+
using: enumType(["btree", "hash"]).optional(),
|
12516
|
+
algorithm: enumType(["default", "inplace", "copy"]).optional(),
|
12517
|
+
lock: enumType(["default", "none", "shared", "exclusive"]).optional()
|
12518
|
+
}).strict();
|
12519
|
+
fk3 = objectType({
|
12520
|
+
name: stringType(),
|
12521
|
+
tableFrom: stringType(),
|
12522
|
+
columnsFrom: stringType().array(),
|
12523
|
+
tableTo: stringType(),
|
12524
|
+
columnsTo: stringType().array(),
|
12525
|
+
onUpdate: stringType().optional(),
|
12526
|
+
onDelete: stringType().optional()
|
12527
|
+
}).strict();
|
12528
|
+
column3 = objectType({
|
12529
|
+
name: stringType(),
|
12530
|
+
type: stringType(),
|
12531
|
+
primaryKey: booleanType(),
|
12532
|
+
notNull: booleanType(),
|
12533
|
+
autoincrement: booleanType().optional(),
|
12534
|
+
default: anyType().optional(),
|
12535
|
+
onUpdate: anyType().optional()
|
12536
|
+
}).strict();
|
12537
|
+
tableV33 = objectType({
|
12538
|
+
name: stringType(),
|
12539
|
+
columns: recordType(stringType(), column3),
|
12540
|
+
indexes: recordType(stringType(), index3),
|
12541
|
+
foreignKeys: recordType(stringType(), fk3)
|
12542
|
+
}).strict();
|
12543
|
+
compositePK3 = objectType({
|
12544
|
+
name: stringType(),
|
12545
|
+
columns: stringType().array()
|
12546
|
+
}).strict();
|
12547
|
+
uniqueConstraint3 = objectType({
|
12548
|
+
name: stringType(),
|
12549
|
+
columns: stringType().array()
|
12550
|
+
}).strict();
|
12551
|
+
tableV42 = objectType({
|
12552
|
+
name: stringType(),
|
12553
|
+
schema: stringType().optional(),
|
12554
|
+
columns: recordType(stringType(), column3),
|
12555
|
+
indexes: recordType(stringType(), index3),
|
12556
|
+
foreignKeys: recordType(stringType(), fk3)
|
12557
|
+
}).strict();
|
12558
|
+
table3 = objectType({
|
12559
|
+
name: stringType(),
|
12560
|
+
schema: stringType().optional(),
|
12561
|
+
columns: recordType(stringType(), column3),
|
12562
|
+
indexes: recordType(stringType(), index3),
|
12563
|
+
foreignKeys: recordType(stringType(), fk3),
|
12564
|
+
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
12565
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
12566
|
+
}).strict();
|
12567
|
+
dialect5 = literalType("mysql");
|
12568
|
+
schemaHash3 = objectType({
|
12569
|
+
id: stringType(),
|
12570
|
+
prevId: stringType()
|
12571
|
+
});
|
12572
|
+
schemaInternalV32 = objectType({
|
12573
|
+
version: literalType("3"),
|
12574
|
+
dialect: dialect5,
|
12575
|
+
tables: recordType(stringType(), tableV33)
|
12576
|
+
}).strict();
|
12577
|
+
schemaInternalV42 = objectType({
|
12578
|
+
version: literalType("4"),
|
12579
|
+
dialect: dialect5,
|
12580
|
+
tables: recordType(stringType(), tableV42),
|
12581
|
+
schemas: recordType(stringType(), stringType())
|
12582
|
+
}).strict();
|
12583
|
+
kitInternals2 = objectType({
|
12584
|
+
tables: recordType(
|
12585
|
+
stringType(),
|
12586
|
+
objectType({
|
12587
|
+
columns: recordType(
|
12588
|
+
stringType(),
|
12589
|
+
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
12590
|
+
)
|
12591
|
+
}).optional()
|
12592
|
+
)
|
12593
|
+
}).optional();
|
12594
|
+
schemaInternal2 = objectType({
|
12595
|
+
version: literalType("5"),
|
12596
|
+
dialect: dialect5,
|
12597
|
+
tables: recordType(stringType(), table3),
|
12598
|
+
schemas: recordType(stringType(), stringType()),
|
12599
|
+
_meta: objectType({
|
12600
|
+
schemas: recordType(stringType(), stringType()),
|
12601
|
+
tables: recordType(stringType(), stringType()),
|
12602
|
+
columns: recordType(stringType(), stringType())
|
12603
|
+
}),
|
12604
|
+
internal: kitInternals2
|
12605
|
+
}).strict();
|
12606
|
+
schemaV32 = schemaInternalV32.merge(schemaHash3);
|
12607
|
+
schemaV42 = schemaInternalV42.merge(schemaHash3);
|
12608
|
+
schema3 = schemaInternal2.merge(schemaHash3);
|
12609
|
+
tableSquashedV42 = objectType({
|
12610
|
+
name: stringType(),
|
12611
|
+
schema: stringType().optional(),
|
12612
|
+
columns: recordType(stringType(), column3),
|
12613
|
+
indexes: recordType(stringType(), stringType()),
|
12614
|
+
foreignKeys: recordType(stringType(), stringType())
|
12615
|
+
}).strict();
|
12616
|
+
tableSquashed3 = objectType({
|
12617
|
+
name: stringType(),
|
12618
|
+
schema: stringType().optional(),
|
12619
|
+
columns: recordType(stringType(), column3),
|
12620
|
+
indexes: recordType(stringType(), stringType()),
|
12621
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12622
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12623
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
12624
|
+
}).strict();
|
12625
|
+
schemaSquashed2 = objectType({
|
12626
|
+
version: literalType("5"),
|
12627
|
+
dialect: dialect5,
|
12628
|
+
tables: recordType(stringType(), tableSquashed3),
|
12629
|
+
schemas: recordType(stringType(), stringType())
|
12630
|
+
}).strict();
|
12631
|
+
schemaSquashedV4 = objectType({
|
12632
|
+
version: literalType("4"),
|
12633
|
+
dialect: dialect5,
|
12634
|
+
tables: recordType(stringType(), tableSquashedV42),
|
12635
|
+
schemas: recordType(stringType(), stringType())
|
12636
|
+
}).strict();
|
12637
|
+
MySqlSquasher = {
|
12638
|
+
squashIdx: (idx) => {
|
12639
|
+
index3.parse(idx);
|
12640
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
|
12641
|
+
},
|
12642
|
+
unsquashIdx: (input) => {
|
12643
|
+
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
12644
|
+
const destructed = {
|
12645
|
+
name,
|
12646
|
+
columns: columnsString.split(","),
|
12647
|
+
isUnique: isUnique === "true",
|
12648
|
+
using: using ? using : void 0,
|
12649
|
+
algorithm: algorithm ? algorithm : void 0,
|
12650
|
+
lock: lock ? lock : void 0
|
12985
12651
|
};
|
12652
|
+
return index3.parse(destructed);
|
12653
|
+
},
|
12654
|
+
squashPK: (pk) => {
|
12655
|
+
return `${pk.name};${pk.columns.join(",")}`;
|
12656
|
+
},
|
12657
|
+
unsquashPK: (pk) => {
|
12658
|
+
const splitted = pk.split(";");
|
12659
|
+
return { name: splitted[0], columns: splitted[1].split(",") };
|
12660
|
+
},
|
12661
|
+
squashUnique: (unq) => {
|
12662
|
+
return `${unq.name};${unq.columns.join(",")}`;
|
12663
|
+
},
|
12664
|
+
unsquashUnique: (unq) => {
|
12665
|
+
const [name, columns] = unq.split(";");
|
12666
|
+
return { name, columns: columns.split(",") };
|
12667
|
+
},
|
12668
|
+
squashFK: (fk4) => {
|
12669
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
12670
|
+
},
|
12671
|
+
unsquashFK: (input) => {
|
12672
|
+
const [
|
12673
|
+
name,
|
12674
|
+
tableFrom,
|
12675
|
+
columnsFromStr,
|
12676
|
+
tableTo,
|
12677
|
+
columnsToStr,
|
12678
|
+
onUpdate,
|
12679
|
+
onDelete
|
12680
|
+
] = input.split(";");
|
12681
|
+
const result = fk3.parse({
|
12682
|
+
name,
|
12683
|
+
tableFrom,
|
12684
|
+
columnsFrom: columnsFromStr.split(","),
|
12685
|
+
tableTo,
|
12686
|
+
columnsTo: columnsToStr.split(","),
|
12687
|
+
onUpdate,
|
12688
|
+
onDelete
|
12689
|
+
});
|
12690
|
+
return result;
|
12986
12691
|
}
|
12987
|
-
await assertES5(res.unregister);
|
12988
|
-
return res;
|
12989
12692
|
};
|
12990
|
-
|
12991
|
-
|
12992
|
-
|
12993
|
-
|
12994
|
-
|
12995
|
-
|
12996
|
-
|
12997
|
-
|
12998
|
-
});
|
12999
|
-
|
13000
|
-
|
13001
|
-
|
13002
|
-
|
13003
|
-
|
13004
|
-
|
13005
|
-
|
13006
|
-
|
13007
|
-
|
13008
|
-
|
13009
|
-
|
13010
|
-
|
13011
|
-
|
13012
|
-
|
13013
|
-
|
13014
|
-
|
13015
|
-
|
13016
|
-
|
13017
|
-
|
13018
|
-
|
13019
|
-
|
13020
|
-
|
13021
|
-
|
13022
|
-
|
13023
|
-
|
12693
|
+
squashMysqlScheme = (json) => {
|
12694
|
+
const mappedTables = Object.fromEntries(
|
12695
|
+
Object.entries(json.tables).map((it) => {
|
12696
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12697
|
+
return MySqlSquasher.squashIdx(index4);
|
12698
|
+
});
|
12699
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12700
|
+
return MySqlSquasher.squashFK(fk4);
|
12701
|
+
});
|
12702
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12703
|
+
return MySqlSquasher.squashPK(pk);
|
12704
|
+
});
|
12705
|
+
const squashedUniqueConstraints = mapValues(
|
12706
|
+
it[1].uniqueConstraints,
|
12707
|
+
(unq) => {
|
12708
|
+
return MySqlSquasher.squashUnique(unq);
|
12709
|
+
}
|
12710
|
+
);
|
12711
|
+
return [
|
12712
|
+
it[0],
|
12713
|
+
{
|
12714
|
+
name: it[1].name,
|
12715
|
+
schema: it[1].schema,
|
12716
|
+
columns: it[1].columns,
|
12717
|
+
indexes: squashedIndexes,
|
12718
|
+
foreignKeys: squashedFKs,
|
12719
|
+
compositePrimaryKeys: squashedPKs,
|
12720
|
+
uniqueConstraints: squashedUniqueConstraints
|
12721
|
+
}
|
12722
|
+
];
|
12723
|
+
})
|
12724
|
+
);
|
12725
|
+
return {
|
12726
|
+
version: "5",
|
12727
|
+
dialect: json.dialect,
|
12728
|
+
tables: mappedTables,
|
12729
|
+
schemas: json.schemas
|
12730
|
+
};
|
13024
12731
|
};
|
13025
|
-
|
13026
|
-
|
13027
|
-
|
13028
|
-
|
13029
|
-
|
13030
|
-
|
13031
|
-
|
13032
|
-
|
13033
|
-
|
13034
|
-
|
13035
|
-
|
13036
|
-
|
12732
|
+
mysqlSchema = schema3;
|
12733
|
+
backwardCompatibleMysqlSchema = unionType([
|
12734
|
+
schemaV32,
|
12735
|
+
schemaV42,
|
12736
|
+
schema3
|
12737
|
+
]);
|
12738
|
+
dryMySql = mysqlSchema.parse({
|
12739
|
+
version: snapshotVersion,
|
12740
|
+
dialect: "mysql",
|
12741
|
+
id: originUUID,
|
12742
|
+
prevId: "",
|
12743
|
+
tables: {},
|
12744
|
+
schemas: {},
|
12745
|
+
_meta: {
|
12746
|
+
schemas: {},
|
12747
|
+
tables: {},
|
12748
|
+
columns: {}
|
13037
12749
|
}
|
13038
|
-
|
13039
|
-
return { tables: Array.from(new Set(tables)), enums, schemas };
|
13040
|
-
};
|
12750
|
+
});
|
13041
12751
|
}
|
13042
12752
|
});
|
13043
12753
|
|
@@ -13045,7 +12755,6 @@ var init_pgImports = __esm({
|
|
13045
12755
|
var import_fs2, import_crypto, prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot, preparePgDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSqliteMigrationSnapshot, fillPgSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
|
13046
12756
|
var init_migrationPreparator = __esm({
|
13047
12757
|
"src/migrationPreparator.ts"() {
|
13048
|
-
"use strict";
|
13049
12758
|
import_fs2 = __toESM(require("fs"));
|
13050
12759
|
import_crypto = require("crypto");
|
13051
12760
|
init_serializer();
|
@@ -13056,18 +12765,18 @@ var init_migrationPreparator = __esm({
|
|
13056
12765
|
const serialized = await serializeMySql(schemaPath);
|
13057
12766
|
const id = (0, import_crypto.randomUUID)();
|
13058
12767
|
const idPrev = prev.id;
|
13059
|
-
const { version, dialect:
|
13060
|
-
const result = { version, dialect:
|
12768
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12769
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13061
12770
|
return { prev, cur: result };
|
13062
12771
|
};
|
13063
12772
|
prepareSQLiteDbPushSnapshot = async (prev, schemaPath) => {
|
13064
12773
|
const serialized = await serializeSQLite(schemaPath);
|
13065
12774
|
const id = (0, import_crypto.randomUUID)();
|
13066
12775
|
const idPrev = prev.id;
|
13067
|
-
const { version, dialect:
|
12776
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
13068
12777
|
const result = {
|
13069
12778
|
version,
|
13070
|
-
dialect:
|
12779
|
+
dialect: dialect6,
|
13071
12780
|
id,
|
13072
12781
|
prevId: idPrev,
|
13073
12782
|
...rest
|
@@ -13078,8 +12787,8 @@ var init_migrationPreparator = __esm({
|
|
13078
12787
|
const serialized = await serializePg(schemaPath, schemaFilter);
|
13079
12788
|
const id = (0, import_crypto.randomUUID)();
|
13080
12789
|
const idPrev = prev.id;
|
13081
|
-
const { version, dialect:
|
13082
|
-
const result = { version, dialect:
|
12790
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12791
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13083
12792
|
return { prev, cur: result };
|
13084
12793
|
};
|
13085
12794
|
prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath) => {
|
@@ -13089,8 +12798,8 @@ var init_migrationPreparator = __esm({
|
|
13089
12798
|
const serialized = await serializeMySql(schemaPath);
|
13090
12799
|
const id = (0, import_crypto.randomUUID)();
|
13091
12800
|
const idPrev = prevSnapshot.id;
|
13092
|
-
const { version, dialect:
|
13093
|
-
const result = { version, dialect:
|
12801
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12802
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13094
12803
|
const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
|
13095
12804
|
const custom = {
|
13096
12805
|
id,
|
@@ -13106,10 +12815,10 @@ var init_migrationPreparator = __esm({
|
|
13106
12815
|
const serialized = await serializeSQLite(schemaPath);
|
13107
12816
|
const id = (0, import_crypto.randomUUID)();
|
13108
12817
|
const idPrev = prevSnapshot.id;
|
13109
|
-
const { version, dialect:
|
12818
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
13110
12819
|
const result = {
|
13111
12820
|
version,
|
13112
|
-
dialect:
|
12821
|
+
dialect: dialect6,
|
13113
12822
|
id,
|
13114
12823
|
prevId: idPrev,
|
13115
12824
|
...rest
|
@@ -13134,7 +12843,7 @@ var init_migrationPreparator = __esm({
|
|
13134
12843
|
const serialized = await serializePg(schemaPath);
|
13135
12844
|
const id = (0, import_crypto.randomUUID)();
|
13136
12845
|
const idPrev = prevSnapshot.id;
|
13137
|
-
const result = { id,
|
12846
|
+
const result = fillPgSnapshot({ serialized, id, idPrev });
|
13138
12847
|
const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
|
13139
12848
|
const custom = fillPgSnapshot({ serialized: prevRest, id, idPrev });
|
13140
12849
|
return { prev: prevSnapshot, cur: result, custom };
|
@@ -13152,363 +12861,6 @@ var init_migrationPreparator = __esm({
|
|
13152
12861
|
}
|
13153
12862
|
});
|
13154
12863
|
|
13155
|
-
// node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js
|
13156
|
-
var require_pluralize = __commonJS({
|
13157
|
-
"node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js"(exports, module2) {
|
13158
|
-
(function(root, pluralize) {
|
13159
|
-
if (typeof require === "function" && typeof exports === "object" && typeof module2 === "object") {
|
13160
|
-
module2.exports = pluralize();
|
13161
|
-
} else if (typeof define === "function" && define.amd) {
|
13162
|
-
define(function() {
|
13163
|
-
return pluralize();
|
13164
|
-
});
|
13165
|
-
} else {
|
13166
|
-
root.pluralize = pluralize();
|
13167
|
-
}
|
13168
|
-
})(exports, function() {
|
13169
|
-
var pluralRules = [];
|
13170
|
-
var singularRules = [];
|
13171
|
-
var uncountables = {};
|
13172
|
-
var irregularPlurals = {};
|
13173
|
-
var irregularSingles = {};
|
13174
|
-
function sanitizeRule(rule) {
|
13175
|
-
if (typeof rule === "string") {
|
13176
|
-
return new RegExp("^" + rule + "$", "i");
|
13177
|
-
}
|
13178
|
-
return rule;
|
13179
|
-
}
|
13180
|
-
function restoreCase(word, token) {
|
13181
|
-
if (word === token)
|
13182
|
-
return token;
|
13183
|
-
if (word === word.toLowerCase())
|
13184
|
-
return token.toLowerCase();
|
13185
|
-
if (word === word.toUpperCase())
|
13186
|
-
return token.toUpperCase();
|
13187
|
-
if (word[0] === word[0].toUpperCase()) {
|
13188
|
-
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
13189
|
-
}
|
13190
|
-
return token.toLowerCase();
|
13191
|
-
}
|
13192
|
-
function interpolate(str, args) {
|
13193
|
-
return str.replace(/\$(\d{1,2})/g, function(match2, index4) {
|
13194
|
-
return args[index4] || "";
|
13195
|
-
});
|
13196
|
-
}
|
13197
|
-
function replace(word, rule) {
|
13198
|
-
return word.replace(rule[0], function(match2, index4) {
|
13199
|
-
var result = interpolate(rule[1], arguments);
|
13200
|
-
if (match2 === "") {
|
13201
|
-
return restoreCase(word[index4 - 1], result);
|
13202
|
-
}
|
13203
|
-
return restoreCase(match2, result);
|
13204
|
-
});
|
13205
|
-
}
|
13206
|
-
function sanitizeWord(token, word, rules) {
|
13207
|
-
if (!token.length || uncountables.hasOwnProperty(token)) {
|
13208
|
-
return word;
|
13209
|
-
}
|
13210
|
-
var len = rules.length;
|
13211
|
-
while (len--) {
|
13212
|
-
var rule = rules[len];
|
13213
|
-
if (rule[0].test(word))
|
13214
|
-
return replace(word, rule);
|
13215
|
-
}
|
13216
|
-
return word;
|
13217
|
-
}
|
13218
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
13219
|
-
return function(word) {
|
13220
|
-
var token = word.toLowerCase();
|
13221
|
-
if (keepMap.hasOwnProperty(token)) {
|
13222
|
-
return restoreCase(word, token);
|
13223
|
-
}
|
13224
|
-
if (replaceMap.hasOwnProperty(token)) {
|
13225
|
-
return restoreCase(word, replaceMap[token]);
|
13226
|
-
}
|
13227
|
-
return sanitizeWord(token, word, rules);
|
13228
|
-
};
|
13229
|
-
}
|
13230
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
13231
|
-
return function(word) {
|
13232
|
-
var token = word.toLowerCase();
|
13233
|
-
if (keepMap.hasOwnProperty(token))
|
13234
|
-
return true;
|
13235
|
-
if (replaceMap.hasOwnProperty(token))
|
13236
|
-
return false;
|
13237
|
-
return sanitizeWord(token, token, rules) === token;
|
13238
|
-
};
|
13239
|
-
}
|
13240
|
-
function pluralize(word, count, inclusive) {
|
13241
|
-
var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
|
13242
|
-
return (inclusive ? count + " " : "") + pluralized;
|
13243
|
-
}
|
13244
|
-
pluralize.plural = replaceWord(
|
13245
|
-
irregularSingles,
|
13246
|
-
irregularPlurals,
|
13247
|
-
pluralRules
|
13248
|
-
);
|
13249
|
-
pluralize.isPlural = checkWord(
|
13250
|
-
irregularSingles,
|
13251
|
-
irregularPlurals,
|
13252
|
-
pluralRules
|
13253
|
-
);
|
13254
|
-
pluralize.singular = replaceWord(
|
13255
|
-
irregularPlurals,
|
13256
|
-
irregularSingles,
|
13257
|
-
singularRules
|
13258
|
-
);
|
13259
|
-
pluralize.isSingular = checkWord(
|
13260
|
-
irregularPlurals,
|
13261
|
-
irregularSingles,
|
13262
|
-
singularRules
|
13263
|
-
);
|
13264
|
-
pluralize.addPluralRule = function(rule, replacement) {
|
13265
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
13266
|
-
};
|
13267
|
-
pluralize.addSingularRule = function(rule, replacement) {
|
13268
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
13269
|
-
};
|
13270
|
-
pluralize.addUncountableRule = function(word) {
|
13271
|
-
if (typeof word === "string") {
|
13272
|
-
uncountables[word.toLowerCase()] = true;
|
13273
|
-
return;
|
13274
|
-
}
|
13275
|
-
pluralize.addPluralRule(word, "$0");
|
13276
|
-
pluralize.addSingularRule(word, "$0");
|
13277
|
-
};
|
13278
|
-
pluralize.addIrregularRule = function(single, plural2) {
|
13279
|
-
plural2 = plural2.toLowerCase();
|
13280
|
-
single = single.toLowerCase();
|
13281
|
-
irregularSingles[single] = plural2;
|
13282
|
-
irregularPlurals[plural2] = single;
|
13283
|
-
};
|
13284
|
-
[
|
13285
|
-
// Pronouns.
|
13286
|
-
["I", "we"],
|
13287
|
-
["me", "us"],
|
13288
|
-
["he", "they"],
|
13289
|
-
["she", "they"],
|
13290
|
-
["them", "them"],
|
13291
|
-
["myself", "ourselves"],
|
13292
|
-
["yourself", "yourselves"],
|
13293
|
-
["itself", "themselves"],
|
13294
|
-
["herself", "themselves"],
|
13295
|
-
["himself", "themselves"],
|
13296
|
-
["themself", "themselves"],
|
13297
|
-
["is", "are"],
|
13298
|
-
["was", "were"],
|
13299
|
-
["has", "have"],
|
13300
|
-
["this", "these"],
|
13301
|
-
["that", "those"],
|
13302
|
-
// Words ending in with a consonant and `o`.
|
13303
|
-
["echo", "echoes"],
|
13304
|
-
["dingo", "dingoes"],
|
13305
|
-
["volcano", "volcanoes"],
|
13306
|
-
["tornado", "tornadoes"],
|
13307
|
-
["torpedo", "torpedoes"],
|
13308
|
-
// Ends with `us`.
|
13309
|
-
["genus", "genera"],
|
13310
|
-
["viscus", "viscera"],
|
13311
|
-
// Ends with `ma`.
|
13312
|
-
["stigma", "stigmata"],
|
13313
|
-
["stoma", "stomata"],
|
13314
|
-
["dogma", "dogmata"],
|
13315
|
-
["lemma", "lemmata"],
|
13316
|
-
["schema", "schemata"],
|
13317
|
-
["anathema", "anathemata"],
|
13318
|
-
// Other irregular rules.
|
13319
|
-
["ox", "oxen"],
|
13320
|
-
["axe", "axes"],
|
13321
|
-
["die", "dice"],
|
13322
|
-
["yes", "yeses"],
|
13323
|
-
["foot", "feet"],
|
13324
|
-
["eave", "eaves"],
|
13325
|
-
["goose", "geese"],
|
13326
|
-
["tooth", "teeth"],
|
13327
|
-
["quiz", "quizzes"],
|
13328
|
-
["human", "humans"],
|
13329
|
-
["proof", "proofs"],
|
13330
|
-
["carve", "carves"],
|
13331
|
-
["valve", "valves"],
|
13332
|
-
["looey", "looies"],
|
13333
|
-
["thief", "thieves"],
|
13334
|
-
["groove", "grooves"],
|
13335
|
-
["pickaxe", "pickaxes"],
|
13336
|
-
["passerby", "passersby"]
|
13337
|
-
].forEach(function(rule) {
|
13338
|
-
return pluralize.addIrregularRule(rule[0], rule[1]);
|
13339
|
-
});
|
13340
|
-
[
|
13341
|
-
[/s?$/i, "s"],
|
13342
|
-
[/[^\u0000-\u007F]$/i, "$0"],
|
13343
|
-
[/([^aeiou]ese)$/i, "$1"],
|
13344
|
-
[/(ax|test)is$/i, "$1es"],
|
13345
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
13346
|
-
[/(e[mn]u)s?$/i, "$1s"],
|
13347
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
13348
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
13349
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
13350
|
-
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
13351
|
-
[/(her|at|gr)o$/i, "$1oes"],
|
13352
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
13353
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
13354
|
-
[/sis$/i, "ses"],
|
13355
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
13356
|
-
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
13357
|
-
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
13358
|
-
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
13359
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
13360
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
13361
|
-
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
13362
|
-
[/(child)(?:ren)?$/i, "$1ren"],
|
13363
|
-
[/eaux$/i, "$0"],
|
13364
|
-
[/m[ae]n$/i, "men"],
|
13365
|
-
["thou", "you"]
|
13366
|
-
].forEach(function(rule) {
|
13367
|
-
return pluralize.addPluralRule(rule[0], rule[1]);
|
13368
|
-
});
|
13369
|
-
[
|
13370
|
-
[/s$/i, ""],
|
13371
|
-
[/(ss)$/i, "$1"],
|
13372
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
13373
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
13374
|
-
[/ies$/i, "y"],
|
13375
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
13376
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
13377
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
13378
|
-
[/(seraph|cherub)im$/i, "$1"],
|
13379
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
13380
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
13381
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
13382
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
13383
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
13384
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
13385
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
13386
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
13387
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
13388
|
-
[/(matr|append)ices$/i, "$1ix"],
|
13389
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
13390
|
-
[/(child)ren$/i, "$1"],
|
13391
|
-
[/(eau)x?$/i, "$1"],
|
13392
|
-
[/men$/i, "man"]
|
13393
|
-
].forEach(function(rule) {
|
13394
|
-
return pluralize.addSingularRule(rule[0], rule[1]);
|
13395
|
-
});
|
13396
|
-
[
|
13397
|
-
// Singular words with no plurals.
|
13398
|
-
"adulthood",
|
13399
|
-
"advice",
|
13400
|
-
"agenda",
|
13401
|
-
"aid",
|
13402
|
-
"aircraft",
|
13403
|
-
"alcohol",
|
13404
|
-
"ammo",
|
13405
|
-
"analytics",
|
13406
|
-
"anime",
|
13407
|
-
"athletics",
|
13408
|
-
"audio",
|
13409
|
-
"bison",
|
13410
|
-
"blood",
|
13411
|
-
"bream",
|
13412
|
-
"buffalo",
|
13413
|
-
"butter",
|
13414
|
-
"carp",
|
13415
|
-
"cash",
|
13416
|
-
"chassis",
|
13417
|
-
"chess",
|
13418
|
-
"clothing",
|
13419
|
-
"cod",
|
13420
|
-
"commerce",
|
13421
|
-
"cooperation",
|
13422
|
-
"corps",
|
13423
|
-
"debris",
|
13424
|
-
"diabetes",
|
13425
|
-
"digestion",
|
13426
|
-
"elk",
|
13427
|
-
"energy",
|
13428
|
-
"equipment",
|
13429
|
-
"excretion",
|
13430
|
-
"expertise",
|
13431
|
-
"firmware",
|
13432
|
-
"flounder",
|
13433
|
-
"fun",
|
13434
|
-
"gallows",
|
13435
|
-
"garbage",
|
13436
|
-
"graffiti",
|
13437
|
-
"hardware",
|
13438
|
-
"headquarters",
|
13439
|
-
"health",
|
13440
|
-
"herpes",
|
13441
|
-
"highjinks",
|
13442
|
-
"homework",
|
13443
|
-
"housework",
|
13444
|
-
"information",
|
13445
|
-
"jeans",
|
13446
|
-
"justice",
|
13447
|
-
"kudos",
|
13448
|
-
"labour",
|
13449
|
-
"literature",
|
13450
|
-
"machinery",
|
13451
|
-
"mackerel",
|
13452
|
-
"mail",
|
13453
|
-
"media",
|
13454
|
-
"mews",
|
13455
|
-
"moose",
|
13456
|
-
"music",
|
13457
|
-
"mud",
|
13458
|
-
"manga",
|
13459
|
-
"news",
|
13460
|
-
"only",
|
13461
|
-
"personnel",
|
13462
|
-
"pike",
|
13463
|
-
"plankton",
|
13464
|
-
"pliers",
|
13465
|
-
"police",
|
13466
|
-
"pollution",
|
13467
|
-
"premises",
|
13468
|
-
"rain",
|
13469
|
-
"research",
|
13470
|
-
"rice",
|
13471
|
-
"salmon",
|
13472
|
-
"scissors",
|
13473
|
-
"series",
|
13474
|
-
"sewage",
|
13475
|
-
"shambles",
|
13476
|
-
"shrimp",
|
13477
|
-
"software",
|
13478
|
-
"species",
|
13479
|
-
"staff",
|
13480
|
-
"swine",
|
13481
|
-
"tennis",
|
13482
|
-
"traffic",
|
13483
|
-
"transportation",
|
13484
|
-
"trout",
|
13485
|
-
"tuna",
|
13486
|
-
"wealth",
|
13487
|
-
"welfare",
|
13488
|
-
"whiting",
|
13489
|
-
"wildebeest",
|
13490
|
-
"wildlife",
|
13491
|
-
"you",
|
13492
|
-
/pok[eé]mon$/i,
|
13493
|
-
// Regexes.
|
13494
|
-
/[^aeiou]ese$/i,
|
13495
|
-
// "chinese", "japanese"
|
13496
|
-
/deer$/i,
|
13497
|
-
// "deer", "reindeer"
|
13498
|
-
/fish$/i,
|
13499
|
-
// "fish", "blowfish", "angelfish"
|
13500
|
-
/measles$/i,
|
13501
|
-
/o[iu]s$/i,
|
13502
|
-
// "carnivorous"
|
13503
|
-
/pox$/i,
|
13504
|
-
// "chickpox", "smallpox"
|
13505
|
-
/sheep$/i
|
13506
|
-
].forEach(pluralize.addUncountableRule);
|
13507
|
-
return pluralize;
|
13508
|
-
});
|
13509
|
-
}
|
13510
|
-
});
|
13511
|
-
|
13512
12864
|
// node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
|
13513
12865
|
var require_balanced_match = __commonJS({
|
13514
12866
|
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module2) {
|
@@ -13798,7 +13150,6 @@ function applyJsonDiff(json1, json2) {
|
|
13798
13150
|
var import_json_diff, findAlternationsInTable, alternationsInColumn;
|
13799
13151
|
var init_jsonDiffer = __esm({
|
13800
13152
|
"src/jsonDiffer.js"() {
|
13801
|
-
"use strict";
|
13802
13153
|
"use-strict";
|
13803
13154
|
import_json_diff = require("json-diff");
|
13804
13155
|
findAlternationsInTable = (table4, tableSchema) => {
|
@@ -13971,21 +13322,20 @@ var init_jsonDiffer = __esm({
|
|
13971
13322
|
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, prepareAlterTableColumnsJson, _prepareDropColumns, _prepareAddColumns, _prepareSQLiteAddColumns, _prepareAlterColumns, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
13972
13323
|
var init_jsonStatements = __esm({
|
13973
13324
|
"src/jsonStatements.ts"() {
|
13974
|
-
"use strict";
|
13975
13325
|
init_mysqlSchema();
|
13976
13326
|
init_pgSchema();
|
13977
13327
|
init_sqliteSchema();
|
13978
13328
|
preparePgCreateTableJson = (table4, json2) => {
|
13979
13329
|
const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13980
|
-
const tableKey = `${schema4 || "public"}.${name}`;
|
13981
|
-
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
13982
13330
|
return {
|
13983
13331
|
type: "create_table",
|
13984
13332
|
tableName: name,
|
13985
13333
|
schema: schema4,
|
13986
13334
|
columns: Object.values(columns),
|
13987
13335
|
compositePKs: Object.values(compositePrimaryKeys),
|
13988
|
-
compositePkName
|
13336
|
+
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
|
13337
|
+
Object.values(compositePrimaryKeys)[0]
|
13338
|
+
).name}`].name : "",
|
13989
13339
|
uniqueConstraints: Object.values(uniqueConstraints)
|
13990
13340
|
};
|
13991
13341
|
};
|
@@ -14084,12 +13434,11 @@ var init_jsonStatements = __esm({
|
|
14084
13434
|
};
|
14085
13435
|
});
|
14086
13436
|
};
|
14087
|
-
prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2,
|
13437
|
+
prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect6) => {
|
14088
13438
|
const addColumns = [];
|
14089
13439
|
const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
|
14090
|
-
const
|
14091
|
-
|
14092
|
-
if (dialect7 === "sqlite") {
|
13440
|
+
const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
|
13441
|
+
if (dialect6 === "sqlite") {
|
14093
13442
|
let jsonCreateFKStatements = Object.values(addedFk);
|
14094
13443
|
const sqliteAddColumns = _prepareSQLiteAddColumns(
|
14095
13444
|
tableName,
|
@@ -14138,22 +13487,19 @@ var init_jsonStatements = __esm({
|
|
14138
13487
|
};
|
14139
13488
|
});
|
14140
13489
|
};
|
14141
|
-
_prepareAlterColumns = (
|
13490
|
+
_prepareAlterColumns = (tableName, schema4, columns, json2) => {
|
14142
13491
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
14143
13492
|
let statements = [];
|
14144
13493
|
let dropPkStatements = [];
|
14145
13494
|
let setPkStatements = [];
|
14146
13495
|
for (const column4 of columns) {
|
14147
13496
|
const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
|
14148
|
-
const
|
14149
|
-
const
|
14150
|
-
const
|
14151
|
-
const
|
14152
|
-
const
|
14153
|
-
const
|
14154
|
-
const columnNotNull = table4.columns[columnName].notNull;
|
14155
|
-
const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
|
14156
|
-
const columnPk = table4.columns[columnName].primaryKey;
|
13497
|
+
const columnType = json2.tables[tableName].columns[columnName].type;
|
13498
|
+
const columnDefault = json2.tables[tableName].columns[columnName].default;
|
13499
|
+
const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
|
13500
|
+
const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
|
13501
|
+
const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
|
13502
|
+
const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
|
14157
13503
|
if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
|
14158
13504
|
statements.push({
|
14159
13505
|
type: "alter_table_alter_column_set_autoincrement",
|
@@ -14200,14 +13546,13 @@ var init_jsonStatements = __esm({
|
|
14200
13546
|
}
|
14201
13547
|
for (const column4 of columns) {
|
14202
13548
|
const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
|
14203
|
-
const
|
14204
|
-
const
|
14205
|
-
const
|
14206
|
-
const
|
14207
|
-
const
|
14208
|
-
const
|
14209
|
-
const
|
14210
|
-
const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
|
13549
|
+
const columnType = json2.tables[tableName].columns[columnName].type;
|
13550
|
+
const columnDefault = json2.tables[tableName].columns[columnName].default;
|
13551
|
+
const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
|
13552
|
+
const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
|
13553
|
+
const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
|
13554
|
+
const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
|
13555
|
+
const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
|
14211
13556
|
if (typeof column4.name !== "string") {
|
14212
13557
|
statements.push({
|
14213
13558
|
type: "alter_table_rename_column",
|
@@ -14558,7 +13903,6 @@ var init_jsonStatements = __esm({
|
|
14558
13903
|
var prepareMigrationMetadata, adjectives, heroes;
|
14559
13904
|
var init_words = __esm({
|
14560
13905
|
"src/utils/words.ts"() {
|
14561
|
-
"use strict";
|
14562
13906
|
prepareMigrationMetadata = (idx) => {
|
14563
13907
|
const prefix = idx.toFixed(0).padStart(4, "0");
|
14564
13908
|
const suffix = `${adjectives.random()}_${heroes.random()}`;
|
@@ -15879,7 +15223,6 @@ var init_words = __esm({
|
|
15879
15223
|
// src/cli/commands/pgUp.ts
|
15880
15224
|
var init_pgUp = __esm({
|
15881
15225
|
"src/cli/commands/pgUp.ts"() {
|
15882
|
-
"use strict";
|
15883
15226
|
init_source();
|
15884
15227
|
init_global();
|
15885
15228
|
init_pgSchema();
|
@@ -15890,7 +15233,6 @@ var init_pgUp = __esm({
|
|
15890
15233
|
// src/cli/commands/mysqlUp.ts
|
15891
15234
|
var init_mysqlUp = __esm({
|
15892
15235
|
"src/cli/commands/mysqlUp.ts"() {
|
15893
|
-
"use strict";
|
15894
15236
|
init_source();
|
15895
15237
|
init_mysqlSchema();
|
15896
15238
|
init_utils2();
|
@@ -15900,7 +15242,6 @@ var init_mysqlUp = __esm({
|
|
15900
15242
|
// src/cli/commands/upFolders.ts
|
15901
15243
|
var init_upFolders = __esm({
|
15902
15244
|
"src/cli/commands/upFolders.ts"() {
|
15903
|
-
"use strict";
|
15904
15245
|
init_jsonDiffer();
|
15905
15246
|
init_mysqlSchema();
|
15906
15247
|
init_sqliteSchema();
|
@@ -15914,10 +15255,9 @@ var init_upFolders = __esm({
|
|
15914
15255
|
});
|
15915
15256
|
|
15916
15257
|
// src/utils.ts
|
15917
|
-
var import_fs3, import_path2, assertV1OutFolder, dryJournal,
|
15258
|
+
var import_fs3, import_path2, assertV1OutFolder, dryJournal, prepareOutFolder2, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
15918
15259
|
var init_utils2 = __esm({
|
15919
15260
|
"src/utils.ts"() {
|
15920
|
-
"use strict";
|
15921
15261
|
import_fs3 = require("fs");
|
15922
15262
|
init_views();
|
15923
15263
|
init_mysqlSchema();
|
@@ -15928,7 +15268,7 @@ var init_utils2 = __esm({
|
|
15928
15268
|
init_global();
|
15929
15269
|
init_upFolders();
|
15930
15270
|
init_snapshotsDiffer();
|
15931
|
-
assertV1OutFolder = (out) => {
|
15271
|
+
assertV1OutFolder = (out, dialect6) => {
|
15932
15272
|
if (!(0, import_fs3.existsSync)(out))
|
15933
15273
|
return;
|
15934
15274
|
const oldMigrationFolders = (0, import_fs3.readdirSync)(out).filter(
|
@@ -15937,43 +15277,43 @@ var init_utils2 = __esm({
|
|
15937
15277
|
if (oldMigrationFolders.length > 0) {
|
15938
15278
|
console.log(
|
15939
15279
|
`Your migrations folder format is outdated, please run ${source_default.green.bold(
|
15940
|
-
`drizzle-kit up`
|
15280
|
+
`drizzle-kit up:${dialect6}`
|
15941
15281
|
)}`
|
15942
15282
|
);
|
15943
15283
|
process.exit(1);
|
15944
15284
|
}
|
15945
15285
|
};
|
15946
|
-
dryJournal = (
|
15286
|
+
dryJournal = (dialect6) => {
|
15947
15287
|
return {
|
15948
15288
|
version: snapshotVersion,
|
15949
|
-
dialect:
|
15289
|
+
dialect: dialect6,
|
15950
15290
|
entries: []
|
15951
15291
|
};
|
15952
15292
|
};
|
15953
|
-
|
15293
|
+
prepareOutFolder2 = (out, dialect6) => {
|
15954
15294
|
const meta = (0, import_path2.join)(out, "meta");
|
15955
15295
|
const journalPath = (0, import_path2.join)(meta, "_journal.json");
|
15956
15296
|
if (!(0, import_fs3.existsSync)((0, import_path2.join)(out, "meta"))) {
|
15957
15297
|
(0, import_fs3.mkdirSync)(meta, { recursive: true });
|
15958
|
-
(0, import_fs3.writeFileSync)(journalPath, JSON.stringify(dryJournal(
|
15298
|
+
(0, import_fs3.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect6)));
|
15959
15299
|
}
|
15960
15300
|
const journal = JSON.parse((0, import_fs3.readFileSync)(journalPath).toString());
|
15961
15301
|
const snapshots = (0, import_fs3.readdirSync)(meta).filter((it) => !it.startsWith("_")).map((it) => (0, import_path2.join)(meta, it));
|
15962
15302
|
snapshots.sort();
|
15963
15303
|
return { meta, snapshots, journal };
|
15964
15304
|
};
|
15965
|
-
validatorForDialect = (
|
15966
|
-
switch (
|
15305
|
+
validatorForDialect = (dialect6) => {
|
15306
|
+
switch (dialect6) {
|
15967
15307
|
case "pg":
|
15968
|
-
return { validator: backwardCompatiblePgSchema, version:
|
15308
|
+
return { validator: backwardCompatiblePgSchema, version: 5 };
|
15969
15309
|
case "sqlite":
|
15970
|
-
return { validator: backwardCompatibleSqliteSchema, version:
|
15310
|
+
return { validator: backwardCompatibleSqliteSchema, version: 5 };
|
15971
15311
|
case "mysql":
|
15972
15312
|
return { validator: backwardCompatibleMysqlSchema, version: 5 };
|
15973
15313
|
}
|
15974
15314
|
};
|
15975
|
-
validateWithReport = (snapshots,
|
15976
|
-
const { validator, version } = validatorForDialect(
|
15315
|
+
validateWithReport = (snapshots, dialect6) => {
|
15316
|
+
const { validator, version } = validatorForDialect(dialect6);
|
15977
15317
|
const result = snapshots.reduce(
|
15978
15318
|
(accum, it) => {
|
15979
15319
|
const raw = JSON.parse((0, import_fs3.readFileSync)(`./${it}`).toString());
|
@@ -16014,14 +15354,14 @@ var init_utils2 = __esm({
|
|
16014
15354
|
);
|
16015
15355
|
return result;
|
16016
15356
|
};
|
16017
|
-
prepareMigrationFolder = (outFolder = "drizzle",
|
16018
|
-
const { snapshots, journal } =
|
16019
|
-
const report = validateWithReport(snapshots,
|
15357
|
+
prepareMigrationFolder = (outFolder = "drizzle", dialect6) => {
|
15358
|
+
const { snapshots, journal } = prepareOutFolder2(outFolder, dialect6);
|
15359
|
+
const report = validateWithReport(snapshots, dialect6);
|
16020
15360
|
if (report.nonLatest.length > 0) {
|
16021
15361
|
console.log(
|
16022
15362
|
report.nonLatest.map((it) => {
|
16023
15363
|
return `${it}/snapshot.json is not of the latest version`;
|
16024
|
-
}).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
|
15364
|
+
}).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect6}`)}`).join("\n")
|
16025
15365
|
);
|
16026
15366
|
process.exit(0);
|
16027
15367
|
}
|
@@ -16090,7 +15430,6 @@ var init_utils2 = __esm({
|
|
16090
15430
|
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, valueFromSelfOrPatchedNew, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
|
16091
15431
|
var init_snapshotsDiffer = __esm({
|
16092
15432
|
"src/snapshotsDiffer.ts"() {
|
16093
|
-
"use strict";
|
16094
15433
|
init_sqlgenerator();
|
16095
15434
|
init_lib();
|
16096
15435
|
init_jsonDiffer();
|
@@ -16098,7 +15437,6 @@ var init_snapshotsDiffer = __esm({
|
|
16098
15437
|
init_utils2();
|
16099
15438
|
init_sqliteSchema();
|
16100
15439
|
init_mysqlSchema();
|
16101
|
-
init_global();
|
16102
15440
|
makeChanged = (schema4) => {
|
16103
15441
|
return objectType({
|
16104
15442
|
type: enumType(["changed"]),
|
@@ -16137,7 +15475,7 @@ var init_snapshotsDiffer = __esm({
|
|
16137
15475
|
return unionType([
|
16138
15476
|
objectType({
|
16139
15477
|
type: literalType("none"),
|
16140
|
-
value: schema4
|
15478
|
+
value: schema4.optional()
|
16141
15479
|
}),
|
16142
15480
|
objectType({
|
16143
15481
|
type: literalType("added"),
|
@@ -16259,9 +15597,10 @@ var init_snapshotsDiffer = __esm({
|
|
16259
15597
|
addedSchemas: stringType().array(),
|
16260
15598
|
deletedSchemas: stringType().array()
|
16261
15599
|
}).strict();
|
16262
|
-
applySnapshotsDiff = async (json1, json2,
|
15600
|
+
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
16263
15601
|
var _a, _b;
|
16264
|
-
|
15602
|
+
let diffResult;
|
15603
|
+
if (dialect6 === "mysql") {
|
16265
15604
|
for (const tableName in json1.tables) {
|
16266
15605
|
const table4 = json1.tables[tableName];
|
16267
15606
|
for (const indexName3 in table4.indexes) {
|
@@ -16288,26 +15627,13 @@ var init_snapshotsDiffer = __esm({
|
|
16288
15627
|
}
|
16289
15628
|
}
|
16290
15629
|
}
|
15630
|
+
diffResult = applyJsonDiff(json1, json2);
|
16291
15631
|
}
|
16292
|
-
|
15632
|
+
diffResult = applyJsonDiff(json1, json2);
|
16293
15633
|
if (Object.keys(diffResult).length === 0) {
|
16294
15634
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
16295
15635
|
}
|
16296
15636
|
const typedResult = diffResultScheme.parse(diffResult);
|
16297
|
-
typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
|
16298
|
-
let schemaToTrim;
|
16299
|
-
if (it.schema.type === "none") {
|
16300
|
-
schemaToTrim = it.schema.value || "public";
|
16301
|
-
} else if (it.schema.type === "deleted") {
|
16302
|
-
schemaToTrim = it.schema.value;
|
16303
|
-
} else if (it.schema.type === "added") {
|
16304
|
-
schemaToTrim = "public";
|
16305
|
-
} else {
|
16306
|
-
schemaToTrim = it.schema.old;
|
16307
|
-
}
|
16308
|
-
it.name = it.name.substring(schemaToTrim.length + 1);
|
16309
|
-
return it;
|
16310
|
-
});
|
16311
15637
|
const {
|
16312
15638
|
created: createdSchemas,
|
16313
15639
|
deleted: deletedSchemas,
|
@@ -16399,9 +15725,9 @@ var init_snapshotsDiffer = __esm({
|
|
16399
15725
|
let addedColumns = [];
|
16400
15726
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
16401
15727
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
16402
|
-
if (
|
15728
|
+
if (dialect6 === "sqlite") {
|
16403
15729
|
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
16404
|
-
} else if (
|
15730
|
+
} else if (dialect6 === "mysql") {
|
16405
15731
|
addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
|
16406
15732
|
} else {
|
16407
15733
|
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
@@ -16410,9 +15736,9 @@ var init_snapshotsDiffer = __esm({
|
|
16410
15736
|
let deletedColumns = [];
|
16411
15737
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
16412
15738
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
16413
|
-
if (
|
15739
|
+
if (dialect6 === "sqlite") {
|
16414
15740
|
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
16415
|
-
} else if (
|
15741
|
+
} else if (dialect6 === "mysql") {
|
16416
15742
|
deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
|
16417
15743
|
} else {
|
16418
15744
|
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
@@ -16422,7 +15748,7 @@ var init_snapshotsDiffer = __esm({
|
|
16422
15748
|
let addedCompositePKs = [];
|
16423
15749
|
let deletedCompositePKs = [];
|
16424
15750
|
let alteredCompositePKs = [];
|
16425
|
-
if (
|
15751
|
+
if (dialect6 === "sqlite") {
|
16426
15752
|
if (doPerformDeleteAndCreate) {
|
16427
15753
|
addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
16428
15754
|
it.name,
|
@@ -16437,7 +15763,7 @@ var init_snapshotsDiffer = __esm({
|
|
16437
15763
|
it.name,
|
16438
15764
|
it.alteredCompositePKs
|
16439
15765
|
);
|
16440
|
-
} else if (
|
15766
|
+
} else if (dialect6 === "pg") {
|
16441
15767
|
if (doPerformDeleteAndCreate) {
|
16442
15768
|
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
16443
15769
|
it.name,
|
@@ -16459,7 +15785,7 @@ var init_snapshotsDiffer = __esm({
|
|
16459
15785
|
prevFull,
|
16460
15786
|
curFull
|
16461
15787
|
);
|
16462
|
-
} else
|
15788
|
+
} else {
|
16463
15789
|
addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
|
16464
15790
|
it.name,
|
16465
15791
|
it.addedCompositePKs,
|
@@ -16477,8 +15803,6 @@ var init_snapshotsDiffer = __esm({
|
|
16477
15803
|
prevFull,
|
16478
15804
|
curFull
|
16479
15805
|
);
|
16480
|
-
} else {
|
16481
|
-
assertUnreachable(dialect7);
|
16482
15806
|
}
|
16483
15807
|
let addedUniqueConstraints = [];
|
16484
15808
|
let deletedUniqueConstraints = [];
|
@@ -16561,7 +15885,7 @@ var init_snapshotsDiffer = __esm({
|
|
16561
15885
|
it.altered,
|
16562
15886
|
it.addedForeignKeys,
|
16563
15887
|
json2,
|
16564
|
-
|
15888
|
+
dialect6
|
16565
15889
|
);
|
16566
15890
|
}).flat().reduce(
|
16567
15891
|
(res, it) => {
|
@@ -16638,7 +15962,7 @@ var init_snapshotsDiffer = __esm({
|
|
16638
15962
|
const jsonAlterEnumsWithAddedValues = ((_b = typedResult.alteredEnums) == null ? void 0 : _b.map((it) => {
|
16639
15963
|
return prepareAddValuesToEnumJson(it.name, it.addedValues);
|
16640
15964
|
}).flat()) ?? [];
|
16641
|
-
if (
|
15965
|
+
if (dialect6 === "mysql") {
|
16642
15966
|
createdSchemas.push(...renamedSchemas.map((it) => it.to));
|
16643
15967
|
deletedSchemas.push(...renamedSchemas.map((it) => it.from));
|
16644
15968
|
renamedSchemas.splice(0, renamedSchemas.length);
|
@@ -16662,25 +15986,23 @@ var init_snapshotsDiffer = __esm({
|
|
16662
15986
|
jsonStatements.push(...renameSchemas);
|
16663
15987
|
jsonStatements.push(...createEnums);
|
16664
15988
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
16665
|
-
if (
|
15989
|
+
if (dialect6 === "sqlite") {
|
16666
15990
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
16667
|
-
} else if (
|
15991
|
+
} else if (dialect6 === "pg") {
|
16668
15992
|
const jsonPgCreateTables = created.map((it) => {
|
16669
15993
|
return preparePgCreateTableJson(it, curFull);
|
16670
15994
|
});
|
16671
15995
|
jsonStatements.push(...jsonPgCreateTables);
|
16672
|
-
} else
|
15996
|
+
} else {
|
16673
15997
|
const jsonMySqlCreateTables = created.map((it) => {
|
16674
15998
|
return prepareMySqlCreateTableJson(it, curFull);
|
16675
15999
|
});
|
16676
16000
|
jsonStatements.push(...jsonMySqlCreateTables);
|
16677
|
-
} else {
|
16678
|
-
assertUnreachable(dialect7);
|
16679
16001
|
}
|
16680
16002
|
jsonStatements.push(...jsonDropTables);
|
16681
16003
|
jsonStatements.push(...jsonRenameTables);
|
16682
16004
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16683
|
-
if (
|
16005
|
+
if (dialect6 !== "mysql") {
|
16684
16006
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16685
16007
|
}
|
16686
16008
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
@@ -16688,7 +16010,7 @@ var init_snapshotsDiffer = __esm({
|
|
16688
16010
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
16689
16011
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
16690
16012
|
jsonStatements.push(...jsonAddedCompositePKs);
|
16691
|
-
if (
|
16013
|
+
if (dialect6 === "mysql") {
|
16692
16014
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16693
16015
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16694
16016
|
}
|
@@ -16697,10 +16019,10 @@ var init_snapshotsDiffer = __esm({
|
|
16697
16019
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16698
16020
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16699
16021
|
jsonStatements.push(...jsonTableAlternations.dropColumns);
|
16700
|
-
if (
|
16022
|
+
if (dialect6 !== "sqlite")
|
16701
16023
|
jsonStatements.push(...jsonCreateReferences);
|
16702
16024
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16703
|
-
if (
|
16025
|
+
if (dialect6 !== "mysql") {
|
16704
16026
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16705
16027
|
}
|
16706
16028
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
@@ -16708,7 +16030,7 @@ var init_snapshotsDiffer = __esm({
|
|
16708
16030
|
jsonStatements.push(...filteredJsonSetNewTableSchemas);
|
16709
16031
|
jsonStatements.push(...jsonRemoveTableFromSchemas);
|
16710
16032
|
jsonStatements.push(...dropSchemas);
|
16711
|
-
const sqlStatements = fromJson(jsonStatements,
|
16033
|
+
const sqlStatements = fromJson(jsonStatements, dialect6);
|
16712
16034
|
const uniqueSqlStatements = [];
|
16713
16035
|
sqlStatements.forEach((ss) => {
|
16714
16036
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -16743,7 +16065,6 @@ __export(migrate_exports, {
|
|
16743
16065
|
var import_fs4, import_path3, import_hanji4, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
16744
16066
|
var init_migrate = __esm({
|
16745
16067
|
"src/cli/commands/migrate.ts"() {
|
16746
|
-
"use strict";
|
16747
16068
|
import_fs4 = __toESM(require("fs"));
|
16748
16069
|
init_migrationPreparator();
|
16749
16070
|
init_snapshotsDiffer();
|
@@ -16761,7 +16082,7 @@ var init_migrate = __esm({
|
|
16761
16082
|
const outFolder = config.out;
|
16762
16083
|
const schemaPath = config.schema;
|
16763
16084
|
try {
|
16764
|
-
assertV1OutFolder(outFolder);
|
16085
|
+
assertV1OutFolder(outFolder, "pg");
|
16765
16086
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "pg");
|
16766
16087
|
const { prev, cur, custom } = await preparePgMigrationSnapshot(
|
16767
16088
|
snapshots,
|
@@ -16821,56 +16142,66 @@ var init_migrate = __esm({
|
|
16821
16142
|
return { sqlStatements, statements, validatedCur, validatedPrev };
|
16822
16143
|
} catch (e) {
|
16823
16144
|
console.error(e);
|
16824
|
-
process.exit(1);
|
16825
16145
|
}
|
16826
16146
|
};
|
16827
16147
|
prepareSQLitePush = async (config, snapshot) => {
|
16828
16148
|
const schemaPath = config.schema;
|
16829
|
-
|
16830
|
-
|
16831
|
-
|
16832
|
-
|
16833
|
-
|
16834
|
-
|
16835
|
-
|
16836
|
-
|
16837
|
-
|
16838
|
-
|
16839
|
-
|
16840
|
-
|
16841
|
-
|
16842
|
-
|
16843
|
-
|
16844
|
-
|
16845
|
-
|
16846
|
-
|
16847
|
-
|
16149
|
+
try {
|
16150
|
+
const { prev, cur } = await prepareSQLiteDbPushSnapshot(
|
16151
|
+
snapshot,
|
16152
|
+
schemaPath
|
16153
|
+
);
|
16154
|
+
const validatedPrev = sqliteSchema.parse(prev);
|
16155
|
+
const validatedCur = sqliteSchema.parse(cur);
|
16156
|
+
const squashedPrev = squashSqliteScheme(validatedPrev);
|
16157
|
+
const squashedCur = squashSqliteScheme(validatedCur);
|
16158
|
+
const { sqlStatements, statements, _meta } = await prepareSQL(
|
16159
|
+
squashedPrev,
|
16160
|
+
squashedCur,
|
16161
|
+
"sqlite",
|
16162
|
+
validatedPrev,
|
16163
|
+
validatedCur
|
16164
|
+
);
|
16165
|
+
return {
|
16166
|
+
sqlStatements,
|
16167
|
+
statements,
|
16168
|
+
squashedPrev,
|
16169
|
+
squashedCur,
|
16170
|
+
meta: _meta
|
16171
|
+
};
|
16172
|
+
} catch (e) {
|
16173
|
+
console.error(e);
|
16174
|
+
}
|
16848
16175
|
};
|
16849
16176
|
preparePgPush = async (config, snapshot, schemaFilter) => {
|
16850
16177
|
const schemaPath = config.schema;
|
16851
|
-
|
16852
|
-
|
16853
|
-
|
16854
|
-
|
16855
|
-
|
16856
|
-
|
16857
|
-
|
16858
|
-
|
16859
|
-
|
16860
|
-
|
16861
|
-
|
16862
|
-
|
16863
|
-
|
16864
|
-
|
16865
|
-
|
16866
|
-
|
16867
|
-
|
16178
|
+
try {
|
16179
|
+
const { prev, cur } = await preparePgDbPushSnapshot(
|
16180
|
+
snapshot,
|
16181
|
+
schemaPath,
|
16182
|
+
schemaFilter
|
16183
|
+
);
|
16184
|
+
const validatedPrev = pgSchema.parse(prev);
|
16185
|
+
const validatedCur = pgSchema.parse(cur);
|
16186
|
+
const squashedPrev = squashPgScheme(validatedPrev);
|
16187
|
+
const squashedCur = squashPgScheme(validatedCur);
|
16188
|
+
const { sqlStatements, statements } = await prepareSQL(
|
16189
|
+
squashedPrev,
|
16190
|
+
squashedCur,
|
16191
|
+
"pg",
|
16192
|
+
validatedPrev,
|
16193
|
+
validatedCur
|
16194
|
+
);
|
16195
|
+
return { sqlStatements, statements, squashedPrev, squashedCur };
|
16196
|
+
} catch (e) {
|
16197
|
+
console.error(e);
|
16198
|
+
}
|
16868
16199
|
};
|
16869
16200
|
prepareAndMigrateMySql = async (config) => {
|
16870
16201
|
const outFolder = config.out;
|
16871
16202
|
const schemaPath = config.schema;
|
16872
16203
|
try {
|
16873
|
-
assertV1OutFolder(outFolder);
|
16204
|
+
assertV1OutFolder(outFolder, "mysql");
|
16874
16205
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
|
16875
16206
|
const { prev, cur, custom } = await prepareMySqlMigrationSnapshot(
|
16876
16207
|
snapshots,
|
@@ -16914,7 +16245,7 @@ var init_migrate = __esm({
|
|
16914
16245
|
const outFolder = config.out;
|
16915
16246
|
const schemaPath = config.schema;
|
16916
16247
|
try {
|
16917
|
-
assertV1OutFolder(outFolder);
|
16248
|
+
assertV1OutFolder(outFolder, "sqlite");
|
16918
16249
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
|
16919
16250
|
const { prev, cur, custom } = await prepareSqliteMigrationSnapshot(
|
16920
16251
|
snapshots,
|
@@ -16939,9 +16270,7 @@ var init_migrate = __esm({
|
|
16939
16270
|
const { sqlStatements, _meta } = await prepareSQL(
|
16940
16271
|
squashedPrev,
|
16941
16272
|
squashedCur,
|
16942
|
-
"sqlite"
|
16943
|
-
validatedPrev,
|
16944
|
-
validatedCur
|
16273
|
+
"sqlite"
|
16945
16274
|
);
|
16946
16275
|
writeResult({
|
16947
16276
|
cur,
|
@@ -16956,7 +16285,7 @@ var init_migrate = __esm({
|
|
16956
16285
|
console.error(e);
|
16957
16286
|
}
|
16958
16287
|
};
|
16959
|
-
prepareSQL = async (prev, cur,
|
16288
|
+
prepareSQL = async (prev, cur, dialect6, prevFull, curFull) => {
|
16960
16289
|
const schemasResolver = async (input) => {
|
16961
16290
|
try {
|
16962
16291
|
const { created, deleted, renamed } = await promptSchemasConflict(
|
@@ -16998,7 +16327,7 @@ var init_migrate = __esm({
|
|
16998
16327
|
return await applySnapshotsDiff(
|
16999
16328
|
prev,
|
17000
16329
|
cur,
|
17001
|
-
|
16330
|
+
dialect6,
|
17002
16331
|
schemasResolver,
|
17003
16332
|
tablesResolver,
|
17004
16333
|
columnsResolver,
|
@@ -17240,7 +16569,6 @@ ${sql2}
|
|
17240
16569
|
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, SQLiteAlterTableAddUniqueConstraintConvertor, SQLiteAlterTableDropUniqueConstraintConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, SQLiteAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, SqliteAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, MySqlModifyColumn, SqliteAlterTableAlterColumnDropDefaultConvertor, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, SqliteAlterTableCreateCompositePrimaryKeyConvertor, SqliteAlterTableDeleteCompositePrimaryKeyConvertor, SqliteAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetAutoincrementConvertor, SqliteAlterTableAlterColumnDropAutoincrementConvertor, PgAlterTableAlterColumnDropNotNullConvertor, SqliteAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, SqliteCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, SqliteAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, SqliteDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MysqlCreateSchemaConvertor, MysqlDropSchemaConvertor, MysqlAlterTableSetSchemaConvertor, MysqlAlterTableSetNewSchemaConvertor, MysqlAlterTableRemoveFromSchemaConvertor, MySqlDropIndexConvertor, convertors, fromJson;
|
17241
16570
|
var init_sqlgenerator = __esm({
|
17242
16571
|
"src/sqlgenerator.ts"() {
|
17243
|
-
"use strict";
|
17244
16572
|
init_migrate();
|
17245
16573
|
init_mysqlSchema();
|
17246
16574
|
init_pgSchema();
|
@@ -17295,8 +16623,8 @@ var init_sqlgenerator = __esm({
|
|
17295
16623
|
Convertor = class {
|
17296
16624
|
};
|
17297
16625
|
PgCreateTableConvertor = class extends Convertor {
|
17298
|
-
can(statement,
|
17299
|
-
return statement.type === "create_table" &&
|
16626
|
+
can(statement, dialect6) {
|
16627
|
+
return statement.type === "create_table" && dialect6 === "pg";
|
17300
16628
|
}
|
17301
16629
|
convert(st) {
|
17302
16630
|
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
@@ -17334,8 +16662,8 @@ var init_sqlgenerator = __esm({
|
|
17334
16662
|
}
|
17335
16663
|
};
|
17336
16664
|
MySqlCreateTableConvertor = class extends Convertor {
|
17337
|
-
can(statement,
|
17338
|
-
return statement.type === "create_table" &&
|
16665
|
+
can(statement, dialect6) {
|
16666
|
+
return statement.type === "create_table" && dialect6 === "mysql";
|
17339
16667
|
}
|
17340
16668
|
convert(st) {
|
17341
16669
|
const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
|
@@ -17373,8 +16701,8 @@ var init_sqlgenerator = __esm({
|
|
17373
16701
|
}
|
17374
16702
|
};
|
17375
16703
|
SQLiteCreateTableConvertor = class extends Convertor {
|
17376
|
-
can(statement,
|
17377
|
-
return statement.type === "sqlite_create_table" &&
|
16704
|
+
can(statement, dialect6) {
|
16705
|
+
return statement.type === "sqlite_create_table" && dialect6 === "sqlite";
|
17378
16706
|
}
|
17379
16707
|
convert(st) {
|
17380
16708
|
const {
|
@@ -17436,8 +16764,8 @@ var init_sqlgenerator = __esm({
|
|
17436
16764
|
}
|
17437
16765
|
};
|
17438
16766
|
PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17439
|
-
can(statement,
|
17440
|
-
return statement.type === "create_unique_constraint" &&
|
16767
|
+
can(statement, dialect6) {
|
16768
|
+
return statement.type === "create_unique_constraint" && dialect6 === "pg";
|
17441
16769
|
}
|
17442
16770
|
convert(statement) {
|
17443
16771
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
@@ -17446,8 +16774,8 @@ var init_sqlgenerator = __esm({
|
|
17446
16774
|
}
|
17447
16775
|
};
|
17448
16776
|
PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17449
|
-
can(statement,
|
17450
|
-
return statement.type === "delete_unique_constraint" &&
|
16777
|
+
can(statement, dialect6) {
|
16778
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "pg";
|
17451
16779
|
}
|
17452
16780
|
convert(statement) {
|
17453
16781
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
@@ -17456,8 +16784,8 @@ var init_sqlgenerator = __esm({
|
|
17456
16784
|
}
|
17457
16785
|
};
|
17458
16786
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17459
|
-
can(statement,
|
17460
|
-
return statement.type === "create_unique_constraint" &&
|
16787
|
+
can(statement, dialect6) {
|
16788
|
+
return statement.type === "create_unique_constraint" && dialect6 === "mysql";
|
17461
16789
|
}
|
17462
16790
|
convert(statement) {
|
17463
16791
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
@@ -17466,8 +16794,8 @@ var init_sqlgenerator = __esm({
|
|
17466
16794
|
}
|
17467
16795
|
};
|
17468
16796
|
MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17469
|
-
can(statement,
|
17470
|
-
return statement.type === "delete_unique_constraint" &&
|
16797
|
+
can(statement, dialect6) {
|
16798
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "mysql";
|
17471
16799
|
}
|
17472
16800
|
convert(statement) {
|
17473
16801
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
@@ -17476,8 +16804,8 @@ var init_sqlgenerator = __esm({
|
|
17476
16804
|
}
|
17477
16805
|
};
|
17478
16806
|
SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17479
|
-
can(statement,
|
17480
|
-
return statement.type === "create_unique_constraint" &&
|
16807
|
+
can(statement, dialect6) {
|
16808
|
+
return statement.type === "create_unique_constraint" && dialect6 === "sqlite";
|
17481
16809
|
}
|
17482
16810
|
convert(statement) {
|
17483
16811
|
return `/*
|
@@ -17489,8 +16817,8 @@ var init_sqlgenerator = __esm({
|
|
17489
16817
|
}
|
17490
16818
|
};
|
17491
16819
|
SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17492
|
-
can(statement,
|
17493
|
-
return statement.type === "delete_unique_constraint" &&
|
16820
|
+
can(statement, dialect6) {
|
16821
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "sqlite";
|
17494
16822
|
}
|
17495
16823
|
convert(statement) {
|
17496
16824
|
return `/*
|
@@ -17533,8 +16861,8 @@ var init_sqlgenerator = __esm({
|
|
17533
16861
|
}
|
17534
16862
|
};
|
17535
16863
|
PgDropTableConvertor = class extends Convertor {
|
17536
|
-
can(statement,
|
17537
|
-
return statement.type === "drop_table" &&
|
16864
|
+
can(statement, dialect6) {
|
16865
|
+
return statement.type === "drop_table" && dialect6 === "pg";
|
17538
16866
|
}
|
17539
16867
|
convert(statement) {
|
17540
16868
|
const { tableName, schema: schema4 } = statement;
|
@@ -17543,8 +16871,8 @@ var init_sqlgenerator = __esm({
|
|
17543
16871
|
}
|
17544
16872
|
};
|
17545
16873
|
MySQLDropTableConvertor = class extends Convertor {
|
17546
|
-
can(statement,
|
17547
|
-
return statement.type === "drop_table" &&
|
16874
|
+
can(statement, dialect6) {
|
16875
|
+
return statement.type === "drop_table" && dialect6 === "mysql";
|
17548
16876
|
}
|
17549
16877
|
convert(statement) {
|
17550
16878
|
const { tableName } = statement;
|
@@ -17552,8 +16880,8 @@ var init_sqlgenerator = __esm({
|
|
17552
16880
|
}
|
17553
16881
|
};
|
17554
16882
|
SQLiteDropTableConvertor = class extends Convertor {
|
17555
|
-
can(statement,
|
17556
|
-
return statement.type === "drop_table" &&
|
16883
|
+
can(statement, dialect6) {
|
16884
|
+
return statement.type === "drop_table" && dialect6 === "sqlite";
|
17557
16885
|
}
|
17558
16886
|
convert(statement) {
|
17559
16887
|
const { tableName } = statement;
|
@@ -17561,8 +16889,8 @@ var init_sqlgenerator = __esm({
|
|
17561
16889
|
}
|
17562
16890
|
};
|
17563
16891
|
PgRenameTableConvertor = class extends Convertor {
|
17564
|
-
can(statement,
|
17565
|
-
return statement.type === "rename_table" &&
|
16892
|
+
can(statement, dialect6) {
|
16893
|
+
return statement.type === "rename_table" && dialect6 === "pg";
|
17566
16894
|
}
|
17567
16895
|
convert(statement) {
|
17568
16896
|
const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
|
@@ -17572,8 +16900,8 @@ var init_sqlgenerator = __esm({
|
|
17572
16900
|
}
|
17573
16901
|
};
|
17574
16902
|
SqliteRenameTableConvertor = class extends Convertor {
|
17575
|
-
can(statement,
|
17576
|
-
return statement.type === "rename_table" &&
|
16903
|
+
can(statement, dialect6) {
|
16904
|
+
return statement.type === "rename_table" && dialect6 === "sqlite";
|
17577
16905
|
}
|
17578
16906
|
convert(statement) {
|
17579
16907
|
const { tableNameFrom, tableNameTo } = statement;
|
@@ -17581,8 +16909,8 @@ var init_sqlgenerator = __esm({
|
|
17581
16909
|
}
|
17582
16910
|
};
|
17583
16911
|
MySqlRenameTableConvertor = class extends Convertor {
|
17584
|
-
can(statement,
|
17585
|
-
return statement.type === "rename_table" &&
|
16912
|
+
can(statement, dialect6) {
|
16913
|
+
return statement.type === "rename_table" && dialect6 === "mysql";
|
17586
16914
|
}
|
17587
16915
|
convert(statement) {
|
17588
16916
|
const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
|
@@ -17592,8 +16920,8 @@ var init_sqlgenerator = __esm({
|
|
17592
16920
|
}
|
17593
16921
|
};
|
17594
16922
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
17595
|
-
can(statement,
|
17596
|
-
return statement.type === "alter_table_rename_column" &&
|
16923
|
+
can(statement, dialect6) {
|
16924
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "pg";
|
17597
16925
|
}
|
17598
16926
|
convert(statement) {
|
17599
16927
|
const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
|
@@ -17602,8 +16930,8 @@ var init_sqlgenerator = __esm({
|
|
17602
16930
|
}
|
17603
16931
|
};
|
17604
16932
|
MySqlAlterTableRenameColumnConvertor = class extends Convertor {
|
17605
|
-
can(statement,
|
17606
|
-
return statement.type === "alter_table_rename_column" &&
|
16933
|
+
can(statement, dialect6) {
|
16934
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "mysql";
|
17607
16935
|
}
|
17608
16936
|
convert(statement) {
|
17609
16937
|
const { tableName, oldColumnName, newColumnName } = statement;
|
@@ -17611,8 +16939,8 @@ var init_sqlgenerator = __esm({
|
|
17611
16939
|
}
|
17612
16940
|
};
|
17613
16941
|
SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
|
17614
|
-
can(statement,
|
17615
|
-
return statement.type === "alter_table_rename_column" &&
|
16942
|
+
can(statement, dialect6) {
|
16943
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "sqlite";
|
17616
16944
|
}
|
17617
16945
|
convert(statement) {
|
17618
16946
|
const { tableName, oldColumnName, newColumnName } = statement;
|
@@ -17620,8 +16948,8 @@ var init_sqlgenerator = __esm({
|
|
17620
16948
|
}
|
17621
16949
|
};
|
17622
16950
|
PgAlterTableDropColumnConvertor = class extends Convertor {
|
17623
|
-
can(statement,
|
17624
|
-
return statement.type === "alter_table_drop_column" &&
|
16951
|
+
can(statement, dialect6) {
|
16952
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "pg";
|
17625
16953
|
}
|
17626
16954
|
convert(statement) {
|
17627
16955
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17630,8 +16958,8 @@ var init_sqlgenerator = __esm({
|
|
17630
16958
|
}
|
17631
16959
|
};
|
17632
16960
|
MySqlAlterTableDropColumnConvertor = class extends Convertor {
|
17633
|
-
can(statement,
|
17634
|
-
return statement.type === "alter_table_drop_column" &&
|
16961
|
+
can(statement, dialect6) {
|
16962
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "mysql";
|
17635
16963
|
}
|
17636
16964
|
convert(statement) {
|
17637
16965
|
const { tableName, columnName } = statement;
|
@@ -17639,8 +16967,8 @@ var init_sqlgenerator = __esm({
|
|
17639
16967
|
}
|
17640
16968
|
};
|
17641
16969
|
SQLiteAlterTableDropColumnConvertor = class extends Convertor {
|
17642
|
-
can(statement,
|
17643
|
-
return statement.type === "alter_table_drop_column" &&
|
16970
|
+
can(statement, dialect6) {
|
16971
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "sqlite";
|
17644
16972
|
}
|
17645
16973
|
convert(statement) {
|
17646
16974
|
const { tableName, columnName } = statement;
|
@@ -17648,8 +16976,8 @@ var init_sqlgenerator = __esm({
|
|
17648
16976
|
}
|
17649
16977
|
};
|
17650
16978
|
PgAlterTableAddColumnConvertor = class extends Convertor {
|
17651
|
-
can(statement,
|
17652
|
-
return statement.type === "alter_table_add_column" &&
|
16979
|
+
can(statement, dialect6) {
|
16980
|
+
return statement.type === "alter_table_add_column" && dialect6 === "pg";
|
17653
16981
|
}
|
17654
16982
|
convert(statement) {
|
17655
16983
|
const { tableName, column: column4, schema: schema4 } = statement;
|
@@ -17662,8 +16990,8 @@ var init_sqlgenerator = __esm({
|
|
17662
16990
|
}
|
17663
16991
|
};
|
17664
16992
|
MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
17665
|
-
can(statement,
|
17666
|
-
return statement.type === "alter_table_add_column" &&
|
16993
|
+
can(statement, dialect6) {
|
16994
|
+
return statement.type === "alter_table_add_column" && dialect6 === "mysql";
|
17667
16995
|
}
|
17668
16996
|
convert(statement) {
|
17669
16997
|
const { tableName, column: column4 } = statement;
|
@@ -17677,8 +17005,8 @@ var init_sqlgenerator = __esm({
|
|
17677
17005
|
}
|
17678
17006
|
};
|
17679
17007
|
SQLiteAlterTableAddColumnConvertor = class extends Convertor {
|
17680
|
-
can(statement,
|
17681
|
-
return statement.type === "sqlite_alter_table_add_column" &&
|
17008
|
+
can(statement, dialect6) {
|
17009
|
+
return statement.type === "sqlite_alter_table_add_column" && dialect6 === "sqlite";
|
17682
17010
|
}
|
17683
17011
|
convert(statement) {
|
17684
17012
|
const { tableName, column: column4, referenceData } = statement;
|
@@ -17692,8 +17020,8 @@ var init_sqlgenerator = __esm({
|
|
17692
17020
|
}
|
17693
17021
|
};
|
17694
17022
|
PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
17695
|
-
can(statement,
|
17696
|
-
return statement.type === "alter_table_alter_column_set_type" &&
|
17023
|
+
can(statement, dialect6) {
|
17024
|
+
return statement.type === "alter_table_alter_column_set_type" && dialect6 === "pg";
|
17697
17025
|
}
|
17698
17026
|
convert(statement) {
|
17699
17027
|
const { tableName, columnName, newDataType, schema: schema4 } = statement;
|
@@ -17702,8 +17030,8 @@ var init_sqlgenerator = __esm({
|
|
17702
17030
|
}
|
17703
17031
|
};
|
17704
17032
|
SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
17705
|
-
can(statement,
|
17706
|
-
return statement.type === "alter_table_alter_column_set_type" &&
|
17033
|
+
can(statement, dialect6) {
|
17034
|
+
return statement.type === "alter_table_alter_column_set_type" && dialect6 === "sqlite";
|
17707
17035
|
}
|
17708
17036
|
convert(statement) {
|
17709
17037
|
return `/*
|
@@ -17717,8 +17045,8 @@ var init_sqlgenerator = __esm({
|
|
17717
17045
|
}
|
17718
17046
|
};
|
17719
17047
|
PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
17720
|
-
can(statement,
|
17721
|
-
return statement.type === "alter_table_alter_column_set_default" &&
|
17048
|
+
can(statement, dialect6) {
|
17049
|
+
return statement.type === "alter_table_alter_column_set_default" && dialect6 === "pg";
|
17722
17050
|
}
|
17723
17051
|
convert(statement) {
|
17724
17052
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17727,8 +17055,8 @@ var init_sqlgenerator = __esm({
|
|
17727
17055
|
}
|
17728
17056
|
};
|
17729
17057
|
SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
17730
|
-
can(statement,
|
17731
|
-
return statement.type === "alter_table_alter_column_set_default" &&
|
17058
|
+
can(statement, dialect6) {
|
17059
|
+
return statement.type === "alter_table_alter_column_set_default" && dialect6 === "sqlite";
|
17732
17060
|
}
|
17733
17061
|
convert(statement) {
|
17734
17062
|
return `/*
|
@@ -17742,8 +17070,8 @@ var init_sqlgenerator = __esm({
|
|
17742
17070
|
}
|
17743
17071
|
};
|
17744
17072
|
PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
17745
|
-
can(statement,
|
17746
|
-
return statement.type === "alter_table_alter_column_drop_default" &&
|
17073
|
+
can(statement, dialect6) {
|
17074
|
+
return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "pg";
|
17747
17075
|
}
|
17748
17076
|
convert(statement) {
|
17749
17077
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17752,24 +17080,24 @@ var init_sqlgenerator = __esm({
|
|
17752
17080
|
}
|
17753
17081
|
};
|
17754
17082
|
MySqlAlterTableAddPk = class extends Convertor {
|
17755
|
-
can(statement,
|
17756
|
-
return statement.type === "alter_table_alter_column_set_pk" &&
|
17083
|
+
can(statement, dialect6) {
|
17084
|
+
return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "mysql";
|
17757
17085
|
}
|
17758
17086
|
convert(statement) {
|
17759
17087
|
return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
|
17760
17088
|
}
|
17761
17089
|
};
|
17762
17090
|
MySqlAlterTableDropPk = class extends Convertor {
|
17763
|
-
can(statement,
|
17764
|
-
return statement.type === "alter_table_alter_column_drop_pk" &&
|
17091
|
+
can(statement, dialect6) {
|
17092
|
+
return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "mysql";
|
17765
17093
|
}
|
17766
17094
|
convert(statement) {
|
17767
17095
|
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
|
17768
17096
|
}
|
17769
17097
|
};
|
17770
17098
|
MySqlModifyColumn = class extends Convertor {
|
17771
|
-
can(statement,
|
17772
|
-
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") &&
|
17099
|
+
can(statement, dialect6) {
|
17100
|
+
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect6 === "mysql";
|
17773
17101
|
}
|
17774
17102
|
convert(statement) {
|
17775
17103
|
const { tableName, columnName } = statement;
|
@@ -17839,8 +17167,8 @@ var init_sqlgenerator = __esm({
|
|
17839
17167
|
}
|
17840
17168
|
};
|
17841
17169
|
SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
17842
|
-
can(statement,
|
17843
|
-
return statement.type === "alter_table_alter_column_drop_default" &&
|
17170
|
+
can(statement, dialect6) {
|
17171
|
+
return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "sqlite";
|
17844
17172
|
}
|
17845
17173
|
convert(statement) {
|
17846
17174
|
return `/*
|
@@ -17854,8 +17182,8 @@ var init_sqlgenerator = __esm({
|
|
17854
17182
|
}
|
17855
17183
|
};
|
17856
17184
|
PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17857
|
-
can(statement,
|
17858
|
-
return statement.type === "create_composite_pk" &&
|
17185
|
+
can(statement, dialect6) {
|
17186
|
+
return statement.type === "create_composite_pk" && dialect6 === "pg";
|
17859
17187
|
}
|
17860
17188
|
convert(statement) {
|
17861
17189
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
@@ -17864,8 +17192,8 @@ var init_sqlgenerator = __esm({
|
|
17864
17192
|
}
|
17865
17193
|
};
|
17866
17194
|
PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17867
|
-
can(statement,
|
17868
|
-
return statement.type === "delete_composite_pk" &&
|
17195
|
+
can(statement, dialect6) {
|
17196
|
+
return statement.type === "delete_composite_pk" && dialect6 === "pg";
|
17869
17197
|
}
|
17870
17198
|
convert(statement) {
|
17871
17199
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
@@ -17874,8 +17202,8 @@ var init_sqlgenerator = __esm({
|
|
17874
17202
|
}
|
17875
17203
|
};
|
17876
17204
|
PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
17877
|
-
can(statement,
|
17878
|
-
return statement.type === "alter_composite_pk" &&
|
17205
|
+
can(statement, dialect6) {
|
17206
|
+
return statement.type === "alter_composite_pk" && dialect6 === "pg";
|
17879
17207
|
}
|
17880
17208
|
convert(statement) {
|
17881
17209
|
const { name, columns } = PgSquasher.unsquashPK(statement.old);
|
@@ -17888,8 +17216,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17888
17216
|
}
|
17889
17217
|
};
|
17890
17218
|
MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17891
|
-
can(statement,
|
17892
|
-
return statement.type === "create_composite_pk" &&
|
17219
|
+
can(statement, dialect6) {
|
17220
|
+
return statement.type === "create_composite_pk" && dialect6 === "mysql";
|
17893
17221
|
}
|
17894
17222
|
convert(statement) {
|
17895
17223
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
@@ -17897,8 +17225,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17897
17225
|
}
|
17898
17226
|
};
|
17899
17227
|
MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17900
|
-
can(statement,
|
17901
|
-
return statement.type === "delete_composite_pk" &&
|
17228
|
+
can(statement, dialect6) {
|
17229
|
+
return statement.type === "delete_composite_pk" && dialect6 === "mysql";
|
17902
17230
|
}
|
17903
17231
|
convert(statement) {
|
17904
17232
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
@@ -17906,8 +17234,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17906
17234
|
}
|
17907
17235
|
};
|
17908
17236
|
MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
17909
|
-
can(statement,
|
17910
|
-
return statement.type === "alter_composite_pk" &&
|
17237
|
+
can(statement, dialect6) {
|
17238
|
+
return statement.type === "alter_composite_pk" && dialect6 === "mysql";
|
17911
17239
|
}
|
17912
17240
|
convert(statement) {
|
17913
17241
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
|
@@ -17918,8 +17246,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17918
17246
|
}
|
17919
17247
|
};
|
17920
17248
|
SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17921
|
-
can(statement,
|
17922
|
-
return statement.type === "create_composite_pk" &&
|
17249
|
+
can(statement, dialect6) {
|
17250
|
+
return statement.type === "create_composite_pk" && dialect6 === "sqlite";
|
17923
17251
|
}
|
17924
17252
|
convert(statement) {
|
17925
17253
|
let msg = "/*\n";
|
@@ -17945,8 +17273,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17945
17273
|
}
|
17946
17274
|
};
|
17947
17275
|
SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17948
|
-
can(statement,
|
17949
|
-
return statement.type === "delete_composite_pk" &&
|
17276
|
+
can(statement, dialect6) {
|
17277
|
+
return statement.type === "delete_composite_pk" && dialect6 === "sqlite";
|
17950
17278
|
}
|
17951
17279
|
convert(statement) {
|
17952
17280
|
let msg = "/*\n";
|
@@ -17972,8 +17300,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17972
17300
|
}
|
17973
17301
|
};
|
17974
17302
|
SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
17975
|
-
can(statement,
|
17976
|
-
return statement.type === "alter_composite_pk" &&
|
17303
|
+
can(statement, dialect6) {
|
17304
|
+
return statement.type === "alter_composite_pk" && dialect6 === "sqlite";
|
17977
17305
|
}
|
17978
17306
|
convert(statement) {
|
17979
17307
|
let msg = "/*\n";
|
@@ -17997,8 +17325,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17997
17325
|
}
|
17998
17326
|
};
|
17999
17327
|
PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
18000
|
-
can(statement,
|
18001
|
-
return statement.type === "alter_table_alter_column_set_pk" &&
|
17328
|
+
can(statement, dialect6) {
|
17329
|
+
return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "pg";
|
18002
17330
|
}
|
18003
17331
|
convert(statement) {
|
18004
17332
|
const { tableName, columnName } = statement;
|
@@ -18007,8 +17335,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18007
17335
|
}
|
18008
17336
|
};
|
18009
17337
|
PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
|
18010
|
-
can(statement,
|
18011
|
-
return statement.type === "alter_table_alter_column_drop_pk" &&
|
17338
|
+
can(statement, dialect6) {
|
17339
|
+
return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "pg";
|
18012
17340
|
}
|
18013
17341
|
convert(statement) {
|
18014
17342
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -18031,8 +17359,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18031
17359
|
}
|
18032
17360
|
};
|
18033
17361
|
PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
18034
|
-
can(statement,
|
18035
|
-
return statement.type === "alter_table_alter_column_set_notnull" &&
|
17362
|
+
can(statement, dialect6) {
|
17363
|
+
return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "pg";
|
18036
17364
|
}
|
18037
17365
|
convert(statement) {
|
18038
17366
|
const { tableName, columnName } = statement;
|
@@ -18041,8 +17369,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18041
17369
|
}
|
18042
17370
|
};
|
18043
17371
|
SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
18044
|
-
can(statement,
|
18045
|
-
return statement.type === "alter_table_alter_column_set_notnull" &&
|
17372
|
+
can(statement, dialect6) {
|
17373
|
+
return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "sqlite";
|
18046
17374
|
}
|
18047
17375
|
convert(statement) {
|
18048
17376
|
return `/*
|
@@ -18056,8 +17384,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18056
17384
|
}
|
18057
17385
|
};
|
18058
17386
|
SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
|
18059
|
-
can(statement,
|
18060
|
-
return statement.type === "alter_table_alter_column_set_autoincrement" &&
|
17387
|
+
can(statement, dialect6) {
|
17388
|
+
return statement.type === "alter_table_alter_column_set_autoincrement" && dialect6 === "sqlite";
|
18061
17389
|
}
|
18062
17390
|
convert(statement) {
|
18063
17391
|
return `/*
|
@@ -18071,8 +17399,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18071
17399
|
}
|
18072
17400
|
};
|
18073
17401
|
SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
|
18074
|
-
can(statement,
|
18075
|
-
return statement.type === "alter_table_alter_column_drop_autoincrement" &&
|
17402
|
+
can(statement, dialect6) {
|
17403
|
+
return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect6 === "sqlite";
|
18076
17404
|
}
|
18077
17405
|
convert(statement) {
|
18078
17406
|
return `/*
|
@@ -18086,8 +17414,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18086
17414
|
}
|
18087
17415
|
};
|
18088
17416
|
PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
18089
|
-
can(statement,
|
18090
|
-
return statement.type === "alter_table_alter_column_drop_notnull" &&
|
17417
|
+
can(statement, dialect6) {
|
17418
|
+
return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "pg";
|
18091
17419
|
}
|
18092
17420
|
convert(statement) {
|
18093
17421
|
const { tableName, columnName } = statement;
|
@@ -18096,8 +17424,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18096
17424
|
}
|
18097
17425
|
};
|
18098
17426
|
SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
18099
|
-
can(statement,
|
18100
|
-
return statement.type === "alter_table_alter_column_drop_notnull" &&
|
17427
|
+
can(statement, dialect6) {
|
17428
|
+
return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "sqlite";
|
18101
17429
|
}
|
18102
17430
|
convert(statement) {
|
18103
17431
|
return `/*
|
@@ -18111,8 +17439,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18111
17439
|
}
|
18112
17440
|
};
|
18113
17441
|
PgCreateForeignKeyConvertor = class extends Convertor {
|
18114
|
-
can(statement,
|
18115
|
-
return statement.type === "create_reference" &&
|
17442
|
+
can(statement, dialect6) {
|
17443
|
+
return statement.type === "create_reference" && dialect6 === "pg";
|
18116
17444
|
}
|
18117
17445
|
convert(statement) {
|
18118
17446
|
const {
|
@@ -18141,8 +17469,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18141
17469
|
}
|
18142
17470
|
};
|
18143
17471
|
SqliteCreateForeignKeyConvertor = class extends Convertor {
|
18144
|
-
can(statement,
|
18145
|
-
return statement.type === "create_reference" &&
|
17472
|
+
can(statement, dialect6) {
|
17473
|
+
return statement.type === "create_reference" && dialect6 === "sqlite";
|
18146
17474
|
}
|
18147
17475
|
convert(statement) {
|
18148
17476
|
return `/*
|
@@ -18155,8 +17483,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18155
17483
|
}
|
18156
17484
|
};
|
18157
17485
|
MySqlCreateForeignKeyConvertor = class extends Convertor {
|
18158
|
-
can(statement,
|
18159
|
-
return statement.type === "create_reference" &&
|
17486
|
+
can(statement, dialect6) {
|
17487
|
+
return statement.type === "create_reference" && dialect6 === "mysql";
|
18160
17488
|
}
|
18161
17489
|
convert(statement) {
|
18162
17490
|
const {
|
@@ -18176,8 +17504,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18176
17504
|
}
|
18177
17505
|
};
|
18178
17506
|
PgAlterForeignKeyConvertor = class extends Convertor {
|
18179
|
-
can(statement,
|
18180
|
-
return statement.type === "alter_reference" &&
|
17507
|
+
can(statement, dialect6) {
|
17508
|
+
return statement.type === "alter_reference" && dialect6 === "pg";
|
18181
17509
|
}
|
18182
17510
|
convert(statement) {
|
18183
17511
|
const newFk = PgSquasher.unsquashFK(statement.data);
|
@@ -18201,8 +17529,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18201
17529
|
}
|
18202
17530
|
};
|
18203
17531
|
SqliteAlterForeignKeyConvertor = class extends Convertor {
|
18204
|
-
can(statement,
|
18205
|
-
return statement.type === "alter_reference" &&
|
17532
|
+
can(statement, dialect6) {
|
17533
|
+
return statement.type === "alter_reference" && dialect6 === "sqlite";
|
18206
17534
|
}
|
18207
17535
|
convert(statement) {
|
18208
17536
|
return `/*
|
@@ -18215,8 +17543,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18215
17543
|
}
|
18216
17544
|
};
|
18217
17545
|
PgDeleteForeignKeyConvertor = class extends Convertor {
|
18218
|
-
can(statement,
|
18219
|
-
return statement.type === "delete_reference" &&
|
17546
|
+
can(statement, dialect6) {
|
17547
|
+
return statement.type === "delete_reference" && dialect6 === "pg";
|
18220
17548
|
}
|
18221
17549
|
convert(statement) {
|
18222
17550
|
const tableFrom = statement.tableName;
|
@@ -18227,8 +17555,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18227
17555
|
}
|
18228
17556
|
};
|
18229
17557
|
SqliteDeleteForeignKeyConvertor = class extends Convertor {
|
18230
|
-
can(statement,
|
18231
|
-
return statement.type === "delete_reference" &&
|
17558
|
+
can(statement, dialect6) {
|
17559
|
+
return statement.type === "delete_reference" && dialect6 === "sqlite";
|
18232
17560
|
}
|
18233
17561
|
convert(statement) {
|
18234
17562
|
return `/*
|
@@ -18241,8 +17569,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18241
17569
|
}
|
18242
17570
|
};
|
18243
17571
|
MySqlDeleteForeignKeyConvertor = class extends Convertor {
|
18244
|
-
can(statement,
|
18245
|
-
return statement.type === "delete_reference" &&
|
17572
|
+
can(statement, dialect6) {
|
17573
|
+
return statement.type === "delete_reference" && dialect6 === "mysql";
|
18246
17574
|
}
|
18247
17575
|
convert(statement) {
|
18248
17576
|
const tableFrom = statement.tableName;
|
@@ -18252,8 +17580,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18252
17580
|
}
|
18253
17581
|
};
|
18254
17582
|
CreatePgIndexConvertor = class extends Convertor {
|
18255
|
-
can(statement,
|
18256
|
-
return statement.type === "create_index" &&
|
17583
|
+
can(statement, dialect6) {
|
17584
|
+
return statement.type === "create_index" && dialect6 === "pg";
|
18257
17585
|
}
|
18258
17586
|
convert(statement) {
|
18259
17587
|
const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18264,8 +17592,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18264
17592
|
}
|
18265
17593
|
};
|
18266
17594
|
CreateMySqlIndexConvertor = class extends Convertor {
|
18267
|
-
can(statement,
|
18268
|
-
return statement.type === "create_index" &&
|
17595
|
+
can(statement, dialect6) {
|
17596
|
+
return statement.type === "create_index" && dialect6 === "mysql";
|
18269
17597
|
}
|
18270
17598
|
convert(statement) {
|
18271
17599
|
const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
|
@@ -18277,8 +17605,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18277
17605
|
}
|
18278
17606
|
};
|
18279
17607
|
CreateSqliteIndexConvertor = class extends Convertor {
|
18280
|
-
can(statement,
|
18281
|
-
return statement.type === "create_index" &&
|
17608
|
+
can(statement, dialect6) {
|
17609
|
+
return statement.type === "create_index" && dialect6 === "sqlite";
|
18282
17610
|
}
|
18283
17611
|
convert(statement) {
|
18284
17612
|
const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
|
@@ -18291,8 +17619,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18291
17619
|
}
|
18292
17620
|
};
|
18293
17621
|
PgDropIndexConvertor = class extends Convertor {
|
18294
|
-
can(statement,
|
18295
|
-
return statement.type === "drop_index" &&
|
17622
|
+
can(statement, dialect6) {
|
17623
|
+
return statement.type === "drop_index" && dialect6 === "pg";
|
18296
17624
|
}
|
18297
17625
|
convert(statement) {
|
18298
17626
|
const { name } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18300,8 +17628,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18300
17628
|
}
|
18301
17629
|
};
|
18302
17630
|
PgCreateSchemaConvertor = class extends Convertor {
|
18303
|
-
can(statement,
|
18304
|
-
return statement.type === "create_schema" &&
|
17631
|
+
can(statement, dialect6) {
|
17632
|
+
return statement.type === "create_schema" && dialect6 === "pg";
|
18305
17633
|
}
|
18306
17634
|
convert(statement) {
|
18307
17635
|
const { name } = statement;
|
@@ -18310,8 +17638,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18310
17638
|
}
|
18311
17639
|
};
|
18312
17640
|
PgRenameSchemaConvertor = class extends Convertor {
|
18313
|
-
can(statement,
|
18314
|
-
return statement.type === "rename_schema" &&
|
17641
|
+
can(statement, dialect6) {
|
17642
|
+
return statement.type === "rename_schema" && dialect6 === "pg";
|
18315
17643
|
}
|
18316
17644
|
convert(statement) {
|
18317
17645
|
const { from, to } = statement;
|
@@ -18320,8 +17648,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18320
17648
|
}
|
18321
17649
|
};
|
18322
17650
|
PgDropSchemaConvertor = class extends Convertor {
|
18323
|
-
can(statement,
|
18324
|
-
return statement.type === "drop_schema" &&
|
17651
|
+
can(statement, dialect6) {
|
17652
|
+
return statement.type === "drop_schema" && dialect6 === "pg";
|
18325
17653
|
}
|
18326
17654
|
convert(statement) {
|
18327
17655
|
const { name } = statement;
|
@@ -18330,8 +17658,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18330
17658
|
}
|
18331
17659
|
};
|
18332
17660
|
PgAlterTableSetSchemaConvertor = class extends Convertor {
|
18333
|
-
can(statement,
|
18334
|
-
return statement.type === "alter_table_set_schema" &&
|
17661
|
+
can(statement, dialect6) {
|
17662
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "pg";
|
18335
17663
|
}
|
18336
17664
|
convert(statement) {
|
18337
17665
|
const { tableName, schema: schema4 } = statement;
|
@@ -18340,8 +17668,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18340
17668
|
}
|
18341
17669
|
};
|
18342
17670
|
PgAlterTableSetNewSchemaConvertor = class extends Convertor {
|
18343
|
-
can(statement,
|
18344
|
-
return statement.type === "alter_table_set_new_schema" &&
|
17671
|
+
can(statement, dialect6) {
|
17672
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "pg";
|
18345
17673
|
}
|
18346
17674
|
convert(statement) {
|
18347
17675
|
const { tableName, to, from } = statement;
|
@@ -18351,8 +17679,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18351
17679
|
}
|
18352
17680
|
};
|
18353
17681
|
PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
18354
|
-
can(statement,
|
18355
|
-
return statement.type === "alter_table_remove_from_schema" &&
|
17682
|
+
can(statement, dialect6) {
|
17683
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
|
18356
17684
|
}
|
18357
17685
|
convert(statement) {
|
18358
17686
|
const { tableName, schema: schema4 } = statement;
|
@@ -18362,8 +17690,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18362
17690
|
}
|
18363
17691
|
};
|
18364
17692
|
SqliteDropIndexConvertor = class extends Convertor {
|
18365
|
-
can(statement,
|
18366
|
-
return statement.type === "drop_index" &&
|
17693
|
+
can(statement, dialect6) {
|
17694
|
+
return statement.type === "drop_index" && dialect6 === "sqlite";
|
18367
17695
|
}
|
18368
17696
|
convert(statement) {
|
18369
17697
|
const { name } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18371,8 +17699,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18371
17699
|
}
|
18372
17700
|
};
|
18373
17701
|
MysqlCreateSchemaConvertor = class extends Convertor {
|
18374
|
-
can(statement,
|
18375
|
-
return statement.type === "create_schema" &&
|
17702
|
+
can(statement, dialect6) {
|
17703
|
+
return statement.type === "create_schema" && dialect6 === "mysql";
|
18376
17704
|
}
|
18377
17705
|
convert(statement) {
|
18378
17706
|
const { name } = statement;
|
@@ -18381,8 +17709,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18381
17709
|
}
|
18382
17710
|
};
|
18383
17711
|
MysqlDropSchemaConvertor = class extends Convertor {
|
18384
|
-
can(statement,
|
18385
|
-
return statement.type === "drop_schema" &&
|
17712
|
+
can(statement, dialect6) {
|
17713
|
+
return statement.type === "drop_schema" && dialect6 === "mysql";
|
18386
17714
|
}
|
18387
17715
|
convert(statement) {
|
18388
17716
|
const { name } = statement;
|
@@ -18391,8 +17719,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18391
17719
|
}
|
18392
17720
|
};
|
18393
17721
|
MysqlAlterTableSetSchemaConvertor = class extends Convertor {
|
18394
|
-
can(statement,
|
18395
|
-
return statement.type === "alter_table_set_schema" &&
|
17722
|
+
can(statement, dialect6) {
|
17723
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
|
18396
17724
|
}
|
18397
17725
|
convert(statement) {
|
18398
17726
|
const { tableName, schema: schema4 } = statement;
|
@@ -18403,8 +17731,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18403
17731
|
}
|
18404
17732
|
};
|
18405
17733
|
MysqlAlterTableSetNewSchemaConvertor = class extends Convertor {
|
18406
|
-
can(statement,
|
18407
|
-
return statement.type === "alter_table_set_new_schema" &&
|
17734
|
+
can(statement, dialect6) {
|
17735
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "mysql";
|
18408
17736
|
}
|
18409
17737
|
convert(statement) {
|
18410
17738
|
const { tableName, to, from } = statement;
|
@@ -18415,8 +17743,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18415
17743
|
}
|
18416
17744
|
};
|
18417
17745
|
MysqlAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
18418
|
-
can(statement,
|
18419
|
-
return statement.type === "alter_table_remove_from_schema" &&
|
17746
|
+
can(statement, dialect6) {
|
17747
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
|
18420
17748
|
}
|
18421
17749
|
convert(statement) {
|
18422
17750
|
const { tableName, schema: schema4 } = statement;
|
@@ -18427,8 +17755,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18427
17755
|
}
|
18428
17756
|
};
|
18429
17757
|
MySqlDropIndexConvertor = class extends Convertor {
|
18430
|
-
can(statement,
|
18431
|
-
return statement.type === "drop_index" &&
|
17758
|
+
can(statement, dialect6) {
|
17759
|
+
return statement.type === "drop_index" && dialect6 === "mysql";
|
18432
17760
|
}
|
18433
17761
|
convert(statement) {
|
18434
17762
|
const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
|
@@ -18514,10 +17842,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18514
17842
|
convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
|
18515
17843
|
convertors.push(new MySqlAlterTableAddPk());
|
18516
17844
|
convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
|
18517
|
-
fromJson = (statements,
|
17845
|
+
fromJson = (statements, dialect6) => {
|
18518
17846
|
const result = statements.map((statement) => {
|
18519
17847
|
const filtered = convertors.filter((it) => {
|
18520
|
-
return it.can(statement,
|
17848
|
+
return it.can(statement, dialect6);
|
18521
17849
|
});
|
18522
17850
|
const convertor = filtered.length === 1 ? filtered[0] : void 0;
|
18523
17851
|
if (!convertor) {
|
@@ -18558,7 +17886,6 @@ drop type __venum;
|
|
18558
17886
|
var import_hanji5, Select;
|
18559
17887
|
var init_selector_ui = __esm({
|
18560
17888
|
"src/cli/selector-ui.ts"() {
|
18561
|
-
"use strict";
|
18562
17889
|
init_source();
|
18563
17890
|
import_hanji5 = __toESM(require_hanji());
|
18564
17891
|
Select = class extends import_hanji5.Prompt {
|
@@ -35160,7 +34487,6 @@ __export(drivers_exports, {
|
|
35160
34487
|
var import_drizzle_orm9, DrizzleDbClient, DrizzleORMPgClient, DrizzleORMMySQLClient, DrizzleORMSQLiteClient, BetterSqlite, MySQL2Client, TursoSqlite, PgPostgres;
|
35161
34488
|
var init_drivers = __esm({
|
35162
34489
|
"src/drivers/index.ts"() {
|
35163
|
-
"use strict";
|
35164
34490
|
import_drizzle_orm9 = require("drizzle-orm");
|
35165
34491
|
DrizzleDbClient = class {
|
35166
34492
|
constructor(db) {
|
@@ -35242,7 +34568,6 @@ __export(mysqlPushUtils_exports, {
|
|
35242
34568
|
var import_hanji9, filterStatements, logSuggestionsAndReturn2;
|
35243
34569
|
var init_mysqlPushUtils = __esm({
|
35244
34570
|
"src/cli/commands/mysqlPushUtils.ts"() {
|
35245
|
-
"use strict";
|
35246
34571
|
init_source();
|
35247
34572
|
import_hanji9 = __toESM(require_hanji());
|
35248
34573
|
init_mysqlSchema();
|
@@ -35518,7 +34843,6 @@ init_pgSerializer();
|
|
35518
34843
|
|
35519
34844
|
// src/introspect-pg.ts
|
35520
34845
|
var import_drizzle_orm8 = require("drizzle-orm");
|
35521
|
-
var import_pluralize = __toESM(require_pluralize());
|
35522
34846
|
var import_relations = require("drizzle-orm/relations");
|
35523
34847
|
|
35524
34848
|
// node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
|
@@ -35620,7 +34944,7 @@ String.prototype.camelCase = function() {
|
|
35620
34944
|
return camelCase(String(this));
|
35621
34945
|
};
|
35622
34946
|
String.prototype.concatIf = function(it, condition) {
|
35623
|
-
return condition ? `${this}${it}` :
|
34947
|
+
return condition ? `${this}${it}` : this;
|
35624
34948
|
};
|
35625
34949
|
Array.prototype.random = function() {
|
35626
34950
|
return this[~~(Math.random() * this.length)];
|