drizzle-kit 0.22.0-12a1bf8 → 0.22.0-25da1e6
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +443 -230
- package/index.d.mts +1 -8
- package/index.d.ts +1 -8
- package/package.json +1 -1
- package/payload.d.mts +100 -18
- package/payload.d.ts +100 -18
- package/payload.js +299 -186
- package/payload.mjs +312 -197
- package/utils-studio.js +122 -8
- package/utils-studio.mjs +122 -8
- package/utils.js +23 -2
- package/utils.mjs +23 -2
package/payload.mjs
CHANGED
@@ -8005,7 +8005,16 @@ var init_mysqlSchema = __esm({
|
|
8005
8005
|
object({ isDefaultAnExpression: boolean().optional() }).optional()
|
8006
8006
|
)
|
8007
8007
|
}).optional()
|
8008
|
-
)
|
8008
|
+
).optional(),
|
8009
|
+
indexes: record(
|
8010
|
+
string(),
|
8011
|
+
object({
|
8012
|
+
columns: record(
|
8013
|
+
string(),
|
8014
|
+
object({ isExpression: boolean().optional() }).optional()
|
8015
|
+
)
|
8016
|
+
}).optional()
|
8017
|
+
).optional()
|
8009
8018
|
}).optional();
|
8010
8019
|
dialect = literal("mysql");
|
8011
8020
|
schemaHash = object({
|
@@ -8690,7 +8699,7 @@ import {
|
|
8690
8699
|
literal as literal3,
|
8691
8700
|
union as union4
|
8692
8701
|
} from "zod";
|
8693
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
8702
|
+
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
8694
8703
|
var init_sqliteSchema = __esm({
|
8695
8704
|
"src/serializer/sqliteSchema.ts"() {
|
8696
8705
|
"use strict";
|
@@ -8767,6 +8776,17 @@ var init_sqliteSchema = __esm({
|
|
8767
8776
|
columns: record3(string3(), string3())
|
8768
8777
|
})
|
8769
8778
|
}).strict();
|
8779
|
+
kitInternals3 = object3({
|
8780
|
+
indexes: record3(
|
8781
|
+
string3(),
|
8782
|
+
object3({
|
8783
|
+
columns: record3(
|
8784
|
+
string3(),
|
8785
|
+
object3({ isExpression: boolean3().optional() }).optional()
|
8786
|
+
)
|
8787
|
+
}).optional()
|
8788
|
+
).optional()
|
8789
|
+
}).optional();
|
8770
8790
|
latestVersion = literal3("6");
|
8771
8791
|
schemaInternal2 = object3({
|
8772
8792
|
version: latestVersion,
|
@@ -8776,7 +8796,8 @@ var init_sqliteSchema = __esm({
|
|
8776
8796
|
_meta: object3({
|
8777
8797
|
tables: record3(string3(), string3()),
|
8778
8798
|
columns: record3(string3(), string3())
|
8779
|
-
})
|
8799
|
+
}),
|
8800
|
+
internal: kitInternals3
|
8780
8801
|
}).strict();
|
8781
8802
|
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
8782
8803
|
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
@@ -8965,7 +8986,7 @@ var init_views = __esm({
|
|
8965
8986
|
init_source();
|
8966
8987
|
init_utils5();
|
8967
8988
|
error = (error2, greyMsg = "") => {
|
8968
|
-
return `${source_default.
|
8989
|
+
return `${source_default.bgRed.bold(" Error ")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
8969
8990
|
};
|
8970
8991
|
isRenamePromptItem = (item) => {
|
8971
8992
|
return "from" in item && "to" in item;
|
@@ -9172,12 +9193,102 @@ var init_serializer = __esm({
|
|
9172
9193
|
}
|
9173
9194
|
});
|
9174
9195
|
|
9196
|
+
// src/schemaValidator.ts
|
9197
|
+
import { enum as enumType4, union as union5 } from "zod";
|
9198
|
+
var dialect3, commonSquashedSchema, commonSchema;
|
9199
|
+
var init_schemaValidator = __esm({
|
9200
|
+
"src/schemaValidator.ts"() {
|
9201
|
+
"use strict";
|
9202
|
+
init_mysqlSchema();
|
9203
|
+
init_pgSchema();
|
9204
|
+
init_sqliteSchema();
|
9205
|
+
dialect3 = enumType4(["postgresql", "mysql", "sqlite"]);
|
9206
|
+
commonSquashedSchema = union5([
|
9207
|
+
pgSchemaSquashed,
|
9208
|
+
mysqlSchemaSquashed,
|
9209
|
+
SQLiteSchemaSquashed
|
9210
|
+
]);
|
9211
|
+
commonSchema = union5([
|
9212
|
+
pgSchema,
|
9213
|
+
mysqlSchema,
|
9214
|
+
sqliteSchema
|
9215
|
+
]);
|
9216
|
+
}
|
9217
|
+
});
|
9218
|
+
|
9219
|
+
// src/cli/validations/common.ts
|
9220
|
+
import { object as object4, string as string4, union as union6, boolean as boolean4, literal as literal4 } from "zod";
|
9221
|
+
var sqliteDriversLiterals, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
9222
|
+
var init_common2 = __esm({
|
9223
|
+
"src/cli/validations/common.ts"() {
|
9224
|
+
"use strict";
|
9225
|
+
init_outputs();
|
9226
|
+
init_schemaValidator();
|
9227
|
+
sqliteDriversLiterals = [
|
9228
|
+
literal4("turso"),
|
9229
|
+
literal4("d1-http"),
|
9230
|
+
literal4("expo")
|
9231
|
+
];
|
9232
|
+
sqliteDriver = union6(sqliteDriversLiterals);
|
9233
|
+
postgresDriver = literal4("aws-data-api");
|
9234
|
+
mysqlDriver = literal4("mysql2");
|
9235
|
+
driver = union6([sqliteDriver, postgresDriver, mysqlDriver]);
|
9236
|
+
configCommonSchema = object4({
|
9237
|
+
dialect: dialect3,
|
9238
|
+
schema: union6([string4(), string4().array()]).optional(),
|
9239
|
+
out: string4().optional(),
|
9240
|
+
breakpoints: boolean4().optional().default(true),
|
9241
|
+
driver: driver.optional(),
|
9242
|
+
tablesFilter: union6([string4(), string4().array()]).optional(),
|
9243
|
+
schemaFilter: union6([string4(), string4().array()]).default(["public"])
|
9244
|
+
});
|
9245
|
+
casing = union6([literal4("camel"), literal4("preserve")]).default(
|
9246
|
+
"preserve"
|
9247
|
+
);
|
9248
|
+
introspectParams = object4({
|
9249
|
+
schema: union6([string4(), string4().array()]).optional(),
|
9250
|
+
out: string4().optional().default("./drizzle"),
|
9251
|
+
breakpoints: boolean4().default(true),
|
9252
|
+
tablesFilter: union6([string4(), string4().array()]).optional(),
|
9253
|
+
schemaFilter: union6([string4(), string4().array()]).default(["public"]),
|
9254
|
+
introspect: object4({
|
9255
|
+
casing
|
9256
|
+
}).default({ casing: "camel" })
|
9257
|
+
});
|
9258
|
+
configIntrospectCliSchema = object4({
|
9259
|
+
schema: union6([string4(), string4().array()]).optional(),
|
9260
|
+
out: string4().optional().default("./drizzle"),
|
9261
|
+
breakpoints: boolean4().default(true),
|
9262
|
+
tablesFilter: union6([string4(), string4().array()]).optional(),
|
9263
|
+
schemaFilter: union6([string4(), string4().array()]).default(["public"]),
|
9264
|
+
introspectCasing: union6([literal4("camel"), literal4("preserve")]).default(
|
9265
|
+
"camel"
|
9266
|
+
)
|
9267
|
+
});
|
9268
|
+
configGenerateSchema = object4({
|
9269
|
+
schema: union6([string4(), string4().array()]),
|
9270
|
+
out: string4().optional().default("./drizzle"),
|
9271
|
+
breakpoints: boolean4().default(true)
|
9272
|
+
});
|
9273
|
+
configPushSchema = object4({
|
9274
|
+
dialect: dialect3,
|
9275
|
+
schema: union6([string4(), string4().array()]),
|
9276
|
+
tablesFilter: union6([string4(), string4().array()]).optional(),
|
9277
|
+
schemaFilter: union6([string4(), string4().array()]).default(["public"]),
|
9278
|
+
verbose: boolean4().default(false),
|
9279
|
+
strict: boolean4().default(false),
|
9280
|
+
out: string4().optional()
|
9281
|
+
});
|
9282
|
+
}
|
9283
|
+
});
|
9284
|
+
|
9175
9285
|
// src/cli/validations/outputs.ts
|
9176
9286
|
var withStyle;
|
9177
9287
|
var init_outputs = __esm({
|
9178
9288
|
"src/cli/validations/outputs.ts"() {
|
9179
9289
|
"use strict";
|
9180
9290
|
init_source();
|
9291
|
+
init_common2();
|
9181
9292
|
withStyle = {
|
9182
9293
|
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
9183
9294
|
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
@@ -9190,203 +9301,131 @@ var init_outputs = __esm({
|
|
9190
9301
|
});
|
9191
9302
|
|
9192
9303
|
// src/cli/validations/mysql.ts
|
9193
|
-
import { boolean as
|
9304
|
+
import { boolean as boolean5, coerce, object as object5, string as string5, union as union7 } from "zod";
|
9194
9305
|
var mysqlCredentials;
|
9195
9306
|
var init_mysql = __esm({
|
9196
9307
|
"src/cli/validations/mysql.ts"() {
|
9197
9308
|
"use strict";
|
9198
9309
|
init_outputs();
|
9199
|
-
|
9200
|
-
|
9201
|
-
|
9202
|
-
|
9203
|
-
|
9204
|
-
|
9205
|
-
|
9206
|
-
|
9207
|
-
|
9208
|
-
|
9209
|
-
|
9210
|
-
|
9211
|
-
|
9212
|
-
|
9213
|
-
|
9214
|
-
|
9215
|
-
|
9216
|
-
|
9310
|
+
init_common2();
|
9311
|
+
init_views();
|
9312
|
+
mysqlCredentials = union7([
|
9313
|
+
object5({
|
9314
|
+
host: string5().min(1),
|
9315
|
+
port: coerce.number().min(1).optional(),
|
9316
|
+
user: string5().min(1).optional(),
|
9317
|
+
password: string5().min(1).optional(),
|
9318
|
+
database: string5().min(1),
|
9319
|
+
ssl: union7([
|
9320
|
+
string5(),
|
9321
|
+
object5({
|
9322
|
+
pfx: string5().optional(),
|
9323
|
+
key: string5().optional(),
|
9324
|
+
passphrase: string5().optional(),
|
9325
|
+
cert: string5().optional(),
|
9326
|
+
ca: union7([string5(), string5().array()]).optional(),
|
9327
|
+
crl: union7([string5(), string5().array()]).optional(),
|
9328
|
+
ciphers: string5().optional(),
|
9329
|
+
rejectUnauthorized: boolean5().optional()
|
9217
9330
|
})
|
9218
9331
|
]).optional()
|
9219
9332
|
}),
|
9220
|
-
|
9221
|
-
url:
|
9333
|
+
object5({
|
9334
|
+
url: string5().min(1)
|
9222
9335
|
})
|
9223
9336
|
]);
|
9224
9337
|
}
|
9225
9338
|
});
|
9226
9339
|
|
9227
|
-
// src/cli/validations/
|
9228
|
-
import {
|
9340
|
+
// src/cli/validations/postgres.ts
|
9341
|
+
import {
|
9342
|
+
boolean as boolean6,
|
9343
|
+
coerce as coerce2,
|
9344
|
+
literal as literal5,
|
9345
|
+
object as object6,
|
9346
|
+
string as string6,
|
9347
|
+
undefined as undefined2,
|
9348
|
+
union as union8
|
9349
|
+
} from "zod";
|
9229
9350
|
var postgresCredentials;
|
9230
|
-
var
|
9231
|
-
"src/cli/validations/
|
9351
|
+
var init_postgres = __esm({
|
9352
|
+
"src/cli/validations/postgres.ts"() {
|
9232
9353
|
"use strict";
|
9233
|
-
|
9234
|
-
|
9235
|
-
|
9236
|
-
|
9237
|
-
|
9238
|
-
|
9239
|
-
|
9240
|
-
|
9241
|
-
|
9242
|
-
|
9243
|
-
|
9244
|
-
|
9245
|
-
|
9246
|
-
|
9247
|
-
|
9248
|
-
|
9354
|
+
init_common2();
|
9355
|
+
init_views();
|
9356
|
+
postgresCredentials = union8([
|
9357
|
+
object6({
|
9358
|
+
driver: undefined2(),
|
9359
|
+
host: string6().min(1),
|
9360
|
+
port: coerce2.number().min(1).optional(),
|
9361
|
+
user: string6().min(1).optional(),
|
9362
|
+
password: string6().min(1).optional(),
|
9363
|
+
database: string6().min(1),
|
9364
|
+
ssl: union8([
|
9365
|
+
literal5("require"),
|
9366
|
+
literal5("allow"),
|
9367
|
+
literal5("prefer"),
|
9368
|
+
literal5("verify-full"),
|
9369
|
+
boolean6(),
|
9370
|
+
object6({}).passthrough()
|
9371
|
+
]).optional()
|
9372
|
+
}).transform((o) => {
|
9373
|
+
delete o.driver;
|
9374
|
+
return o;
|
9249
9375
|
}),
|
9250
|
-
|
9251
|
-
|
9376
|
+
object6({
|
9377
|
+
driver: undefined2(),
|
9378
|
+
url: string6().min(1)
|
9379
|
+
}).transform((o) => {
|
9380
|
+
delete o.driver;
|
9381
|
+
return o;
|
9252
9382
|
}),
|
9253
|
-
|
9254
|
-
driver:
|
9255
|
-
database:
|
9256
|
-
secretArn:
|
9257
|
-
resourceArn:
|
9383
|
+
object6({
|
9384
|
+
driver: literal5("aws-data-api"),
|
9385
|
+
database: string6().min(1),
|
9386
|
+
secretArn: string6().min(1),
|
9387
|
+
resourceArn: string6().min(1)
|
9258
9388
|
})
|
9259
9389
|
]);
|
9260
9390
|
}
|
9261
9391
|
});
|
9262
9392
|
|
9263
9393
|
// src/cli/validations/sqlite.ts
|
9264
|
-
import { literal as
|
9394
|
+
import { literal as literal6, object as object7, string as string7, undefined as undefined3, union as union9 } from "zod";
|
9265
9395
|
var sqliteCredentials;
|
9266
9396
|
var init_sqlite = __esm({
|
9267
9397
|
"src/cli/validations/sqlite.ts"() {
|
9268
9398
|
"use strict";
|
9269
|
-
|
9270
|
-
|
9271
|
-
|
9272
|
-
|
9273
|
-
|
9274
|
-
|
9399
|
+
init_common2();
|
9400
|
+
init_views();
|
9401
|
+
init_global();
|
9402
|
+
sqliteCredentials = union9([
|
9403
|
+
object7({
|
9404
|
+
driver: literal6("turso"),
|
9405
|
+
url: string7().min(1),
|
9406
|
+
authToken: string7().min(1).optional()
|
9275
9407
|
}),
|
9276
|
-
|
9277
|
-
driver:
|
9278
|
-
accountId:
|
9279
|
-
databaseId:
|
9280
|
-
token:
|
9408
|
+
object7({
|
9409
|
+
driver: literal6("d1-http"),
|
9410
|
+
accountId: string7().min(1),
|
9411
|
+
databaseId: string7().min(1),
|
9412
|
+
token: string7().min(1)
|
9281
9413
|
}),
|
9282
|
-
|
9283
|
-
|
9414
|
+
object7({
|
9415
|
+
driver: undefined3(),
|
9416
|
+
url: string7().min(1)
|
9417
|
+
}).transform((o) => {
|
9418
|
+
delete o.driver;
|
9419
|
+
return o;
|
9284
9420
|
})
|
9285
9421
|
]);
|
9286
9422
|
}
|
9287
9423
|
});
|
9288
9424
|
|
9289
|
-
// src/schemaValidator.ts
|
9290
|
-
import { enum as enumType4, union as union8 } from "zod";
|
9291
|
-
var dialect3, commonSquashedSchema, commonSchema;
|
9292
|
-
var init_schemaValidator = __esm({
|
9293
|
-
"src/schemaValidator.ts"() {
|
9294
|
-
"use strict";
|
9295
|
-
init_mysqlSchema();
|
9296
|
-
init_pgSchema();
|
9297
|
-
init_sqliteSchema();
|
9298
|
-
dialect3 = enumType4(["postgresql", "mysql", "sqlite"]);
|
9299
|
-
commonSquashedSchema = union8([
|
9300
|
-
pgSchemaSquashed,
|
9301
|
-
mysqlSchemaSquashed,
|
9302
|
-
SQLiteSchemaSquashed
|
9303
|
-
]);
|
9304
|
-
commonSchema = union8([
|
9305
|
-
pgSchema,
|
9306
|
-
mysqlSchema,
|
9307
|
-
sqliteSchema
|
9308
|
-
]);
|
9309
|
-
}
|
9310
|
-
});
|
9311
|
-
|
9312
|
-
// src/cli/validations/common.ts
|
9313
|
-
import {
|
9314
|
-
object as object7,
|
9315
|
-
string as string7,
|
9316
|
-
union as union9,
|
9317
|
-
boolean as boolean6,
|
9318
|
-
literal as literal6
|
9319
|
-
} from "zod";
|
9320
|
-
var sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
9321
|
-
var init_common2 = __esm({
|
9322
|
-
"src/cli/validations/common.ts"() {
|
9323
|
-
"use strict";
|
9324
|
-
init_outputs();
|
9325
|
-
init_schemaValidator();
|
9326
|
-
sqliteDriver = union9([
|
9327
|
-
literal6("better-sqlite"),
|
9328
|
-
literal6("turso"),
|
9329
|
-
literal6("libsql"),
|
9330
|
-
literal6("d1"),
|
9331
|
-
literal6("d1-http"),
|
9332
|
-
literal6("expo")
|
9333
|
-
]);
|
9334
|
-
postgresDriver = literal6("aws-data-api");
|
9335
|
-
mysqlDriver = literal6("mysql2");
|
9336
|
-
driver = union9([sqliteDriver, postgresDriver, mysqlDriver]);
|
9337
|
-
configCommonSchema = object7({
|
9338
|
-
dialect: dialect3,
|
9339
|
-
schema: union9([string7(), string7().array()]).optional(),
|
9340
|
-
out: string7().optional(),
|
9341
|
-
breakpoints: boolean6().optional().default(true),
|
9342
|
-
driver: driver.optional(),
|
9343
|
-
tablesFilter: union9([string7(), string7().array()]).optional(),
|
9344
|
-
schemaFilter: union9([string7(), string7().array()]).default(["public"])
|
9345
|
-
});
|
9346
|
-
casing = union9([literal6("camel"), literal6("preserve")]).default(
|
9347
|
-
"preserve"
|
9348
|
-
);
|
9349
|
-
introspectParams = object7({
|
9350
|
-
schema: union9([string7(), string7().array()]).optional(),
|
9351
|
-
out: string7().optional().default("./drizzle"),
|
9352
|
-
breakpoints: boolean6().default(true),
|
9353
|
-
tablesFilter: union9([string7(), string7().array()]).optional(),
|
9354
|
-
schemaFilter: union9([string7(), string7().array()]).default(["public"]),
|
9355
|
-
introspect: object7({
|
9356
|
-
casing
|
9357
|
-
}).default({ casing: "camel" })
|
9358
|
-
});
|
9359
|
-
configIntrospectCliSchema = object7({
|
9360
|
-
schema: union9([string7(), string7().array()]).optional(),
|
9361
|
-
out: string7().optional().default("./drizzle"),
|
9362
|
-
breakpoints: boolean6().default(true),
|
9363
|
-
tablesFilter: union9([string7(), string7().array()]).optional(),
|
9364
|
-
schemaFilter: union9([string7(), string7().array()]).default(["public"]),
|
9365
|
-
introspectCasing: union9([literal6("camel"), literal6("preserve")]).default(
|
9366
|
-
"camel"
|
9367
|
-
)
|
9368
|
-
});
|
9369
|
-
configGenerateSchema = object7({
|
9370
|
-
schema: union9([string7(), string7().array()]),
|
9371
|
-
out: string7().optional().default("./drizzle"),
|
9372
|
-
breakpoints: boolean6().default(true)
|
9373
|
-
});
|
9374
|
-
configPushSchema = object7({
|
9375
|
-
dialect: dialect3,
|
9376
|
-
schema: union9([string7(), string7().array()]),
|
9377
|
-
tablesFilter: union9([string7(), string7().array()]).optional(),
|
9378
|
-
schemaFilter: union9([string7(), string7().array()]).default(["public"]),
|
9379
|
-
verbose: boolean6().default(false),
|
9380
|
-
strict: boolean6().default(false),
|
9381
|
-
out: string7().optional()
|
9382
|
-
});
|
9383
|
-
}
|
9384
|
-
});
|
9385
|
-
|
9386
9425
|
// src/cli/validations/cli.ts
|
9387
9426
|
import {
|
9388
9427
|
boolean as boolean7,
|
9389
|
-
intersection
|
9428
|
+
intersection,
|
9390
9429
|
literal as literal7,
|
9391
9430
|
object as object8,
|
9392
9431
|
string as string8,
|
@@ -9430,7 +9469,7 @@ var init_cli = __esm({
|
|
9430
9469
|
dialect: dialect3.optional(),
|
9431
9470
|
out: string8().optional()
|
9432
9471
|
});
|
9433
|
-
cliConfigCheck =
|
9472
|
+
cliConfigCheck = intersection(
|
9434
9473
|
object8({
|
9435
9474
|
config: string8().optional()
|
9436
9475
|
}),
|
@@ -9440,7 +9479,7 @@ var init_cli = __esm({
|
|
9440
9479
|
});
|
9441
9480
|
|
9442
9481
|
// src/cli/validations/studio.ts
|
9443
|
-
import { coerce as
|
9482
|
+
import { coerce as coerce3, intersection as intersection2, object as object9, string as string9, union as union11 } from "zod";
|
9444
9483
|
var credentials, studioCliParams, studioConfig;
|
9445
9484
|
var init_studio = __esm({
|
9446
9485
|
"src/cli/validations/studio.ts"() {
|
@@ -9448,14 +9487,14 @@ var init_studio = __esm({
|
|
9448
9487
|
init_mysql();
|
9449
9488
|
init_sqlite();
|
9450
9489
|
init_schemaValidator();
|
9451
|
-
|
9452
|
-
credentials =
|
9490
|
+
init_postgres();
|
9491
|
+
credentials = intersection2(
|
9453
9492
|
postgresCredentials,
|
9454
9493
|
mysqlCredentials,
|
9455
9494
|
sqliteCredentials
|
9456
9495
|
);
|
9457
9496
|
studioCliParams = object9({
|
9458
|
-
port:
|
9497
|
+
port: coerce3.number().optional().default(4983),
|
9459
9498
|
host: string9().optional().default("127.0.0.1"),
|
9460
9499
|
config: string9().optional()
|
9461
9500
|
});
|
@@ -9491,7 +9530,7 @@ var init_utils6 = __esm({
|
|
9491
9530
|
init_views();
|
9492
9531
|
init_global();
|
9493
9532
|
init_mysql();
|
9494
|
-
|
9533
|
+
init_postgres();
|
9495
9534
|
init_sqlite();
|
9496
9535
|
init_common2();
|
9497
9536
|
init_schemaValidator();
|
@@ -12122,7 +12161,7 @@ var init_jsonStatements = __esm({
|
|
12122
12161
|
uniqueConstraints: Object.values(uniqueConstraints)
|
12123
12162
|
};
|
12124
12163
|
};
|
12125
|
-
prepareMySqlCreateTableJson = (table4, json2) => {
|
12164
|
+
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
12126
12165
|
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
12127
12166
|
return {
|
12128
12167
|
type: "create_table",
|
@@ -12131,7 +12170,8 @@ var init_jsonStatements = __esm({
|
|
12131
12170
|
columns: Object.values(columns),
|
12132
12171
|
compositePKs: Object.values(compositePrimaryKeys),
|
12133
12172
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
12134
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
12173
|
+
uniqueConstraints: Object.values(uniqueConstraints),
|
12174
|
+
internals
|
12135
12175
|
};
|
12136
12176
|
};
|
12137
12177
|
prepareSQLiteCreateTable = (table4) => {
|
@@ -12885,13 +12925,14 @@ var init_jsonStatements = __esm({
|
|
12885
12925
|
};
|
12886
12926
|
});
|
12887
12927
|
};
|
12888
|
-
prepareCreateIndexesJson = (tableName, schema4, indexes) => {
|
12928
|
+
prepareCreateIndexesJson = (tableName, schema4, indexes, internal) => {
|
12889
12929
|
return Object.values(indexes).map((indexData) => {
|
12890
12930
|
return {
|
12891
12931
|
type: "create_index",
|
12892
12932
|
tableName,
|
12893
12933
|
data: indexData,
|
12894
|
-
schema: schema4
|
12934
|
+
schema: schema4,
|
12935
|
+
internal
|
12895
12936
|
};
|
12896
12937
|
});
|
12897
12938
|
};
|
@@ -13091,7 +13132,7 @@ import {
|
|
13091
13132
|
array as array2,
|
13092
13133
|
record as record4,
|
13093
13134
|
literal as literal8,
|
13094
|
-
never
|
13135
|
+
never as never2
|
13095
13136
|
} from "zod";
|
13096
13137
|
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff;
|
13097
13138
|
var init_snapshotsDiffer = __esm({
|
@@ -13253,11 +13294,11 @@ var init_snapshotsDiffer = __esm({
|
|
13253
13294
|
}).strict();
|
13254
13295
|
diffResultSchemeMysql = object11({
|
13255
13296
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
13256
|
-
alteredEnums:
|
13297
|
+
alteredEnums: never2().array()
|
13257
13298
|
}).strict();
|
13258
13299
|
diffResultSchemeSQLite = object11({
|
13259
13300
|
alteredTablesWithColumns: alteredTableScheme.array(),
|
13260
|
-
alteredEnums:
|
13301
|
+
alteredEnums: never2().array()
|
13261
13302
|
}).strict();
|
13262
13303
|
schemaChangeFor = (table4, renamedSchemas) => {
|
13263
13304
|
for (let ren of renamedSchemas) {
|
@@ -13839,7 +13880,12 @@ var init_snapshotsDiffer = __esm({
|
|
13839
13880
|
const typedResult = diffResultSchemeMysql.parse(diffResult);
|
13840
13881
|
const jsonStatements = [];
|
13841
13882
|
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
13842
|
-
return prepareCreateIndexesJson(
|
13883
|
+
return prepareCreateIndexesJson(
|
13884
|
+
it.name,
|
13885
|
+
it.schema,
|
13886
|
+
it.indexes,
|
13887
|
+
curFull.internal
|
13888
|
+
);
|
13843
13889
|
}).flat();
|
13844
13890
|
const jsonDropTables = deletedTables.map((it) => {
|
13845
13891
|
return prepareDropTableJson(it);
|
@@ -13938,7 +13984,8 @@ var init_snapshotsDiffer = __esm({
|
|
13938
13984
|
return prepareCreateIndexesJson(
|
13939
13985
|
it.name,
|
13940
13986
|
it.schema,
|
13941
|
-
it.addedIndexes || {}
|
13987
|
+
it.addedIndexes || {},
|
13988
|
+
curFull.internal
|
13942
13989
|
);
|
13943
13990
|
}).flat();
|
13944
13991
|
const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
|
@@ -13998,7 +14045,11 @@ var init_snapshotsDiffer = __esm({
|
|
13998
14045
|
(t) => t.type === "delete_reference"
|
13999
14046
|
);
|
14000
14047
|
const jsonMySqlCreateTables = createdTables.map((it) => {
|
14001
|
-
return prepareMySqlCreateTableJson(
|
14048
|
+
return prepareMySqlCreateTableJson(
|
14049
|
+
it,
|
14050
|
+
curFull,
|
14051
|
+
curFull.internal
|
14052
|
+
);
|
14002
14053
|
});
|
14003
14054
|
jsonStatements.push(...jsonMySqlCreateTables);
|
14004
14055
|
jsonStatements.push(...jsonDropTables);
|
@@ -14038,7 +14089,7 @@ var init_snapshotsDiffer = __esm({
|
|
14038
14089
|
_meta
|
14039
14090
|
};
|
14040
14091
|
};
|
14041
|
-
applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2) => {
|
14092
|
+
applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull) => {
|
14042
14093
|
const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
|
14043
14094
|
const {
|
14044
14095
|
created: createdTables,
|
@@ -14118,7 +14169,12 @@ var init_snapshotsDiffer = __esm({
|
|
14118
14169
|
return prepareSQLiteCreateTable(it);
|
14119
14170
|
});
|
14120
14171
|
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
14121
|
-
return prepareCreateIndexesJson(
|
14172
|
+
return prepareCreateIndexesJson(
|
14173
|
+
it.name,
|
14174
|
+
it.schema,
|
14175
|
+
it.indexes,
|
14176
|
+
curFull.internal
|
14177
|
+
);
|
14122
14178
|
}).flat();
|
14123
14179
|
const jsonDropTables = deletedTables.map((it) => {
|
14124
14180
|
return prepareDropTableJson(it);
|
@@ -14220,7 +14276,8 @@ var init_snapshotsDiffer = __esm({
|
|
14220
14276
|
return prepareCreateIndexesJson(
|
14221
14277
|
it.name,
|
14222
14278
|
it.schema,
|
14223
|
-
it.addedIndexes || {}
|
14279
|
+
it.addedIndexes || {},
|
14280
|
+
curFull.internal
|
14224
14281
|
);
|
14225
14282
|
}).flat();
|
14226
14283
|
const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
|
@@ -14654,7 +14711,14 @@ var init_sqlgenerator = __esm({
|
|
14654
14711
|
return statement.type === "create_table" && dialect7 === "mysql";
|
14655
14712
|
}
|
14656
14713
|
convert(st) {
|
14657
|
-
const {
|
14714
|
+
const {
|
14715
|
+
tableName,
|
14716
|
+
columns,
|
14717
|
+
schema: schema4,
|
14718
|
+
compositePKs,
|
14719
|
+
uniqueConstraints,
|
14720
|
+
internals
|
14721
|
+
} = st;
|
14658
14722
|
let statement = "";
|
14659
14723
|
statement += `CREATE TABLE \`${tableName}\` (
|
14660
14724
|
`;
|
@@ -14677,7 +14741,10 @@ var init_sqlgenerator = __esm({
|
|
14677
14741
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
14678
14742
|
statement += ",\n";
|
14679
14743
|
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
14680
|
-
|
14744
|
+
const uniqueString = unsquashedUnique.columns.map((it) => {
|
14745
|
+
return internals?.indexes ? internals?.indexes[unsquashedUnique.name]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
14746
|
+
}).join(",");
|
14747
|
+
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
14681
14748
|
}
|
14682
14749
|
}
|
14683
14750
|
statement += `
|
@@ -15606,8 +15673,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15606
15673
|
statement.data
|
15607
15674
|
);
|
15608
15675
|
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
15609
|
-
const
|
15610
|
-
|
15676
|
+
const uniqueString = columns.map((it) => {
|
15677
|
+
return statement.internal?.indexes ? statement.internal?.indexes[name2]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
15678
|
+
}).join(",");
|
15679
|
+
return `CREATE ${indexPart} \`${name2}\` ON \`${statement.tableName}\` (${uniqueString});`;
|
15611
15680
|
}
|
15612
15681
|
};
|
15613
15682
|
CreateSqliteIndexConvertor = class extends Convertor {
|
@@ -15620,8 +15689,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15620
15689
|
);
|
15621
15690
|
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
15622
15691
|
const whereStatement = where ? ` WHERE ${where}` : "";
|
15623
|
-
const
|
15624
|
-
|
15692
|
+
const uniqueString = columns.map((it) => {
|
15693
|
+
return statement.internal?.indexes ? statement.internal?.indexes[name2]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
15694
|
+
}).join(",");
|
15695
|
+
return `CREATE ${indexPart} \`${name2}\` ON \`${statement.tableName}\` (${uniqueString})${whereStatement};`;
|
15625
15696
|
}
|
15626
15697
|
};
|
15627
15698
|
PgDropIndexConvertor = class extends Convertor {
|
@@ -19197,6 +19268,7 @@ var init_sqliteSerializer = __esm({
|
|
19197
19268
|
dialect5 = new SQLiteSyncDialect();
|
19198
19269
|
generateSqliteSnapshot = (tables) => {
|
19199
19270
|
const result = {};
|
19271
|
+
const internal = { indexes: {} };
|
19200
19272
|
for (const table4 of tables) {
|
19201
19273
|
const columnsObject = {};
|
19202
19274
|
const indexesObject = {};
|
@@ -19283,7 +19355,25 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19283
19355
|
const name2 = value.config.name;
|
19284
19356
|
let indexColumns = columns2.map((it) => {
|
19285
19357
|
if (is(it, SQL)) {
|
19286
|
-
|
19358
|
+
const sql2 = dialect5.sqlToQuery(it, "indexes").sql;
|
19359
|
+
if (typeof internal.indexes[name2] === "undefined") {
|
19360
|
+
internal.indexes[name2] = {
|
19361
|
+
columns: {
|
19362
|
+
[sql2]: {
|
19363
|
+
isExpression: true
|
19364
|
+
}
|
19365
|
+
}
|
19366
|
+
};
|
19367
|
+
} else {
|
19368
|
+
if (typeof internal.indexes[name2]?.columns[sql2] === "undefined") {
|
19369
|
+
internal.indexes[name2].columns[sql2] = {
|
19370
|
+
isExpression: true
|
19371
|
+
};
|
19372
|
+
} else {
|
19373
|
+
internal.indexes[name2].columns[sql2].isExpression = true;
|
19374
|
+
}
|
19375
|
+
}
|
19376
|
+
return sql2;
|
19287
19377
|
} else {
|
19288
19378
|
return it.name;
|
19289
19379
|
}
|
@@ -19357,7 +19447,8 @@ The unique constraint ${source_default.underline.blue(
|
|
19357
19447
|
_meta: {
|
19358
19448
|
tables: {},
|
19359
19449
|
columns: {}
|
19360
|
-
}
|
19450
|
+
},
|
19451
|
+
internal
|
19361
19452
|
};
|
19362
19453
|
};
|
19363
19454
|
fromDatabase2 = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
@@ -23619,6 +23710,7 @@ var init_mysqlSerializer = __esm({
|
|
23619
23710
|
dialect6 = new MySqlDialect();
|
23620
23711
|
generateMySqlSnapshot = (tables) => {
|
23621
23712
|
const result = {};
|
23713
|
+
const internal = { tables: {}, indexes: {} };
|
23622
23714
|
for (const table4 of tables) {
|
23623
23715
|
const {
|
23624
23716
|
name: tableName,
|
@@ -23770,9 +23862,27 @@ The unique constraint ${source_default.underline.blue(
|
|
23770
23862
|
const name2 = value.config.name;
|
23771
23863
|
let indexColumns = columns2.map((it) => {
|
23772
23864
|
if (is(it, SQL)) {
|
23773
|
-
|
23865
|
+
const sql2 = dialect6.sqlToQuery(it, "indexes").sql;
|
23866
|
+
if (typeof internal.indexes[name2] === "undefined") {
|
23867
|
+
internal.indexes[name2] = {
|
23868
|
+
columns: {
|
23869
|
+
[sql2]: {
|
23870
|
+
isExpression: true
|
23871
|
+
}
|
23872
|
+
}
|
23873
|
+
};
|
23874
|
+
} else {
|
23875
|
+
if (typeof internal.indexes[name2]?.columns[sql2] === "undefined") {
|
23876
|
+
internal.indexes[name2].columns[sql2] = {
|
23877
|
+
isExpression: true
|
23878
|
+
};
|
23879
|
+
} else {
|
23880
|
+
internal.indexes[name2].columns[sql2].isExpression = true;
|
23881
|
+
}
|
23882
|
+
}
|
23883
|
+
return sql2;
|
23774
23884
|
} else {
|
23775
|
-
return it.name
|
23885
|
+
return `${it.name}`;
|
23776
23886
|
}
|
23777
23887
|
});
|
23778
23888
|
if (value.config.unique) {
|
@@ -23839,12 +23949,13 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
23839
23949
|
_meta: {
|
23840
23950
|
tables: {},
|
23841
23951
|
columns: {}
|
23842
|
-
}
|
23952
|
+
},
|
23953
|
+
internal
|
23843
23954
|
};
|
23844
23955
|
};
|
23845
23956
|
fromDatabase3 = async (db, inputSchema, tablesFilter = (table4) => true, progressCallback) => {
|
23846
23957
|
const result = {};
|
23847
|
-
const internals = { tables: {} };
|
23958
|
+
const internals = { tables: {}, indexes: {} };
|
23848
23959
|
const columns = await db.query(`select * from information_schema.columns
|
23849
23960
|
where table_schema = '${inputSchema}' and table_name != '__drizzle_migrations'
|
23850
23961
|
order by table_name, ordinal_position;`);
|
@@ -25373,7 +25484,9 @@ var generateSQLiteMigration = async (prev, cur) => {
|
|
25373
25484
|
squashedPrev,
|
25374
25485
|
squashedCur,
|
25375
25486
|
tablesResolver,
|
25376
|
-
columnsResolver
|
25487
|
+
columnsResolver,
|
25488
|
+
validatedPrev,
|
25489
|
+
validatedCur
|
25377
25490
|
);
|
25378
25491
|
return sqlStatements;
|
25379
25492
|
};
|
@@ -25402,7 +25515,9 @@ var pushSQLiteSchema = async (imports, drizzleInstance) => {
|
|
25402
25515
|
squashedPrev,
|
25403
25516
|
squashedCur,
|
25404
25517
|
tablesResolver,
|
25405
|
-
columnsResolver
|
25518
|
+
columnsResolver,
|
25519
|
+
validatedPrev,
|
25520
|
+
validatedCur
|
25406
25521
|
);
|
25407
25522
|
const { shouldAskForApprove, statementsToExecute, infoToPrint } = await logSuggestionsAndReturn(
|
25408
25523
|
db,
|