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.mjs
CHANGED
@@ -1085,7 +1085,6 @@ var require_hanji = __commonJS({
|
|
1085
1085
|
var import_hanji, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, ResolveSchemasSelect;
|
1086
1086
|
var init_views = __esm({
|
1087
1087
|
"src/cli/views.ts"() {
|
1088
|
-
"use strict";
|
1089
1088
|
init_source();
|
1090
1089
|
import_hanji = __toESM(require_hanji());
|
1091
1090
|
info = (msg, greyMsg = "") => {
|
@@ -1107,7 +1106,7 @@ var init_views = __esm({
|
|
1107
1106
|
)}`;
|
1108
1107
|
}).join("\n");
|
1109
1108
|
msg += "\n";
|
1110
|
-
const enums = Object.values(
|
1109
|
+
const enums = Object.values(schema4["enums"] || {});
|
1111
1110
|
if (enums.length > 0) {
|
1112
1111
|
msg += "\n";
|
1113
1112
|
msg += source_default.bold(`${enums.length} enums
|
@@ -1122,7 +1121,7 @@ var init_views = __esm({
|
|
1122
1121
|
return msg;
|
1123
1122
|
};
|
1124
1123
|
isRenamePromptItem = (item) => {
|
1125
|
-
return "from"
|
1124
|
+
return item["from"] && item["to"];
|
1126
1125
|
};
|
1127
1126
|
ResolveColumnSelect = class extends import_hanji.Prompt {
|
1128
1127
|
constructor(tableName, base, data) {
|
@@ -1272,7 +1271,6 @@ import { is } from "drizzle-orm";
|
|
1272
1271
|
var prepareFromExports, prepareFromMySqlImports;
|
1273
1272
|
var init_mysqlImports = __esm({
|
1274
1273
|
"src/serializer/mysqlImports.ts"() {
|
1275
|
-
"use strict";
|
1276
1274
|
init_utils();
|
1277
1275
|
prepareFromExports = (exports) => {
|
1278
1276
|
const tables = [];
|
@@ -1312,7 +1310,6 @@ var init_mysqlImports = __esm({
|
|
1312
1310
|
var withStyle;
|
1313
1311
|
var init_outputs = __esm({
|
1314
1312
|
"src/cli/validations/outputs.ts"() {
|
1315
|
-
"use strict";
|
1316
1313
|
init_source();
|
1317
1314
|
withStyle = {
|
1318
1315
|
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
@@ -1358,7 +1355,6 @@ function clearDefaults(defaultValue, collate) {
|
|
1358
1355
|
var dialect, indexName, generateMySqlSnapshot, fromDatabase;
|
1359
1356
|
var init_mysqlSerializer = __esm({
|
1360
1357
|
"src/serializer/mysqlSerializer.ts"() {
|
1361
|
-
"use strict";
|
1362
1358
|
init_serializer();
|
1363
1359
|
init_outputs();
|
1364
1360
|
init_source();
|
@@ -1570,8 +1566,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1570
1566
|
lock: value.config.lock
|
1571
1567
|
};
|
1572
1568
|
});
|
1573
|
-
|
1574
|
-
result[tableKey] = {
|
1569
|
+
result[tableName] = {
|
1575
1570
|
name: tableName,
|
1576
1571
|
schema: schema4,
|
1577
1572
|
columns: columnsObject,
|
@@ -1585,7 +1580,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1585
1580
|
mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
|
1586
1581
|
);
|
1587
1582
|
return {
|
1588
|
-
version: "
|
1583
|
+
version: "5",
|
1589
1584
|
dialect: "mysql",
|
1590
1585
|
tables: result,
|
1591
1586
|
schemas,
|
@@ -1840,7 +1835,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
1840
1835
|
}
|
1841
1836
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
1842
1837
|
return {
|
1843
|
-
version: "
|
1838
|
+
version: "5",
|
1844
1839
|
dialect: "mysql",
|
1845
1840
|
tables: result,
|
1846
1841
|
schemas: schemasObject,
|
@@ -1871,7 +1866,6 @@ import { is as is3, SQL as SQL2, getTableName as getTableName2 } from "drizzle-o
|
|
1871
1866
|
var dialect2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
1872
1867
|
var init_pgSerializer = __esm({
|
1873
1868
|
"src/serializer/pgSerializer.ts"() {
|
1874
|
-
"use strict";
|
1875
1869
|
init_serializer();
|
1876
1870
|
init_source();
|
1877
1871
|
init_outputs();
|
@@ -2059,8 +2053,7 @@ ${withStyle.errorWarning(
|
|
2059
2053
|
isUnique: value.config.unique ?? false
|
2060
2054
|
};
|
2061
2055
|
});
|
2062
|
-
|
2063
|
-
result[tableKey] = {
|
2056
|
+
result[tableName] = {
|
2064
2057
|
name: tableName,
|
2065
2058
|
schema: schema4 ?? "",
|
2066
2059
|
columns: columnsObject,
|
@@ -2089,7 +2082,7 @@ ${withStyle.errorWarning(
|
|
2089
2082
|
}).map((it) => [it.schemaName, it.schemaName])
|
2090
2083
|
);
|
2091
2084
|
return {
|
2092
|
-
version: "
|
2085
|
+
version: "5",
|
2093
2086
|
dialect: "pg",
|
2094
2087
|
tables: result,
|
2095
2088
|
enums: enumsToReturn,
|
@@ -2110,7 +2103,7 @@ ${withStyle.errorWarning(
|
|
2110
2103
|
--end;
|
2111
2104
|
return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
|
2112
2105
|
};
|
2113
|
-
fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
|
2106
|
+
fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
|
2114
2107
|
const result = {};
|
2115
2108
|
const internals = { tables: {} };
|
2116
2109
|
const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
|
@@ -2437,7 +2430,7 @@ ${withStyle.errorWarning(
|
|
2437
2430
|
}
|
2438
2431
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
2439
2432
|
return {
|
2440
|
-
version: "
|
2433
|
+
version: "5",
|
2441
2434
|
dialect: "pg",
|
2442
2435
|
tables: result,
|
2443
2436
|
enums: enumsToReturn,
|
@@ -2520,7 +2513,6 @@ import { is as is4 } from "drizzle-orm";
|
|
2520
2513
|
var prepareFromExports2, prepareFromSqliteImports;
|
2521
2514
|
var init_sqliteImports = __esm({
|
2522
2515
|
"src/serializer/sqliteImports.ts"() {
|
2523
|
-
"use strict";
|
2524
2516
|
init_utils();
|
2525
2517
|
prepareFromExports2 = (exports) => {
|
2526
2518
|
const tables = [];
|
@@ -2564,7 +2556,6 @@ import {
|
|
2564
2556
|
uniqueKeyName as uniqueKeyName3
|
2565
2557
|
} from "drizzle-orm/sqlite-core";
|
2566
2558
|
function mapSqlToSqliteType(sqlType) {
|
2567
|
-
const lowered = sqlType.toLowerCase();
|
2568
2559
|
if ([
|
2569
2560
|
"int",
|
2570
2561
|
"integer",
|
@@ -2576,27 +2567,24 @@ function mapSqlToSqliteType(sqlType) {
|
|
2576
2567
|
"unsigned big int",
|
2577
2568
|
"int2",
|
2578
2569
|
"int8"
|
2579
|
-
].
|
2570
|
+
].includes(sqlType.toLowerCase())) {
|
2580
2571
|
return "integer";
|
2581
2572
|
} else if ([
|
2582
2573
|
"character",
|
2583
2574
|
"varchar",
|
2584
|
-
"
|
2585
|
-
"national varying character",
|
2575
|
+
"vatying character",
|
2586
2576
|
"nchar",
|
2587
2577
|
"native character",
|
2588
2578
|
"nvarchar",
|
2589
2579
|
"text",
|
2590
2580
|
"clob"
|
2591
|
-
].some((it) =>
|
2592
|
-
const match2 = lowered.match(/\d+/);
|
2593
|
-
if (match2) {
|
2594
|
-
return `text(${match2[0]})`;
|
2595
|
-
}
|
2581
|
+
].some((it) => it.startsWith(sqlType.toLowerCase()))) {
|
2596
2582
|
return "text";
|
2597
|
-
} else if (
|
2583
|
+
} else if (sqlType.toLowerCase() === "blob") {
|
2598
2584
|
return "blob";
|
2599
|
-
} else if (["real", "double", "double precision", "float"].
|
2585
|
+
} else if (["real", "double", "double precision", "float"].includes(
|
2586
|
+
sqlType.toLowerCase()
|
2587
|
+
)) {
|
2600
2588
|
return "real";
|
2601
2589
|
} else {
|
2602
2590
|
return "numeric";
|
@@ -2605,7 +2593,6 @@ function mapSqlToSqliteType(sqlType) {
|
|
2605
2593
|
var dialect3, generateSqliteSnapshot, fromDatabase3;
|
2606
2594
|
var init_sqliteSerializer = __esm({
|
2607
2595
|
"src/serializer/sqliteSerializer.ts"() {
|
2608
|
-
"use strict";
|
2609
2596
|
init_serializer();
|
2610
2597
|
init_outputs();
|
2611
2598
|
init_source();
|
@@ -2979,7 +2966,6 @@ import * as glob from "glob";
|
|
2979
2966
|
var sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
|
2980
2967
|
var init_serializer = __esm({
|
2981
2968
|
"src/serializer/index.ts"() {
|
2982
|
-
"use strict";
|
2983
2969
|
init_source();
|
2984
2970
|
init_views();
|
2985
2971
|
sqlToStr = (sql2) => {
|
@@ -3046,26 +3032,6 @@ ${filenames.join("\n")}
|
|
3046
3032
|
}
|
3047
3033
|
});
|
3048
3034
|
|
3049
|
-
// src/global.ts
|
3050
|
-
function assertUnreachable(x) {
|
3051
|
-
throw new Error("Didn't expect to get here");
|
3052
|
-
}
|
3053
|
-
var originUUID, snapshotVersion, mapValues;
|
3054
|
-
var init_global = __esm({
|
3055
|
-
"src/global.ts"() {
|
3056
|
-
"use strict";
|
3057
|
-
originUUID = "00000000-0000-0000-0000-000000000000";
|
3058
|
-
snapshotVersion = "6";
|
3059
|
-
mapValues = (obj, map) => {
|
3060
|
-
const result = Object.keys(obj).reduce(function(result2, key) {
|
3061
|
-
result2[key] = map(obj[key]);
|
3062
|
-
return result2;
|
3063
|
-
}, {});
|
3064
|
-
return result;
|
3065
|
-
};
|
3066
|
-
}
|
3067
|
-
});
|
3068
|
-
|
3069
3035
|
// node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
|
3070
3036
|
function getErrorMap() {
|
3071
3037
|
return overrideErrorMap;
|
@@ -6212,1250 +6178,132 @@ var init_lib = __esm({
|
|
6212
6178
|
}
|
6213
6179
|
});
|
6214
6180
|
|
6215
|
-
// src/
|
6216
|
-
var
|
6217
|
-
|
6218
|
-
|
6219
|
-
|
6220
|
-
|
6221
|
-
|
6222
|
-
|
6223
|
-
|
6224
|
-
|
6225
|
-
|
6226
|
-
|
6227
|
-
|
6228
|
-
|
6229
|
-
|
6230
|
-
|
6231
|
-
|
6232
|
-
|
6233
|
-
|
6234
|
-
|
6235
|
-
|
6236
|
-
|
6237
|
-
|
6238
|
-
|
6239
|
-
|
6240
|
-
|
6241
|
-
|
6242
|
-
|
6243
|
-
|
6244
|
-
autoincrement: booleanType().optional(),
|
6245
|
-
default: anyType().optional(),
|
6246
|
-
onUpdate: anyType().optional()
|
6247
|
-
}).strict();
|
6248
|
-
tableV3 = objectType({
|
6249
|
-
name: stringType(),
|
6250
|
-
columns: recordType(stringType(), column),
|
6251
|
-
indexes: recordType(stringType(), index),
|
6252
|
-
foreignKeys: recordType(stringType(), fk)
|
6253
|
-
}).strict();
|
6254
|
-
compositePK = objectType({
|
6255
|
-
name: stringType(),
|
6256
|
-
columns: stringType().array()
|
6257
|
-
}).strict();
|
6258
|
-
uniqueConstraint = objectType({
|
6259
|
-
name: stringType(),
|
6260
|
-
columns: stringType().array()
|
6261
|
-
}).strict();
|
6262
|
-
tableV4 = objectType({
|
6263
|
-
name: stringType(),
|
6264
|
-
schema: stringType().optional(),
|
6265
|
-
columns: recordType(stringType(), column),
|
6266
|
-
indexes: recordType(stringType(), index),
|
6267
|
-
foreignKeys: recordType(stringType(), fk)
|
6268
|
-
}).strict();
|
6269
|
-
table = objectType({
|
6270
|
-
name: stringType(),
|
6271
|
-
schema: stringType().optional(),
|
6272
|
-
columns: recordType(stringType(), column),
|
6273
|
-
indexes: recordType(stringType(), index),
|
6274
|
-
foreignKeys: recordType(stringType(), fk),
|
6275
|
-
compositePrimaryKeys: recordType(stringType(), compositePK),
|
6276
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
6277
|
-
}).strict();
|
6278
|
-
kitInternals = objectType({
|
6279
|
-
tables: recordType(
|
6280
|
-
stringType(),
|
6281
|
-
objectType({
|
6282
|
-
columns: recordType(
|
6283
|
-
stringType(),
|
6284
|
-
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
6285
|
-
)
|
6286
|
-
}).optional()
|
6287
|
-
)
|
6288
|
-
}).optional();
|
6289
|
-
dialect4 = literalType("mysql");
|
6290
|
-
schemaHash = objectType({
|
6291
|
-
id: stringType(),
|
6292
|
-
prevId: stringType()
|
6293
|
-
});
|
6294
|
-
schemaInternalV3 = objectType({
|
6295
|
-
version: literalType("3"),
|
6296
|
-
dialect: dialect4,
|
6297
|
-
tables: recordType(stringType(), tableV3)
|
6298
|
-
}).strict();
|
6299
|
-
schemaInternalV4 = objectType({
|
6300
|
-
version: literalType("4"),
|
6301
|
-
dialect: dialect4,
|
6302
|
-
tables: recordType(stringType(), tableV4),
|
6303
|
-
schemas: recordType(stringType(), stringType())
|
6304
|
-
}).strict();
|
6305
|
-
schemaInternalV5 = objectType({
|
6306
|
-
version: literalType("5"),
|
6307
|
-
dialect: dialect4,
|
6308
|
-
tables: recordType(stringType(), table),
|
6309
|
-
schemas: recordType(stringType(), stringType()),
|
6310
|
-
_meta: objectType({
|
6311
|
-
schemas: recordType(stringType(), stringType()),
|
6312
|
-
tables: recordType(stringType(), stringType()),
|
6313
|
-
columns: recordType(stringType(), stringType())
|
6314
|
-
}),
|
6315
|
-
internal: kitInternals
|
6316
|
-
}).strict();
|
6317
|
-
schemaInternalV6 = objectType({
|
6318
|
-
version: literalType("6"),
|
6319
|
-
dialect: dialect4,
|
6320
|
-
tables: recordType(stringType(), table),
|
6321
|
-
schemas: recordType(stringType(), stringType()),
|
6322
|
-
_meta: objectType({
|
6323
|
-
schemas: recordType(stringType(), stringType()),
|
6324
|
-
tables: recordType(stringType(), stringType()),
|
6325
|
-
columns: recordType(stringType(), stringType())
|
6326
|
-
}),
|
6327
|
-
internal: kitInternals
|
6328
|
-
}).strict();
|
6329
|
-
schemaInternal = objectType({
|
6330
|
-
version: literalType("6"),
|
6331
|
-
dialect: dialect4,
|
6332
|
-
tables: recordType(stringType(), table),
|
6333
|
-
schemas: recordType(stringType(), stringType()),
|
6334
|
-
_meta: objectType({
|
6335
|
-
schemas: recordType(stringType(), stringType()),
|
6336
|
-
tables: recordType(stringType(), stringType()),
|
6337
|
-
columns: recordType(stringType(), stringType())
|
6338
|
-
}),
|
6339
|
-
internal: kitInternals
|
6340
|
-
}).strict();
|
6341
|
-
schemaV3 = schemaInternalV3.merge(schemaHash);
|
6342
|
-
schemaV4 = schemaInternalV4.merge(schemaHash);
|
6343
|
-
schemaV5 = schemaInternalV5.merge(schemaHash);
|
6344
|
-
schema2 = schemaInternal.merge(schemaHash);
|
6345
|
-
tableSquashedV4 = objectType({
|
6346
|
-
name: stringType(),
|
6347
|
-
schema: stringType().optional(),
|
6348
|
-
columns: recordType(stringType(), column),
|
6349
|
-
indexes: recordType(stringType(), stringType()),
|
6350
|
-
foreignKeys: recordType(stringType(), stringType())
|
6351
|
-
}).strict();
|
6352
|
-
tableSquashed = objectType({
|
6353
|
-
name: stringType(),
|
6354
|
-
schema: stringType().optional(),
|
6355
|
-
columns: recordType(stringType(), column),
|
6356
|
-
indexes: recordType(stringType(), stringType()),
|
6357
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6358
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6359
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6360
|
-
}).strict();
|
6361
|
-
schemaSquashed = objectType({
|
6362
|
-
version: literalType("5"),
|
6363
|
-
dialect: dialect4,
|
6364
|
-
tables: recordType(stringType(), tableSquashed),
|
6365
|
-
schemas: recordType(stringType(), stringType())
|
6366
|
-
}).strict();
|
6367
|
-
schemaSquashedV4 = objectType({
|
6368
|
-
version: literalType("4"),
|
6369
|
-
dialect: dialect4,
|
6370
|
-
tables: recordType(stringType(), tableSquashedV4),
|
6371
|
-
schemas: recordType(stringType(), stringType())
|
6372
|
-
}).strict();
|
6373
|
-
MySqlSquasher = {
|
6374
|
-
squashIdx: (idx) => {
|
6375
|
-
index.parse(idx);
|
6376
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
|
6377
|
-
},
|
6378
|
-
unsquashIdx: (input) => {
|
6379
|
-
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
6380
|
-
const destructed = {
|
6381
|
-
name,
|
6382
|
-
columns: columnsString.split(","),
|
6383
|
-
isUnique: isUnique === "true",
|
6384
|
-
using: using ? using : void 0,
|
6385
|
-
algorithm: algorithm ? algorithm : void 0,
|
6386
|
-
lock: lock ? lock : void 0
|
6387
|
-
};
|
6388
|
-
return index.parse(destructed);
|
6389
|
-
},
|
6390
|
-
squashPK: (pk) => {
|
6391
|
-
return `${pk.name};${pk.columns.join(",")}`;
|
6392
|
-
},
|
6393
|
-
unsquashPK: (pk) => {
|
6394
|
-
const splitted = pk.split(";");
|
6395
|
-
return { name: splitted[0], columns: splitted[1].split(",") };
|
6396
|
-
},
|
6397
|
-
squashUnique: (unq) => {
|
6398
|
-
return `${unq.name};${unq.columns.join(",")}`;
|
6399
|
-
},
|
6400
|
-
unsquashUnique: (unq) => {
|
6401
|
-
const [name, columns] = unq.split(";");
|
6402
|
-
return { name, columns: columns.split(",") };
|
6403
|
-
},
|
6404
|
-
squashFK: (fk4) => {
|
6405
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
6406
|
-
},
|
6407
|
-
unsquashFK: (input) => {
|
6408
|
-
const [
|
6409
|
-
name,
|
6410
|
-
tableFrom,
|
6411
|
-
columnsFromStr,
|
6412
|
-
tableTo,
|
6413
|
-
columnsToStr,
|
6414
|
-
onUpdate,
|
6415
|
-
onDelete
|
6416
|
-
] = input.split(";");
|
6417
|
-
const result = fk.parse({
|
6418
|
-
name,
|
6419
|
-
tableFrom,
|
6420
|
-
columnsFrom: columnsFromStr.split(","),
|
6421
|
-
tableTo,
|
6422
|
-
columnsTo: columnsToStr.split(","),
|
6423
|
-
onUpdate,
|
6424
|
-
onDelete
|
6425
|
-
});
|
6426
|
-
return result;
|
6181
|
+
// src/cli/commands/_es5.ts
|
6182
|
+
var es5_exports = {};
|
6183
|
+
__export(es5_exports, {
|
6184
|
+
default: () => es5_default
|
6185
|
+
});
|
6186
|
+
var _, es5_default;
|
6187
|
+
var init_es5 = __esm({
|
6188
|
+
"src/cli/commands/_es5.ts"() {
|
6189
|
+
_ = "";
|
6190
|
+
es5_default = _;
|
6191
|
+
}
|
6192
|
+
});
|
6193
|
+
|
6194
|
+
// node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
6195
|
+
var require_ms = __commonJS({
|
6196
|
+
"node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module) {
|
6197
|
+
var s = 1e3;
|
6198
|
+
var m = s * 60;
|
6199
|
+
var h = m * 60;
|
6200
|
+
var d = h * 24;
|
6201
|
+
var w = d * 7;
|
6202
|
+
var y = d * 365.25;
|
6203
|
+
module.exports = function(val, options) {
|
6204
|
+
options = options || {};
|
6205
|
+
var type = typeof val;
|
6206
|
+
if (type === "string" && val.length > 0) {
|
6207
|
+
return parse(val);
|
6208
|
+
} else if (type === "number" && isFinite(val)) {
|
6209
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
6427
6210
|
}
|
6428
|
-
|
6429
|
-
|
6430
|
-
const mappedTables = Object.fromEntries(
|
6431
|
-
Object.entries(json.tables).map((it) => {
|
6432
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6433
|
-
return MySqlSquasher.squashIdx(index4);
|
6434
|
-
});
|
6435
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6436
|
-
return MySqlSquasher.squashFK(fk4);
|
6437
|
-
});
|
6438
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6439
|
-
return MySqlSquasher.squashPK(pk);
|
6440
|
-
});
|
6441
|
-
const squashedUniqueConstraints = mapValues(
|
6442
|
-
it[1].uniqueConstraints,
|
6443
|
-
(unq) => {
|
6444
|
-
return MySqlSquasher.squashUnique(unq);
|
6445
|
-
}
|
6446
|
-
);
|
6447
|
-
return [
|
6448
|
-
it[0],
|
6449
|
-
{
|
6450
|
-
name: it[1].name,
|
6451
|
-
schema: it[1].schema,
|
6452
|
-
columns: it[1].columns,
|
6453
|
-
indexes: squashedIndexes,
|
6454
|
-
foreignKeys: squashedFKs,
|
6455
|
-
compositePrimaryKeys: squashedPKs,
|
6456
|
-
uniqueConstraints: squashedUniqueConstraints
|
6457
|
-
}
|
6458
|
-
];
|
6459
|
-
})
|
6211
|
+
throw new Error(
|
6212
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
6460
6213
|
);
|
6461
|
-
return {
|
6462
|
-
version: "5",
|
6463
|
-
dialect: json.dialect,
|
6464
|
-
tables: mappedTables,
|
6465
|
-
schemas: json.schemas
|
6466
|
-
};
|
6467
6214
|
};
|
6468
|
-
|
6469
|
-
|
6470
|
-
|
6471
|
-
|
6472
|
-
dryMySql = mysqlSchema.parse({
|
6473
|
-
version: snapshotVersion,
|
6474
|
-
dialect: "mysql",
|
6475
|
-
id: originUUID,
|
6476
|
-
prevId: "",
|
6477
|
-
tables: {},
|
6478
|
-
schemas: {},
|
6479
|
-
_meta: {
|
6480
|
-
schemas: {},
|
6481
|
-
tables: {},
|
6482
|
-
columns: {}
|
6215
|
+
function parse(str) {
|
6216
|
+
str = String(str);
|
6217
|
+
if (str.length > 100) {
|
6218
|
+
return;
|
6483
6219
|
}
|
6484
|
-
|
6485
|
-
|
6486
|
-
|
6487
|
-
|
6488
|
-
|
6489
|
-
|
6490
|
-
var
|
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
|
-
|
6555
|
-
|
6556
|
-
|
6557
|
-
|
6558
|
-
|
6559
|
-
|
6560
|
-
|
6561
|
-
|
6562
|
-
|
6563
|
-
|
6564
|
-
|
6565
|
-
|
6566
|
-
}
|
6567
|
-
|
6568
|
-
|
6569
|
-
|
6570
|
-
|
6571
|
-
notNull: booleanType(),
|
6572
|
-
default: anyType().optional(),
|
6573
|
-
isUnique: anyType().optional(),
|
6574
|
-
uniqueName: stringType().optional(),
|
6575
|
-
nullsNotDistinct: booleanType().optional()
|
6576
|
-
}).strict();
|
6577
|
-
tableV32 = objectType({
|
6578
|
-
name: stringType(),
|
6579
|
-
columns: recordType(stringType(), column2),
|
6580
|
-
indexes: recordType(stringType(), index2),
|
6581
|
-
foreignKeys: recordType(stringType(), fk2)
|
6582
|
-
}).strict();
|
6583
|
-
compositePK2 = objectType({
|
6584
|
-
name: stringType(),
|
6585
|
-
columns: stringType().array()
|
6586
|
-
}).strict();
|
6587
|
-
uniqueConstraint2 = objectType({
|
6588
|
-
name: stringType(),
|
6589
|
-
columns: stringType().array(),
|
6590
|
-
nullsNotDistinct: booleanType()
|
6591
|
-
}).strict();
|
6592
|
-
tableV42 = objectType({
|
6593
|
-
name: stringType(),
|
6594
|
-
schema: stringType(),
|
6595
|
-
columns: recordType(stringType(), column2),
|
6596
|
-
indexes: recordType(stringType(), index2),
|
6597
|
-
foreignKeys: recordType(stringType(), fk2)
|
6598
|
-
}).strict();
|
6599
|
-
table2 = objectType({
|
6600
|
-
name: stringType(),
|
6601
|
-
schema: stringType(),
|
6602
|
-
columns: recordType(stringType(), column2),
|
6603
|
-
indexes: recordType(stringType(), index2),
|
6604
|
-
foreignKeys: recordType(stringType(), fk2),
|
6605
|
-
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
6606
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
6607
|
-
}).strict();
|
6608
|
-
schemaHash2 = objectType({
|
6609
|
-
id: stringType(),
|
6610
|
-
prevId: stringType()
|
6611
|
-
});
|
6612
|
-
kitInternals2 = objectType({
|
6613
|
-
tables: recordType(
|
6614
|
-
stringType(),
|
6615
|
-
objectType({
|
6616
|
-
columns: recordType(
|
6617
|
-
stringType(),
|
6618
|
-
objectType({
|
6619
|
-
isArray: booleanType().optional(),
|
6620
|
-
dimensions: numberType().optional(),
|
6621
|
-
rawType: stringType().optional()
|
6622
|
-
}).optional()
|
6623
|
-
)
|
6624
|
-
}).optional()
|
6625
|
-
)
|
6626
|
-
}).optional();
|
6627
|
-
pgSchemaInternalV3 = objectType({
|
6628
|
-
version: literalType("3"),
|
6629
|
-
dialect: literalType("pg"),
|
6630
|
-
tables: recordType(stringType(), tableV32),
|
6631
|
-
enums: recordType(stringType(), enumSchema)
|
6632
|
-
}).strict();
|
6633
|
-
pgSchemaInternalV4 = objectType({
|
6634
|
-
version: literalType("4"),
|
6635
|
-
dialect: literalType("pg"),
|
6636
|
-
tables: recordType(stringType(), tableV42),
|
6637
|
-
enums: recordType(stringType(), enumSchema),
|
6638
|
-
schemas: recordType(stringType(), stringType())
|
6639
|
-
}).strict();
|
6640
|
-
pgSchemaInternalV5 = objectType({
|
6641
|
-
version: literalType("5"),
|
6642
|
-
dialect: literalType("pg"),
|
6643
|
-
tables: recordType(stringType(), table2),
|
6644
|
-
enums: recordType(stringType(), enumSchema),
|
6645
|
-
schemas: recordType(stringType(), stringType()),
|
6646
|
-
_meta: objectType({
|
6647
|
-
schemas: recordType(stringType(), stringType()),
|
6648
|
-
tables: recordType(stringType(), stringType()),
|
6649
|
-
columns: recordType(stringType(), stringType())
|
6650
|
-
}),
|
6651
|
-
internal: kitInternals2
|
6652
|
-
}).strict();
|
6653
|
-
pgSchemaExternal = objectType({
|
6654
|
-
version: literalType("5"),
|
6655
|
-
dialect: literalType("pg"),
|
6656
|
-
tables: arrayType(table2),
|
6657
|
-
enums: arrayType(enumSchema),
|
6658
|
-
schemas: arrayType(objectType({ name: stringType() })),
|
6659
|
-
_meta: objectType({
|
6660
|
-
schemas: recordType(stringType(), stringType()),
|
6661
|
-
tables: recordType(stringType(), stringType()),
|
6662
|
-
columns: recordType(stringType(), stringType())
|
6663
|
-
})
|
6664
|
-
}).strict();
|
6665
|
-
pgSchemaInternal = objectType({
|
6666
|
-
version: literalType("6"),
|
6667
|
-
dialect: literalType("pg"),
|
6668
|
-
tables: recordType(stringType(), table2),
|
6669
|
-
enums: recordType(stringType(), enumSchema),
|
6670
|
-
schemas: recordType(stringType(), stringType()),
|
6671
|
-
_meta: objectType({
|
6672
|
-
schemas: recordType(stringType(), stringType()),
|
6673
|
-
tables: recordType(stringType(), stringType()),
|
6674
|
-
columns: recordType(stringType(), stringType())
|
6675
|
-
}),
|
6676
|
-
internal: kitInternals2
|
6677
|
-
}).strict();
|
6678
|
-
tableSquashed2 = objectType({
|
6679
|
-
name: stringType(),
|
6680
|
-
schema: stringType(),
|
6681
|
-
columns: recordType(stringType(), column2),
|
6682
|
-
indexes: recordType(stringType(), stringType()),
|
6683
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6684
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6685
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
6686
|
-
}).strict();
|
6687
|
-
tableSquashedV42 = objectType({
|
6688
|
-
name: stringType(),
|
6689
|
-
schema: stringType(),
|
6690
|
-
columns: recordType(stringType(), column2),
|
6691
|
-
indexes: recordType(stringType(), stringType()),
|
6692
|
-
foreignKeys: recordType(stringType(), stringType())
|
6693
|
-
}).strict();
|
6694
|
-
pgSchemaSquashedV4 = objectType({
|
6695
|
-
version: literalType("4"),
|
6696
|
-
dialect: enumType(["pg"]),
|
6697
|
-
tables: recordType(stringType(), tableSquashedV42),
|
6698
|
-
enums: recordType(stringType(), enumSchema),
|
6699
|
-
schemas: recordType(stringType(), stringType())
|
6700
|
-
}).strict();
|
6701
|
-
pgSchemaSquashed = objectType({
|
6702
|
-
version: literalType("6"),
|
6703
|
-
dialect: enumType(["pg"]),
|
6704
|
-
tables: recordType(stringType(), tableSquashed2),
|
6705
|
-
enums: recordType(stringType(), enumSchema),
|
6706
|
-
schemas: recordType(stringType(), stringType())
|
6707
|
-
}).strict();
|
6708
|
-
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
6709
|
-
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
6710
|
-
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
6711
|
-
pgSchema = pgSchemaInternal.merge(schemaHash2);
|
6712
|
-
backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
|
6713
|
-
PgSquasher = {
|
6714
|
-
squashIdx: (idx) => {
|
6715
|
-
index2.parse(idx);
|
6716
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
|
6717
|
-
},
|
6718
|
-
unsquashIdx: (input) => {
|
6719
|
-
const [name, columnsString, isUnique] = input.split(";");
|
6720
|
-
const result = index2.parse({
|
6721
|
-
name,
|
6722
|
-
columns: columnsString.split(","),
|
6723
|
-
isUnique: isUnique === "true"
|
6724
|
-
});
|
6725
|
-
return result;
|
6726
|
-
},
|
6727
|
-
squashFK: (fk4) => {
|
6728
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
6729
|
-
},
|
6730
|
-
squashPK: (pk) => {
|
6731
|
-
return `${pk.columns.join(",")};${pk.name}`;
|
6732
|
-
},
|
6733
|
-
unsquashPK: (pk) => {
|
6734
|
-
const splitted = pk.split(";");
|
6735
|
-
return { name: splitted[1], columns: splitted[0].split(",") };
|
6736
|
-
},
|
6737
|
-
squashUnique: (unq) => {
|
6738
|
-
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
6739
|
-
},
|
6740
|
-
unsquashUnique: (unq) => {
|
6741
|
-
const [name, columns, nullsNotDistinct] = unq.split(";");
|
6742
|
-
return {
|
6743
|
-
name,
|
6744
|
-
columns: columns.split(","),
|
6745
|
-
nullsNotDistinct: nullsNotDistinct === "true"
|
6746
|
-
};
|
6747
|
-
},
|
6748
|
-
unsquashFK: (input) => {
|
6749
|
-
const [
|
6750
|
-
name,
|
6751
|
-
tableFrom,
|
6752
|
-
columnsFromStr,
|
6753
|
-
tableTo,
|
6754
|
-
columnsToStr,
|
6755
|
-
onUpdate,
|
6756
|
-
onDelete,
|
6757
|
-
schemaTo
|
6758
|
-
] = input.split(";");
|
6759
|
-
const result = fk2.parse({
|
6760
|
-
name,
|
6761
|
-
tableFrom,
|
6762
|
-
columnsFrom: columnsFromStr.split(","),
|
6763
|
-
schemaTo,
|
6764
|
-
tableTo,
|
6765
|
-
columnsTo: columnsToStr.split(","),
|
6766
|
-
onUpdate,
|
6767
|
-
onDelete
|
6768
|
-
});
|
6769
|
-
return result;
|
6770
|
-
}
|
6771
|
-
};
|
6772
|
-
squashPgScheme = (json) => {
|
6773
|
-
const mappedTables = Object.fromEntries(
|
6774
|
-
Object.entries(json.tables).map((it) => {
|
6775
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6776
|
-
return PgSquasher.squashIdx(index4);
|
6777
|
-
});
|
6778
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6779
|
-
return PgSquasher.squashFK(fk4);
|
6780
|
-
});
|
6781
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6782
|
-
return PgSquasher.squashPK(pk);
|
6783
|
-
});
|
6784
|
-
const squashedUniqueConstraints = mapValues(
|
6785
|
-
it[1].uniqueConstraints,
|
6786
|
-
(unq) => {
|
6787
|
-
return PgSquasher.squashUnique(unq);
|
6788
|
-
}
|
6789
|
-
);
|
6790
|
-
return [
|
6791
|
-
it[0],
|
6792
|
-
{
|
6793
|
-
name: it[1].name,
|
6794
|
-
schema: it[1].schema,
|
6795
|
-
columns: it[1].columns,
|
6796
|
-
indexes: squashedIndexes,
|
6797
|
-
foreignKeys: squashedFKs,
|
6798
|
-
compositePrimaryKeys: squashedPKs,
|
6799
|
-
uniqueConstraints: squashedUniqueConstraints
|
6800
|
-
}
|
6801
|
-
];
|
6802
|
-
})
|
6803
|
-
);
|
6804
|
-
return {
|
6805
|
-
version: "6",
|
6806
|
-
dialect: json.dialect,
|
6807
|
-
tables: mappedTables,
|
6808
|
-
enums: json.enums,
|
6809
|
-
schemas: json.schemas
|
6810
|
-
};
|
6811
|
-
};
|
6812
|
-
dryPg = pgSchema.parse({
|
6813
|
-
version: snapshotVersion,
|
6814
|
-
dialect: "pg",
|
6815
|
-
id: originUUID,
|
6816
|
-
prevId: "",
|
6817
|
-
tables: {},
|
6818
|
-
enums: {},
|
6819
|
-
schemas: {},
|
6820
|
-
_meta: {
|
6821
|
-
schemas: {},
|
6822
|
-
tables: {},
|
6823
|
-
columns: {}
|
6824
|
-
}
|
6825
|
-
});
|
6826
|
-
}
|
6827
|
-
});
|
6828
|
-
|
6829
|
-
// src/serializer/sqliteSchema.ts
|
6830
|
-
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;
|
6831
|
-
var init_sqliteSchema = __esm({
|
6832
|
-
"src/serializer/sqliteSchema.ts"() {
|
6833
|
-
"use strict";
|
6834
|
-
init_global();
|
6835
|
-
init_lib();
|
6836
|
-
index3 = objectType({
|
6837
|
-
name: stringType(),
|
6838
|
-
columns: stringType().array(),
|
6839
|
-
where: stringType().optional(),
|
6840
|
-
isUnique: booleanType()
|
6841
|
-
}).strict();
|
6842
|
-
fk3 = objectType({
|
6843
|
-
name: stringType(),
|
6844
|
-
tableFrom: stringType(),
|
6845
|
-
columnsFrom: stringType().array(),
|
6846
|
-
tableTo: stringType(),
|
6847
|
-
columnsTo: stringType().array(),
|
6848
|
-
onUpdate: stringType().optional(),
|
6849
|
-
onDelete: stringType().optional()
|
6850
|
-
}).strict();
|
6851
|
-
compositePK3 = objectType({
|
6852
|
-
columns: stringType().array(),
|
6853
|
-
name: stringType().optional()
|
6854
|
-
}).strict();
|
6855
|
-
column3 = objectType({
|
6856
|
-
name: stringType(),
|
6857
|
-
type: stringType(),
|
6858
|
-
primaryKey: booleanType(),
|
6859
|
-
notNull: booleanType(),
|
6860
|
-
autoincrement: booleanType().optional(),
|
6861
|
-
default: anyType().optional()
|
6862
|
-
}).strict();
|
6863
|
-
tableV33 = objectType({
|
6864
|
-
name: stringType(),
|
6865
|
-
columns: recordType(stringType(), column3),
|
6866
|
-
indexes: recordType(stringType(), index3),
|
6867
|
-
foreignKeys: recordType(stringType(), fk3)
|
6868
|
-
}).strict();
|
6869
|
-
uniqueConstraint3 = objectType({
|
6870
|
-
name: stringType(),
|
6871
|
-
columns: stringType().array()
|
6872
|
-
}).strict();
|
6873
|
-
table3 = objectType({
|
6874
|
-
name: stringType(),
|
6875
|
-
columns: recordType(stringType(), column3),
|
6876
|
-
indexes: recordType(stringType(), index3),
|
6877
|
-
foreignKeys: recordType(stringType(), fk3),
|
6878
|
-
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
6879
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
6880
|
-
}).strict();
|
6881
|
-
dialect5 = enumType(["sqlite"]);
|
6882
|
-
schemaHash3 = objectType({
|
6883
|
-
id: stringType(),
|
6884
|
-
prevId: stringType()
|
6885
|
-
}).strict();
|
6886
|
-
schemaInternalV32 = objectType({
|
6887
|
-
version: literalType("3"),
|
6888
|
-
dialect: dialect5,
|
6889
|
-
tables: recordType(stringType(), tableV33),
|
6890
|
-
enums: objectType({})
|
6891
|
-
}).strict();
|
6892
|
-
schemaInternalV42 = objectType({
|
6893
|
-
version: literalType("4"),
|
6894
|
-
dialect: dialect5,
|
6895
|
-
tables: recordType(stringType(), table3),
|
6896
|
-
enums: objectType({})
|
6897
|
-
}).strict();
|
6898
|
-
latestVersion = literalType("5");
|
6899
|
-
schemaInternal2 = objectType({
|
6900
|
-
version: latestVersion,
|
6901
|
-
dialect: dialect5,
|
6902
|
-
tables: recordType(stringType(), table3),
|
6903
|
-
enums: objectType({}),
|
6904
|
-
_meta: objectType({
|
6905
|
-
tables: recordType(stringType(), stringType()),
|
6906
|
-
columns: recordType(stringType(), stringType())
|
6907
|
-
})
|
6908
|
-
}).strict();
|
6909
|
-
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
6910
|
-
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
6911
|
-
schema3 = schemaInternal2.merge(schemaHash3).strict();
|
6912
|
-
tableSquashed3 = objectType({
|
6913
|
-
name: stringType(),
|
6914
|
-
columns: recordType(stringType(), column3),
|
6915
|
-
indexes: recordType(stringType(), stringType()),
|
6916
|
-
foreignKeys: recordType(stringType(), stringType()),
|
6917
|
-
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6918
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6919
|
-
}).strict();
|
6920
|
-
schemaSquashed2 = objectType({
|
6921
|
-
version: latestVersion,
|
6922
|
-
dialect: dialect5,
|
6923
|
-
tables: recordType(stringType(), tableSquashed3),
|
6924
|
-
enums: anyType()
|
6925
|
-
}).strict();
|
6926
|
-
SQLiteSquasher = {
|
6927
|
-
squashIdx: (idx) => {
|
6928
|
-
index3.parse(idx);
|
6929
|
-
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
|
6930
|
-
},
|
6931
|
-
unsquashIdx: (input) => {
|
6932
|
-
const [name, columnsString, isUnique, where] = input.split(";");
|
6933
|
-
const result = index3.parse({
|
6934
|
-
name,
|
6935
|
-
columns: columnsString.split(","),
|
6936
|
-
isUnique: isUnique === "true",
|
6937
|
-
where: where ?? void 0
|
6938
|
-
});
|
6939
|
-
return result;
|
6940
|
-
},
|
6941
|
-
squashUnique: (unq) => {
|
6942
|
-
return `${unq.name};${unq.columns.join(",")}`;
|
6943
|
-
},
|
6944
|
-
unsquashUnique: (unq) => {
|
6945
|
-
const [name, columns] = unq.split(";");
|
6946
|
-
return { name, columns: columns.split(",") };
|
6947
|
-
},
|
6948
|
-
squashFK: (fk4) => {
|
6949
|
-
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
6950
|
-
},
|
6951
|
-
unsquashFK: (input) => {
|
6952
|
-
const [
|
6953
|
-
name,
|
6954
|
-
tableFrom,
|
6955
|
-
columnsFromStr,
|
6956
|
-
tableTo,
|
6957
|
-
columnsToStr,
|
6958
|
-
onUpdate,
|
6959
|
-
onDelete
|
6960
|
-
] = input.split(";");
|
6961
|
-
const result = fk3.parse({
|
6962
|
-
name,
|
6963
|
-
tableFrom,
|
6964
|
-
columnsFrom: columnsFromStr.split(","),
|
6965
|
-
tableTo,
|
6966
|
-
columnsTo: columnsToStr.split(","),
|
6967
|
-
onUpdate,
|
6968
|
-
onDelete
|
6969
|
-
});
|
6970
|
-
return result;
|
6971
|
-
},
|
6972
|
-
squashPK: (pk) => {
|
6973
|
-
return pk.columns.join(",");
|
6974
|
-
},
|
6975
|
-
unsquashPK: (pk) => {
|
6976
|
-
return pk.split(",");
|
6977
|
-
}
|
6978
|
-
};
|
6979
|
-
squashSqliteScheme = (json) => {
|
6980
|
-
const mappedTables = Object.fromEntries(
|
6981
|
-
Object.entries(json.tables).map((it) => {
|
6982
|
-
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
6983
|
-
return SQLiteSquasher.squashIdx(index4);
|
6984
|
-
});
|
6985
|
-
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
6986
|
-
return SQLiteSquasher.squashFK(fk4);
|
6987
|
-
});
|
6988
|
-
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
6989
|
-
return SQLiteSquasher.squashPK(pk);
|
6990
|
-
});
|
6991
|
-
const squashedUniqueConstraints = mapValues(
|
6992
|
-
it[1].uniqueConstraints,
|
6993
|
-
(unq) => {
|
6994
|
-
return SQLiteSquasher.squashUnique(unq);
|
6995
|
-
}
|
6996
|
-
);
|
6997
|
-
return [
|
6998
|
-
it[0],
|
6999
|
-
{
|
7000
|
-
name: it[1].name,
|
7001
|
-
columns: it[1].columns,
|
7002
|
-
indexes: squashedIndexes,
|
7003
|
-
foreignKeys: squashedFKs,
|
7004
|
-
compositePrimaryKeys: squashedPKs,
|
7005
|
-
uniqueConstraints: squashedUniqueConstraints
|
7006
|
-
}
|
7007
|
-
];
|
7008
|
-
})
|
7009
|
-
);
|
7010
|
-
return {
|
7011
|
-
version: "5",
|
7012
|
-
dialect: json.dialect,
|
7013
|
-
tables: mappedTables,
|
7014
|
-
enums: json.enums
|
7015
|
-
};
|
7016
|
-
};
|
7017
|
-
drySQLite = schema3.parse({
|
7018
|
-
version: "5",
|
7019
|
-
dialect: "sqlite",
|
7020
|
-
id: originUUID,
|
7021
|
-
prevId: "",
|
7022
|
-
tables: {},
|
7023
|
-
enums: {},
|
7024
|
-
_meta: {
|
7025
|
-
tables: {},
|
7026
|
-
columns: {}
|
7027
|
-
}
|
7028
|
-
});
|
7029
|
-
sqliteSchema = schema3;
|
7030
|
-
SQLiteSchemaSquashed = schemaSquashed2;
|
7031
|
-
backwardCompatibleSqliteSchema = schema3;
|
7032
|
-
}
|
7033
|
-
});
|
7034
|
-
|
7035
|
-
// src/schemaValidator.ts
|
7036
|
-
var dialect6, commonSquashedSchema, commonSchema;
|
7037
|
-
var init_schemaValidator = __esm({
|
7038
|
-
"src/schemaValidator.ts"() {
|
7039
|
-
"use strict";
|
7040
|
-
init_lib();
|
7041
|
-
init_mysqlSchema();
|
7042
|
-
init_pgSchema();
|
7043
|
-
init_sqliteSchema();
|
7044
|
-
dialect6 = enumType(["pg", "mysql", "sqlite"]);
|
7045
|
-
commonSquashedSchema = unionType([
|
7046
|
-
pgSchemaSquashed,
|
7047
|
-
mysqlSchemaSquashed,
|
7048
|
-
SQLiteSchemaSquashed
|
7049
|
-
]);
|
7050
|
-
commonSchema = unionType([
|
7051
|
-
pgSchema,
|
7052
|
-
mysqlSchema,
|
7053
|
-
sqliteSchema
|
7054
|
-
]);
|
7055
|
-
}
|
7056
|
-
});
|
7057
|
-
|
7058
|
-
// src/cli/validations/common.ts
|
7059
|
-
var driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema;
|
7060
|
-
var init_common = __esm({
|
7061
|
-
"src/cli/validations/common.ts"() {
|
7062
|
-
"use strict";
|
7063
|
-
init_outputs();
|
7064
|
-
init_lib();
|
7065
|
-
init_schemaValidator();
|
7066
|
-
driver = unionType([
|
7067
|
-
literalType("better-sqlite"),
|
7068
|
-
literalType("turso"),
|
7069
|
-
literalType("libsql"),
|
7070
|
-
literalType("d1"),
|
7071
|
-
literalType("expo"),
|
7072
|
-
literalType("pg"),
|
7073
|
-
literalType("mysql2")
|
7074
|
-
]);
|
7075
|
-
configCommonSchema = objectType({
|
7076
|
-
dialect: dialect6,
|
7077
|
-
schema: unionType([stringType(), stringType().array()]),
|
7078
|
-
out: stringType().optional(),
|
7079
|
-
breakpoints: booleanType().default(true),
|
7080
|
-
driver: driver.optional(),
|
7081
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7082
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
7083
|
-
});
|
7084
|
-
introspectCasing = objectType({
|
7085
|
-
casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
|
7086
|
-
}).default({ casing: "camel" });
|
7087
|
-
configIntrospectSchema = objectType({
|
7088
|
-
schema: unionType([stringType(), stringType().array()]).optional(),
|
7089
|
-
out: stringType().optional().default("./drizzle"),
|
7090
|
-
breakpoints: booleanType().default(true),
|
7091
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7092
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7093
|
-
introspect: introspectCasing
|
7094
|
-
});
|
7095
|
-
configIntrospectCliSchema = objectType({
|
7096
|
-
schema: unionType([stringType(), stringType().array()]).optional(),
|
7097
|
-
out: stringType().optional().default("./drizzle"),
|
7098
|
-
breakpoints: booleanType().default(true),
|
7099
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7100
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7101
|
-
introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
|
7102
|
-
"camel"
|
7103
|
-
)
|
7104
|
-
});
|
7105
|
-
configGenerateSchema = objectType({
|
7106
|
-
schema: unionType([stringType(), stringType().array()]),
|
7107
|
-
out: stringType().optional().default("./drizzle"),
|
7108
|
-
breakpoints: booleanType().default(true)
|
7109
|
-
});
|
7110
|
-
configPushSchema = objectType({
|
7111
|
-
dialect: dialect6,
|
7112
|
-
schema: unionType([stringType(), stringType().array()]),
|
7113
|
-
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
7114
|
-
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
7115
|
-
verbose: booleanType().default(false),
|
7116
|
-
strict: booleanType().default(false)
|
7117
|
-
});
|
7118
|
-
mysqlConnectionSchema = unionType([
|
7119
|
-
objectType({
|
7120
|
-
host: stringType(),
|
7121
|
-
port: coerce.number().optional(),
|
7122
|
-
user: stringType().default("mysql"),
|
7123
|
-
password: stringType().optional(),
|
7124
|
-
database: stringType()
|
7125
|
-
// ssl: boolean().optional(),
|
7126
|
-
}),
|
7127
|
-
objectType({
|
7128
|
-
connectionString: stringType()
|
7129
|
-
}),
|
7130
|
-
objectType({})
|
7131
|
-
]);
|
7132
|
-
mySqlCliConfigSchema = intersectionType(
|
7133
|
-
configCommonSchema,
|
7134
|
-
mysqlConnectionSchema
|
7135
|
-
);
|
7136
|
-
}
|
7137
|
-
});
|
7138
|
-
|
7139
|
-
// src/cli/validations/mysql.ts
|
7140
|
-
var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams;
|
7141
|
-
var init_mysql = __esm({
|
7142
|
-
"src/cli/validations/mysql.ts"() {
|
7143
|
-
"use strict";
|
7144
|
-
init_lib();
|
7145
|
-
init_utils();
|
7146
|
-
init_common();
|
7147
|
-
init_common();
|
7148
|
-
init_outputs();
|
7149
|
-
mysqlConnectionCli = unionType([
|
7150
|
-
objectType({
|
7151
|
-
driver: literalType("mysql2"),
|
7152
|
-
host: stringType(),
|
7153
|
-
port: coerce.number().optional(),
|
7154
|
-
user: stringType().default("mysql"),
|
7155
|
-
password: stringType().optional(),
|
7156
|
-
database: stringType()
|
7157
|
-
}),
|
7158
|
-
objectType({
|
7159
|
-
driver: literalType("mysql2"),
|
7160
|
-
uri: stringType()
|
7161
|
-
// TODO: change docs
|
7162
|
-
})
|
7163
|
-
]);
|
7164
|
-
mysql2credentials = unionType([
|
7165
|
-
objectType({
|
7166
|
-
host: stringType(),
|
7167
|
-
port: coerce.number().optional(),
|
7168
|
-
user: stringType().default("mysql"),
|
7169
|
-
password: stringType().optional(),
|
7170
|
-
database: stringType()
|
7171
|
-
}),
|
7172
|
-
objectType({
|
7173
|
-
uri: stringType()
|
7174
|
-
// TODO: change docs
|
7175
|
-
})
|
7176
|
-
]);
|
7177
|
-
mysqlConnectionConfig = objectType({
|
7178
|
-
driver: literalType("mysql2"),
|
7179
|
-
dbCredentials: mysql2credentials
|
7180
|
-
});
|
7181
|
-
mysqlConfigIntrospectSchema = intersectionType(
|
7182
|
-
configIntrospectSchema,
|
7183
|
-
mysqlConnectionConfig
|
7184
|
-
);
|
7185
|
-
mysqlCliIntrospectParams = intersectionType(
|
7186
|
-
configIntrospectCliSchema,
|
7187
|
-
mysqlConnectionCli
|
7188
|
-
);
|
7189
|
-
mysqlCliPushParams = intersectionType(
|
7190
|
-
configPushSchema,
|
7191
|
-
mysqlConnectionCli
|
7192
|
-
);
|
7193
|
-
mysqlConfigPushParams = intersectionType(
|
7194
|
-
configPushSchema,
|
7195
|
-
mysqlConnectionConfig
|
7196
|
-
);
|
7197
|
-
}
|
7198
|
-
});
|
7199
|
-
|
7200
|
-
// src/cli/validations/pg.ts
|
7201
|
-
var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, pgCliPushParams, pgConfigPushParams;
|
7202
|
-
var init_pg = __esm({
|
7203
|
-
"src/cli/validations/pg.ts"() {
|
7204
|
-
"use strict";
|
7205
|
-
init_lib();
|
7206
|
-
init_utils();
|
7207
|
-
init_common();
|
7208
|
-
init_common();
|
7209
|
-
init_outputs();
|
7210
|
-
pgConnectionCli = unionType([
|
7211
|
-
objectType({
|
7212
|
-
driver: literalType("pg"),
|
7213
|
-
host: stringType(),
|
7214
|
-
port: coerce.number().optional(),
|
7215
|
-
user: stringType().default("postgres"),
|
7216
|
-
password: stringType().optional(),
|
7217
|
-
database: stringType(),
|
7218
|
-
ssl: coerce.boolean().optional(),
|
7219
|
-
type: literalType("params").default("params")
|
7220
|
-
}),
|
7221
|
-
objectType({
|
7222
|
-
driver: literalType("pg"),
|
7223
|
-
connectionString: stringType(),
|
7224
|
-
type: literalType("url").default("url")
|
7225
|
-
})
|
7226
|
-
]);
|
7227
|
-
pgConnectionConfig = unionType([
|
7228
|
-
objectType({
|
7229
|
-
driver: literalType("pg"),
|
7230
|
-
dbCredentials: objectType({
|
7231
|
-
host: stringType(),
|
7232
|
-
port: coerce.number().optional(),
|
7233
|
-
user: stringType().default("postgres"),
|
7234
|
-
password: stringType().optional(),
|
7235
|
-
database: stringType(),
|
7236
|
-
ssl: coerce.boolean().optional(),
|
7237
|
-
type: literalType("params").default("params").optional()
|
7238
|
-
})
|
7239
|
-
}),
|
7240
|
-
objectType({
|
7241
|
-
driver: literalType("pg"),
|
7242
|
-
dbCredentials: objectType({
|
7243
|
-
connectionString: stringType(),
|
7244
|
-
type: literalType("url").default("url").optional()
|
7245
|
-
})
|
7246
|
-
})
|
7247
|
-
]);
|
7248
|
-
pgConfigIntrospectSchema = intersectionType(
|
7249
|
-
configIntrospectSchema,
|
7250
|
-
pgConnectionConfig
|
7251
|
-
);
|
7252
|
-
pgCliIntrospectParams = intersectionType(
|
7253
|
-
configIntrospectCliSchema,
|
7254
|
-
pgConnectionCli
|
7255
|
-
);
|
7256
|
-
pgCliPushParams = intersectionType(
|
7257
|
-
configPushSchema,
|
7258
|
-
pgConnectionCli
|
7259
|
-
);
|
7260
|
-
pgConfigPushParams = intersectionType(
|
7261
|
-
configPushSchema,
|
7262
|
-
pgConnectionConfig
|
7263
|
-
);
|
7264
|
-
}
|
7265
|
-
});
|
7266
|
-
|
7267
|
-
// src/cli/validations/sqlite.ts
|
7268
|
-
var sqliteConnectionCli, sqliteConnectionSchema, sqliteCliConfigSchema, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams;
|
7269
|
-
var init_sqlite = __esm({
|
7270
|
-
"src/cli/validations/sqlite.ts"() {
|
7271
|
-
"use strict";
|
7272
|
-
init_lib();
|
7273
|
-
init_utils();
|
7274
|
-
init_common();
|
7275
|
-
init_common();
|
7276
|
-
init_outputs();
|
7277
|
-
sqliteConnectionCli = unionType([
|
7278
|
-
objectType({
|
7279
|
-
driver: literalType("turso"),
|
7280
|
-
url: stringType(),
|
7281
|
-
authToken: stringType()
|
7282
|
-
}),
|
7283
|
-
objectType({
|
7284
|
-
driver: literalType("better-sqlite"),
|
7285
|
-
url: stringType()
|
7286
|
-
}),
|
7287
|
-
objectType({
|
7288
|
-
driver: literalType("libsql"),
|
7289
|
-
url: stringType()
|
7290
|
-
})
|
7291
|
-
]);
|
7292
|
-
sqliteConnectionSchema = unionType([
|
7293
|
-
objectType({
|
7294
|
-
driver: literalType("turso"),
|
7295
|
-
dbCredentials: objectType({
|
7296
|
-
url: stringType(),
|
7297
|
-
authToken: stringType().optional()
|
7298
|
-
})
|
7299
|
-
}),
|
7300
|
-
objectType({
|
7301
|
-
driver: literalType("libsql"),
|
7302
|
-
dbCredentials: objectType({
|
7303
|
-
url: stringType()
|
7304
|
-
})
|
7305
|
-
}),
|
7306
|
-
objectType({
|
7307
|
-
driver: literalType("better-sqlite"),
|
7308
|
-
dbCredentials: objectType({
|
7309
|
-
url: stringType()
|
7310
|
-
})
|
7311
|
-
})
|
7312
|
-
]);
|
7313
|
-
sqliteCliConfigSchema = intersectionType(
|
7314
|
-
configIntrospectSchema,
|
7315
|
-
sqliteConnectionSchema
|
7316
|
-
);
|
7317
|
-
sqliteCliIntrospectParams = intersectionType(
|
7318
|
-
configIntrospectCliSchema,
|
7319
|
-
sqliteConnectionCli
|
7320
|
-
);
|
7321
|
-
sqliteCliPushParams = intersectionType(
|
7322
|
-
configPushSchema,
|
7323
|
-
sqliteConnectionCli
|
7324
|
-
);
|
7325
|
-
sqliteConfigPushParams = intersectionType(
|
7326
|
-
configPushSchema,
|
7327
|
-
sqliteConnectionSchema
|
7328
|
-
);
|
7329
|
-
}
|
7330
|
-
});
|
7331
|
-
|
7332
|
-
// src/cli/commands/_es5.ts
|
7333
|
-
var es5_exports = {};
|
7334
|
-
__export(es5_exports, {
|
7335
|
-
default: () => es5_default
|
7336
|
-
});
|
7337
|
-
var _, es5_default;
|
7338
|
-
var init_es5 = __esm({
|
7339
|
-
"src/cli/commands/_es5.ts"() {
|
7340
|
-
"use strict";
|
7341
|
-
_ = "";
|
7342
|
-
es5_default = _;
|
7343
|
-
}
|
7344
|
-
});
|
7345
|
-
|
7346
|
-
// node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
|
7347
|
-
var require_ms = __commonJS({
|
7348
|
-
"node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module) {
|
7349
|
-
var s = 1e3;
|
7350
|
-
var m = s * 60;
|
7351
|
-
var h = m * 60;
|
7352
|
-
var d = h * 24;
|
7353
|
-
var w = d * 7;
|
7354
|
-
var y = d * 365.25;
|
7355
|
-
module.exports = function(val, options) {
|
7356
|
-
options = options || {};
|
7357
|
-
var type = typeof val;
|
7358
|
-
if (type === "string" && val.length > 0) {
|
7359
|
-
return parse(val);
|
7360
|
-
} else if (type === "number" && isFinite(val)) {
|
7361
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
7362
|
-
}
|
7363
|
-
throw new Error(
|
7364
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
7365
|
-
);
|
7366
|
-
};
|
7367
|
-
function parse(str) {
|
7368
|
-
str = String(str);
|
7369
|
-
if (str.length > 100) {
|
7370
|
-
return;
|
7371
|
-
}
|
7372
|
-
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(
|
7373
|
-
str
|
7374
|
-
);
|
7375
|
-
if (!match2) {
|
7376
|
-
return;
|
7377
|
-
}
|
7378
|
-
var n = parseFloat(match2[1]);
|
7379
|
-
var type = (match2[2] || "ms").toLowerCase();
|
7380
|
-
switch (type) {
|
7381
|
-
case "years":
|
7382
|
-
case "year":
|
7383
|
-
case "yrs":
|
7384
|
-
case "yr":
|
7385
|
-
case "y":
|
7386
|
-
return n * y;
|
7387
|
-
case "weeks":
|
7388
|
-
case "week":
|
7389
|
-
case "w":
|
7390
|
-
return n * w;
|
7391
|
-
case "days":
|
7392
|
-
case "day":
|
7393
|
-
case "d":
|
7394
|
-
return n * d;
|
7395
|
-
case "hours":
|
7396
|
-
case "hour":
|
7397
|
-
case "hrs":
|
7398
|
-
case "hr":
|
7399
|
-
case "h":
|
7400
|
-
return n * h;
|
7401
|
-
case "minutes":
|
7402
|
-
case "minute":
|
7403
|
-
case "mins":
|
7404
|
-
case "min":
|
7405
|
-
case "m":
|
7406
|
-
return n * m;
|
7407
|
-
case "seconds":
|
7408
|
-
case "second":
|
7409
|
-
case "secs":
|
7410
|
-
case "sec":
|
7411
|
-
case "s":
|
7412
|
-
return n * s;
|
7413
|
-
case "milliseconds":
|
7414
|
-
case "millisecond":
|
7415
|
-
case "msecs":
|
7416
|
-
case "msec":
|
7417
|
-
case "ms":
|
7418
|
-
return n;
|
7419
|
-
default:
|
7420
|
-
return void 0;
|
7421
|
-
}
|
7422
|
-
}
|
7423
|
-
function fmtShort(ms) {
|
7424
|
-
var msAbs = Math.abs(ms);
|
7425
|
-
if (msAbs >= d) {
|
7426
|
-
return Math.round(ms / d) + "d";
|
7427
|
-
}
|
7428
|
-
if (msAbs >= h) {
|
7429
|
-
return Math.round(ms / h) + "h";
|
7430
|
-
}
|
7431
|
-
if (msAbs >= m) {
|
7432
|
-
return Math.round(ms / m) + "m";
|
7433
|
-
}
|
7434
|
-
if (msAbs >= s) {
|
7435
|
-
return Math.round(ms / s) + "s";
|
7436
|
-
}
|
7437
|
-
return ms + "ms";
|
7438
|
-
}
|
7439
|
-
function fmtLong(ms) {
|
7440
|
-
var msAbs = Math.abs(ms);
|
7441
|
-
if (msAbs >= d) {
|
7442
|
-
return plural2(ms, msAbs, d, "day");
|
7443
|
-
}
|
7444
|
-
if (msAbs >= h) {
|
7445
|
-
return plural2(ms, msAbs, h, "hour");
|
7446
|
-
}
|
7447
|
-
if (msAbs >= m) {
|
7448
|
-
return plural2(ms, msAbs, m, "minute");
|
7449
|
-
}
|
7450
|
-
if (msAbs >= s) {
|
7451
|
-
return plural2(ms, msAbs, s, "second");
|
7452
|
-
}
|
7453
|
-
return ms + " ms";
|
7454
|
-
}
|
7455
|
-
function plural2(ms, msAbs, n, name) {
|
7456
|
-
var isPlural = msAbs >= n * 1.5;
|
7457
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
7458
|
-
}
|
6220
|
+
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(
|
6221
|
+
str
|
6222
|
+
);
|
6223
|
+
if (!match2) {
|
6224
|
+
return;
|
6225
|
+
}
|
6226
|
+
var n = parseFloat(match2[1]);
|
6227
|
+
var type = (match2[2] || "ms").toLowerCase();
|
6228
|
+
switch (type) {
|
6229
|
+
case "years":
|
6230
|
+
case "year":
|
6231
|
+
case "yrs":
|
6232
|
+
case "yr":
|
6233
|
+
case "y":
|
6234
|
+
return n * y;
|
6235
|
+
case "weeks":
|
6236
|
+
case "week":
|
6237
|
+
case "w":
|
6238
|
+
return n * w;
|
6239
|
+
case "days":
|
6240
|
+
case "day":
|
6241
|
+
case "d":
|
6242
|
+
return n * d;
|
6243
|
+
case "hours":
|
6244
|
+
case "hour":
|
6245
|
+
case "hrs":
|
6246
|
+
case "hr":
|
6247
|
+
case "h":
|
6248
|
+
return n * h;
|
6249
|
+
case "minutes":
|
6250
|
+
case "minute":
|
6251
|
+
case "mins":
|
6252
|
+
case "min":
|
6253
|
+
case "m":
|
6254
|
+
return n * m;
|
6255
|
+
case "seconds":
|
6256
|
+
case "second":
|
6257
|
+
case "secs":
|
6258
|
+
case "sec":
|
6259
|
+
case "s":
|
6260
|
+
return n * s;
|
6261
|
+
case "milliseconds":
|
6262
|
+
case "millisecond":
|
6263
|
+
case "msecs":
|
6264
|
+
case "msec":
|
6265
|
+
case "ms":
|
6266
|
+
return n;
|
6267
|
+
default:
|
6268
|
+
return void 0;
|
6269
|
+
}
|
6270
|
+
}
|
6271
|
+
function fmtShort(ms) {
|
6272
|
+
var msAbs = Math.abs(ms);
|
6273
|
+
if (msAbs >= d) {
|
6274
|
+
return Math.round(ms / d) + "d";
|
6275
|
+
}
|
6276
|
+
if (msAbs >= h) {
|
6277
|
+
return Math.round(ms / h) + "h";
|
6278
|
+
}
|
6279
|
+
if (msAbs >= m) {
|
6280
|
+
return Math.round(ms / m) + "m";
|
6281
|
+
}
|
6282
|
+
if (msAbs >= s) {
|
6283
|
+
return Math.round(ms / s) + "s";
|
6284
|
+
}
|
6285
|
+
return ms + "ms";
|
6286
|
+
}
|
6287
|
+
function fmtLong(ms) {
|
6288
|
+
var msAbs = Math.abs(ms);
|
6289
|
+
if (msAbs >= d) {
|
6290
|
+
return plural(ms, msAbs, d, "day");
|
6291
|
+
}
|
6292
|
+
if (msAbs >= h) {
|
6293
|
+
return plural(ms, msAbs, h, "hour");
|
6294
|
+
}
|
6295
|
+
if (msAbs >= m) {
|
6296
|
+
return plural(ms, msAbs, m, "minute");
|
6297
|
+
}
|
6298
|
+
if (msAbs >= s) {
|
6299
|
+
return plural(ms, msAbs, s, "second");
|
6300
|
+
}
|
6301
|
+
return ms + " ms";
|
6302
|
+
}
|
6303
|
+
function plural(ms, msAbs, n, name) {
|
6304
|
+
var isPlural = msAbs >= n * 1.5;
|
6305
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
6306
|
+
}
|
7459
6307
|
}
|
7460
6308
|
});
|
7461
6309
|
|
@@ -12780,285 +11628,1148 @@ var require_node2 = __commonJS({
|
|
12780
11628
|
return jsoncParse(content);
|
12781
11629
|
}
|
12782
11630
|
});
|
12783
|
-
var getOptions = (cwd) => {
|
12784
|
-
var _a, _b, _c, _d;
|
12785
|
-
const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
12786
|
-
if (path3 && data) {
|
11631
|
+
var getOptions = (cwd) => {
|
11632
|
+
var _a, _b, _c, _d;
|
11633
|
+
const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
|
11634
|
+
if (path3 && data) {
|
11635
|
+
return {
|
11636
|
+
jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
|
11637
|
+
jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
|
11638
|
+
target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
|
11639
|
+
};
|
11640
|
+
}
|
11641
|
+
return {};
|
11642
|
+
};
|
11643
|
+
var inferPackageFormat = (cwd, filename) => {
|
11644
|
+
if (filename.endsWith(".mjs")) {
|
11645
|
+
return "esm";
|
11646
|
+
}
|
11647
|
+
if (filename.endsWith(".cjs")) {
|
11648
|
+
return "cjs";
|
11649
|
+
}
|
11650
|
+
const { data } = joycon.loadSync(["package.json"], cwd);
|
11651
|
+
return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
|
11652
|
+
};
|
11653
|
+
var import_tsconfig_paths = __toModule(require_lib4());
|
11654
|
+
var noOp = () => {
|
11655
|
+
};
|
11656
|
+
function registerTsconfigPaths() {
|
11657
|
+
const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
|
11658
|
+
if (configLoaderResult.resultType === "failed") {
|
11659
|
+
return noOp;
|
11660
|
+
}
|
11661
|
+
const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
|
11662
|
+
const Module = __require("module");
|
11663
|
+
const originalResolveFilename = Module._resolveFilename;
|
11664
|
+
Module._resolveFilename = function(request, _parent) {
|
11665
|
+
const isCoreModule = _module2.builtinModules.includes(request);
|
11666
|
+
if (!isCoreModule) {
|
11667
|
+
const found = matchPath(request);
|
11668
|
+
if (found) {
|
11669
|
+
const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
|
11670
|
+
return originalResolveFilename.apply(this, modifiedArguments);
|
11671
|
+
}
|
11672
|
+
}
|
11673
|
+
return originalResolveFilename.apply(this, arguments);
|
11674
|
+
};
|
11675
|
+
return () => {
|
11676
|
+
Module._resolveFilename = originalResolveFilename;
|
11677
|
+
};
|
11678
|
+
}
|
11679
|
+
var _debug = require_src2();
|
11680
|
+
var _debug2 = _interopRequireDefault2(_debug);
|
11681
|
+
var debug = _debug2.default.call(void 0, "esbuild-register");
|
11682
|
+
var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
|
11683
|
+
var map = {};
|
11684
|
+
function installSourceMapSupport() {
|
11685
|
+
if (_process2.default.setSourceMapsEnabled) {
|
11686
|
+
;
|
11687
|
+
_process2.default.setSourceMapsEnabled(true);
|
11688
|
+
} else {
|
11689
|
+
import_source_map_support.default.install({
|
11690
|
+
handleUncaughtExceptions: false,
|
11691
|
+
environment: "node",
|
11692
|
+
retrieveSourceMap(file) {
|
11693
|
+
if (map[file]) {
|
11694
|
+
return {
|
11695
|
+
url: file,
|
11696
|
+
map: map[file]
|
11697
|
+
};
|
11698
|
+
}
|
11699
|
+
return null;
|
11700
|
+
}
|
11701
|
+
});
|
11702
|
+
}
|
11703
|
+
}
|
11704
|
+
function patchCommonJsLoader(compile) {
|
11705
|
+
const extensions = _module3.default.Module._extensions;
|
11706
|
+
const jsHandler = extensions[".js"];
|
11707
|
+
extensions[".js"] = function(module2, filename) {
|
11708
|
+
try {
|
11709
|
+
return jsHandler.call(this, module2, filename);
|
11710
|
+
} catch (error2) {
|
11711
|
+
if (error2.code !== "ERR_REQUIRE_ESM") {
|
11712
|
+
throw error2;
|
11713
|
+
}
|
11714
|
+
let content = _fs3.default.readFileSync(filename, "utf8");
|
11715
|
+
content = compile(content, filename, "cjs");
|
11716
|
+
module2._compile(content, filename);
|
11717
|
+
}
|
11718
|
+
};
|
11719
|
+
return () => {
|
11720
|
+
extensions[".js"] = jsHandler;
|
11721
|
+
};
|
11722
|
+
}
|
11723
|
+
var FILE_LOADERS = {
|
11724
|
+
".js": "js",
|
11725
|
+
".jsx": "jsx",
|
11726
|
+
".ts": "ts",
|
11727
|
+
".tsx": "tsx",
|
11728
|
+
".mjs": "js",
|
11729
|
+
".mts": "ts",
|
11730
|
+
".cts": "ts"
|
11731
|
+
};
|
11732
|
+
var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
|
11733
|
+
var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
|
11734
|
+
function register(esbuildOptions = {}) {
|
11735
|
+
const {
|
11736
|
+
extensions = DEFAULT_EXTENSIONS,
|
11737
|
+
hookIgnoreNodeModules = true,
|
11738
|
+
hookMatcher,
|
11739
|
+
...overrides
|
11740
|
+
} = esbuildOptions;
|
11741
|
+
const compile = function compile2(code, filename, format) {
|
11742
|
+
const define = {
|
11743
|
+
"import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
|
11744
|
+
...overrides.define
|
11745
|
+
};
|
11746
|
+
const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
|
11747
|
+
if (code.includes(banner)) {
|
11748
|
+
return code;
|
11749
|
+
}
|
11750
|
+
const dir = _path2.dirname.call(void 0, filename);
|
11751
|
+
const options = getOptions(dir);
|
11752
|
+
format = format != null ? format : inferPackageFormat(dir, filename);
|
11753
|
+
const result = _esbuild.transformSync.call(void 0, code, {
|
11754
|
+
sourcefile: filename,
|
11755
|
+
loader: getLoader(filename),
|
11756
|
+
sourcemap: "both",
|
11757
|
+
target: options.target,
|
11758
|
+
jsxFactory: options.jsxFactory,
|
11759
|
+
jsxFragment: options.jsxFragment,
|
11760
|
+
format,
|
11761
|
+
define,
|
11762
|
+
banner,
|
11763
|
+
...overrides
|
11764
|
+
});
|
11765
|
+
const js = result.code;
|
11766
|
+
debug("compiled %s", filename);
|
11767
|
+
debug("%s", js);
|
11768
|
+
const warnings = result.warnings;
|
11769
|
+
if (warnings && warnings.length > 0) {
|
11770
|
+
for (const warning of warnings) {
|
11771
|
+
console.log(warning.location);
|
11772
|
+
console.log(warning.text);
|
11773
|
+
}
|
11774
|
+
}
|
11775
|
+
if (format === "esm")
|
11776
|
+
return js;
|
11777
|
+
return removeNodePrefix(js);
|
11778
|
+
};
|
11779
|
+
const revert = (0, import_pirates.addHook)(compile, {
|
11780
|
+
exts: extensions,
|
11781
|
+
ignoreNodeModules: hookIgnoreNodeModules,
|
11782
|
+
matcher: hookMatcher
|
11783
|
+
});
|
11784
|
+
installSourceMapSupport();
|
11785
|
+
const unpatchCommonJsLoader = patchCommonJsLoader(compile);
|
11786
|
+
const unregisterTsconfigPaths = registerTsconfigPaths();
|
11787
|
+
return {
|
11788
|
+
unregister() {
|
11789
|
+
revert();
|
11790
|
+
unpatchCommonJsLoader();
|
11791
|
+
unregisterTsconfigPaths();
|
11792
|
+
}
|
11793
|
+
};
|
11794
|
+
}
|
11795
|
+
exports.register = register;
|
11796
|
+
}
|
11797
|
+
});
|
11798
|
+
|
11799
|
+
// src/cli/commands/utils.ts
|
11800
|
+
var import_hanji2, assertES5, safeRegister, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
|
11801
|
+
var init_utils = __esm({
|
11802
|
+
"src/cli/commands/utils.ts"() {
|
11803
|
+
init_serializer();
|
11804
|
+
init_lib();
|
11805
|
+
init_source();
|
11806
|
+
init_views();
|
11807
|
+
import_hanji2 = __toESM(require_hanji());
|
11808
|
+
assertES5 = async (unregister) => {
|
11809
|
+
try {
|
11810
|
+
init_es5();
|
11811
|
+
} catch (e) {
|
11812
|
+
if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
|
11813
|
+
const es5Error = e.errors.filter(
|
11814
|
+
(it) => {
|
11815
|
+
var _a;
|
11816
|
+
return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
|
11817
|
+
}
|
11818
|
+
).length > 0;
|
11819
|
+
if (es5Error) {
|
11820
|
+
console.log(
|
11821
|
+
error(
|
11822
|
+
`Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
|
11823
|
+
)
|
11824
|
+
);
|
11825
|
+
process.exit(1);
|
11826
|
+
}
|
11827
|
+
}
|
11828
|
+
console.error(e);
|
11829
|
+
process.exit(1);
|
11830
|
+
}
|
11831
|
+
};
|
11832
|
+
safeRegister = async () => {
|
11833
|
+
const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
|
11834
|
+
let res;
|
11835
|
+
try {
|
11836
|
+
res = register({
|
11837
|
+
format: "cjs",
|
11838
|
+
loader: "ts"
|
11839
|
+
});
|
11840
|
+
} catch {
|
11841
|
+
res = {
|
11842
|
+
unregister: () => {
|
11843
|
+
}
|
11844
|
+
};
|
11845
|
+
}
|
11846
|
+
await assertES5(res.unregister);
|
11847
|
+
return res;
|
11848
|
+
};
|
11849
|
+
driver = unionType([
|
11850
|
+
literalType("better-sqlite"),
|
11851
|
+
literalType("turso"),
|
11852
|
+
literalType("libsql"),
|
11853
|
+
literalType("d1"),
|
11854
|
+
literalType("expo"),
|
11855
|
+
literalType("pg"),
|
11856
|
+
literalType("mysql2")
|
11857
|
+
]);
|
11858
|
+
configCommonSchema = objectType({
|
11859
|
+
schema: unionType([stringType(), stringType().array()]),
|
11860
|
+
out: stringType().optional(),
|
11861
|
+
breakpoints: booleanType().default(true),
|
11862
|
+
driver: driver.optional(),
|
11863
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11864
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
11865
|
+
});
|
11866
|
+
introspectCasing = objectType({
|
11867
|
+
casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
|
11868
|
+
}).default({ casing: "camel" });
|
11869
|
+
configIntrospectSchema = objectType({
|
11870
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
11871
|
+
out: stringType().optional().default("./drizzle"),
|
11872
|
+
breakpoints: booleanType().default(true),
|
11873
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11874
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11875
|
+
introspect: introspectCasing
|
11876
|
+
});
|
11877
|
+
configIntrospectCliSchema = objectType({
|
11878
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
11879
|
+
out: stringType().optional().default("./drizzle"),
|
11880
|
+
breakpoints: booleanType().default(true),
|
11881
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11882
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11883
|
+
introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
|
11884
|
+
"camel"
|
11885
|
+
)
|
11886
|
+
});
|
11887
|
+
configGenerateSchema = objectType({
|
11888
|
+
schema: unionType([stringType(), stringType().array()]),
|
11889
|
+
out: stringType().optional().default("./drizzle"),
|
11890
|
+
breakpoints: booleanType().default(true)
|
11891
|
+
});
|
11892
|
+
configPushSchema = objectType({
|
11893
|
+
schema: unionType([stringType(), stringType().array()]),
|
11894
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11895
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
11896
|
+
verbose: booleanType().default(false),
|
11897
|
+
strict: booleanType().default(false)
|
11898
|
+
});
|
11899
|
+
mysqlConnectionSchema = unionType([
|
11900
|
+
objectType({
|
11901
|
+
host: stringType(),
|
11902
|
+
port: coerce.number().optional(),
|
11903
|
+
user: stringType().default("mysql"),
|
11904
|
+
password: stringType().optional(),
|
11905
|
+
database: stringType()
|
11906
|
+
// ssl: boolean().optional(),
|
11907
|
+
}),
|
11908
|
+
objectType({
|
11909
|
+
connectionString: stringType()
|
11910
|
+
}),
|
11911
|
+
objectType({})
|
11912
|
+
]);
|
11913
|
+
mySqlCliConfigSchema = intersectionType(
|
11914
|
+
configCommonSchema,
|
11915
|
+
mysqlConnectionSchema
|
11916
|
+
);
|
11917
|
+
mySqlIntrospectConfigSchema = intersectionType(
|
11918
|
+
configIntrospectSchema,
|
11919
|
+
mysqlConnectionSchema
|
11920
|
+
);
|
11921
|
+
}
|
11922
|
+
});
|
11923
|
+
|
11924
|
+
// src/serializer/pgImports.ts
|
11925
|
+
var pgImports_exports = {};
|
11926
|
+
__export(pgImports_exports, {
|
11927
|
+
prepareFromExports: () => prepareFromExports3,
|
11928
|
+
prepareFromPgImports: () => prepareFromPgImports
|
11929
|
+
});
|
11930
|
+
import {
|
11931
|
+
PgTable,
|
11932
|
+
PgSchema as PgSchema2,
|
11933
|
+
isPgEnum
|
11934
|
+
} from "drizzle-orm/pg-core";
|
11935
|
+
import { is as is6 } from "drizzle-orm";
|
11936
|
+
var prepareFromExports3, prepareFromPgImports;
|
11937
|
+
var init_pgImports = __esm({
|
11938
|
+
"src/serializer/pgImports.ts"() {
|
11939
|
+
init_utils();
|
11940
|
+
prepareFromExports3 = (exports) => {
|
11941
|
+
const tables = [];
|
11942
|
+
const enums = [];
|
11943
|
+
const schemas = [];
|
11944
|
+
const i0values = Object.values(exports);
|
11945
|
+
i0values.forEach((t) => {
|
11946
|
+
if (isPgEnum(t)) {
|
11947
|
+
enums.push(t);
|
11948
|
+
return;
|
11949
|
+
}
|
11950
|
+
if (is6(t, PgTable)) {
|
11951
|
+
tables.push(t);
|
11952
|
+
}
|
11953
|
+
if (is6(t, PgSchema2)) {
|
11954
|
+
schemas.push(t);
|
11955
|
+
}
|
11956
|
+
});
|
11957
|
+
return { tables, enums, schemas };
|
11958
|
+
};
|
11959
|
+
prepareFromPgImports = async (imports) => {
|
11960
|
+
let tables = [];
|
11961
|
+
let enums = [];
|
11962
|
+
let schemas = [];
|
11963
|
+
const { unregister } = await safeRegister();
|
11964
|
+
for (let i = 0; i < imports.length; i++) {
|
11965
|
+
const it = imports[i];
|
11966
|
+
const i0 = __require(`${it}`);
|
11967
|
+
const prepared = prepareFromExports3(i0);
|
11968
|
+
tables.push(...prepared.tables);
|
11969
|
+
enums.push(...prepared.enums);
|
11970
|
+
schemas.push(...prepared.schemas);
|
11971
|
+
}
|
11972
|
+
unregister();
|
11973
|
+
return { tables: Array.from(new Set(tables)), enums, schemas };
|
11974
|
+
};
|
11975
|
+
}
|
11976
|
+
});
|
11977
|
+
|
11978
|
+
// src/global.ts
|
11979
|
+
var originUUID, snapshotVersion, mapValues;
|
11980
|
+
var init_global = __esm({
|
11981
|
+
"src/global.ts"() {
|
11982
|
+
originUUID = "00000000-0000-0000-0000-000000000000";
|
11983
|
+
snapshotVersion = "5";
|
11984
|
+
mapValues = (obj, map) => {
|
11985
|
+
const result = Object.keys(obj).reduce(function(result2, key) {
|
11986
|
+
result2[key] = map(obj[key]);
|
11987
|
+
return result2;
|
11988
|
+
}, {});
|
11989
|
+
return result;
|
11990
|
+
};
|
11991
|
+
}
|
11992
|
+
});
|
11993
|
+
|
11994
|
+
// src/serializer/pgSchema.ts
|
11995
|
+
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;
|
11996
|
+
var init_pgSchema = __esm({
|
11997
|
+
"src/serializer/pgSchema.ts"() {
|
11998
|
+
init_global();
|
11999
|
+
init_lib();
|
12000
|
+
indexV2 = objectType({
|
12001
|
+
name: stringType(),
|
12002
|
+
columns: recordType(
|
12003
|
+
stringType(),
|
12004
|
+
objectType({
|
12005
|
+
name: stringType()
|
12006
|
+
})
|
12007
|
+
),
|
12008
|
+
isUnique: booleanType()
|
12009
|
+
}).strict();
|
12010
|
+
columnV2 = objectType({
|
12011
|
+
name: stringType(),
|
12012
|
+
type: stringType(),
|
12013
|
+
primaryKey: booleanType(),
|
12014
|
+
notNull: booleanType(),
|
12015
|
+
default: anyType().optional(),
|
12016
|
+
references: stringType().optional()
|
12017
|
+
}).strict();
|
12018
|
+
tableV2 = objectType({
|
12019
|
+
name: stringType(),
|
12020
|
+
columns: recordType(stringType(), columnV2),
|
12021
|
+
indexes: recordType(stringType(), indexV2)
|
12022
|
+
}).strict();
|
12023
|
+
enumSchema = objectType({
|
12024
|
+
name: stringType(),
|
12025
|
+
values: recordType(stringType(), stringType())
|
12026
|
+
}).strict();
|
12027
|
+
pgSchemaV2 = objectType({
|
12028
|
+
version: literalType("2"),
|
12029
|
+
tables: recordType(stringType(), tableV2),
|
12030
|
+
enums: recordType(stringType(), enumSchema)
|
12031
|
+
}).strict();
|
12032
|
+
references = objectType({
|
12033
|
+
foreignKeyName: stringType(),
|
12034
|
+
table: stringType(),
|
12035
|
+
column: stringType(),
|
12036
|
+
onDelete: stringType().optional(),
|
12037
|
+
onUpdate: stringType().optional()
|
12038
|
+
}).strict();
|
12039
|
+
columnV1 = objectType({
|
12040
|
+
name: stringType(),
|
12041
|
+
type: stringType(),
|
12042
|
+
primaryKey: booleanType(),
|
12043
|
+
notNull: booleanType(),
|
12044
|
+
default: anyType().optional(),
|
12045
|
+
references: references.optional()
|
12046
|
+
}).strict();
|
12047
|
+
tableV1 = objectType({
|
12048
|
+
name: stringType(),
|
12049
|
+
columns: recordType(stringType(), columnV1),
|
12050
|
+
indexes: recordType(stringType(), indexV2)
|
12051
|
+
}).strict();
|
12052
|
+
pgSchemaV1 = objectType({
|
12053
|
+
version: literalType("1"),
|
12054
|
+
tables: recordType(stringType(), tableV1),
|
12055
|
+
enums: recordType(stringType(), enumSchema)
|
12056
|
+
}).strict();
|
12057
|
+
index = objectType({
|
12058
|
+
name: stringType(),
|
12059
|
+
columns: stringType().array(),
|
12060
|
+
isUnique: booleanType()
|
12061
|
+
}).strict();
|
12062
|
+
fk = objectType({
|
12063
|
+
name: stringType(),
|
12064
|
+
tableFrom: stringType(),
|
12065
|
+
columnsFrom: stringType().array(),
|
12066
|
+
tableTo: stringType(),
|
12067
|
+
schemaTo: stringType().optional(),
|
12068
|
+
columnsTo: stringType().array(),
|
12069
|
+
onUpdate: stringType().optional(),
|
12070
|
+
onDelete: stringType().optional()
|
12071
|
+
}).strict();
|
12072
|
+
column = objectType({
|
12073
|
+
name: stringType(),
|
12074
|
+
type: stringType(),
|
12075
|
+
primaryKey: booleanType(),
|
12076
|
+
notNull: booleanType(),
|
12077
|
+
default: anyType().optional(),
|
12078
|
+
isUnique: anyType().optional(),
|
12079
|
+
uniqueName: stringType().optional(),
|
12080
|
+
nullsNotDistinct: booleanType().optional()
|
12081
|
+
}).strict();
|
12082
|
+
tableV3 = objectType({
|
12083
|
+
name: stringType(),
|
12084
|
+
columns: recordType(stringType(), column),
|
12085
|
+
indexes: recordType(stringType(), index),
|
12086
|
+
foreignKeys: recordType(stringType(), fk)
|
12087
|
+
}).strict();
|
12088
|
+
compositePK = objectType({
|
12089
|
+
name: stringType(),
|
12090
|
+
columns: stringType().array()
|
12091
|
+
}).strict();
|
12092
|
+
uniqueConstraint = objectType({
|
12093
|
+
name: stringType(),
|
12094
|
+
columns: stringType().array(),
|
12095
|
+
nullsNotDistinct: booleanType()
|
12096
|
+
}).strict();
|
12097
|
+
tableV4 = objectType({
|
12098
|
+
name: stringType(),
|
12099
|
+
schema: stringType(),
|
12100
|
+
columns: recordType(stringType(), column),
|
12101
|
+
indexes: recordType(stringType(), index),
|
12102
|
+
foreignKeys: recordType(stringType(), fk)
|
12103
|
+
}).strict();
|
12104
|
+
table = objectType({
|
12105
|
+
name: stringType(),
|
12106
|
+
schema: stringType(),
|
12107
|
+
columns: recordType(stringType(), column),
|
12108
|
+
indexes: recordType(stringType(), index),
|
12109
|
+
foreignKeys: recordType(stringType(), fk),
|
12110
|
+
compositePrimaryKeys: recordType(stringType(), compositePK),
|
12111
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
12112
|
+
}).strict();
|
12113
|
+
schemaHash = objectType({
|
12114
|
+
id: stringType(),
|
12115
|
+
prevId: stringType()
|
12116
|
+
});
|
12117
|
+
pgSchemaInternalV3 = objectType({
|
12118
|
+
version: literalType("3"),
|
12119
|
+
dialect: literalType("pg"),
|
12120
|
+
tables: recordType(stringType(), tableV3),
|
12121
|
+
enums: recordType(stringType(), enumSchema)
|
12122
|
+
}).strict();
|
12123
|
+
pgSchemaInternalV4 = objectType({
|
12124
|
+
version: literalType("4"),
|
12125
|
+
dialect: literalType("pg"),
|
12126
|
+
tables: recordType(stringType(), tableV4),
|
12127
|
+
enums: recordType(stringType(), enumSchema),
|
12128
|
+
schemas: recordType(stringType(), stringType())
|
12129
|
+
}).strict();
|
12130
|
+
pgSchemaExternal = objectType({
|
12131
|
+
version: literalType("5"),
|
12132
|
+
dialect: literalType("pg"),
|
12133
|
+
tables: arrayType(table),
|
12134
|
+
enums: arrayType(enumSchema),
|
12135
|
+
schemas: arrayType(objectType({ name: stringType() })),
|
12136
|
+
_meta: objectType({
|
12137
|
+
schemas: recordType(stringType(), stringType()),
|
12138
|
+
tables: recordType(stringType(), stringType()),
|
12139
|
+
columns: recordType(stringType(), stringType())
|
12140
|
+
})
|
12141
|
+
}).strict();
|
12142
|
+
kitInternals = objectType({
|
12143
|
+
tables: recordType(
|
12144
|
+
stringType(),
|
12145
|
+
objectType({
|
12146
|
+
columns: recordType(
|
12147
|
+
stringType(),
|
12148
|
+
objectType({
|
12149
|
+
isArray: booleanType().optional(),
|
12150
|
+
dimensions: numberType().optional(),
|
12151
|
+
rawType: stringType().optional()
|
12152
|
+
}).optional()
|
12153
|
+
)
|
12154
|
+
}).optional()
|
12155
|
+
)
|
12156
|
+
}).optional();
|
12157
|
+
pgSchemaInternal = objectType({
|
12158
|
+
version: literalType("5"),
|
12159
|
+
dialect: literalType("pg"),
|
12160
|
+
tables: recordType(stringType(), table),
|
12161
|
+
enums: recordType(stringType(), enumSchema),
|
12162
|
+
schemas: recordType(stringType(), stringType()),
|
12163
|
+
_meta: objectType({
|
12164
|
+
schemas: recordType(stringType(), stringType()),
|
12165
|
+
tables: recordType(stringType(), stringType()),
|
12166
|
+
columns: recordType(stringType(), stringType())
|
12167
|
+
}),
|
12168
|
+
internal: kitInternals
|
12169
|
+
}).strict();
|
12170
|
+
tableSquashed = objectType({
|
12171
|
+
name: stringType(),
|
12172
|
+
schema: stringType(),
|
12173
|
+
columns: recordType(stringType(), column),
|
12174
|
+
indexes: recordType(stringType(), stringType()),
|
12175
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12176
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12177
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
12178
|
+
}).strict();
|
12179
|
+
tableSquashedV4 = objectType({
|
12180
|
+
name: stringType(),
|
12181
|
+
schema: stringType(),
|
12182
|
+
columns: recordType(stringType(), column),
|
12183
|
+
indexes: recordType(stringType(), stringType()),
|
12184
|
+
foreignKeys: recordType(stringType(), stringType())
|
12185
|
+
}).strict();
|
12186
|
+
pgSchemaSquashedV4 = objectType({
|
12187
|
+
version: literalType("4"),
|
12188
|
+
dialect: enumType(["pg"]),
|
12189
|
+
tables: recordType(stringType(), tableSquashedV4),
|
12190
|
+
enums: recordType(stringType(), enumSchema),
|
12191
|
+
schemas: recordType(stringType(), stringType())
|
12192
|
+
}).strict();
|
12193
|
+
pgSchemaSquashed = objectType({
|
12194
|
+
version: literalType("5"),
|
12195
|
+
dialect: enumType(["pg"]),
|
12196
|
+
tables: recordType(stringType(), tableSquashed),
|
12197
|
+
enums: recordType(stringType(), enumSchema),
|
12198
|
+
schemas: recordType(stringType(), stringType())
|
12199
|
+
}).strict();
|
12200
|
+
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash);
|
12201
|
+
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash);
|
12202
|
+
pgSchema = pgSchemaInternal.merge(schemaHash);
|
12203
|
+
backwardCompatiblePgSchema = unionType([
|
12204
|
+
pgSchemaV1,
|
12205
|
+
pgSchemaV2,
|
12206
|
+
pgSchemaV3,
|
12207
|
+
pgSchemaV4,
|
12208
|
+
pgSchema
|
12209
|
+
]);
|
12210
|
+
PgSquasher = {
|
12211
|
+
squashIdx: (idx) => {
|
12212
|
+
index.parse(idx);
|
12213
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
|
12214
|
+
},
|
12215
|
+
unsquashIdx: (input) => {
|
12216
|
+
const [name, columnsString, isUnique] = input.split(";");
|
12217
|
+
const result = index.parse({
|
12218
|
+
name,
|
12219
|
+
columns: columnsString.split(","),
|
12220
|
+
isUnique: isUnique === "true"
|
12221
|
+
});
|
12222
|
+
return result;
|
12223
|
+
},
|
12224
|
+
squashFK: (fk4) => {
|
12225
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
|
12226
|
+
},
|
12227
|
+
squashPK: (pk) => {
|
12228
|
+
return `${pk.columns.join(",")};${pk.name}`;
|
12229
|
+
},
|
12230
|
+
unsquashPK: (pk) => {
|
12231
|
+
const splitted = pk.split(";");
|
12232
|
+
return { name: splitted[1], columns: splitted[0].split(",") };
|
12233
|
+
},
|
12234
|
+
squashUnique: (unq) => {
|
12235
|
+
return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
|
12236
|
+
},
|
12237
|
+
unsquashUnique: (unq) => {
|
12238
|
+
const [name, columns, nullsNotDistinct] = unq.split(";");
|
12787
12239
|
return {
|
12788
|
-
|
12789
|
-
|
12790
|
-
|
12240
|
+
name,
|
12241
|
+
columns: columns.split(","),
|
12242
|
+
nullsNotDistinct: nullsNotDistinct === "true"
|
12791
12243
|
};
|
12244
|
+
},
|
12245
|
+
unsquashFK: (input) => {
|
12246
|
+
const [
|
12247
|
+
name,
|
12248
|
+
tableFrom,
|
12249
|
+
columnsFromStr,
|
12250
|
+
tableTo,
|
12251
|
+
columnsToStr,
|
12252
|
+
onUpdate,
|
12253
|
+
onDelete,
|
12254
|
+
schemaTo
|
12255
|
+
] = input.split(";");
|
12256
|
+
const result = fk.parse({
|
12257
|
+
name,
|
12258
|
+
tableFrom,
|
12259
|
+
columnsFrom: columnsFromStr.split(","),
|
12260
|
+
schemaTo,
|
12261
|
+
tableTo,
|
12262
|
+
columnsTo: columnsToStr.split(","),
|
12263
|
+
onUpdate,
|
12264
|
+
onDelete
|
12265
|
+
});
|
12266
|
+
return result;
|
12792
12267
|
}
|
12793
|
-
return {};
|
12794
|
-
};
|
12795
|
-
var inferPackageFormat = (cwd, filename) => {
|
12796
|
-
if (filename.endsWith(".mjs")) {
|
12797
|
-
return "esm";
|
12798
|
-
}
|
12799
|
-
if (filename.endsWith(".cjs")) {
|
12800
|
-
return "cjs";
|
12801
|
-
}
|
12802
|
-
const { data } = joycon.loadSync(["package.json"], cwd);
|
12803
|
-
return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
|
12804
|
-
};
|
12805
|
-
var import_tsconfig_paths = __toModule(require_lib4());
|
12806
|
-
var noOp = () => {
|
12807
12268
|
};
|
12808
|
-
|
12809
|
-
const
|
12810
|
-
|
12811
|
-
|
12812
|
-
|
12813
|
-
|
12814
|
-
|
12815
|
-
|
12816
|
-
|
12817
|
-
|
12818
|
-
|
12819
|
-
|
12820
|
-
|
12821
|
-
|
12822
|
-
|
12823
|
-
|
12824
|
-
}
|
12825
|
-
return originalResolveFilename.apply(this, arguments);
|
12826
|
-
};
|
12827
|
-
return () => {
|
12828
|
-
Module._resolveFilename = originalResolveFilename;
|
12829
|
-
};
|
12830
|
-
}
|
12831
|
-
var _debug = require_src2();
|
12832
|
-
var _debug2 = _interopRequireDefault2(_debug);
|
12833
|
-
var debug = _debug2.default.call(void 0, "esbuild-register");
|
12834
|
-
var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
|
12835
|
-
var map = {};
|
12836
|
-
function installSourceMapSupport() {
|
12837
|
-
if (_process2.default.setSourceMapsEnabled) {
|
12838
|
-
;
|
12839
|
-
_process2.default.setSourceMapsEnabled(true);
|
12840
|
-
} else {
|
12841
|
-
import_source_map_support.default.install({
|
12842
|
-
handleUncaughtExceptions: false,
|
12843
|
-
environment: "node",
|
12844
|
-
retrieveSourceMap(file) {
|
12845
|
-
if (map[file]) {
|
12846
|
-
return {
|
12847
|
-
url: file,
|
12848
|
-
map: map[file]
|
12849
|
-
};
|
12269
|
+
squashPgScheme = (json) => {
|
12270
|
+
const mappedTables = Object.fromEntries(
|
12271
|
+
Object.entries(json.tables).map((it) => {
|
12272
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12273
|
+
return PgSquasher.squashIdx(index4);
|
12274
|
+
});
|
12275
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12276
|
+
return PgSquasher.squashFK(fk4);
|
12277
|
+
});
|
12278
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12279
|
+
return PgSquasher.squashPK(pk);
|
12280
|
+
});
|
12281
|
+
const squashedUniqueConstraints = mapValues(
|
12282
|
+
it[1].uniqueConstraints,
|
12283
|
+
(unq) => {
|
12284
|
+
return PgSquasher.squashUnique(unq);
|
12850
12285
|
}
|
12851
|
-
|
12852
|
-
|
12853
|
-
|
12854
|
-
|
12855
|
-
|
12856
|
-
|
12857
|
-
|
12858
|
-
|
12859
|
-
|
12860
|
-
|
12861
|
-
|
12862
|
-
|
12863
|
-
|
12864
|
-
|
12865
|
-
|
12866
|
-
|
12867
|
-
|
12868
|
-
|
12869
|
-
|
12870
|
-
|
12871
|
-
|
12872
|
-
extensions[".js"] = jsHandler;
|
12286
|
+
);
|
12287
|
+
return [
|
12288
|
+
it[0],
|
12289
|
+
{
|
12290
|
+
name: it[1].name,
|
12291
|
+
schema: it[1].schema,
|
12292
|
+
columns: it[1].columns,
|
12293
|
+
indexes: squashedIndexes,
|
12294
|
+
foreignKeys: squashedFKs,
|
12295
|
+
compositePrimaryKeys: squashedPKs,
|
12296
|
+
uniqueConstraints: squashedUniqueConstraints
|
12297
|
+
}
|
12298
|
+
];
|
12299
|
+
})
|
12300
|
+
);
|
12301
|
+
return {
|
12302
|
+
version: "5",
|
12303
|
+
dialect: json.dialect,
|
12304
|
+
tables: mappedTables,
|
12305
|
+
enums: json.enums,
|
12306
|
+
schemas: json.schemas
|
12873
12307
|
};
|
12874
|
-
}
|
12875
|
-
var FILE_LOADERS = {
|
12876
|
-
".js": "js",
|
12877
|
-
".jsx": "jsx",
|
12878
|
-
".ts": "ts",
|
12879
|
-
".tsx": "tsx",
|
12880
|
-
".mjs": "js",
|
12881
|
-
".mts": "ts",
|
12882
|
-
".cts": "ts"
|
12883
12308
|
};
|
12884
|
-
|
12885
|
-
|
12886
|
-
|
12887
|
-
|
12888
|
-
|
12889
|
-
|
12890
|
-
|
12891
|
-
|
12892
|
-
|
12893
|
-
|
12894
|
-
|
12895
|
-
|
12896
|
-
|
12897
|
-
|
12898
|
-
|
12899
|
-
|
12900
|
-
|
12901
|
-
|
12902
|
-
|
12903
|
-
|
12904
|
-
|
12905
|
-
|
12906
|
-
|
12907
|
-
|
12908
|
-
|
12909
|
-
|
12910
|
-
|
12911
|
-
|
12912
|
-
|
12913
|
-
|
12914
|
-
|
12915
|
-
|
12309
|
+
dryPg = pgSchema.parse({
|
12310
|
+
version: snapshotVersion,
|
12311
|
+
dialect: "pg",
|
12312
|
+
id: originUUID,
|
12313
|
+
prevId: "",
|
12314
|
+
tables: {},
|
12315
|
+
enums: {},
|
12316
|
+
schemas: {},
|
12317
|
+
_meta: {
|
12318
|
+
schemas: {},
|
12319
|
+
tables: {},
|
12320
|
+
columns: {}
|
12321
|
+
}
|
12322
|
+
});
|
12323
|
+
}
|
12324
|
+
});
|
12325
|
+
|
12326
|
+
// src/serializer/sqliteSchema.ts
|
12327
|
+
var index2, fk2, compositePK2, column2, tableV32, uniqueConstraint2, table2, dialect4, schemaHash2, schemaInternalV3, schemaInternalV4, latestVersion, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed2, schemaSquashed, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, backwardCompatibleSqliteSchema;
|
12328
|
+
var init_sqliteSchema = __esm({
|
12329
|
+
"src/serializer/sqliteSchema.ts"() {
|
12330
|
+
init_global();
|
12331
|
+
init_lib();
|
12332
|
+
index2 = objectType({
|
12333
|
+
name: stringType(),
|
12334
|
+
columns: stringType().array(),
|
12335
|
+
where: stringType().optional(),
|
12336
|
+
isUnique: booleanType()
|
12337
|
+
}).strict();
|
12338
|
+
fk2 = objectType({
|
12339
|
+
name: stringType(),
|
12340
|
+
tableFrom: stringType(),
|
12341
|
+
columnsFrom: stringType().array(),
|
12342
|
+
tableTo: stringType(),
|
12343
|
+
columnsTo: stringType().array(),
|
12344
|
+
onUpdate: stringType().optional(),
|
12345
|
+
onDelete: stringType().optional()
|
12346
|
+
}).strict();
|
12347
|
+
compositePK2 = objectType({
|
12348
|
+
columns: stringType().array(),
|
12349
|
+
name: stringType().optional()
|
12350
|
+
}).strict();
|
12351
|
+
column2 = objectType({
|
12352
|
+
name: stringType(),
|
12353
|
+
type: stringType(),
|
12354
|
+
primaryKey: booleanType(),
|
12355
|
+
notNull: booleanType(),
|
12356
|
+
autoincrement: booleanType().optional(),
|
12357
|
+
default: anyType().optional()
|
12358
|
+
}).strict();
|
12359
|
+
tableV32 = objectType({
|
12360
|
+
name: stringType(),
|
12361
|
+
columns: recordType(stringType(), column2),
|
12362
|
+
indexes: recordType(stringType(), index2),
|
12363
|
+
foreignKeys: recordType(stringType(), fk2)
|
12364
|
+
}).strict();
|
12365
|
+
uniqueConstraint2 = objectType({
|
12366
|
+
name: stringType(),
|
12367
|
+
columns: stringType().array()
|
12368
|
+
}).strict();
|
12369
|
+
table2 = objectType({
|
12370
|
+
name: stringType(),
|
12371
|
+
columns: recordType(stringType(), column2),
|
12372
|
+
indexes: recordType(stringType(), index2),
|
12373
|
+
foreignKeys: recordType(stringType(), fk2),
|
12374
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
12375
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
12376
|
+
}).strict();
|
12377
|
+
dialect4 = enumType(["sqlite"]);
|
12378
|
+
schemaHash2 = objectType({
|
12379
|
+
id: stringType(),
|
12380
|
+
prevId: stringType()
|
12381
|
+
}).strict();
|
12382
|
+
schemaInternalV3 = objectType({
|
12383
|
+
version: literalType("3"),
|
12384
|
+
dialect: dialect4,
|
12385
|
+
tables: recordType(stringType(), tableV32),
|
12386
|
+
enums: objectType({})
|
12387
|
+
}).strict();
|
12388
|
+
schemaInternalV4 = objectType({
|
12389
|
+
version: literalType("4"),
|
12390
|
+
dialect: dialect4,
|
12391
|
+
tables: recordType(stringType(), table2),
|
12392
|
+
enums: objectType({})
|
12393
|
+
}).strict();
|
12394
|
+
latestVersion = literalType("5");
|
12395
|
+
schemaInternal = objectType({
|
12396
|
+
version: latestVersion,
|
12397
|
+
dialect: dialect4,
|
12398
|
+
tables: recordType(stringType(), table2),
|
12399
|
+
enums: objectType({}),
|
12400
|
+
_meta: objectType({
|
12401
|
+
tables: recordType(stringType(), stringType()),
|
12402
|
+
columns: recordType(stringType(), stringType())
|
12403
|
+
})
|
12404
|
+
}).strict();
|
12405
|
+
schemaV3 = schemaInternalV3.merge(schemaHash2).strict();
|
12406
|
+
schemaV4 = schemaInternalV4.merge(schemaHash2).strict();
|
12407
|
+
schema2 = schemaInternal.merge(schemaHash2).strict();
|
12408
|
+
tableSquashed2 = objectType({
|
12409
|
+
name: stringType(),
|
12410
|
+
columns: recordType(stringType(), column2),
|
12411
|
+
indexes: recordType(stringType(), stringType()),
|
12412
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12413
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12414
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
12415
|
+
}).strict();
|
12416
|
+
schemaSquashed = objectType({
|
12417
|
+
version: latestVersion,
|
12418
|
+
dialect: dialect4,
|
12419
|
+
tables: recordType(stringType(), tableSquashed2),
|
12420
|
+
enums: anyType()
|
12421
|
+
}).strict();
|
12422
|
+
SQLiteSquasher = {
|
12423
|
+
squashIdx: (idx) => {
|
12424
|
+
index2.parse(idx);
|
12425
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
|
12426
|
+
},
|
12427
|
+
unsquashIdx: (input) => {
|
12428
|
+
const [name, columnsString, isUnique, where] = input.split(";");
|
12429
|
+
const result = index2.parse({
|
12430
|
+
name,
|
12431
|
+
columns: columnsString.split(","),
|
12432
|
+
isUnique: isUnique === "true",
|
12433
|
+
where: where ?? void 0
|
12916
12434
|
});
|
12917
|
-
|
12918
|
-
|
12919
|
-
|
12920
|
-
|
12921
|
-
|
12922
|
-
|
12923
|
-
|
12924
|
-
|
12925
|
-
|
12926
|
-
|
12927
|
-
|
12928
|
-
|
12929
|
-
|
12930
|
-
|
12931
|
-
|
12932
|
-
|
12933
|
-
|
12934
|
-
|
12935
|
-
|
12936
|
-
|
12937
|
-
|
12938
|
-
|
12435
|
+
return result;
|
12436
|
+
},
|
12437
|
+
squashUnique: (unq) => {
|
12438
|
+
return `${unq.name};${unq.columns.join(",")}`;
|
12439
|
+
},
|
12440
|
+
unsquashUnique: (unq) => {
|
12441
|
+
const [name, columns] = unq.split(";");
|
12442
|
+
return { name, columns: columns.split(",") };
|
12443
|
+
},
|
12444
|
+
squashFK: (fk4) => {
|
12445
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
12446
|
+
},
|
12447
|
+
unsquashFK: (input) => {
|
12448
|
+
const [
|
12449
|
+
name,
|
12450
|
+
tableFrom,
|
12451
|
+
columnsFromStr,
|
12452
|
+
tableTo,
|
12453
|
+
columnsToStr,
|
12454
|
+
onUpdate,
|
12455
|
+
onDelete
|
12456
|
+
] = input.split(";");
|
12457
|
+
const result = fk2.parse({
|
12458
|
+
name,
|
12459
|
+
tableFrom,
|
12460
|
+
columnsFrom: columnsFromStr.split(","),
|
12461
|
+
tableTo,
|
12462
|
+
columnsTo: columnsToStr.split(","),
|
12463
|
+
onUpdate,
|
12464
|
+
onDelete
|
12465
|
+
});
|
12466
|
+
return result;
|
12467
|
+
},
|
12468
|
+
squashPK: (pk) => {
|
12469
|
+
return pk.columns.join(",");
|
12470
|
+
},
|
12471
|
+
unsquashPK: (pk) => {
|
12472
|
+
return pk.split(",");
|
12473
|
+
}
|
12474
|
+
};
|
12475
|
+
squashSqliteScheme = (json) => {
|
12476
|
+
const mappedTables = Object.fromEntries(
|
12477
|
+
Object.entries(json.tables).map((it) => {
|
12478
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12479
|
+
return SQLiteSquasher.squashIdx(index4);
|
12480
|
+
});
|
12481
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12482
|
+
return SQLiteSquasher.squashFK(fk4);
|
12483
|
+
});
|
12484
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12485
|
+
return SQLiteSquasher.squashPK(pk);
|
12486
|
+
});
|
12487
|
+
const squashedUniqueConstraints = mapValues(it[1].uniqueConstraints, (unq) => {
|
12488
|
+
return SQLiteSquasher.squashUnique(unq);
|
12489
|
+
});
|
12490
|
+
return [
|
12491
|
+
it[0],
|
12492
|
+
{
|
12493
|
+
name: it[1].name,
|
12494
|
+
columns: it[1].columns,
|
12495
|
+
indexes: squashedIndexes,
|
12496
|
+
foreignKeys: squashedFKs,
|
12497
|
+
compositePrimaryKeys: squashedPKs,
|
12498
|
+
uniqueConstraints: squashedUniqueConstraints
|
12499
|
+
}
|
12500
|
+
];
|
12501
|
+
})
|
12502
|
+
);
|
12939
12503
|
return {
|
12940
|
-
|
12941
|
-
|
12942
|
-
|
12943
|
-
|
12944
|
-
}
|
12504
|
+
version: "5",
|
12505
|
+
dialect: json.dialect,
|
12506
|
+
tables: mappedTables,
|
12507
|
+
enums: json.enums
|
12945
12508
|
};
|
12946
|
-
}
|
12947
|
-
|
12509
|
+
};
|
12510
|
+
drySQLite = schema2.parse({
|
12511
|
+
version: snapshotVersion,
|
12512
|
+
dialect: "sqlite",
|
12513
|
+
id: originUUID,
|
12514
|
+
prevId: "",
|
12515
|
+
tables: {},
|
12516
|
+
enums: {},
|
12517
|
+
_meta: {
|
12518
|
+
tables: {},
|
12519
|
+
columns: {}
|
12520
|
+
}
|
12521
|
+
});
|
12522
|
+
sqliteSchema = schema2;
|
12523
|
+
backwardCompatibleSqliteSchema = unionType([schemaV3, schemaV4, schema2]);
|
12948
12524
|
}
|
12949
12525
|
});
|
12950
12526
|
|
12951
|
-
// src/
|
12952
|
-
var
|
12953
|
-
var
|
12954
|
-
"src/
|
12955
|
-
"use strict";
|
12956
|
-
init_serializer();
|
12957
|
-
init_source();
|
12958
|
-
init_views();
|
12959
|
-
import_hanji2 = __toESM(require_hanji());
|
12960
|
-
init_outputs();
|
12527
|
+
// src/serializer/mysqlSchema.ts
|
12528
|
+
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;
|
12529
|
+
var init_mysqlSchema = __esm({
|
12530
|
+
"src/serializer/mysqlSchema.ts"() {
|
12961
12531
|
init_global();
|
12962
|
-
|
12963
|
-
|
12964
|
-
|
12965
|
-
|
12966
|
-
|
12967
|
-
|
12968
|
-
|
12969
|
-
|
12970
|
-
|
12971
|
-
|
12972
|
-
|
12973
|
-
|
12974
|
-
|
12975
|
-
|
12976
|
-
|
12977
|
-
|
12978
|
-
|
12979
|
-
|
12980
|
-
|
12981
|
-
|
12982
|
-
|
12983
|
-
|
12984
|
-
|
12985
|
-
|
12986
|
-
|
12987
|
-
|
12988
|
-
|
12989
|
-
|
12990
|
-
|
12991
|
-
|
12992
|
-
|
12993
|
-
|
12994
|
-
|
12995
|
-
|
12996
|
-
|
12997
|
-
|
12998
|
-
|
12999
|
-
|
13000
|
-
|
13001
|
-
|
12532
|
+
init_lib();
|
12533
|
+
index3 = objectType({
|
12534
|
+
name: stringType(),
|
12535
|
+
columns: stringType().array(),
|
12536
|
+
isUnique: booleanType(),
|
12537
|
+
using: enumType(["btree", "hash"]).optional(),
|
12538
|
+
algorithm: enumType(["default", "inplace", "copy"]).optional(),
|
12539
|
+
lock: enumType(["default", "none", "shared", "exclusive"]).optional()
|
12540
|
+
}).strict();
|
12541
|
+
fk3 = objectType({
|
12542
|
+
name: stringType(),
|
12543
|
+
tableFrom: stringType(),
|
12544
|
+
columnsFrom: stringType().array(),
|
12545
|
+
tableTo: stringType(),
|
12546
|
+
columnsTo: stringType().array(),
|
12547
|
+
onUpdate: stringType().optional(),
|
12548
|
+
onDelete: stringType().optional()
|
12549
|
+
}).strict();
|
12550
|
+
column3 = objectType({
|
12551
|
+
name: stringType(),
|
12552
|
+
type: stringType(),
|
12553
|
+
primaryKey: booleanType(),
|
12554
|
+
notNull: booleanType(),
|
12555
|
+
autoincrement: booleanType().optional(),
|
12556
|
+
default: anyType().optional(),
|
12557
|
+
onUpdate: anyType().optional()
|
12558
|
+
}).strict();
|
12559
|
+
tableV33 = objectType({
|
12560
|
+
name: stringType(),
|
12561
|
+
columns: recordType(stringType(), column3),
|
12562
|
+
indexes: recordType(stringType(), index3),
|
12563
|
+
foreignKeys: recordType(stringType(), fk3)
|
12564
|
+
}).strict();
|
12565
|
+
compositePK3 = objectType({
|
12566
|
+
name: stringType(),
|
12567
|
+
columns: stringType().array()
|
12568
|
+
}).strict();
|
12569
|
+
uniqueConstraint3 = objectType({
|
12570
|
+
name: stringType(),
|
12571
|
+
columns: stringType().array()
|
12572
|
+
}).strict();
|
12573
|
+
tableV42 = objectType({
|
12574
|
+
name: stringType(),
|
12575
|
+
schema: stringType().optional(),
|
12576
|
+
columns: recordType(stringType(), column3),
|
12577
|
+
indexes: recordType(stringType(), index3),
|
12578
|
+
foreignKeys: recordType(stringType(), fk3)
|
12579
|
+
}).strict();
|
12580
|
+
table3 = objectType({
|
12581
|
+
name: stringType(),
|
12582
|
+
schema: stringType().optional(),
|
12583
|
+
columns: recordType(stringType(), column3),
|
12584
|
+
indexes: recordType(stringType(), index3),
|
12585
|
+
foreignKeys: recordType(stringType(), fk3),
|
12586
|
+
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
12587
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
12588
|
+
}).strict();
|
12589
|
+
dialect5 = literalType("mysql");
|
12590
|
+
schemaHash3 = objectType({
|
12591
|
+
id: stringType(),
|
12592
|
+
prevId: stringType()
|
12593
|
+
});
|
12594
|
+
schemaInternalV32 = objectType({
|
12595
|
+
version: literalType("3"),
|
12596
|
+
dialect: dialect5,
|
12597
|
+
tables: recordType(stringType(), tableV33)
|
12598
|
+
}).strict();
|
12599
|
+
schemaInternalV42 = objectType({
|
12600
|
+
version: literalType("4"),
|
12601
|
+
dialect: dialect5,
|
12602
|
+
tables: recordType(stringType(), tableV42),
|
12603
|
+
schemas: recordType(stringType(), stringType())
|
12604
|
+
}).strict();
|
12605
|
+
kitInternals2 = objectType({
|
12606
|
+
tables: recordType(
|
12607
|
+
stringType(),
|
12608
|
+
objectType({
|
12609
|
+
columns: recordType(
|
12610
|
+
stringType(),
|
12611
|
+
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
12612
|
+
)
|
12613
|
+
}).optional()
|
12614
|
+
)
|
12615
|
+
}).optional();
|
12616
|
+
schemaInternal2 = objectType({
|
12617
|
+
version: literalType("5"),
|
12618
|
+
dialect: dialect5,
|
12619
|
+
tables: recordType(stringType(), table3),
|
12620
|
+
schemas: recordType(stringType(), stringType()),
|
12621
|
+
_meta: objectType({
|
12622
|
+
schemas: recordType(stringType(), stringType()),
|
12623
|
+
tables: recordType(stringType(), stringType()),
|
12624
|
+
columns: recordType(stringType(), stringType())
|
12625
|
+
}),
|
12626
|
+
internal: kitInternals2
|
12627
|
+
}).strict();
|
12628
|
+
schemaV32 = schemaInternalV32.merge(schemaHash3);
|
12629
|
+
schemaV42 = schemaInternalV42.merge(schemaHash3);
|
12630
|
+
schema3 = schemaInternal2.merge(schemaHash3);
|
12631
|
+
tableSquashedV42 = objectType({
|
12632
|
+
name: stringType(),
|
12633
|
+
schema: stringType().optional(),
|
12634
|
+
columns: recordType(stringType(), column3),
|
12635
|
+
indexes: recordType(stringType(), stringType()),
|
12636
|
+
foreignKeys: recordType(stringType(), stringType())
|
12637
|
+
}).strict();
|
12638
|
+
tableSquashed3 = objectType({
|
12639
|
+
name: stringType(),
|
12640
|
+
schema: stringType().optional(),
|
12641
|
+
columns: recordType(stringType(), column3),
|
12642
|
+
indexes: recordType(stringType(), stringType()),
|
12643
|
+
foreignKeys: recordType(stringType(), stringType()),
|
12644
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12645
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
12646
|
+
}).strict();
|
12647
|
+
schemaSquashed2 = objectType({
|
12648
|
+
version: literalType("5"),
|
12649
|
+
dialect: dialect5,
|
12650
|
+
tables: recordType(stringType(), tableSquashed3),
|
12651
|
+
schemas: recordType(stringType(), stringType())
|
12652
|
+
}).strict();
|
12653
|
+
schemaSquashedV4 = objectType({
|
12654
|
+
version: literalType("4"),
|
12655
|
+
dialect: dialect5,
|
12656
|
+
tables: recordType(stringType(), tableSquashedV42),
|
12657
|
+
schemas: recordType(stringType(), stringType())
|
12658
|
+
}).strict();
|
12659
|
+
MySqlSquasher = {
|
12660
|
+
squashIdx: (idx) => {
|
12661
|
+
index3.parse(idx);
|
12662
|
+
return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
|
12663
|
+
},
|
12664
|
+
unsquashIdx: (input) => {
|
12665
|
+
const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
|
12666
|
+
const destructed = {
|
12667
|
+
name,
|
12668
|
+
columns: columnsString.split(","),
|
12669
|
+
isUnique: isUnique === "true",
|
12670
|
+
using: using ? using : void 0,
|
12671
|
+
algorithm: algorithm ? algorithm : void 0,
|
12672
|
+
lock: lock ? lock : void 0
|
13002
12673
|
};
|
12674
|
+
return index3.parse(destructed);
|
12675
|
+
},
|
12676
|
+
squashPK: (pk) => {
|
12677
|
+
return `${pk.name};${pk.columns.join(",")}`;
|
12678
|
+
},
|
12679
|
+
unsquashPK: (pk) => {
|
12680
|
+
const splitted = pk.split(";");
|
12681
|
+
return { name: splitted[0], columns: splitted[1].split(",") };
|
12682
|
+
},
|
12683
|
+
squashUnique: (unq) => {
|
12684
|
+
return `${unq.name};${unq.columns.join(",")}`;
|
12685
|
+
},
|
12686
|
+
unsquashUnique: (unq) => {
|
12687
|
+
const [name, columns] = unq.split(";");
|
12688
|
+
return { name, columns: columns.split(",") };
|
12689
|
+
},
|
12690
|
+
squashFK: (fk4) => {
|
12691
|
+
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
|
12692
|
+
},
|
12693
|
+
unsquashFK: (input) => {
|
12694
|
+
const [
|
12695
|
+
name,
|
12696
|
+
tableFrom,
|
12697
|
+
columnsFromStr,
|
12698
|
+
tableTo,
|
12699
|
+
columnsToStr,
|
12700
|
+
onUpdate,
|
12701
|
+
onDelete
|
12702
|
+
] = input.split(";");
|
12703
|
+
const result = fk3.parse({
|
12704
|
+
name,
|
12705
|
+
tableFrom,
|
12706
|
+
columnsFrom: columnsFromStr.split(","),
|
12707
|
+
tableTo,
|
12708
|
+
columnsTo: columnsToStr.split(","),
|
12709
|
+
onUpdate,
|
12710
|
+
onDelete
|
12711
|
+
});
|
12712
|
+
return result;
|
13003
12713
|
}
|
13004
|
-
await assertES5(res.unregister);
|
13005
|
-
return res;
|
13006
12714
|
};
|
13007
|
-
|
13008
|
-
|
13009
|
-
|
13010
|
-
|
13011
|
-
|
13012
|
-
|
13013
|
-
|
13014
|
-
|
13015
|
-
});
|
13016
|
-
|
13017
|
-
|
13018
|
-
|
13019
|
-
|
13020
|
-
|
13021
|
-
|
13022
|
-
|
13023
|
-
|
13024
|
-
|
13025
|
-
|
13026
|
-
|
13027
|
-
|
13028
|
-
|
13029
|
-
|
13030
|
-
|
13031
|
-
|
13032
|
-
|
13033
|
-
|
13034
|
-
|
13035
|
-
|
13036
|
-
|
13037
|
-
|
13038
|
-
|
13039
|
-
|
13040
|
-
|
13041
|
-
|
13042
|
-
|
13043
|
-
|
13044
|
-
|
12715
|
+
squashMysqlScheme = (json) => {
|
12716
|
+
const mappedTables = Object.fromEntries(
|
12717
|
+
Object.entries(json.tables).map((it) => {
|
12718
|
+
const squashedIndexes = mapValues(it[1].indexes, (index4) => {
|
12719
|
+
return MySqlSquasher.squashIdx(index4);
|
12720
|
+
});
|
12721
|
+
const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
|
12722
|
+
return MySqlSquasher.squashFK(fk4);
|
12723
|
+
});
|
12724
|
+
const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
|
12725
|
+
return MySqlSquasher.squashPK(pk);
|
12726
|
+
});
|
12727
|
+
const squashedUniqueConstraints = mapValues(
|
12728
|
+
it[1].uniqueConstraints,
|
12729
|
+
(unq) => {
|
12730
|
+
return MySqlSquasher.squashUnique(unq);
|
12731
|
+
}
|
12732
|
+
);
|
12733
|
+
return [
|
12734
|
+
it[0],
|
12735
|
+
{
|
12736
|
+
name: it[1].name,
|
12737
|
+
schema: it[1].schema,
|
12738
|
+
columns: it[1].columns,
|
12739
|
+
indexes: squashedIndexes,
|
12740
|
+
foreignKeys: squashedFKs,
|
12741
|
+
compositePrimaryKeys: squashedPKs,
|
12742
|
+
uniqueConstraints: squashedUniqueConstraints
|
12743
|
+
}
|
12744
|
+
];
|
12745
|
+
})
|
12746
|
+
);
|
12747
|
+
return {
|
12748
|
+
version: "5",
|
12749
|
+
dialect: json.dialect,
|
12750
|
+
tables: mappedTables,
|
12751
|
+
schemas: json.schemas
|
12752
|
+
};
|
13045
12753
|
};
|
13046
|
-
|
13047
|
-
|
13048
|
-
|
13049
|
-
|
13050
|
-
|
13051
|
-
|
13052
|
-
|
13053
|
-
|
13054
|
-
|
13055
|
-
|
13056
|
-
|
13057
|
-
|
12754
|
+
mysqlSchema = schema3;
|
12755
|
+
backwardCompatibleMysqlSchema = unionType([
|
12756
|
+
schemaV32,
|
12757
|
+
schemaV42,
|
12758
|
+
schema3
|
12759
|
+
]);
|
12760
|
+
dryMySql = mysqlSchema.parse({
|
12761
|
+
version: snapshotVersion,
|
12762
|
+
dialect: "mysql",
|
12763
|
+
id: originUUID,
|
12764
|
+
prevId: "",
|
12765
|
+
tables: {},
|
12766
|
+
schemas: {},
|
12767
|
+
_meta: {
|
12768
|
+
schemas: {},
|
12769
|
+
tables: {},
|
12770
|
+
columns: {}
|
13058
12771
|
}
|
13059
|
-
|
13060
|
-
return { tables: Array.from(new Set(tables)), enums, schemas };
|
13061
|
-
};
|
12772
|
+
});
|
13062
12773
|
}
|
13063
12774
|
});
|
13064
12775
|
|
@@ -13068,7 +12779,6 @@ import { randomUUID } from "crypto";
|
|
13068
12779
|
var prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot, preparePgDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSqliteMigrationSnapshot, fillPgSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
|
13069
12780
|
var init_migrationPreparator = __esm({
|
13070
12781
|
"src/migrationPreparator.ts"() {
|
13071
|
-
"use strict";
|
13072
12782
|
init_serializer();
|
13073
12783
|
init_pgSchema();
|
13074
12784
|
init_sqliteSchema();
|
@@ -13077,18 +12787,18 @@ var init_migrationPreparator = __esm({
|
|
13077
12787
|
const serialized = await serializeMySql(schemaPath);
|
13078
12788
|
const id = randomUUID();
|
13079
12789
|
const idPrev = prev.id;
|
13080
|
-
const { version, dialect:
|
13081
|
-
const result = { version, dialect:
|
12790
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12791
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13082
12792
|
return { prev, cur: result };
|
13083
12793
|
};
|
13084
12794
|
prepareSQLiteDbPushSnapshot = async (prev, schemaPath) => {
|
13085
12795
|
const serialized = await serializeSQLite(schemaPath);
|
13086
12796
|
const id = randomUUID();
|
13087
12797
|
const idPrev = prev.id;
|
13088
|
-
const { version, dialect:
|
12798
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
13089
12799
|
const result = {
|
13090
12800
|
version,
|
13091
|
-
dialect:
|
12801
|
+
dialect: dialect6,
|
13092
12802
|
id,
|
13093
12803
|
prevId: idPrev,
|
13094
12804
|
...rest
|
@@ -13099,8 +12809,8 @@ var init_migrationPreparator = __esm({
|
|
13099
12809
|
const serialized = await serializePg(schemaPath, schemaFilter);
|
13100
12810
|
const id = randomUUID();
|
13101
12811
|
const idPrev = prev.id;
|
13102
|
-
const { version, dialect:
|
13103
|
-
const result = { version, dialect:
|
12812
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12813
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13104
12814
|
return { prev, cur: result };
|
13105
12815
|
};
|
13106
12816
|
prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath) => {
|
@@ -13110,8 +12820,8 @@ var init_migrationPreparator = __esm({
|
|
13110
12820
|
const serialized = await serializeMySql(schemaPath);
|
13111
12821
|
const id = randomUUID();
|
13112
12822
|
const idPrev = prevSnapshot.id;
|
13113
|
-
const { version, dialect:
|
13114
|
-
const result = { version, dialect:
|
12823
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
12824
|
+
const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
|
13115
12825
|
const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
|
13116
12826
|
const custom = {
|
13117
12827
|
id,
|
@@ -13127,10 +12837,10 @@ var init_migrationPreparator = __esm({
|
|
13127
12837
|
const serialized = await serializeSQLite(schemaPath);
|
13128
12838
|
const id = randomUUID();
|
13129
12839
|
const idPrev = prevSnapshot.id;
|
13130
|
-
const { version, dialect:
|
12840
|
+
const { version, dialect: dialect6, ...rest } = serialized;
|
13131
12841
|
const result = {
|
13132
12842
|
version,
|
13133
|
-
dialect:
|
12843
|
+
dialect: dialect6,
|
13134
12844
|
id,
|
13135
12845
|
prevId: idPrev,
|
13136
12846
|
...rest
|
@@ -13155,7 +12865,7 @@ var init_migrationPreparator = __esm({
|
|
13155
12865
|
const serialized = await serializePg(schemaPath);
|
13156
12866
|
const id = randomUUID();
|
13157
12867
|
const idPrev = prevSnapshot.id;
|
13158
|
-
const result = { id,
|
12868
|
+
const result = fillPgSnapshot({ serialized, id, idPrev });
|
13159
12869
|
const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
|
13160
12870
|
const custom = fillPgSnapshot({ serialized: prevRest, id, idPrev });
|
13161
12871
|
return { prev: prevSnapshot, cur: result, custom };
|
@@ -13173,363 +12883,6 @@ var init_migrationPreparator = __esm({
|
|
13173
12883
|
}
|
13174
12884
|
});
|
13175
12885
|
|
13176
|
-
// node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js
|
13177
|
-
var require_pluralize = __commonJS({
|
13178
|
-
"node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.js"(exports, module) {
|
13179
|
-
(function(root, pluralize) {
|
13180
|
-
if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
|
13181
|
-
module.exports = pluralize();
|
13182
|
-
} else if (typeof define === "function" && define.amd) {
|
13183
|
-
define(function() {
|
13184
|
-
return pluralize();
|
13185
|
-
});
|
13186
|
-
} else {
|
13187
|
-
root.pluralize = pluralize();
|
13188
|
-
}
|
13189
|
-
})(exports, function() {
|
13190
|
-
var pluralRules = [];
|
13191
|
-
var singularRules = [];
|
13192
|
-
var uncountables = {};
|
13193
|
-
var irregularPlurals = {};
|
13194
|
-
var irregularSingles = {};
|
13195
|
-
function sanitizeRule(rule) {
|
13196
|
-
if (typeof rule === "string") {
|
13197
|
-
return new RegExp("^" + rule + "$", "i");
|
13198
|
-
}
|
13199
|
-
return rule;
|
13200
|
-
}
|
13201
|
-
function restoreCase(word, token) {
|
13202
|
-
if (word === token)
|
13203
|
-
return token;
|
13204
|
-
if (word === word.toLowerCase())
|
13205
|
-
return token.toLowerCase();
|
13206
|
-
if (word === word.toUpperCase())
|
13207
|
-
return token.toUpperCase();
|
13208
|
-
if (word[0] === word[0].toUpperCase()) {
|
13209
|
-
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
13210
|
-
}
|
13211
|
-
return token.toLowerCase();
|
13212
|
-
}
|
13213
|
-
function interpolate(str, args) {
|
13214
|
-
return str.replace(/\$(\d{1,2})/g, function(match2, index4) {
|
13215
|
-
return args[index4] || "";
|
13216
|
-
});
|
13217
|
-
}
|
13218
|
-
function replace(word, rule) {
|
13219
|
-
return word.replace(rule[0], function(match2, index4) {
|
13220
|
-
var result = interpolate(rule[1], arguments);
|
13221
|
-
if (match2 === "") {
|
13222
|
-
return restoreCase(word[index4 - 1], result);
|
13223
|
-
}
|
13224
|
-
return restoreCase(match2, result);
|
13225
|
-
});
|
13226
|
-
}
|
13227
|
-
function sanitizeWord(token, word, rules) {
|
13228
|
-
if (!token.length || uncountables.hasOwnProperty(token)) {
|
13229
|
-
return word;
|
13230
|
-
}
|
13231
|
-
var len = rules.length;
|
13232
|
-
while (len--) {
|
13233
|
-
var rule = rules[len];
|
13234
|
-
if (rule[0].test(word))
|
13235
|
-
return replace(word, rule);
|
13236
|
-
}
|
13237
|
-
return word;
|
13238
|
-
}
|
13239
|
-
function replaceWord(replaceMap, keepMap, rules) {
|
13240
|
-
return function(word) {
|
13241
|
-
var token = word.toLowerCase();
|
13242
|
-
if (keepMap.hasOwnProperty(token)) {
|
13243
|
-
return restoreCase(word, token);
|
13244
|
-
}
|
13245
|
-
if (replaceMap.hasOwnProperty(token)) {
|
13246
|
-
return restoreCase(word, replaceMap[token]);
|
13247
|
-
}
|
13248
|
-
return sanitizeWord(token, word, rules);
|
13249
|
-
};
|
13250
|
-
}
|
13251
|
-
function checkWord(replaceMap, keepMap, rules, bool) {
|
13252
|
-
return function(word) {
|
13253
|
-
var token = word.toLowerCase();
|
13254
|
-
if (keepMap.hasOwnProperty(token))
|
13255
|
-
return true;
|
13256
|
-
if (replaceMap.hasOwnProperty(token))
|
13257
|
-
return false;
|
13258
|
-
return sanitizeWord(token, token, rules) === token;
|
13259
|
-
};
|
13260
|
-
}
|
13261
|
-
function pluralize(word, count, inclusive) {
|
13262
|
-
var pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
|
13263
|
-
return (inclusive ? count + " " : "") + pluralized;
|
13264
|
-
}
|
13265
|
-
pluralize.plural = replaceWord(
|
13266
|
-
irregularSingles,
|
13267
|
-
irregularPlurals,
|
13268
|
-
pluralRules
|
13269
|
-
);
|
13270
|
-
pluralize.isPlural = checkWord(
|
13271
|
-
irregularSingles,
|
13272
|
-
irregularPlurals,
|
13273
|
-
pluralRules
|
13274
|
-
);
|
13275
|
-
pluralize.singular = replaceWord(
|
13276
|
-
irregularPlurals,
|
13277
|
-
irregularSingles,
|
13278
|
-
singularRules
|
13279
|
-
);
|
13280
|
-
pluralize.isSingular = checkWord(
|
13281
|
-
irregularPlurals,
|
13282
|
-
irregularSingles,
|
13283
|
-
singularRules
|
13284
|
-
);
|
13285
|
-
pluralize.addPluralRule = function(rule, replacement) {
|
13286
|
-
pluralRules.push([sanitizeRule(rule), replacement]);
|
13287
|
-
};
|
13288
|
-
pluralize.addSingularRule = function(rule, replacement) {
|
13289
|
-
singularRules.push([sanitizeRule(rule), replacement]);
|
13290
|
-
};
|
13291
|
-
pluralize.addUncountableRule = function(word) {
|
13292
|
-
if (typeof word === "string") {
|
13293
|
-
uncountables[word.toLowerCase()] = true;
|
13294
|
-
return;
|
13295
|
-
}
|
13296
|
-
pluralize.addPluralRule(word, "$0");
|
13297
|
-
pluralize.addSingularRule(word, "$0");
|
13298
|
-
};
|
13299
|
-
pluralize.addIrregularRule = function(single, plural2) {
|
13300
|
-
plural2 = plural2.toLowerCase();
|
13301
|
-
single = single.toLowerCase();
|
13302
|
-
irregularSingles[single] = plural2;
|
13303
|
-
irregularPlurals[plural2] = single;
|
13304
|
-
};
|
13305
|
-
[
|
13306
|
-
// Pronouns.
|
13307
|
-
["I", "we"],
|
13308
|
-
["me", "us"],
|
13309
|
-
["he", "they"],
|
13310
|
-
["she", "they"],
|
13311
|
-
["them", "them"],
|
13312
|
-
["myself", "ourselves"],
|
13313
|
-
["yourself", "yourselves"],
|
13314
|
-
["itself", "themselves"],
|
13315
|
-
["herself", "themselves"],
|
13316
|
-
["himself", "themselves"],
|
13317
|
-
["themself", "themselves"],
|
13318
|
-
["is", "are"],
|
13319
|
-
["was", "were"],
|
13320
|
-
["has", "have"],
|
13321
|
-
["this", "these"],
|
13322
|
-
["that", "those"],
|
13323
|
-
// Words ending in with a consonant and `o`.
|
13324
|
-
["echo", "echoes"],
|
13325
|
-
["dingo", "dingoes"],
|
13326
|
-
["volcano", "volcanoes"],
|
13327
|
-
["tornado", "tornadoes"],
|
13328
|
-
["torpedo", "torpedoes"],
|
13329
|
-
// Ends with `us`.
|
13330
|
-
["genus", "genera"],
|
13331
|
-
["viscus", "viscera"],
|
13332
|
-
// Ends with `ma`.
|
13333
|
-
["stigma", "stigmata"],
|
13334
|
-
["stoma", "stomata"],
|
13335
|
-
["dogma", "dogmata"],
|
13336
|
-
["lemma", "lemmata"],
|
13337
|
-
["schema", "schemata"],
|
13338
|
-
["anathema", "anathemata"],
|
13339
|
-
// Other irregular rules.
|
13340
|
-
["ox", "oxen"],
|
13341
|
-
["axe", "axes"],
|
13342
|
-
["die", "dice"],
|
13343
|
-
["yes", "yeses"],
|
13344
|
-
["foot", "feet"],
|
13345
|
-
["eave", "eaves"],
|
13346
|
-
["goose", "geese"],
|
13347
|
-
["tooth", "teeth"],
|
13348
|
-
["quiz", "quizzes"],
|
13349
|
-
["human", "humans"],
|
13350
|
-
["proof", "proofs"],
|
13351
|
-
["carve", "carves"],
|
13352
|
-
["valve", "valves"],
|
13353
|
-
["looey", "looies"],
|
13354
|
-
["thief", "thieves"],
|
13355
|
-
["groove", "grooves"],
|
13356
|
-
["pickaxe", "pickaxes"],
|
13357
|
-
["passerby", "passersby"]
|
13358
|
-
].forEach(function(rule) {
|
13359
|
-
return pluralize.addIrregularRule(rule[0], rule[1]);
|
13360
|
-
});
|
13361
|
-
[
|
13362
|
-
[/s?$/i, "s"],
|
13363
|
-
[/[^\u0000-\u007F]$/i, "$0"],
|
13364
|
-
[/([^aeiou]ese)$/i, "$1"],
|
13365
|
-
[/(ax|test)is$/i, "$1es"],
|
13366
|
-
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
13367
|
-
[/(e[mn]u)s?$/i, "$1s"],
|
13368
|
-
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
13369
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
13370
|
-
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
13371
|
-
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
13372
|
-
[/(her|at|gr)o$/i, "$1oes"],
|
13373
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
13374
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
13375
|
-
[/sis$/i, "ses"],
|
13376
|
-
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
13377
|
-
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
13378
|
-
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
13379
|
-
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
13380
|
-
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
13381
|
-
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
13382
|
-
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
13383
|
-
[/(child)(?:ren)?$/i, "$1ren"],
|
13384
|
-
[/eaux$/i, "$0"],
|
13385
|
-
[/m[ae]n$/i, "men"],
|
13386
|
-
["thou", "you"]
|
13387
|
-
].forEach(function(rule) {
|
13388
|
-
return pluralize.addPluralRule(rule[0], rule[1]);
|
13389
|
-
});
|
13390
|
-
[
|
13391
|
-
[/s$/i, ""],
|
13392
|
-
[/(ss)$/i, "$1"],
|
13393
|
-
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
13394
|
-
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
13395
|
-
[/ies$/i, "y"],
|
13396
|
-
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
13397
|
-
[/\b(mon|smil)ies$/i, "$1ey"],
|
13398
|
-
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
13399
|
-
[/(seraph|cherub)im$/i, "$1"],
|
13400
|
-
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
13401
|
-
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
13402
|
-
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
13403
|
-
[/(test)(?:is|es)$/i, "$1is"],
|
13404
|
-
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
13405
|
-
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
13406
|
-
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
13407
|
-
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
13408
|
-
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
13409
|
-
[/(matr|append)ices$/i, "$1ix"],
|
13410
|
-
[/(pe)(rson|ople)$/i, "$1rson"],
|
13411
|
-
[/(child)ren$/i, "$1"],
|
13412
|
-
[/(eau)x?$/i, "$1"],
|
13413
|
-
[/men$/i, "man"]
|
13414
|
-
].forEach(function(rule) {
|
13415
|
-
return pluralize.addSingularRule(rule[0], rule[1]);
|
13416
|
-
});
|
13417
|
-
[
|
13418
|
-
// Singular words with no plurals.
|
13419
|
-
"adulthood",
|
13420
|
-
"advice",
|
13421
|
-
"agenda",
|
13422
|
-
"aid",
|
13423
|
-
"aircraft",
|
13424
|
-
"alcohol",
|
13425
|
-
"ammo",
|
13426
|
-
"analytics",
|
13427
|
-
"anime",
|
13428
|
-
"athletics",
|
13429
|
-
"audio",
|
13430
|
-
"bison",
|
13431
|
-
"blood",
|
13432
|
-
"bream",
|
13433
|
-
"buffalo",
|
13434
|
-
"butter",
|
13435
|
-
"carp",
|
13436
|
-
"cash",
|
13437
|
-
"chassis",
|
13438
|
-
"chess",
|
13439
|
-
"clothing",
|
13440
|
-
"cod",
|
13441
|
-
"commerce",
|
13442
|
-
"cooperation",
|
13443
|
-
"corps",
|
13444
|
-
"debris",
|
13445
|
-
"diabetes",
|
13446
|
-
"digestion",
|
13447
|
-
"elk",
|
13448
|
-
"energy",
|
13449
|
-
"equipment",
|
13450
|
-
"excretion",
|
13451
|
-
"expertise",
|
13452
|
-
"firmware",
|
13453
|
-
"flounder",
|
13454
|
-
"fun",
|
13455
|
-
"gallows",
|
13456
|
-
"garbage",
|
13457
|
-
"graffiti",
|
13458
|
-
"hardware",
|
13459
|
-
"headquarters",
|
13460
|
-
"health",
|
13461
|
-
"herpes",
|
13462
|
-
"highjinks",
|
13463
|
-
"homework",
|
13464
|
-
"housework",
|
13465
|
-
"information",
|
13466
|
-
"jeans",
|
13467
|
-
"justice",
|
13468
|
-
"kudos",
|
13469
|
-
"labour",
|
13470
|
-
"literature",
|
13471
|
-
"machinery",
|
13472
|
-
"mackerel",
|
13473
|
-
"mail",
|
13474
|
-
"media",
|
13475
|
-
"mews",
|
13476
|
-
"moose",
|
13477
|
-
"music",
|
13478
|
-
"mud",
|
13479
|
-
"manga",
|
13480
|
-
"news",
|
13481
|
-
"only",
|
13482
|
-
"personnel",
|
13483
|
-
"pike",
|
13484
|
-
"plankton",
|
13485
|
-
"pliers",
|
13486
|
-
"police",
|
13487
|
-
"pollution",
|
13488
|
-
"premises",
|
13489
|
-
"rain",
|
13490
|
-
"research",
|
13491
|
-
"rice",
|
13492
|
-
"salmon",
|
13493
|
-
"scissors",
|
13494
|
-
"series",
|
13495
|
-
"sewage",
|
13496
|
-
"shambles",
|
13497
|
-
"shrimp",
|
13498
|
-
"software",
|
13499
|
-
"species",
|
13500
|
-
"staff",
|
13501
|
-
"swine",
|
13502
|
-
"tennis",
|
13503
|
-
"traffic",
|
13504
|
-
"transportation",
|
13505
|
-
"trout",
|
13506
|
-
"tuna",
|
13507
|
-
"wealth",
|
13508
|
-
"welfare",
|
13509
|
-
"whiting",
|
13510
|
-
"wildebeest",
|
13511
|
-
"wildlife",
|
13512
|
-
"you",
|
13513
|
-
/pok[eé]mon$/i,
|
13514
|
-
// Regexes.
|
13515
|
-
/[^aeiou]ese$/i,
|
13516
|
-
// "chinese", "japanese"
|
13517
|
-
/deer$/i,
|
13518
|
-
// "deer", "reindeer"
|
13519
|
-
/fish$/i,
|
13520
|
-
// "fish", "blowfish", "angelfish"
|
13521
|
-
/measles$/i,
|
13522
|
-
/o[iu]s$/i,
|
13523
|
-
// "carnivorous"
|
13524
|
-
/pox$/i,
|
13525
|
-
// "chickpox", "smallpox"
|
13526
|
-
/sheep$/i
|
13527
|
-
].forEach(pluralize.addUncountableRule);
|
13528
|
-
return pluralize;
|
13529
|
-
});
|
13530
|
-
}
|
13531
|
-
});
|
13532
|
-
|
13533
12886
|
// node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js
|
13534
12887
|
var require_balanced_match = __commonJS({
|
13535
12888
|
"node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports, module) {
|
@@ -13820,7 +13173,6 @@ function applyJsonDiff(json1, json2) {
|
|
13820
13173
|
var findAlternationsInTable, alternationsInColumn;
|
13821
13174
|
var init_jsonDiffer = __esm({
|
13822
13175
|
"src/jsonDiffer.js"() {
|
13823
|
-
"use strict";
|
13824
13176
|
"use-strict";
|
13825
13177
|
findAlternationsInTable = (table4, tableSchema) => {
|
13826
13178
|
const columns = table4.columns ?? {};
|
@@ -13992,21 +13344,20 @@ var init_jsonDiffer = __esm({
|
|
13992
13344
|
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;
|
13993
13345
|
var init_jsonStatements = __esm({
|
13994
13346
|
"src/jsonStatements.ts"() {
|
13995
|
-
"use strict";
|
13996
13347
|
init_mysqlSchema();
|
13997
13348
|
init_pgSchema();
|
13998
13349
|
init_sqliteSchema();
|
13999
13350
|
preparePgCreateTableJson = (table4, json2) => {
|
14000
13351
|
const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
14001
|
-
const tableKey = `${schema4 || "public"}.${name}`;
|
14002
|
-
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
14003
13352
|
return {
|
14004
13353
|
type: "create_table",
|
14005
13354
|
tableName: name,
|
14006
13355
|
schema: schema4,
|
14007
13356
|
columns: Object.values(columns),
|
14008
13357
|
compositePKs: Object.values(compositePrimaryKeys),
|
14009
|
-
compositePkName
|
13358
|
+
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
|
13359
|
+
Object.values(compositePrimaryKeys)[0]
|
13360
|
+
).name}`].name : "",
|
14010
13361
|
uniqueConstraints: Object.values(uniqueConstraints)
|
14011
13362
|
};
|
14012
13363
|
};
|
@@ -14105,12 +13456,11 @@ var init_jsonStatements = __esm({
|
|
14105
13456
|
};
|
14106
13457
|
});
|
14107
13458
|
};
|
14108
|
-
prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2,
|
13459
|
+
prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect6) => {
|
14109
13460
|
const addColumns = [];
|
14110
13461
|
const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
|
14111
|
-
const
|
14112
|
-
|
14113
|
-
if (dialect7 === "sqlite") {
|
13462
|
+
const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
|
13463
|
+
if (dialect6 === "sqlite") {
|
14114
13464
|
let jsonCreateFKStatements = Object.values(addedFk);
|
14115
13465
|
const sqliteAddColumns = _prepareSQLiteAddColumns(
|
14116
13466
|
tableName,
|
@@ -14159,22 +13509,19 @@ var init_jsonStatements = __esm({
|
|
14159
13509
|
};
|
14160
13510
|
});
|
14161
13511
|
};
|
14162
|
-
_prepareAlterColumns = (
|
13512
|
+
_prepareAlterColumns = (tableName, schema4, columns, json2) => {
|
14163
13513
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
14164
13514
|
let statements = [];
|
14165
13515
|
let dropPkStatements = [];
|
14166
13516
|
let setPkStatements = [];
|
14167
13517
|
for (const column4 of columns) {
|
14168
13518
|
const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
|
14169
|
-
const
|
14170
|
-
const
|
14171
|
-
const
|
14172
|
-
const
|
14173
|
-
const
|
14174
|
-
const
|
14175
|
-
const columnNotNull = table4.columns[columnName].notNull;
|
14176
|
-
const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
|
14177
|
-
const columnPk = table4.columns[columnName].primaryKey;
|
13519
|
+
const columnType = json2.tables[tableName].columns[columnName].type;
|
13520
|
+
const columnDefault = json2.tables[tableName].columns[columnName].default;
|
13521
|
+
const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
|
13522
|
+
const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
|
13523
|
+
const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
|
13524
|
+
const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
|
14178
13525
|
if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
|
14179
13526
|
statements.push({
|
14180
13527
|
type: "alter_table_alter_column_set_autoincrement",
|
@@ -14221,14 +13568,13 @@ var init_jsonStatements = __esm({
|
|
14221
13568
|
}
|
14222
13569
|
for (const column4 of columns) {
|
14223
13570
|
const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
|
14224
|
-
const
|
14225
|
-
const
|
14226
|
-
const
|
14227
|
-
const
|
14228
|
-
const
|
14229
|
-
const
|
14230
|
-
const
|
14231
|
-
const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
|
13571
|
+
const columnType = json2.tables[tableName].columns[columnName].type;
|
13572
|
+
const columnDefault = json2.tables[tableName].columns[columnName].default;
|
13573
|
+
const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
|
13574
|
+
const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
|
13575
|
+
const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
|
13576
|
+
const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
|
13577
|
+
const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
|
14232
13578
|
if (typeof column4.name !== "string") {
|
14233
13579
|
statements.push({
|
14234
13580
|
type: "alter_table_rename_column",
|
@@ -14579,7 +13925,6 @@ var init_jsonStatements = __esm({
|
|
14579
13925
|
var prepareMigrationMetadata, adjectives, heroes;
|
14580
13926
|
var init_words = __esm({
|
14581
13927
|
"src/utils/words.ts"() {
|
14582
|
-
"use strict";
|
14583
13928
|
prepareMigrationMetadata = (idx) => {
|
14584
13929
|
const prefix = idx.toFixed(0).padStart(4, "0");
|
14585
13930
|
const suffix = `${adjectives.random()}_${heroes.random()}`;
|
@@ -15900,7 +15245,6 @@ var init_words = __esm({
|
|
15900
15245
|
// src/cli/commands/pgUp.ts
|
15901
15246
|
var init_pgUp = __esm({
|
15902
15247
|
"src/cli/commands/pgUp.ts"() {
|
15903
|
-
"use strict";
|
15904
15248
|
init_source();
|
15905
15249
|
init_global();
|
15906
15250
|
init_pgSchema();
|
@@ -15911,7 +15255,6 @@ var init_pgUp = __esm({
|
|
15911
15255
|
// src/cli/commands/mysqlUp.ts
|
15912
15256
|
var init_mysqlUp = __esm({
|
15913
15257
|
"src/cli/commands/mysqlUp.ts"() {
|
15914
|
-
"use strict";
|
15915
15258
|
init_source();
|
15916
15259
|
init_mysqlSchema();
|
15917
15260
|
init_utils2();
|
@@ -15921,7 +15264,6 @@ var init_mysqlUp = __esm({
|
|
15921
15264
|
// src/cli/commands/upFolders.ts
|
15922
15265
|
var init_upFolders = __esm({
|
15923
15266
|
"src/cli/commands/upFolders.ts"() {
|
15924
|
-
"use strict";
|
15925
15267
|
init_jsonDiffer();
|
15926
15268
|
init_mysqlSchema();
|
15927
15269
|
init_sqliteSchema();
|
@@ -15943,10 +15285,9 @@ import {
|
|
15943
15285
|
writeFileSync
|
15944
15286
|
} from "fs";
|
15945
15287
|
import { join } from "path";
|
15946
|
-
var assertV1OutFolder, dryJournal,
|
15288
|
+
var assertV1OutFolder, dryJournal, prepareOutFolder2, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
15947
15289
|
var init_utils2 = __esm({
|
15948
15290
|
"src/utils.ts"() {
|
15949
|
-
"use strict";
|
15950
15291
|
init_views();
|
15951
15292
|
init_mysqlSchema();
|
15952
15293
|
init_pgSchema();
|
@@ -15955,7 +15296,7 @@ var init_utils2 = __esm({
|
|
15955
15296
|
init_global();
|
15956
15297
|
init_upFolders();
|
15957
15298
|
init_snapshotsDiffer();
|
15958
|
-
assertV1OutFolder = (out) => {
|
15299
|
+
assertV1OutFolder = (out, dialect6) => {
|
15959
15300
|
if (!existsSync(out))
|
15960
15301
|
return;
|
15961
15302
|
const oldMigrationFolders = readdirSync(out).filter(
|
@@ -15964,43 +15305,43 @@ var init_utils2 = __esm({
|
|
15964
15305
|
if (oldMigrationFolders.length > 0) {
|
15965
15306
|
console.log(
|
15966
15307
|
`Your migrations folder format is outdated, please run ${source_default.green.bold(
|
15967
|
-
`drizzle-kit up`
|
15308
|
+
`drizzle-kit up:${dialect6}`
|
15968
15309
|
)}`
|
15969
15310
|
);
|
15970
15311
|
process.exit(1);
|
15971
15312
|
}
|
15972
15313
|
};
|
15973
|
-
dryJournal = (
|
15314
|
+
dryJournal = (dialect6) => {
|
15974
15315
|
return {
|
15975
15316
|
version: snapshotVersion,
|
15976
|
-
dialect:
|
15317
|
+
dialect: dialect6,
|
15977
15318
|
entries: []
|
15978
15319
|
};
|
15979
15320
|
};
|
15980
|
-
|
15321
|
+
prepareOutFolder2 = (out, dialect6) => {
|
15981
15322
|
const meta = join(out, "meta");
|
15982
15323
|
const journalPath = join(meta, "_journal.json");
|
15983
15324
|
if (!existsSync(join(out, "meta"))) {
|
15984
15325
|
mkdirSync(meta, { recursive: true });
|
15985
|
-
writeFileSync(journalPath, JSON.stringify(dryJournal(
|
15326
|
+
writeFileSync(journalPath, JSON.stringify(dryJournal(dialect6)));
|
15986
15327
|
}
|
15987
15328
|
const journal = JSON.parse(readFileSync(journalPath).toString());
|
15988
15329
|
const snapshots = readdirSync(meta).filter((it) => !it.startsWith("_")).map((it) => join(meta, it));
|
15989
15330
|
snapshots.sort();
|
15990
15331
|
return { meta, snapshots, journal };
|
15991
15332
|
};
|
15992
|
-
validatorForDialect = (
|
15993
|
-
switch (
|
15333
|
+
validatorForDialect = (dialect6) => {
|
15334
|
+
switch (dialect6) {
|
15994
15335
|
case "pg":
|
15995
|
-
return { validator: backwardCompatiblePgSchema, version:
|
15336
|
+
return { validator: backwardCompatiblePgSchema, version: 5 };
|
15996
15337
|
case "sqlite":
|
15997
|
-
return { validator: backwardCompatibleSqliteSchema, version:
|
15338
|
+
return { validator: backwardCompatibleSqliteSchema, version: 5 };
|
15998
15339
|
case "mysql":
|
15999
15340
|
return { validator: backwardCompatibleMysqlSchema, version: 5 };
|
16000
15341
|
}
|
16001
15342
|
};
|
16002
|
-
validateWithReport = (snapshots,
|
16003
|
-
const { validator, version } = validatorForDialect(
|
15343
|
+
validateWithReport = (snapshots, dialect6) => {
|
15344
|
+
const { validator, version } = validatorForDialect(dialect6);
|
16004
15345
|
const result = snapshots.reduce(
|
16005
15346
|
(accum, it) => {
|
16006
15347
|
const raw = JSON.parse(readFileSync(`./${it}`).toString());
|
@@ -16041,14 +15382,14 @@ var init_utils2 = __esm({
|
|
16041
15382
|
);
|
16042
15383
|
return result;
|
16043
15384
|
};
|
16044
|
-
prepareMigrationFolder = (outFolder = "drizzle",
|
16045
|
-
const { snapshots, journal } =
|
16046
|
-
const report = validateWithReport(snapshots,
|
15385
|
+
prepareMigrationFolder = (outFolder = "drizzle", dialect6) => {
|
15386
|
+
const { snapshots, journal } = prepareOutFolder2(outFolder, dialect6);
|
15387
|
+
const report = validateWithReport(snapshots, dialect6);
|
16047
15388
|
if (report.nonLatest.length > 0) {
|
16048
15389
|
console.log(
|
16049
15390
|
report.nonLatest.map((it) => {
|
16050
15391
|
return `${it}/snapshot.json is not of the latest version`;
|
16051
|
-
}).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
|
15392
|
+
}).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect6}`)}`).join("\n")
|
16052
15393
|
);
|
16053
15394
|
process.exit(0);
|
16054
15395
|
}
|
@@ -16117,7 +15458,6 @@ var init_utils2 = __esm({
|
|
16117
15458
|
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, valueFromSelfOrPatchedNew, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
|
16118
15459
|
var init_snapshotsDiffer = __esm({
|
16119
15460
|
"src/snapshotsDiffer.ts"() {
|
16120
|
-
"use strict";
|
16121
15461
|
init_sqlgenerator();
|
16122
15462
|
init_lib();
|
16123
15463
|
init_jsonDiffer();
|
@@ -16125,7 +15465,6 @@ var init_snapshotsDiffer = __esm({
|
|
16125
15465
|
init_utils2();
|
16126
15466
|
init_sqliteSchema();
|
16127
15467
|
init_mysqlSchema();
|
16128
|
-
init_global();
|
16129
15468
|
makeChanged = (schema4) => {
|
16130
15469
|
return objectType({
|
16131
15470
|
type: enumType(["changed"]),
|
@@ -16164,7 +15503,7 @@ var init_snapshotsDiffer = __esm({
|
|
16164
15503
|
return unionType([
|
16165
15504
|
objectType({
|
16166
15505
|
type: literalType("none"),
|
16167
|
-
value: schema4
|
15506
|
+
value: schema4.optional()
|
16168
15507
|
}),
|
16169
15508
|
objectType({
|
16170
15509
|
type: literalType("added"),
|
@@ -16286,9 +15625,10 @@ var init_snapshotsDiffer = __esm({
|
|
16286
15625
|
addedSchemas: stringType().array(),
|
16287
15626
|
deletedSchemas: stringType().array()
|
16288
15627
|
}).strict();
|
16289
|
-
applySnapshotsDiff = async (json1, json2,
|
15628
|
+
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
16290
15629
|
var _a, _b;
|
16291
|
-
|
15630
|
+
let diffResult;
|
15631
|
+
if (dialect6 === "mysql") {
|
16292
15632
|
for (const tableName in json1.tables) {
|
16293
15633
|
const table4 = json1.tables[tableName];
|
16294
15634
|
for (const indexName3 in table4.indexes) {
|
@@ -16315,26 +15655,13 @@ var init_snapshotsDiffer = __esm({
|
|
16315
15655
|
}
|
16316
15656
|
}
|
16317
15657
|
}
|
15658
|
+
diffResult = applyJsonDiff(json1, json2);
|
16318
15659
|
}
|
16319
|
-
|
15660
|
+
diffResult = applyJsonDiff(json1, json2);
|
16320
15661
|
if (Object.keys(diffResult).length === 0) {
|
16321
15662
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
16322
15663
|
}
|
16323
15664
|
const typedResult = diffResultScheme.parse(diffResult);
|
16324
|
-
typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
|
16325
|
-
let schemaToTrim;
|
16326
|
-
if (it.schema.type === "none") {
|
16327
|
-
schemaToTrim = it.schema.value || "public";
|
16328
|
-
} else if (it.schema.type === "deleted") {
|
16329
|
-
schemaToTrim = it.schema.value;
|
16330
|
-
} else if (it.schema.type === "added") {
|
16331
|
-
schemaToTrim = "public";
|
16332
|
-
} else {
|
16333
|
-
schemaToTrim = it.schema.old;
|
16334
|
-
}
|
16335
|
-
it.name = it.name.substring(schemaToTrim.length + 1);
|
16336
|
-
return it;
|
16337
|
-
});
|
16338
15665
|
const {
|
16339
15666
|
created: createdSchemas,
|
16340
15667
|
deleted: deletedSchemas,
|
@@ -16426,9 +15753,9 @@ var init_snapshotsDiffer = __esm({
|
|
16426
15753
|
let addedColumns = [];
|
16427
15754
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
16428
15755
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
16429
|
-
if (
|
15756
|
+
if (dialect6 === "sqlite") {
|
16430
15757
|
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
16431
|
-
} else if (
|
15758
|
+
} else if (dialect6 === "mysql") {
|
16432
15759
|
addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
|
16433
15760
|
} else {
|
16434
15761
|
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
@@ -16437,9 +15764,9 @@ var init_snapshotsDiffer = __esm({
|
|
16437
15764
|
let deletedColumns = [];
|
16438
15765
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
16439
15766
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
16440
|
-
if (
|
15767
|
+
if (dialect6 === "sqlite") {
|
16441
15768
|
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
16442
|
-
} else if (
|
15769
|
+
} else if (dialect6 === "mysql") {
|
16443
15770
|
deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
|
16444
15771
|
} else {
|
16445
15772
|
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
@@ -16449,7 +15776,7 @@ var init_snapshotsDiffer = __esm({
|
|
16449
15776
|
let addedCompositePKs = [];
|
16450
15777
|
let deletedCompositePKs = [];
|
16451
15778
|
let alteredCompositePKs = [];
|
16452
|
-
if (
|
15779
|
+
if (dialect6 === "sqlite") {
|
16453
15780
|
if (doPerformDeleteAndCreate) {
|
16454
15781
|
addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
16455
15782
|
it.name,
|
@@ -16464,7 +15791,7 @@ var init_snapshotsDiffer = __esm({
|
|
16464
15791
|
it.name,
|
16465
15792
|
it.alteredCompositePKs
|
16466
15793
|
);
|
16467
|
-
} else if (
|
15794
|
+
} else if (dialect6 === "pg") {
|
16468
15795
|
if (doPerformDeleteAndCreate) {
|
16469
15796
|
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
16470
15797
|
it.name,
|
@@ -16486,7 +15813,7 @@ var init_snapshotsDiffer = __esm({
|
|
16486
15813
|
prevFull,
|
16487
15814
|
curFull
|
16488
15815
|
);
|
16489
|
-
} else
|
15816
|
+
} else {
|
16490
15817
|
addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
|
16491
15818
|
it.name,
|
16492
15819
|
it.addedCompositePKs,
|
@@ -16504,8 +15831,6 @@ var init_snapshotsDiffer = __esm({
|
|
16504
15831
|
prevFull,
|
16505
15832
|
curFull
|
16506
15833
|
);
|
16507
|
-
} else {
|
16508
|
-
assertUnreachable(dialect7);
|
16509
15834
|
}
|
16510
15835
|
let addedUniqueConstraints = [];
|
16511
15836
|
let deletedUniqueConstraints = [];
|
@@ -16588,7 +15913,7 @@ var init_snapshotsDiffer = __esm({
|
|
16588
15913
|
it.altered,
|
16589
15914
|
it.addedForeignKeys,
|
16590
15915
|
json2,
|
16591
|
-
|
15916
|
+
dialect6
|
16592
15917
|
);
|
16593
15918
|
}).flat().reduce(
|
16594
15919
|
(res, it) => {
|
@@ -16665,7 +15990,7 @@ var init_snapshotsDiffer = __esm({
|
|
16665
15990
|
const jsonAlterEnumsWithAddedValues = ((_b = typedResult.alteredEnums) == null ? void 0 : _b.map((it) => {
|
16666
15991
|
return prepareAddValuesToEnumJson(it.name, it.addedValues);
|
16667
15992
|
}).flat()) ?? [];
|
16668
|
-
if (
|
15993
|
+
if (dialect6 === "mysql") {
|
16669
15994
|
createdSchemas.push(...renamedSchemas.map((it) => it.to));
|
16670
15995
|
deletedSchemas.push(...renamedSchemas.map((it) => it.from));
|
16671
15996
|
renamedSchemas.splice(0, renamedSchemas.length);
|
@@ -16689,25 +16014,23 @@ var init_snapshotsDiffer = __esm({
|
|
16689
16014
|
jsonStatements.push(...renameSchemas);
|
16690
16015
|
jsonStatements.push(...createEnums);
|
16691
16016
|
jsonStatements.push(...jsonAlterEnumsWithAddedValues);
|
16692
|
-
if (
|
16017
|
+
if (dialect6 === "sqlite") {
|
16693
16018
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
16694
|
-
} else if (
|
16019
|
+
} else if (dialect6 === "pg") {
|
16695
16020
|
const jsonPgCreateTables = created.map((it) => {
|
16696
16021
|
return preparePgCreateTableJson(it, curFull);
|
16697
16022
|
});
|
16698
16023
|
jsonStatements.push(...jsonPgCreateTables);
|
16699
|
-
} else
|
16024
|
+
} else {
|
16700
16025
|
const jsonMySqlCreateTables = created.map((it) => {
|
16701
16026
|
return prepareMySqlCreateTableJson(it, curFull);
|
16702
16027
|
});
|
16703
16028
|
jsonStatements.push(...jsonMySqlCreateTables);
|
16704
|
-
} else {
|
16705
|
-
assertUnreachable(dialect7);
|
16706
16029
|
}
|
16707
16030
|
jsonStatements.push(...jsonDropTables);
|
16708
16031
|
jsonStatements.push(...jsonRenameTables);
|
16709
16032
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16710
|
-
if (
|
16033
|
+
if (dialect6 !== "mysql") {
|
16711
16034
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16712
16035
|
}
|
16713
16036
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
@@ -16715,7 +16038,7 @@ var init_snapshotsDiffer = __esm({
|
|
16715
16038
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
16716
16039
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
16717
16040
|
jsonStatements.push(...jsonAddedCompositePKs);
|
16718
|
-
if (
|
16041
|
+
if (dialect6 === "mysql") {
|
16719
16042
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16720
16043
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16721
16044
|
}
|
@@ -16724,10 +16047,10 @@ var init_snapshotsDiffer = __esm({
|
|
16724
16047
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16725
16048
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16726
16049
|
jsonStatements.push(...jsonTableAlternations.dropColumns);
|
16727
|
-
if (
|
16050
|
+
if (dialect6 !== "sqlite")
|
16728
16051
|
jsonStatements.push(...jsonCreateReferences);
|
16729
16052
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16730
|
-
if (
|
16053
|
+
if (dialect6 !== "mysql") {
|
16731
16054
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16732
16055
|
}
|
16733
16056
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
@@ -16735,7 +16058,7 @@ var init_snapshotsDiffer = __esm({
|
|
16735
16058
|
jsonStatements.push(...filteredJsonSetNewTableSchemas);
|
16736
16059
|
jsonStatements.push(...jsonRemoveTableFromSchemas);
|
16737
16060
|
jsonStatements.push(...dropSchemas);
|
16738
|
-
const sqlStatements = fromJson(jsonStatements,
|
16061
|
+
const sqlStatements = fromJson(jsonStatements, dialect6);
|
16739
16062
|
const uniqueSqlStatements = [];
|
16740
16063
|
sqlStatements.forEach((ss) => {
|
16741
16064
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -16772,7 +16095,6 @@ import path2, { join as join2 } from "path";
|
|
16772
16095
|
var import_hanji4, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
16773
16096
|
var init_migrate = __esm({
|
16774
16097
|
"src/cli/commands/migrate.ts"() {
|
16775
|
-
"use strict";
|
16776
16098
|
init_migrationPreparator();
|
16777
16099
|
init_snapshotsDiffer();
|
16778
16100
|
import_hanji4 = __toESM(require_hanji());
|
@@ -16788,7 +16110,7 @@ var init_migrate = __esm({
|
|
16788
16110
|
const outFolder = config.out;
|
16789
16111
|
const schemaPath = config.schema;
|
16790
16112
|
try {
|
16791
|
-
assertV1OutFolder(outFolder);
|
16113
|
+
assertV1OutFolder(outFolder, "pg");
|
16792
16114
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "pg");
|
16793
16115
|
const { prev, cur, custom } = await preparePgMigrationSnapshot(
|
16794
16116
|
snapshots,
|
@@ -16848,56 +16170,66 @@ var init_migrate = __esm({
|
|
16848
16170
|
return { sqlStatements, statements, validatedCur, validatedPrev };
|
16849
16171
|
} catch (e) {
|
16850
16172
|
console.error(e);
|
16851
|
-
process.exit(1);
|
16852
16173
|
}
|
16853
16174
|
};
|
16854
16175
|
prepareSQLitePush = async (config, snapshot) => {
|
16855
16176
|
const schemaPath = config.schema;
|
16856
|
-
|
16857
|
-
|
16858
|
-
|
16859
|
-
|
16860
|
-
|
16861
|
-
|
16862
|
-
|
16863
|
-
|
16864
|
-
|
16865
|
-
|
16866
|
-
|
16867
|
-
|
16868
|
-
|
16869
|
-
|
16870
|
-
|
16871
|
-
|
16872
|
-
|
16873
|
-
|
16874
|
-
|
16177
|
+
try {
|
16178
|
+
const { prev, cur } = await prepareSQLiteDbPushSnapshot(
|
16179
|
+
snapshot,
|
16180
|
+
schemaPath
|
16181
|
+
);
|
16182
|
+
const validatedPrev = sqliteSchema.parse(prev);
|
16183
|
+
const validatedCur = sqliteSchema.parse(cur);
|
16184
|
+
const squashedPrev = squashSqliteScheme(validatedPrev);
|
16185
|
+
const squashedCur = squashSqliteScheme(validatedCur);
|
16186
|
+
const { sqlStatements, statements, _meta } = await prepareSQL(
|
16187
|
+
squashedPrev,
|
16188
|
+
squashedCur,
|
16189
|
+
"sqlite",
|
16190
|
+
validatedPrev,
|
16191
|
+
validatedCur
|
16192
|
+
);
|
16193
|
+
return {
|
16194
|
+
sqlStatements,
|
16195
|
+
statements,
|
16196
|
+
squashedPrev,
|
16197
|
+
squashedCur,
|
16198
|
+
meta: _meta
|
16199
|
+
};
|
16200
|
+
} catch (e) {
|
16201
|
+
console.error(e);
|
16202
|
+
}
|
16875
16203
|
};
|
16876
16204
|
preparePgPush = async (config, snapshot, schemaFilter) => {
|
16877
16205
|
const schemaPath = config.schema;
|
16878
|
-
|
16879
|
-
|
16880
|
-
|
16881
|
-
|
16882
|
-
|
16883
|
-
|
16884
|
-
|
16885
|
-
|
16886
|
-
|
16887
|
-
|
16888
|
-
|
16889
|
-
|
16890
|
-
|
16891
|
-
|
16892
|
-
|
16893
|
-
|
16894
|
-
|
16206
|
+
try {
|
16207
|
+
const { prev, cur } = await preparePgDbPushSnapshot(
|
16208
|
+
snapshot,
|
16209
|
+
schemaPath,
|
16210
|
+
schemaFilter
|
16211
|
+
);
|
16212
|
+
const validatedPrev = pgSchema.parse(prev);
|
16213
|
+
const validatedCur = pgSchema.parse(cur);
|
16214
|
+
const squashedPrev = squashPgScheme(validatedPrev);
|
16215
|
+
const squashedCur = squashPgScheme(validatedCur);
|
16216
|
+
const { sqlStatements, statements } = await prepareSQL(
|
16217
|
+
squashedPrev,
|
16218
|
+
squashedCur,
|
16219
|
+
"pg",
|
16220
|
+
validatedPrev,
|
16221
|
+
validatedCur
|
16222
|
+
);
|
16223
|
+
return { sqlStatements, statements, squashedPrev, squashedCur };
|
16224
|
+
} catch (e) {
|
16225
|
+
console.error(e);
|
16226
|
+
}
|
16895
16227
|
};
|
16896
16228
|
prepareAndMigrateMySql = async (config) => {
|
16897
16229
|
const outFolder = config.out;
|
16898
16230
|
const schemaPath = config.schema;
|
16899
16231
|
try {
|
16900
|
-
assertV1OutFolder(outFolder);
|
16232
|
+
assertV1OutFolder(outFolder, "mysql");
|
16901
16233
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
|
16902
16234
|
const { prev, cur, custom } = await prepareMySqlMigrationSnapshot(
|
16903
16235
|
snapshots,
|
@@ -16941,7 +16273,7 @@ var init_migrate = __esm({
|
|
16941
16273
|
const outFolder = config.out;
|
16942
16274
|
const schemaPath = config.schema;
|
16943
16275
|
try {
|
16944
|
-
assertV1OutFolder(outFolder);
|
16276
|
+
assertV1OutFolder(outFolder, "sqlite");
|
16945
16277
|
const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
|
16946
16278
|
const { prev, cur, custom } = await prepareSqliteMigrationSnapshot(
|
16947
16279
|
snapshots,
|
@@ -16966,9 +16298,7 @@ var init_migrate = __esm({
|
|
16966
16298
|
const { sqlStatements, _meta } = await prepareSQL(
|
16967
16299
|
squashedPrev,
|
16968
16300
|
squashedCur,
|
16969
|
-
"sqlite"
|
16970
|
-
validatedPrev,
|
16971
|
-
validatedCur
|
16301
|
+
"sqlite"
|
16972
16302
|
);
|
16973
16303
|
writeResult({
|
16974
16304
|
cur,
|
@@ -16983,7 +16313,7 @@ var init_migrate = __esm({
|
|
16983
16313
|
console.error(e);
|
16984
16314
|
}
|
16985
16315
|
};
|
16986
|
-
prepareSQL = async (prev, cur,
|
16316
|
+
prepareSQL = async (prev, cur, dialect6, prevFull, curFull) => {
|
16987
16317
|
const schemasResolver = async (input) => {
|
16988
16318
|
try {
|
16989
16319
|
const { created, deleted, renamed } = await promptSchemasConflict(
|
@@ -17025,7 +16355,7 @@ var init_migrate = __esm({
|
|
17025
16355
|
return await applySnapshotsDiff(
|
17026
16356
|
prev,
|
17027
16357
|
cur,
|
17028
|
-
|
16358
|
+
dialect6,
|
17029
16359
|
schemasResolver,
|
17030
16360
|
tablesResolver,
|
17031
16361
|
columnsResolver,
|
@@ -17267,7 +16597,6 @@ ${sql2}
|
|
17267
16597
|
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;
|
17268
16598
|
var init_sqlgenerator = __esm({
|
17269
16599
|
"src/sqlgenerator.ts"() {
|
17270
|
-
"use strict";
|
17271
16600
|
init_migrate();
|
17272
16601
|
init_mysqlSchema();
|
17273
16602
|
init_pgSchema();
|
@@ -17322,8 +16651,8 @@ var init_sqlgenerator = __esm({
|
|
17322
16651
|
Convertor = class {
|
17323
16652
|
};
|
17324
16653
|
PgCreateTableConvertor = class extends Convertor {
|
17325
|
-
can(statement,
|
17326
|
-
return statement.type === "create_table" &&
|
16654
|
+
can(statement, dialect6) {
|
16655
|
+
return statement.type === "create_table" && dialect6 === "pg";
|
17327
16656
|
}
|
17328
16657
|
convert(st) {
|
17329
16658
|
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
@@ -17361,8 +16690,8 @@ var init_sqlgenerator = __esm({
|
|
17361
16690
|
}
|
17362
16691
|
};
|
17363
16692
|
MySqlCreateTableConvertor = class extends Convertor {
|
17364
|
-
can(statement,
|
17365
|
-
return statement.type === "create_table" &&
|
16693
|
+
can(statement, dialect6) {
|
16694
|
+
return statement.type === "create_table" && dialect6 === "mysql";
|
17366
16695
|
}
|
17367
16696
|
convert(st) {
|
17368
16697
|
const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
|
@@ -17400,8 +16729,8 @@ var init_sqlgenerator = __esm({
|
|
17400
16729
|
}
|
17401
16730
|
};
|
17402
16731
|
SQLiteCreateTableConvertor = class extends Convertor {
|
17403
|
-
can(statement,
|
17404
|
-
return statement.type === "sqlite_create_table" &&
|
16732
|
+
can(statement, dialect6) {
|
16733
|
+
return statement.type === "sqlite_create_table" && dialect6 === "sqlite";
|
17405
16734
|
}
|
17406
16735
|
convert(st) {
|
17407
16736
|
const {
|
@@ -17463,8 +16792,8 @@ var init_sqlgenerator = __esm({
|
|
17463
16792
|
}
|
17464
16793
|
};
|
17465
16794
|
PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17466
|
-
can(statement,
|
17467
|
-
return statement.type === "create_unique_constraint" &&
|
16795
|
+
can(statement, dialect6) {
|
16796
|
+
return statement.type === "create_unique_constraint" && dialect6 === "pg";
|
17468
16797
|
}
|
17469
16798
|
convert(statement) {
|
17470
16799
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
@@ -17473,8 +16802,8 @@ var init_sqlgenerator = __esm({
|
|
17473
16802
|
}
|
17474
16803
|
};
|
17475
16804
|
PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17476
|
-
can(statement,
|
17477
|
-
return statement.type === "delete_unique_constraint" &&
|
16805
|
+
can(statement, dialect6) {
|
16806
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "pg";
|
17478
16807
|
}
|
17479
16808
|
convert(statement) {
|
17480
16809
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
@@ -17483,8 +16812,8 @@ var init_sqlgenerator = __esm({
|
|
17483
16812
|
}
|
17484
16813
|
};
|
17485
16814
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17486
|
-
can(statement,
|
17487
|
-
return statement.type === "create_unique_constraint" &&
|
16815
|
+
can(statement, dialect6) {
|
16816
|
+
return statement.type === "create_unique_constraint" && dialect6 === "mysql";
|
17488
16817
|
}
|
17489
16818
|
convert(statement) {
|
17490
16819
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
@@ -17493,8 +16822,8 @@ var init_sqlgenerator = __esm({
|
|
17493
16822
|
}
|
17494
16823
|
};
|
17495
16824
|
MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17496
|
-
can(statement,
|
17497
|
-
return statement.type === "delete_unique_constraint" &&
|
16825
|
+
can(statement, dialect6) {
|
16826
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "mysql";
|
17498
16827
|
}
|
17499
16828
|
convert(statement) {
|
17500
16829
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
@@ -17503,8 +16832,8 @@ var init_sqlgenerator = __esm({
|
|
17503
16832
|
}
|
17504
16833
|
};
|
17505
16834
|
SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
17506
|
-
can(statement,
|
17507
|
-
return statement.type === "create_unique_constraint" &&
|
16835
|
+
can(statement, dialect6) {
|
16836
|
+
return statement.type === "create_unique_constraint" && dialect6 === "sqlite";
|
17508
16837
|
}
|
17509
16838
|
convert(statement) {
|
17510
16839
|
return `/*
|
@@ -17516,8 +16845,8 @@ var init_sqlgenerator = __esm({
|
|
17516
16845
|
}
|
17517
16846
|
};
|
17518
16847
|
SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
17519
|
-
can(statement,
|
17520
|
-
return statement.type === "delete_unique_constraint" &&
|
16848
|
+
can(statement, dialect6) {
|
16849
|
+
return statement.type === "delete_unique_constraint" && dialect6 === "sqlite";
|
17521
16850
|
}
|
17522
16851
|
convert(statement) {
|
17523
16852
|
return `/*
|
@@ -17560,8 +16889,8 @@ var init_sqlgenerator = __esm({
|
|
17560
16889
|
}
|
17561
16890
|
};
|
17562
16891
|
PgDropTableConvertor = class extends Convertor {
|
17563
|
-
can(statement,
|
17564
|
-
return statement.type === "drop_table" &&
|
16892
|
+
can(statement, dialect6) {
|
16893
|
+
return statement.type === "drop_table" && dialect6 === "pg";
|
17565
16894
|
}
|
17566
16895
|
convert(statement) {
|
17567
16896
|
const { tableName, schema: schema4 } = statement;
|
@@ -17570,8 +16899,8 @@ var init_sqlgenerator = __esm({
|
|
17570
16899
|
}
|
17571
16900
|
};
|
17572
16901
|
MySQLDropTableConvertor = class extends Convertor {
|
17573
|
-
can(statement,
|
17574
|
-
return statement.type === "drop_table" &&
|
16902
|
+
can(statement, dialect6) {
|
16903
|
+
return statement.type === "drop_table" && dialect6 === "mysql";
|
17575
16904
|
}
|
17576
16905
|
convert(statement) {
|
17577
16906
|
const { tableName } = statement;
|
@@ -17579,8 +16908,8 @@ var init_sqlgenerator = __esm({
|
|
17579
16908
|
}
|
17580
16909
|
};
|
17581
16910
|
SQLiteDropTableConvertor = class extends Convertor {
|
17582
|
-
can(statement,
|
17583
|
-
return statement.type === "drop_table" &&
|
16911
|
+
can(statement, dialect6) {
|
16912
|
+
return statement.type === "drop_table" && dialect6 === "sqlite";
|
17584
16913
|
}
|
17585
16914
|
convert(statement) {
|
17586
16915
|
const { tableName } = statement;
|
@@ -17588,8 +16917,8 @@ var init_sqlgenerator = __esm({
|
|
17588
16917
|
}
|
17589
16918
|
};
|
17590
16919
|
PgRenameTableConvertor = class extends Convertor {
|
17591
|
-
can(statement,
|
17592
|
-
return statement.type === "rename_table" &&
|
16920
|
+
can(statement, dialect6) {
|
16921
|
+
return statement.type === "rename_table" && dialect6 === "pg";
|
17593
16922
|
}
|
17594
16923
|
convert(statement) {
|
17595
16924
|
const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
|
@@ -17599,8 +16928,8 @@ var init_sqlgenerator = __esm({
|
|
17599
16928
|
}
|
17600
16929
|
};
|
17601
16930
|
SqliteRenameTableConvertor = class extends Convertor {
|
17602
|
-
can(statement,
|
17603
|
-
return statement.type === "rename_table" &&
|
16931
|
+
can(statement, dialect6) {
|
16932
|
+
return statement.type === "rename_table" && dialect6 === "sqlite";
|
17604
16933
|
}
|
17605
16934
|
convert(statement) {
|
17606
16935
|
const { tableNameFrom, tableNameTo } = statement;
|
@@ -17608,8 +16937,8 @@ var init_sqlgenerator = __esm({
|
|
17608
16937
|
}
|
17609
16938
|
};
|
17610
16939
|
MySqlRenameTableConvertor = class extends Convertor {
|
17611
|
-
can(statement,
|
17612
|
-
return statement.type === "rename_table" &&
|
16940
|
+
can(statement, dialect6) {
|
16941
|
+
return statement.type === "rename_table" && dialect6 === "mysql";
|
17613
16942
|
}
|
17614
16943
|
convert(statement) {
|
17615
16944
|
const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
|
@@ -17619,8 +16948,8 @@ var init_sqlgenerator = __esm({
|
|
17619
16948
|
}
|
17620
16949
|
};
|
17621
16950
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
17622
|
-
can(statement,
|
17623
|
-
return statement.type === "alter_table_rename_column" &&
|
16951
|
+
can(statement, dialect6) {
|
16952
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "pg";
|
17624
16953
|
}
|
17625
16954
|
convert(statement) {
|
17626
16955
|
const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
|
@@ -17629,8 +16958,8 @@ var init_sqlgenerator = __esm({
|
|
17629
16958
|
}
|
17630
16959
|
};
|
17631
16960
|
MySqlAlterTableRenameColumnConvertor = class extends Convertor {
|
17632
|
-
can(statement,
|
17633
|
-
return statement.type === "alter_table_rename_column" &&
|
16961
|
+
can(statement, dialect6) {
|
16962
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "mysql";
|
17634
16963
|
}
|
17635
16964
|
convert(statement) {
|
17636
16965
|
const { tableName, oldColumnName, newColumnName } = statement;
|
@@ -17638,8 +16967,8 @@ var init_sqlgenerator = __esm({
|
|
17638
16967
|
}
|
17639
16968
|
};
|
17640
16969
|
SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
|
17641
|
-
can(statement,
|
17642
|
-
return statement.type === "alter_table_rename_column" &&
|
16970
|
+
can(statement, dialect6) {
|
16971
|
+
return statement.type === "alter_table_rename_column" && dialect6 === "sqlite";
|
17643
16972
|
}
|
17644
16973
|
convert(statement) {
|
17645
16974
|
const { tableName, oldColumnName, newColumnName } = statement;
|
@@ -17647,8 +16976,8 @@ var init_sqlgenerator = __esm({
|
|
17647
16976
|
}
|
17648
16977
|
};
|
17649
16978
|
PgAlterTableDropColumnConvertor = class extends Convertor {
|
17650
|
-
can(statement,
|
17651
|
-
return statement.type === "alter_table_drop_column" &&
|
16979
|
+
can(statement, dialect6) {
|
16980
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "pg";
|
17652
16981
|
}
|
17653
16982
|
convert(statement) {
|
17654
16983
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17657,8 +16986,8 @@ var init_sqlgenerator = __esm({
|
|
17657
16986
|
}
|
17658
16987
|
};
|
17659
16988
|
MySqlAlterTableDropColumnConvertor = class extends Convertor {
|
17660
|
-
can(statement,
|
17661
|
-
return statement.type === "alter_table_drop_column" &&
|
16989
|
+
can(statement, dialect6) {
|
16990
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "mysql";
|
17662
16991
|
}
|
17663
16992
|
convert(statement) {
|
17664
16993
|
const { tableName, columnName } = statement;
|
@@ -17666,8 +16995,8 @@ var init_sqlgenerator = __esm({
|
|
17666
16995
|
}
|
17667
16996
|
};
|
17668
16997
|
SQLiteAlterTableDropColumnConvertor = class extends Convertor {
|
17669
|
-
can(statement,
|
17670
|
-
return statement.type === "alter_table_drop_column" &&
|
16998
|
+
can(statement, dialect6) {
|
16999
|
+
return statement.type === "alter_table_drop_column" && dialect6 === "sqlite";
|
17671
17000
|
}
|
17672
17001
|
convert(statement) {
|
17673
17002
|
const { tableName, columnName } = statement;
|
@@ -17675,8 +17004,8 @@ var init_sqlgenerator = __esm({
|
|
17675
17004
|
}
|
17676
17005
|
};
|
17677
17006
|
PgAlterTableAddColumnConvertor = class extends Convertor {
|
17678
|
-
can(statement,
|
17679
|
-
return statement.type === "alter_table_add_column" &&
|
17007
|
+
can(statement, dialect6) {
|
17008
|
+
return statement.type === "alter_table_add_column" && dialect6 === "pg";
|
17680
17009
|
}
|
17681
17010
|
convert(statement) {
|
17682
17011
|
const { tableName, column: column4, schema: schema4 } = statement;
|
@@ -17689,8 +17018,8 @@ var init_sqlgenerator = __esm({
|
|
17689
17018
|
}
|
17690
17019
|
};
|
17691
17020
|
MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
17692
|
-
can(statement,
|
17693
|
-
return statement.type === "alter_table_add_column" &&
|
17021
|
+
can(statement, dialect6) {
|
17022
|
+
return statement.type === "alter_table_add_column" && dialect6 === "mysql";
|
17694
17023
|
}
|
17695
17024
|
convert(statement) {
|
17696
17025
|
const { tableName, column: column4 } = statement;
|
@@ -17704,8 +17033,8 @@ var init_sqlgenerator = __esm({
|
|
17704
17033
|
}
|
17705
17034
|
};
|
17706
17035
|
SQLiteAlterTableAddColumnConvertor = class extends Convertor {
|
17707
|
-
can(statement,
|
17708
|
-
return statement.type === "sqlite_alter_table_add_column" &&
|
17036
|
+
can(statement, dialect6) {
|
17037
|
+
return statement.type === "sqlite_alter_table_add_column" && dialect6 === "sqlite";
|
17709
17038
|
}
|
17710
17039
|
convert(statement) {
|
17711
17040
|
const { tableName, column: column4, referenceData } = statement;
|
@@ -17719,8 +17048,8 @@ var init_sqlgenerator = __esm({
|
|
17719
17048
|
}
|
17720
17049
|
};
|
17721
17050
|
PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
17722
|
-
can(statement,
|
17723
|
-
return statement.type === "alter_table_alter_column_set_type" &&
|
17051
|
+
can(statement, dialect6) {
|
17052
|
+
return statement.type === "alter_table_alter_column_set_type" && dialect6 === "pg";
|
17724
17053
|
}
|
17725
17054
|
convert(statement) {
|
17726
17055
|
const { tableName, columnName, newDataType, schema: schema4 } = statement;
|
@@ -17729,8 +17058,8 @@ var init_sqlgenerator = __esm({
|
|
17729
17058
|
}
|
17730
17059
|
};
|
17731
17060
|
SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
17732
|
-
can(statement,
|
17733
|
-
return statement.type === "alter_table_alter_column_set_type" &&
|
17061
|
+
can(statement, dialect6) {
|
17062
|
+
return statement.type === "alter_table_alter_column_set_type" && dialect6 === "sqlite";
|
17734
17063
|
}
|
17735
17064
|
convert(statement) {
|
17736
17065
|
return `/*
|
@@ -17744,8 +17073,8 @@ var init_sqlgenerator = __esm({
|
|
17744
17073
|
}
|
17745
17074
|
};
|
17746
17075
|
PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
17747
|
-
can(statement,
|
17748
|
-
return statement.type === "alter_table_alter_column_set_default" &&
|
17076
|
+
can(statement, dialect6) {
|
17077
|
+
return statement.type === "alter_table_alter_column_set_default" && dialect6 === "pg";
|
17749
17078
|
}
|
17750
17079
|
convert(statement) {
|
17751
17080
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17754,8 +17083,8 @@ var init_sqlgenerator = __esm({
|
|
17754
17083
|
}
|
17755
17084
|
};
|
17756
17085
|
SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
17757
|
-
can(statement,
|
17758
|
-
return statement.type === "alter_table_alter_column_set_default" &&
|
17086
|
+
can(statement, dialect6) {
|
17087
|
+
return statement.type === "alter_table_alter_column_set_default" && dialect6 === "sqlite";
|
17759
17088
|
}
|
17760
17089
|
convert(statement) {
|
17761
17090
|
return `/*
|
@@ -17769,8 +17098,8 @@ var init_sqlgenerator = __esm({
|
|
17769
17098
|
}
|
17770
17099
|
};
|
17771
17100
|
PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
17772
|
-
can(statement,
|
17773
|
-
return statement.type === "alter_table_alter_column_drop_default" &&
|
17101
|
+
can(statement, dialect6) {
|
17102
|
+
return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "pg";
|
17774
17103
|
}
|
17775
17104
|
convert(statement) {
|
17776
17105
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -17779,24 +17108,24 @@ var init_sqlgenerator = __esm({
|
|
17779
17108
|
}
|
17780
17109
|
};
|
17781
17110
|
MySqlAlterTableAddPk = class extends Convertor {
|
17782
|
-
can(statement,
|
17783
|
-
return statement.type === "alter_table_alter_column_set_pk" &&
|
17111
|
+
can(statement, dialect6) {
|
17112
|
+
return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "mysql";
|
17784
17113
|
}
|
17785
17114
|
convert(statement) {
|
17786
17115
|
return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
|
17787
17116
|
}
|
17788
17117
|
};
|
17789
17118
|
MySqlAlterTableDropPk = class extends Convertor {
|
17790
|
-
can(statement,
|
17791
|
-
return statement.type === "alter_table_alter_column_drop_pk" &&
|
17119
|
+
can(statement, dialect6) {
|
17120
|
+
return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "mysql";
|
17792
17121
|
}
|
17793
17122
|
convert(statement) {
|
17794
17123
|
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
|
17795
17124
|
}
|
17796
17125
|
};
|
17797
17126
|
MySqlModifyColumn = class extends Convertor {
|
17798
|
-
can(statement,
|
17799
|
-
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") &&
|
17127
|
+
can(statement, dialect6) {
|
17128
|
+
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";
|
17800
17129
|
}
|
17801
17130
|
convert(statement) {
|
17802
17131
|
const { tableName, columnName } = statement;
|
@@ -17866,8 +17195,8 @@ var init_sqlgenerator = __esm({
|
|
17866
17195
|
}
|
17867
17196
|
};
|
17868
17197
|
SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
17869
|
-
can(statement,
|
17870
|
-
return statement.type === "alter_table_alter_column_drop_default" &&
|
17198
|
+
can(statement, dialect6) {
|
17199
|
+
return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "sqlite";
|
17871
17200
|
}
|
17872
17201
|
convert(statement) {
|
17873
17202
|
return `/*
|
@@ -17881,8 +17210,8 @@ var init_sqlgenerator = __esm({
|
|
17881
17210
|
}
|
17882
17211
|
};
|
17883
17212
|
PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17884
|
-
can(statement,
|
17885
|
-
return statement.type === "create_composite_pk" &&
|
17213
|
+
can(statement, dialect6) {
|
17214
|
+
return statement.type === "create_composite_pk" && dialect6 === "pg";
|
17886
17215
|
}
|
17887
17216
|
convert(statement) {
|
17888
17217
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
@@ -17891,8 +17220,8 @@ var init_sqlgenerator = __esm({
|
|
17891
17220
|
}
|
17892
17221
|
};
|
17893
17222
|
PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17894
|
-
can(statement,
|
17895
|
-
return statement.type === "delete_composite_pk" &&
|
17223
|
+
can(statement, dialect6) {
|
17224
|
+
return statement.type === "delete_composite_pk" && dialect6 === "pg";
|
17896
17225
|
}
|
17897
17226
|
convert(statement) {
|
17898
17227
|
const { name, columns } = PgSquasher.unsquashPK(statement.data);
|
@@ -17901,8 +17230,8 @@ var init_sqlgenerator = __esm({
|
|
17901
17230
|
}
|
17902
17231
|
};
|
17903
17232
|
PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
17904
|
-
can(statement,
|
17905
|
-
return statement.type === "alter_composite_pk" &&
|
17233
|
+
can(statement, dialect6) {
|
17234
|
+
return statement.type === "alter_composite_pk" && dialect6 === "pg";
|
17906
17235
|
}
|
17907
17236
|
convert(statement) {
|
17908
17237
|
const { name, columns } = PgSquasher.unsquashPK(statement.old);
|
@@ -17915,8 +17244,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17915
17244
|
}
|
17916
17245
|
};
|
17917
17246
|
MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17918
|
-
can(statement,
|
17919
|
-
return statement.type === "create_composite_pk" &&
|
17247
|
+
can(statement, dialect6) {
|
17248
|
+
return statement.type === "create_composite_pk" && dialect6 === "mysql";
|
17920
17249
|
}
|
17921
17250
|
convert(statement) {
|
17922
17251
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
@@ -17924,8 +17253,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17924
17253
|
}
|
17925
17254
|
};
|
17926
17255
|
MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17927
|
-
can(statement,
|
17928
|
-
return statement.type === "delete_composite_pk" &&
|
17256
|
+
can(statement, dialect6) {
|
17257
|
+
return statement.type === "delete_composite_pk" && dialect6 === "mysql";
|
17929
17258
|
}
|
17930
17259
|
convert(statement) {
|
17931
17260
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
|
@@ -17933,8 +17262,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17933
17262
|
}
|
17934
17263
|
};
|
17935
17264
|
MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
17936
|
-
can(statement,
|
17937
|
-
return statement.type === "alter_composite_pk" &&
|
17265
|
+
can(statement, dialect6) {
|
17266
|
+
return statement.type === "alter_composite_pk" && dialect6 === "mysql";
|
17938
17267
|
}
|
17939
17268
|
convert(statement) {
|
17940
17269
|
const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
|
@@ -17945,8 +17274,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17945
17274
|
}
|
17946
17275
|
};
|
17947
17276
|
SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
17948
|
-
can(statement,
|
17949
|
-
return statement.type === "create_composite_pk" &&
|
17277
|
+
can(statement, dialect6) {
|
17278
|
+
return statement.type === "create_composite_pk" && dialect6 === "sqlite";
|
17950
17279
|
}
|
17951
17280
|
convert(statement) {
|
17952
17281
|
let msg = "/*\n";
|
@@ -17972,8 +17301,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17972
17301
|
}
|
17973
17302
|
};
|
17974
17303
|
SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
17975
|
-
can(statement,
|
17976
|
-
return statement.type === "delete_composite_pk" &&
|
17304
|
+
can(statement, dialect6) {
|
17305
|
+
return statement.type === "delete_composite_pk" && dialect6 === "sqlite";
|
17977
17306
|
}
|
17978
17307
|
convert(statement) {
|
17979
17308
|
let msg = "/*\n";
|
@@ -17999,8 +17328,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
17999
17328
|
}
|
18000
17329
|
};
|
18001
17330
|
SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
18002
|
-
can(statement,
|
18003
|
-
return statement.type === "alter_composite_pk" &&
|
17331
|
+
can(statement, dialect6) {
|
17332
|
+
return statement.type === "alter_composite_pk" && dialect6 === "sqlite";
|
18004
17333
|
}
|
18005
17334
|
convert(statement) {
|
18006
17335
|
let msg = "/*\n";
|
@@ -18024,8 +17353,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18024
17353
|
}
|
18025
17354
|
};
|
18026
17355
|
PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
18027
|
-
can(statement,
|
18028
|
-
return statement.type === "alter_table_alter_column_set_pk" &&
|
17356
|
+
can(statement, dialect6) {
|
17357
|
+
return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "pg";
|
18029
17358
|
}
|
18030
17359
|
convert(statement) {
|
18031
17360
|
const { tableName, columnName } = statement;
|
@@ -18034,8 +17363,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18034
17363
|
}
|
18035
17364
|
};
|
18036
17365
|
PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
|
18037
|
-
can(statement,
|
18038
|
-
return statement.type === "alter_table_alter_column_drop_pk" &&
|
17366
|
+
can(statement, dialect6) {
|
17367
|
+
return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "pg";
|
18039
17368
|
}
|
18040
17369
|
convert(statement) {
|
18041
17370
|
const { tableName, columnName, schema: schema4 } = statement;
|
@@ -18058,8 +17387,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18058
17387
|
}
|
18059
17388
|
};
|
18060
17389
|
PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
18061
|
-
can(statement,
|
18062
|
-
return statement.type === "alter_table_alter_column_set_notnull" &&
|
17390
|
+
can(statement, dialect6) {
|
17391
|
+
return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "pg";
|
18063
17392
|
}
|
18064
17393
|
convert(statement) {
|
18065
17394
|
const { tableName, columnName } = statement;
|
@@ -18068,8 +17397,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18068
17397
|
}
|
18069
17398
|
};
|
18070
17399
|
SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
18071
|
-
can(statement,
|
18072
|
-
return statement.type === "alter_table_alter_column_set_notnull" &&
|
17400
|
+
can(statement, dialect6) {
|
17401
|
+
return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "sqlite";
|
18073
17402
|
}
|
18074
17403
|
convert(statement) {
|
18075
17404
|
return `/*
|
@@ -18083,8 +17412,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18083
17412
|
}
|
18084
17413
|
};
|
18085
17414
|
SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
|
18086
|
-
can(statement,
|
18087
|
-
return statement.type === "alter_table_alter_column_set_autoincrement" &&
|
17415
|
+
can(statement, dialect6) {
|
17416
|
+
return statement.type === "alter_table_alter_column_set_autoincrement" && dialect6 === "sqlite";
|
18088
17417
|
}
|
18089
17418
|
convert(statement) {
|
18090
17419
|
return `/*
|
@@ -18098,8 +17427,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18098
17427
|
}
|
18099
17428
|
};
|
18100
17429
|
SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
|
18101
|
-
can(statement,
|
18102
|
-
return statement.type === "alter_table_alter_column_drop_autoincrement" &&
|
17430
|
+
can(statement, dialect6) {
|
17431
|
+
return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect6 === "sqlite";
|
18103
17432
|
}
|
18104
17433
|
convert(statement) {
|
18105
17434
|
return `/*
|
@@ -18113,8 +17442,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18113
17442
|
}
|
18114
17443
|
};
|
18115
17444
|
PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
18116
|
-
can(statement,
|
18117
|
-
return statement.type === "alter_table_alter_column_drop_notnull" &&
|
17445
|
+
can(statement, dialect6) {
|
17446
|
+
return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "pg";
|
18118
17447
|
}
|
18119
17448
|
convert(statement) {
|
18120
17449
|
const { tableName, columnName } = statement;
|
@@ -18123,8 +17452,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18123
17452
|
}
|
18124
17453
|
};
|
18125
17454
|
SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
18126
|
-
can(statement,
|
18127
|
-
return statement.type === "alter_table_alter_column_drop_notnull" &&
|
17455
|
+
can(statement, dialect6) {
|
17456
|
+
return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "sqlite";
|
18128
17457
|
}
|
18129
17458
|
convert(statement) {
|
18130
17459
|
return `/*
|
@@ -18138,8 +17467,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18138
17467
|
}
|
18139
17468
|
};
|
18140
17469
|
PgCreateForeignKeyConvertor = class extends Convertor {
|
18141
|
-
can(statement,
|
18142
|
-
return statement.type === "create_reference" &&
|
17470
|
+
can(statement, dialect6) {
|
17471
|
+
return statement.type === "create_reference" && dialect6 === "pg";
|
18143
17472
|
}
|
18144
17473
|
convert(statement) {
|
18145
17474
|
const {
|
@@ -18168,8 +17497,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18168
17497
|
}
|
18169
17498
|
};
|
18170
17499
|
SqliteCreateForeignKeyConvertor = class extends Convertor {
|
18171
|
-
can(statement,
|
18172
|
-
return statement.type === "create_reference" &&
|
17500
|
+
can(statement, dialect6) {
|
17501
|
+
return statement.type === "create_reference" && dialect6 === "sqlite";
|
18173
17502
|
}
|
18174
17503
|
convert(statement) {
|
18175
17504
|
return `/*
|
@@ -18182,8 +17511,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18182
17511
|
}
|
18183
17512
|
};
|
18184
17513
|
MySqlCreateForeignKeyConvertor = class extends Convertor {
|
18185
|
-
can(statement,
|
18186
|
-
return statement.type === "create_reference" &&
|
17514
|
+
can(statement, dialect6) {
|
17515
|
+
return statement.type === "create_reference" && dialect6 === "mysql";
|
18187
17516
|
}
|
18188
17517
|
convert(statement) {
|
18189
17518
|
const {
|
@@ -18203,8 +17532,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18203
17532
|
}
|
18204
17533
|
};
|
18205
17534
|
PgAlterForeignKeyConvertor = class extends Convertor {
|
18206
|
-
can(statement,
|
18207
|
-
return statement.type === "alter_reference" &&
|
17535
|
+
can(statement, dialect6) {
|
17536
|
+
return statement.type === "alter_reference" && dialect6 === "pg";
|
18208
17537
|
}
|
18209
17538
|
convert(statement) {
|
18210
17539
|
const newFk = PgSquasher.unsquashFK(statement.data);
|
@@ -18228,8 +17557,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18228
17557
|
}
|
18229
17558
|
};
|
18230
17559
|
SqliteAlterForeignKeyConvertor = class extends Convertor {
|
18231
|
-
can(statement,
|
18232
|
-
return statement.type === "alter_reference" &&
|
17560
|
+
can(statement, dialect6) {
|
17561
|
+
return statement.type === "alter_reference" && dialect6 === "sqlite";
|
18233
17562
|
}
|
18234
17563
|
convert(statement) {
|
18235
17564
|
return `/*
|
@@ -18242,8 +17571,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18242
17571
|
}
|
18243
17572
|
};
|
18244
17573
|
PgDeleteForeignKeyConvertor = class extends Convertor {
|
18245
|
-
can(statement,
|
18246
|
-
return statement.type === "delete_reference" &&
|
17574
|
+
can(statement, dialect6) {
|
17575
|
+
return statement.type === "delete_reference" && dialect6 === "pg";
|
18247
17576
|
}
|
18248
17577
|
convert(statement) {
|
18249
17578
|
const tableFrom = statement.tableName;
|
@@ -18254,8 +17583,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18254
17583
|
}
|
18255
17584
|
};
|
18256
17585
|
SqliteDeleteForeignKeyConvertor = class extends Convertor {
|
18257
|
-
can(statement,
|
18258
|
-
return statement.type === "delete_reference" &&
|
17586
|
+
can(statement, dialect6) {
|
17587
|
+
return statement.type === "delete_reference" && dialect6 === "sqlite";
|
18259
17588
|
}
|
18260
17589
|
convert(statement) {
|
18261
17590
|
return `/*
|
@@ -18268,8 +17597,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18268
17597
|
}
|
18269
17598
|
};
|
18270
17599
|
MySqlDeleteForeignKeyConvertor = class extends Convertor {
|
18271
|
-
can(statement,
|
18272
|
-
return statement.type === "delete_reference" &&
|
17600
|
+
can(statement, dialect6) {
|
17601
|
+
return statement.type === "delete_reference" && dialect6 === "mysql";
|
18273
17602
|
}
|
18274
17603
|
convert(statement) {
|
18275
17604
|
const tableFrom = statement.tableName;
|
@@ -18279,8 +17608,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18279
17608
|
}
|
18280
17609
|
};
|
18281
17610
|
CreatePgIndexConvertor = class extends Convertor {
|
18282
|
-
can(statement,
|
18283
|
-
return statement.type === "create_index" &&
|
17611
|
+
can(statement, dialect6) {
|
17612
|
+
return statement.type === "create_index" && dialect6 === "pg";
|
18284
17613
|
}
|
18285
17614
|
convert(statement) {
|
18286
17615
|
const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18291,8 +17620,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18291
17620
|
}
|
18292
17621
|
};
|
18293
17622
|
CreateMySqlIndexConvertor = class extends Convertor {
|
18294
|
-
can(statement,
|
18295
|
-
return statement.type === "create_index" &&
|
17623
|
+
can(statement, dialect6) {
|
17624
|
+
return statement.type === "create_index" && dialect6 === "mysql";
|
18296
17625
|
}
|
18297
17626
|
convert(statement) {
|
18298
17627
|
const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
|
@@ -18304,8 +17633,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18304
17633
|
}
|
18305
17634
|
};
|
18306
17635
|
CreateSqliteIndexConvertor = class extends Convertor {
|
18307
|
-
can(statement,
|
18308
|
-
return statement.type === "create_index" &&
|
17636
|
+
can(statement, dialect6) {
|
17637
|
+
return statement.type === "create_index" && dialect6 === "sqlite";
|
18309
17638
|
}
|
18310
17639
|
convert(statement) {
|
18311
17640
|
const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
|
@@ -18318,8 +17647,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18318
17647
|
}
|
18319
17648
|
};
|
18320
17649
|
PgDropIndexConvertor = class extends Convertor {
|
18321
|
-
can(statement,
|
18322
|
-
return statement.type === "drop_index" &&
|
17650
|
+
can(statement, dialect6) {
|
17651
|
+
return statement.type === "drop_index" && dialect6 === "pg";
|
18323
17652
|
}
|
18324
17653
|
convert(statement) {
|
18325
17654
|
const { name } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18327,8 +17656,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18327
17656
|
}
|
18328
17657
|
};
|
18329
17658
|
PgCreateSchemaConvertor = class extends Convertor {
|
18330
|
-
can(statement,
|
18331
|
-
return statement.type === "create_schema" &&
|
17659
|
+
can(statement, dialect6) {
|
17660
|
+
return statement.type === "create_schema" && dialect6 === "pg";
|
18332
17661
|
}
|
18333
17662
|
convert(statement) {
|
18334
17663
|
const { name } = statement;
|
@@ -18337,8 +17666,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18337
17666
|
}
|
18338
17667
|
};
|
18339
17668
|
PgRenameSchemaConvertor = class extends Convertor {
|
18340
|
-
can(statement,
|
18341
|
-
return statement.type === "rename_schema" &&
|
17669
|
+
can(statement, dialect6) {
|
17670
|
+
return statement.type === "rename_schema" && dialect6 === "pg";
|
18342
17671
|
}
|
18343
17672
|
convert(statement) {
|
18344
17673
|
const { from, to } = statement;
|
@@ -18347,8 +17676,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18347
17676
|
}
|
18348
17677
|
};
|
18349
17678
|
PgDropSchemaConvertor = class extends Convertor {
|
18350
|
-
can(statement,
|
18351
|
-
return statement.type === "drop_schema" &&
|
17679
|
+
can(statement, dialect6) {
|
17680
|
+
return statement.type === "drop_schema" && dialect6 === "pg";
|
18352
17681
|
}
|
18353
17682
|
convert(statement) {
|
18354
17683
|
const { name } = statement;
|
@@ -18357,8 +17686,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18357
17686
|
}
|
18358
17687
|
};
|
18359
17688
|
PgAlterTableSetSchemaConvertor = class extends Convertor {
|
18360
|
-
can(statement,
|
18361
|
-
return statement.type === "alter_table_set_schema" &&
|
17689
|
+
can(statement, dialect6) {
|
17690
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "pg";
|
18362
17691
|
}
|
18363
17692
|
convert(statement) {
|
18364
17693
|
const { tableName, schema: schema4 } = statement;
|
@@ -18367,8 +17696,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18367
17696
|
}
|
18368
17697
|
};
|
18369
17698
|
PgAlterTableSetNewSchemaConvertor = class extends Convertor {
|
18370
|
-
can(statement,
|
18371
|
-
return statement.type === "alter_table_set_new_schema" &&
|
17699
|
+
can(statement, dialect6) {
|
17700
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "pg";
|
18372
17701
|
}
|
18373
17702
|
convert(statement) {
|
18374
17703
|
const { tableName, to, from } = statement;
|
@@ -18378,8 +17707,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18378
17707
|
}
|
18379
17708
|
};
|
18380
17709
|
PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
18381
|
-
can(statement,
|
18382
|
-
return statement.type === "alter_table_remove_from_schema" &&
|
17710
|
+
can(statement, dialect6) {
|
17711
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
|
18383
17712
|
}
|
18384
17713
|
convert(statement) {
|
18385
17714
|
const { tableName, schema: schema4 } = statement;
|
@@ -18389,8 +17718,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18389
17718
|
}
|
18390
17719
|
};
|
18391
17720
|
SqliteDropIndexConvertor = class extends Convertor {
|
18392
|
-
can(statement,
|
18393
|
-
return statement.type === "drop_index" &&
|
17721
|
+
can(statement, dialect6) {
|
17722
|
+
return statement.type === "drop_index" && dialect6 === "sqlite";
|
18394
17723
|
}
|
18395
17724
|
convert(statement) {
|
18396
17725
|
const { name } = PgSquasher.unsquashIdx(statement.data);
|
@@ -18398,8 +17727,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18398
17727
|
}
|
18399
17728
|
};
|
18400
17729
|
MysqlCreateSchemaConvertor = class extends Convertor {
|
18401
|
-
can(statement,
|
18402
|
-
return statement.type === "create_schema" &&
|
17730
|
+
can(statement, dialect6) {
|
17731
|
+
return statement.type === "create_schema" && dialect6 === "mysql";
|
18403
17732
|
}
|
18404
17733
|
convert(statement) {
|
18405
17734
|
const { name } = statement;
|
@@ -18408,8 +17737,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18408
17737
|
}
|
18409
17738
|
};
|
18410
17739
|
MysqlDropSchemaConvertor = class extends Convertor {
|
18411
|
-
can(statement,
|
18412
|
-
return statement.type === "drop_schema" &&
|
17740
|
+
can(statement, dialect6) {
|
17741
|
+
return statement.type === "drop_schema" && dialect6 === "mysql";
|
18413
17742
|
}
|
18414
17743
|
convert(statement) {
|
18415
17744
|
const { name } = statement;
|
@@ -18418,8 +17747,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18418
17747
|
}
|
18419
17748
|
};
|
18420
17749
|
MysqlAlterTableSetSchemaConvertor = class extends Convertor {
|
18421
|
-
can(statement,
|
18422
|
-
return statement.type === "alter_table_set_schema" &&
|
17750
|
+
can(statement, dialect6) {
|
17751
|
+
return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
|
18423
17752
|
}
|
18424
17753
|
convert(statement) {
|
18425
17754
|
const { tableName, schema: schema4 } = statement;
|
@@ -18430,8 +17759,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18430
17759
|
}
|
18431
17760
|
};
|
18432
17761
|
MysqlAlterTableSetNewSchemaConvertor = class extends Convertor {
|
18433
|
-
can(statement,
|
18434
|
-
return statement.type === "alter_table_set_new_schema" &&
|
17762
|
+
can(statement, dialect6) {
|
17763
|
+
return statement.type === "alter_table_set_new_schema" && dialect6 === "mysql";
|
18435
17764
|
}
|
18436
17765
|
convert(statement) {
|
18437
17766
|
const { tableName, to, from } = statement;
|
@@ -18442,8 +17771,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18442
17771
|
}
|
18443
17772
|
};
|
18444
17773
|
MysqlAlterTableRemoveFromSchemaConvertor = class extends Convertor {
|
18445
|
-
can(statement,
|
18446
|
-
return statement.type === "alter_table_remove_from_schema" &&
|
17774
|
+
can(statement, dialect6) {
|
17775
|
+
return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
|
18447
17776
|
}
|
18448
17777
|
convert(statement) {
|
18449
17778
|
const { tableName, schema: schema4 } = statement;
|
@@ -18454,8 +17783,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18454
17783
|
}
|
18455
17784
|
};
|
18456
17785
|
MySqlDropIndexConvertor = class extends Convertor {
|
18457
|
-
can(statement,
|
18458
|
-
return statement.type === "drop_index" &&
|
17786
|
+
can(statement, dialect6) {
|
17787
|
+
return statement.type === "drop_index" && dialect6 === "mysql";
|
18459
17788
|
}
|
18460
17789
|
convert(statement) {
|
18461
17790
|
const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
|
@@ -18541,10 +17870,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
18541
17870
|
convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
|
18542
17871
|
convertors.push(new MySqlAlterTableAddPk());
|
18543
17872
|
convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
|
18544
|
-
fromJson = (statements,
|
17873
|
+
fromJson = (statements, dialect6) => {
|
18545
17874
|
const result = statements.map((statement) => {
|
18546
17875
|
const filtered = convertors.filter((it) => {
|
18547
|
-
return it.can(statement,
|
17876
|
+
return it.can(statement, dialect6);
|
18548
17877
|
});
|
18549
17878
|
const convertor = filtered.length === 1 ? filtered[0] : void 0;
|
18550
17879
|
if (!convertor) {
|
@@ -18585,7 +17914,6 @@ drop type __venum;
|
|
18585
17914
|
var import_hanji5, Select;
|
18586
17915
|
var init_selector_ui = __esm({
|
18587
17916
|
"src/cli/selector-ui.ts"() {
|
18588
|
-
"use strict";
|
18589
17917
|
init_source();
|
18590
17918
|
import_hanji5 = __toESM(require_hanji());
|
18591
17919
|
Select = class extends import_hanji5.Prompt {
|
@@ -35188,7 +34516,6 @@ import { sql } from "drizzle-orm";
|
|
35188
34516
|
var DrizzleDbClient, DrizzleORMPgClient, DrizzleORMMySQLClient, DrizzleORMSQLiteClient, BetterSqlite, MySQL2Client, TursoSqlite, PgPostgres;
|
35189
34517
|
var init_drivers = __esm({
|
35190
34518
|
"src/drivers/index.ts"() {
|
35191
|
-
"use strict";
|
35192
34519
|
DrizzleDbClient = class {
|
35193
34520
|
constructor(db) {
|
35194
34521
|
this.db = db;
|
@@ -35269,7 +34596,6 @@ __export(mysqlPushUtils_exports, {
|
|
35269
34596
|
var import_hanji9, filterStatements, logSuggestionsAndReturn2;
|
35270
34597
|
var init_mysqlPushUtils = __esm({
|
35271
34598
|
"src/cli/commands/mysqlPushUtils.ts"() {
|
35272
|
-
"use strict";
|
35273
34599
|
init_source();
|
35274
34600
|
import_hanji9 = __toESM(require_hanji());
|
35275
34601
|
init_mysqlSchema();
|
@@ -35531,7 +34857,6 @@ init_views();
|
|
35531
34857
|
init_pgSerializer();
|
35532
34858
|
|
35533
34859
|
// src/introspect-pg.ts
|
35534
|
-
var import_pluralize = __toESM(require_pluralize());
|
35535
34860
|
import { getTableName as getTableName4, is as is7 } from "drizzle-orm";
|
35536
34861
|
import {
|
35537
34862
|
createTableRelationsHelpers,
|
@@ -35639,7 +34964,7 @@ String.prototype.camelCase = function() {
|
|
35639
34964
|
return camelCase(String(this));
|
35640
34965
|
};
|
35641
34966
|
String.prototype.concatIf = function(it, condition) {
|
35642
|
-
return condition ? `${this}${it}` :
|
34967
|
+
return condition ? `${this}${it}` : this;
|
35643
34968
|
};
|
35644
34969
|
Array.prototype.random = function() {
|
35645
34970
|
return this[~~(Math.random() * this.length)];
|