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.js
CHANGED
@@ -7990,7 +7990,16 @@ var init_mysqlSchema = __esm({
|
|
7990
7990
|
(0, import_zod.object)({ isDefaultAnExpression: (0, import_zod.boolean)().optional() }).optional()
|
7991
7991
|
)
|
7992
7992
|
}).optional()
|
7993
|
-
)
|
7993
|
+
).optional(),
|
7994
|
+
indexes: (0, import_zod.record)(
|
7995
|
+
(0, import_zod.string)(),
|
7996
|
+
(0, import_zod.object)({
|
7997
|
+
columns: (0, import_zod.record)(
|
7998
|
+
(0, import_zod.string)(),
|
7999
|
+
(0, import_zod.object)({ isExpression: (0, import_zod.boolean)().optional() }).optional()
|
8000
|
+
)
|
8001
|
+
}).optional()
|
8002
|
+
).optional()
|
7994
8003
|
}).optional();
|
7995
8004
|
dialect = (0, import_zod.literal)("mysql");
|
7996
8005
|
schemaHash = (0, import_zod.object)({
|
@@ -8655,7 +8664,7 @@ var init_pgSchema = __esm({
|
|
8655
8664
|
});
|
8656
8665
|
|
8657
8666
|
// src/serializer/sqliteSchema.ts
|
8658
|
-
var import_zod3, 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;
|
8667
|
+
var import_zod3, 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;
|
8659
8668
|
var init_sqliteSchema = __esm({
|
8660
8669
|
"src/serializer/sqliteSchema.ts"() {
|
8661
8670
|
"use strict";
|
@@ -8733,6 +8742,17 @@ var init_sqliteSchema = __esm({
|
|
8733
8742
|
columns: (0, import_zod3.record)((0, import_zod3.string)(), (0, import_zod3.string)())
|
8734
8743
|
})
|
8735
8744
|
}).strict();
|
8745
|
+
kitInternals3 = (0, import_zod3.object)({
|
8746
|
+
indexes: (0, import_zod3.record)(
|
8747
|
+
(0, import_zod3.string)(),
|
8748
|
+
(0, import_zod3.object)({
|
8749
|
+
columns: (0, import_zod3.record)(
|
8750
|
+
(0, import_zod3.string)(),
|
8751
|
+
(0, import_zod3.object)({ isExpression: (0, import_zod3.boolean)().optional() }).optional()
|
8752
|
+
)
|
8753
|
+
}).optional()
|
8754
|
+
).optional()
|
8755
|
+
}).optional();
|
8736
8756
|
latestVersion = (0, import_zod3.literal)("6");
|
8737
8757
|
schemaInternal2 = (0, import_zod3.object)({
|
8738
8758
|
version: latestVersion,
|
@@ -8742,7 +8762,8 @@ var init_sqliteSchema = __esm({
|
|
8742
8762
|
_meta: (0, import_zod3.object)({
|
8743
8763
|
tables: (0, import_zod3.record)((0, import_zod3.string)(), (0, import_zod3.string)()),
|
8744
8764
|
columns: (0, import_zod3.record)((0, import_zod3.string)(), (0, import_zod3.string)())
|
8745
|
-
})
|
8765
|
+
}),
|
8766
|
+
internal: kitInternals3
|
8746
8767
|
}).strict();
|
8747
8768
|
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
8748
8769
|
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
@@ -8931,7 +8952,7 @@ var init_views = __esm({
|
|
8931
8952
|
import_hanji = require("hanji");
|
8932
8953
|
init_utils5();
|
8933
8954
|
error = (error2, greyMsg = "") => {
|
8934
|
-
return `${source_default.
|
8955
|
+
return `${source_default.bgRed.bold(" Error ")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
|
8935
8956
|
};
|
8936
8957
|
isRenamePromptItem = (item) => {
|
8937
8958
|
return "from" in item && "to" in item;
|
@@ -9138,12 +9159,102 @@ var init_serializer = __esm({
|
|
9138
9159
|
}
|
9139
9160
|
});
|
9140
9161
|
|
9162
|
+
// src/schemaValidator.ts
|
9163
|
+
var import_zod4, dialect3, commonSquashedSchema, commonSchema;
|
9164
|
+
var init_schemaValidator = __esm({
|
9165
|
+
"src/schemaValidator.ts"() {
|
9166
|
+
"use strict";
|
9167
|
+
import_zod4 = require("zod");
|
9168
|
+
init_mysqlSchema();
|
9169
|
+
init_pgSchema();
|
9170
|
+
init_sqliteSchema();
|
9171
|
+
dialect3 = (0, import_zod4.enum)(["postgresql", "mysql", "sqlite"]);
|
9172
|
+
commonSquashedSchema = (0, import_zod4.union)([
|
9173
|
+
pgSchemaSquashed,
|
9174
|
+
mysqlSchemaSquashed,
|
9175
|
+
SQLiteSchemaSquashed
|
9176
|
+
]);
|
9177
|
+
commonSchema = (0, import_zod4.union)([
|
9178
|
+
pgSchema,
|
9179
|
+
mysqlSchema,
|
9180
|
+
sqliteSchema
|
9181
|
+
]);
|
9182
|
+
}
|
9183
|
+
});
|
9184
|
+
|
9185
|
+
// src/cli/validations/common.ts
|
9186
|
+
var import_zod5, sqliteDriversLiterals, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
9187
|
+
var init_common2 = __esm({
|
9188
|
+
"src/cli/validations/common.ts"() {
|
9189
|
+
"use strict";
|
9190
|
+
init_outputs();
|
9191
|
+
import_zod5 = require("zod");
|
9192
|
+
init_schemaValidator();
|
9193
|
+
sqliteDriversLiterals = [
|
9194
|
+
(0, import_zod5.literal)("turso"),
|
9195
|
+
(0, import_zod5.literal)("d1-http"),
|
9196
|
+
(0, import_zod5.literal)("expo")
|
9197
|
+
];
|
9198
|
+
sqliteDriver = (0, import_zod5.union)(sqliteDriversLiterals);
|
9199
|
+
postgresDriver = (0, import_zod5.literal)("aws-data-api");
|
9200
|
+
mysqlDriver = (0, import_zod5.literal)("mysql2");
|
9201
|
+
driver = (0, import_zod5.union)([sqliteDriver, postgresDriver, mysqlDriver]);
|
9202
|
+
configCommonSchema = (0, import_zod5.object)({
|
9203
|
+
dialect: dialect3,
|
9204
|
+
schema: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9205
|
+
out: (0, import_zod5.string)().optional(),
|
9206
|
+
breakpoints: (0, import_zod5.boolean)().optional().default(true),
|
9207
|
+
driver: driver.optional(),
|
9208
|
+
tablesFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9209
|
+
schemaFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).default(["public"])
|
9210
|
+
});
|
9211
|
+
casing = (0, import_zod5.union)([(0, import_zod5.literal)("camel"), (0, import_zod5.literal)("preserve")]).default(
|
9212
|
+
"preserve"
|
9213
|
+
);
|
9214
|
+
introspectParams = (0, import_zod5.object)({
|
9215
|
+
schema: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9216
|
+
out: (0, import_zod5.string)().optional().default("./drizzle"),
|
9217
|
+
breakpoints: (0, import_zod5.boolean)().default(true),
|
9218
|
+
tablesFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9219
|
+
schemaFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).default(["public"]),
|
9220
|
+
introspect: (0, import_zod5.object)({
|
9221
|
+
casing
|
9222
|
+
}).default({ casing: "camel" })
|
9223
|
+
});
|
9224
|
+
configIntrospectCliSchema = (0, import_zod5.object)({
|
9225
|
+
schema: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9226
|
+
out: (0, import_zod5.string)().optional().default("./drizzle"),
|
9227
|
+
breakpoints: (0, import_zod5.boolean)().default(true),
|
9228
|
+
tablesFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9229
|
+
schemaFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).default(["public"]),
|
9230
|
+
introspectCasing: (0, import_zod5.union)([(0, import_zod5.literal)("camel"), (0, import_zod5.literal)("preserve")]).default(
|
9231
|
+
"camel"
|
9232
|
+
)
|
9233
|
+
});
|
9234
|
+
configGenerateSchema = (0, import_zod5.object)({
|
9235
|
+
schema: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]),
|
9236
|
+
out: (0, import_zod5.string)().optional().default("./drizzle"),
|
9237
|
+
breakpoints: (0, import_zod5.boolean)().default(true)
|
9238
|
+
});
|
9239
|
+
configPushSchema = (0, import_zod5.object)({
|
9240
|
+
dialect: dialect3,
|
9241
|
+
schema: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]),
|
9242
|
+
tablesFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).optional(),
|
9243
|
+
schemaFilter: (0, import_zod5.union)([(0, import_zod5.string)(), (0, import_zod5.string)().array()]).default(["public"]),
|
9244
|
+
verbose: (0, import_zod5.boolean)().default(false),
|
9245
|
+
strict: (0, import_zod5.boolean)().default(false),
|
9246
|
+
out: (0, import_zod5.string)().optional()
|
9247
|
+
});
|
9248
|
+
}
|
9249
|
+
});
|
9250
|
+
|
9141
9251
|
// src/cli/validations/outputs.ts
|
9142
9252
|
var withStyle;
|
9143
9253
|
var init_outputs = __esm({
|
9144
9254
|
"src/cli/validations/outputs.ts"() {
|
9145
9255
|
"use strict";
|
9146
9256
|
init_source();
|
9257
|
+
init_common2();
|
9147
9258
|
withStyle = {
|
9148
9259
|
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
9149
9260
|
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
@@ -9156,193 +9267,119 @@ var init_outputs = __esm({
|
|
9156
9267
|
});
|
9157
9268
|
|
9158
9269
|
// src/cli/validations/mysql.ts
|
9159
|
-
var
|
9270
|
+
var import_zod6, mysqlCredentials;
|
9160
9271
|
var init_mysql = __esm({
|
9161
9272
|
"src/cli/validations/mysql.ts"() {
|
9162
9273
|
"use strict";
|
9163
|
-
|
9274
|
+
import_zod6 = require("zod");
|
9164
9275
|
init_outputs();
|
9165
|
-
|
9166
|
-
|
9167
|
-
|
9168
|
-
|
9169
|
-
|
9170
|
-
|
9171
|
-
|
9172
|
-
|
9173
|
-
|
9174
|
-
|
9175
|
-
|
9176
|
-
|
9177
|
-
|
9178
|
-
|
9179
|
-
|
9180
|
-
|
9181
|
-
|
9182
|
-
|
9276
|
+
init_common2();
|
9277
|
+
init_views();
|
9278
|
+
mysqlCredentials = (0, import_zod6.union)([
|
9279
|
+
(0, import_zod6.object)({
|
9280
|
+
host: (0, import_zod6.string)().min(1),
|
9281
|
+
port: import_zod6.coerce.number().min(1).optional(),
|
9282
|
+
user: (0, import_zod6.string)().min(1).optional(),
|
9283
|
+
password: (0, import_zod6.string)().min(1).optional(),
|
9284
|
+
database: (0, import_zod6.string)().min(1),
|
9285
|
+
ssl: (0, import_zod6.union)([
|
9286
|
+
(0, import_zod6.string)(),
|
9287
|
+
(0, import_zod6.object)({
|
9288
|
+
pfx: (0, import_zod6.string)().optional(),
|
9289
|
+
key: (0, import_zod6.string)().optional(),
|
9290
|
+
passphrase: (0, import_zod6.string)().optional(),
|
9291
|
+
cert: (0, import_zod6.string)().optional(),
|
9292
|
+
ca: (0, import_zod6.union)([(0, import_zod6.string)(), (0, import_zod6.string)().array()]).optional(),
|
9293
|
+
crl: (0, import_zod6.union)([(0, import_zod6.string)(), (0, import_zod6.string)().array()]).optional(),
|
9294
|
+
ciphers: (0, import_zod6.string)().optional(),
|
9295
|
+
rejectUnauthorized: (0, import_zod6.boolean)().optional()
|
9183
9296
|
})
|
9184
9297
|
]).optional()
|
9185
9298
|
}),
|
9186
|
-
(0,
|
9187
|
-
url: (0,
|
9299
|
+
(0, import_zod6.object)({
|
9300
|
+
url: (0, import_zod6.string)().min(1)
|
9188
9301
|
})
|
9189
9302
|
]);
|
9190
9303
|
}
|
9191
9304
|
});
|
9192
9305
|
|
9193
|
-
// src/cli/validations/
|
9194
|
-
var
|
9195
|
-
var
|
9196
|
-
"src/cli/validations/
|
9306
|
+
// src/cli/validations/postgres.ts
|
9307
|
+
var import_zod7, postgresCredentials;
|
9308
|
+
var init_postgres = __esm({
|
9309
|
+
"src/cli/validations/postgres.ts"() {
|
9197
9310
|
"use strict";
|
9198
|
-
|
9199
|
-
|
9200
|
-
|
9201
|
-
|
9202
|
-
|
9203
|
-
|
9204
|
-
|
9205
|
-
|
9206
|
-
|
9207
|
-
|
9208
|
-
|
9209
|
-
|
9210
|
-
(0,
|
9211
|
-
(0,
|
9212
|
-
(0,
|
9213
|
-
(0,
|
9214
|
-
|
9311
|
+
import_zod7 = require("zod");
|
9312
|
+
init_common2();
|
9313
|
+
init_views();
|
9314
|
+
postgresCredentials = (0, import_zod7.union)([
|
9315
|
+
(0, import_zod7.object)({
|
9316
|
+
driver: (0, import_zod7.undefined)(),
|
9317
|
+
host: (0, import_zod7.string)().min(1),
|
9318
|
+
port: import_zod7.coerce.number().min(1).optional(),
|
9319
|
+
user: (0, import_zod7.string)().min(1).optional(),
|
9320
|
+
password: (0, import_zod7.string)().min(1).optional(),
|
9321
|
+
database: (0, import_zod7.string)().min(1),
|
9322
|
+
ssl: (0, import_zod7.union)([
|
9323
|
+
(0, import_zod7.literal)("require"),
|
9324
|
+
(0, import_zod7.literal)("allow"),
|
9325
|
+
(0, import_zod7.literal)("prefer"),
|
9326
|
+
(0, import_zod7.literal)("verify-full"),
|
9327
|
+
(0, import_zod7.boolean)(),
|
9328
|
+
(0, import_zod7.object)({}).passthrough()
|
9329
|
+
]).optional()
|
9330
|
+
}).transform((o) => {
|
9331
|
+
delete o.driver;
|
9332
|
+
return o;
|
9215
9333
|
}),
|
9216
|
-
(0,
|
9217
|
-
|
9334
|
+
(0, import_zod7.object)({
|
9335
|
+
driver: (0, import_zod7.undefined)(),
|
9336
|
+
url: (0, import_zod7.string)().min(1)
|
9337
|
+
}).transform((o) => {
|
9338
|
+
delete o.driver;
|
9339
|
+
return o;
|
9218
9340
|
}),
|
9219
|
-
(0,
|
9220
|
-
driver: (0,
|
9221
|
-
database: (0,
|
9222
|
-
secretArn: (0,
|
9223
|
-
resourceArn: (0,
|
9341
|
+
(0, import_zod7.object)({
|
9342
|
+
driver: (0, import_zod7.literal)("aws-data-api"),
|
9343
|
+
database: (0, import_zod7.string)().min(1),
|
9344
|
+
secretArn: (0, import_zod7.string)().min(1),
|
9345
|
+
resourceArn: (0, import_zod7.string)().min(1)
|
9224
9346
|
})
|
9225
9347
|
]);
|
9226
9348
|
}
|
9227
9349
|
});
|
9228
9350
|
|
9229
9351
|
// src/cli/validations/sqlite.ts
|
9230
|
-
var
|
9352
|
+
var import_zod8, sqliteCredentials;
|
9231
9353
|
var init_sqlite = __esm({
|
9232
9354
|
"src/cli/validations/sqlite.ts"() {
|
9233
9355
|
"use strict";
|
9234
|
-
|
9235
|
-
|
9236
|
-
|
9237
|
-
|
9238
|
-
|
9239
|
-
|
9240
|
-
|
9356
|
+
import_zod8 = require("zod");
|
9357
|
+
init_common2();
|
9358
|
+
init_views();
|
9359
|
+
init_global();
|
9360
|
+
sqliteCredentials = (0, import_zod8.union)([
|
9361
|
+
(0, import_zod8.object)({
|
9362
|
+
driver: (0, import_zod8.literal)("turso"),
|
9363
|
+
url: (0, import_zod8.string)().min(1),
|
9364
|
+
authToken: (0, import_zod8.string)().min(1).optional()
|
9241
9365
|
}),
|
9242
|
-
(0,
|
9243
|
-
driver: (0,
|
9244
|
-
accountId: (0,
|
9245
|
-
databaseId: (0,
|
9246
|
-
token: (0,
|
9366
|
+
(0, import_zod8.object)({
|
9367
|
+
driver: (0, import_zod8.literal)("d1-http"),
|
9368
|
+
accountId: (0, import_zod8.string)().min(1),
|
9369
|
+
databaseId: (0, import_zod8.string)().min(1),
|
9370
|
+
token: (0, import_zod8.string)().min(1)
|
9247
9371
|
}),
|
9248
|
-
(0,
|
9249
|
-
|
9372
|
+
(0, import_zod8.object)({
|
9373
|
+
driver: (0, import_zod8.undefined)(),
|
9374
|
+
url: (0, import_zod8.string)().min(1)
|
9375
|
+
}).transform((o) => {
|
9376
|
+
delete o.driver;
|
9377
|
+
return o;
|
9250
9378
|
})
|
9251
9379
|
]);
|
9252
9380
|
}
|
9253
9381
|
});
|
9254
9382
|
|
9255
|
-
// src/schemaValidator.ts
|
9256
|
-
var import_zod7, dialect3, commonSquashedSchema, commonSchema;
|
9257
|
-
var init_schemaValidator = __esm({
|
9258
|
-
"src/schemaValidator.ts"() {
|
9259
|
-
"use strict";
|
9260
|
-
import_zod7 = require("zod");
|
9261
|
-
init_mysqlSchema();
|
9262
|
-
init_pgSchema();
|
9263
|
-
init_sqliteSchema();
|
9264
|
-
dialect3 = (0, import_zod7.enum)(["postgresql", "mysql", "sqlite"]);
|
9265
|
-
commonSquashedSchema = (0, import_zod7.union)([
|
9266
|
-
pgSchemaSquashed,
|
9267
|
-
mysqlSchemaSquashed,
|
9268
|
-
SQLiteSchemaSquashed
|
9269
|
-
]);
|
9270
|
-
commonSchema = (0, import_zod7.union)([
|
9271
|
-
pgSchema,
|
9272
|
-
mysqlSchema,
|
9273
|
-
sqliteSchema
|
9274
|
-
]);
|
9275
|
-
}
|
9276
|
-
});
|
9277
|
-
|
9278
|
-
// src/cli/validations/common.ts
|
9279
|
-
var import_zod8, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
9280
|
-
var init_common2 = __esm({
|
9281
|
-
"src/cli/validations/common.ts"() {
|
9282
|
-
"use strict";
|
9283
|
-
init_outputs();
|
9284
|
-
import_zod8 = require("zod");
|
9285
|
-
init_schemaValidator();
|
9286
|
-
sqliteDriver = (0, import_zod8.union)([
|
9287
|
-
(0, import_zod8.literal)("better-sqlite"),
|
9288
|
-
(0, import_zod8.literal)("turso"),
|
9289
|
-
(0, import_zod8.literal)("libsql"),
|
9290
|
-
(0, import_zod8.literal)("d1"),
|
9291
|
-
(0, import_zod8.literal)("d1-http"),
|
9292
|
-
(0, import_zod8.literal)("expo")
|
9293
|
-
]);
|
9294
|
-
postgresDriver = (0, import_zod8.literal)("aws-data-api");
|
9295
|
-
mysqlDriver = (0, import_zod8.literal)("mysql2");
|
9296
|
-
driver = (0, import_zod8.union)([sqliteDriver, postgresDriver, mysqlDriver]);
|
9297
|
-
configCommonSchema = (0, import_zod8.object)({
|
9298
|
-
dialect: dialect3,
|
9299
|
-
schema: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9300
|
-
out: (0, import_zod8.string)().optional(),
|
9301
|
-
breakpoints: (0, import_zod8.boolean)().optional().default(true),
|
9302
|
-
driver: driver.optional(),
|
9303
|
-
tablesFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9304
|
-
schemaFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).default(["public"])
|
9305
|
-
});
|
9306
|
-
casing = (0, import_zod8.union)([(0, import_zod8.literal)("camel"), (0, import_zod8.literal)("preserve")]).default(
|
9307
|
-
"preserve"
|
9308
|
-
);
|
9309
|
-
introspectParams = (0, import_zod8.object)({
|
9310
|
-
schema: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9311
|
-
out: (0, import_zod8.string)().optional().default("./drizzle"),
|
9312
|
-
breakpoints: (0, import_zod8.boolean)().default(true),
|
9313
|
-
tablesFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9314
|
-
schemaFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).default(["public"]),
|
9315
|
-
introspect: (0, import_zod8.object)({
|
9316
|
-
casing
|
9317
|
-
}).default({ casing: "camel" })
|
9318
|
-
});
|
9319
|
-
configIntrospectCliSchema = (0, import_zod8.object)({
|
9320
|
-
schema: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9321
|
-
out: (0, import_zod8.string)().optional().default("./drizzle"),
|
9322
|
-
breakpoints: (0, import_zod8.boolean)().default(true),
|
9323
|
-
tablesFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9324
|
-
schemaFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).default(["public"]),
|
9325
|
-
introspectCasing: (0, import_zod8.union)([(0, import_zod8.literal)("camel"), (0, import_zod8.literal)("preserve")]).default(
|
9326
|
-
"camel"
|
9327
|
-
)
|
9328
|
-
});
|
9329
|
-
configGenerateSchema = (0, import_zod8.object)({
|
9330
|
-
schema: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]),
|
9331
|
-
out: (0, import_zod8.string)().optional().default("./drizzle"),
|
9332
|
-
breakpoints: (0, import_zod8.boolean)().default(true)
|
9333
|
-
});
|
9334
|
-
configPushSchema = (0, import_zod8.object)({
|
9335
|
-
dialect: dialect3,
|
9336
|
-
schema: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]),
|
9337
|
-
tablesFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).optional(),
|
9338
|
-
schemaFilter: (0, import_zod8.union)([(0, import_zod8.string)(), (0, import_zod8.string)().array()]).default(["public"]),
|
9339
|
-
verbose: (0, import_zod8.boolean)().default(false),
|
9340
|
-
strict: (0, import_zod8.boolean)().default(false),
|
9341
|
-
out: (0, import_zod8.string)().optional()
|
9342
|
-
});
|
9343
|
-
}
|
9344
|
-
});
|
9345
|
-
|
9346
9383
|
// src/cli/validations/cli.ts
|
9347
9384
|
var import_zod9, cliConfigGenerate, pushParams, pullParams, configCheck, cliConfigCheck;
|
9348
9385
|
var init_cli = __esm({
|
@@ -9401,7 +9438,7 @@ var init_studio = __esm({
|
|
9401
9438
|
init_mysql();
|
9402
9439
|
init_sqlite();
|
9403
9440
|
init_schemaValidator();
|
9404
|
-
|
9441
|
+
init_postgres();
|
9405
9442
|
credentials = (0, import_zod10.intersection)(
|
9406
9443
|
postgresCredentials,
|
9407
9444
|
mysqlCredentials,
|
@@ -9443,7 +9480,7 @@ var init_utils6 = __esm({
|
|
9443
9480
|
import_hanji2 = require("hanji");
|
9444
9481
|
init_global();
|
9445
9482
|
init_mysql();
|
9446
|
-
|
9483
|
+
init_postgres();
|
9447
9484
|
init_sqlite();
|
9448
9485
|
init_common2();
|
9449
9486
|
init_schemaValidator();
|
@@ -12075,7 +12112,7 @@ var init_jsonStatements = __esm({
|
|
12075
12112
|
uniqueConstraints: Object.values(uniqueConstraints)
|
12076
12113
|
};
|
12077
12114
|
};
|
12078
|
-
prepareMySqlCreateTableJson = (table4, json2) => {
|
12115
|
+
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
12079
12116
|
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
12080
12117
|
return {
|
12081
12118
|
type: "create_table",
|
@@ -12084,7 +12121,8 @@ var init_jsonStatements = __esm({
|
|
12084
12121
|
columns: Object.values(columns),
|
12085
12122
|
compositePKs: Object.values(compositePrimaryKeys),
|
12086
12123
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
12087
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
12124
|
+
uniqueConstraints: Object.values(uniqueConstraints),
|
12125
|
+
internals
|
12088
12126
|
};
|
12089
12127
|
};
|
12090
12128
|
prepareSQLiteCreateTable = (table4) => {
|
@@ -12838,13 +12876,14 @@ var init_jsonStatements = __esm({
|
|
12838
12876
|
};
|
12839
12877
|
});
|
12840
12878
|
};
|
12841
|
-
prepareCreateIndexesJson = (tableName, schema4, indexes) => {
|
12879
|
+
prepareCreateIndexesJson = (tableName, schema4, indexes, internal) => {
|
12842
12880
|
return Object.values(indexes).map((indexData) => {
|
12843
12881
|
return {
|
12844
12882
|
type: "create_index",
|
12845
12883
|
tableName,
|
12846
12884
|
data: indexData,
|
12847
|
-
schema: schema4
|
12885
|
+
schema: schema4,
|
12886
|
+
internal
|
12848
12887
|
};
|
12849
12888
|
});
|
12850
12889
|
};
|
@@ -13781,7 +13820,12 @@ var init_snapshotsDiffer = __esm({
|
|
13781
13820
|
const typedResult = diffResultSchemeMysql.parse(diffResult);
|
13782
13821
|
const jsonStatements = [];
|
13783
13822
|
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
13784
|
-
return prepareCreateIndexesJson(
|
13823
|
+
return prepareCreateIndexesJson(
|
13824
|
+
it.name,
|
13825
|
+
it.schema,
|
13826
|
+
it.indexes,
|
13827
|
+
curFull.internal
|
13828
|
+
);
|
13785
13829
|
}).flat();
|
13786
13830
|
const jsonDropTables = deletedTables.map((it) => {
|
13787
13831
|
return prepareDropTableJson(it);
|
@@ -13880,7 +13924,8 @@ var init_snapshotsDiffer = __esm({
|
|
13880
13924
|
return prepareCreateIndexesJson(
|
13881
13925
|
it.name,
|
13882
13926
|
it.schema,
|
13883
|
-
it.addedIndexes || {}
|
13927
|
+
it.addedIndexes || {},
|
13928
|
+
curFull.internal
|
13884
13929
|
);
|
13885
13930
|
}).flat();
|
13886
13931
|
const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
|
@@ -13940,7 +13985,11 @@ var init_snapshotsDiffer = __esm({
|
|
13940
13985
|
(t) => t.type === "delete_reference"
|
13941
13986
|
);
|
13942
13987
|
const jsonMySqlCreateTables = createdTables.map((it) => {
|
13943
|
-
return prepareMySqlCreateTableJson(
|
13988
|
+
return prepareMySqlCreateTableJson(
|
13989
|
+
it,
|
13990
|
+
curFull,
|
13991
|
+
curFull.internal
|
13992
|
+
);
|
13944
13993
|
});
|
13945
13994
|
jsonStatements.push(...jsonMySqlCreateTables);
|
13946
13995
|
jsonStatements.push(...jsonDropTables);
|
@@ -13980,7 +14029,7 @@ var init_snapshotsDiffer = __esm({
|
|
13980
14029
|
_meta
|
13981
14030
|
};
|
13982
14031
|
};
|
13983
|
-
applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2) => {
|
14032
|
+
applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull) => {
|
13984
14033
|
const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
|
13985
14034
|
const {
|
13986
14035
|
created: createdTables,
|
@@ -14060,7 +14109,12 @@ var init_snapshotsDiffer = __esm({
|
|
14060
14109
|
return prepareSQLiteCreateTable(it);
|
14061
14110
|
});
|
14062
14111
|
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
14063
|
-
return prepareCreateIndexesJson(
|
14112
|
+
return prepareCreateIndexesJson(
|
14113
|
+
it.name,
|
14114
|
+
it.schema,
|
14115
|
+
it.indexes,
|
14116
|
+
curFull.internal
|
14117
|
+
);
|
14064
14118
|
}).flat();
|
14065
14119
|
const jsonDropTables = deletedTables.map((it) => {
|
14066
14120
|
return prepareDropTableJson(it);
|
@@ -14162,7 +14216,8 @@ var init_snapshotsDiffer = __esm({
|
|
14162
14216
|
return prepareCreateIndexesJson(
|
14163
14217
|
it.name,
|
14164
14218
|
it.schema,
|
14165
|
-
it.addedIndexes || {}
|
14219
|
+
it.addedIndexes || {},
|
14220
|
+
curFull.internal
|
14166
14221
|
);
|
14167
14222
|
}).flat();
|
14168
14223
|
const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
|
@@ -14596,7 +14651,14 @@ var init_sqlgenerator = __esm({
|
|
14596
14651
|
return statement.type === "create_table" && dialect7 === "mysql";
|
14597
14652
|
}
|
14598
14653
|
convert(st) {
|
14599
|
-
const {
|
14654
|
+
const {
|
14655
|
+
tableName,
|
14656
|
+
columns,
|
14657
|
+
schema: schema4,
|
14658
|
+
compositePKs,
|
14659
|
+
uniqueConstraints,
|
14660
|
+
internals
|
14661
|
+
} = st;
|
14600
14662
|
let statement = "";
|
14601
14663
|
statement += `CREATE TABLE \`${tableName}\` (
|
14602
14664
|
`;
|
@@ -14619,7 +14681,10 @@ var init_sqlgenerator = __esm({
|
|
14619
14681
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
14620
14682
|
statement += ",\n";
|
14621
14683
|
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
14622
|
-
|
14684
|
+
const uniqueString = unsquashedUnique.columns.map((it) => {
|
14685
|
+
return internals?.indexes ? internals?.indexes[unsquashedUnique.name]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
14686
|
+
}).join(",");
|
14687
|
+
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
14623
14688
|
}
|
14624
14689
|
}
|
14625
14690
|
statement += `
|
@@ -15548,8 +15613,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15548
15613
|
statement.data
|
15549
15614
|
);
|
15550
15615
|
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
15551
|
-
const
|
15552
|
-
|
15616
|
+
const uniqueString = columns.map((it) => {
|
15617
|
+
return statement.internal?.indexes ? statement.internal?.indexes[name2]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
15618
|
+
}).join(",");
|
15619
|
+
return `CREATE ${indexPart} \`${name2}\` ON \`${statement.tableName}\` (${uniqueString});`;
|
15553
15620
|
}
|
15554
15621
|
};
|
15555
15622
|
CreateSqliteIndexConvertor = class extends Convertor {
|
@@ -15562,8 +15629,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15562
15629
|
);
|
15563
15630
|
const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
|
15564
15631
|
const whereStatement = where ? ` WHERE ${where}` : "";
|
15565
|
-
const
|
15566
|
-
|
15632
|
+
const uniqueString = columns.map((it) => {
|
15633
|
+
return statement.internal?.indexes ? statement.internal?.indexes[name2]?.columns[it]?.isExpression ? it : `\`${it}\`` : `\`${it}\``;
|
15634
|
+
}).join(",");
|
15635
|
+
return `CREATE ${indexPart} \`${name2}\` ON \`${statement.tableName}\` (${uniqueString})${whereStatement};`;
|
15567
15636
|
}
|
15568
15637
|
};
|
15569
15638
|
PgDropIndexConvertor = class extends Convertor {
|
@@ -19139,6 +19208,7 @@ var init_sqliteSerializer = __esm({
|
|
19139
19208
|
dialect5 = new SQLiteSyncDialect();
|
19140
19209
|
generateSqliteSnapshot = (tables) => {
|
19141
19210
|
const result = {};
|
19211
|
+
const internal = { indexes: {} };
|
19142
19212
|
for (const table4 of tables) {
|
19143
19213
|
const columnsObject = {};
|
19144
19214
|
const indexesObject = {};
|
@@ -19225,7 +19295,25 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
19225
19295
|
const name2 = value.config.name;
|
19226
19296
|
let indexColumns = columns2.map((it) => {
|
19227
19297
|
if (is(it, SQL)) {
|
19228
|
-
|
19298
|
+
const sql2 = dialect5.sqlToQuery(it, "indexes").sql;
|
19299
|
+
if (typeof internal.indexes[name2] === "undefined") {
|
19300
|
+
internal.indexes[name2] = {
|
19301
|
+
columns: {
|
19302
|
+
[sql2]: {
|
19303
|
+
isExpression: true
|
19304
|
+
}
|
19305
|
+
}
|
19306
|
+
};
|
19307
|
+
} else {
|
19308
|
+
if (typeof internal.indexes[name2]?.columns[sql2] === "undefined") {
|
19309
|
+
internal.indexes[name2].columns[sql2] = {
|
19310
|
+
isExpression: true
|
19311
|
+
};
|
19312
|
+
} else {
|
19313
|
+
internal.indexes[name2].columns[sql2].isExpression = true;
|
19314
|
+
}
|
19315
|
+
}
|
19316
|
+
return sql2;
|
19229
19317
|
} else {
|
19230
19318
|
return it.name;
|
19231
19319
|
}
|
@@ -19299,7 +19387,8 @@ The unique constraint ${source_default.underline.blue(
|
|
19299
19387
|
_meta: {
|
19300
19388
|
tables: {},
|
19301
19389
|
columns: {}
|
19302
|
-
}
|
19390
|
+
},
|
19391
|
+
internal
|
19303
19392
|
};
|
19304
19393
|
};
|
19305
19394
|
fromDatabase2 = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
@@ -23561,6 +23650,7 @@ var init_mysqlSerializer = __esm({
|
|
23561
23650
|
dialect6 = new MySqlDialect();
|
23562
23651
|
generateMySqlSnapshot = (tables) => {
|
23563
23652
|
const result = {};
|
23653
|
+
const internal = { tables: {}, indexes: {} };
|
23564
23654
|
for (const table4 of tables) {
|
23565
23655
|
const {
|
23566
23656
|
name: tableName,
|
@@ -23712,9 +23802,27 @@ The unique constraint ${source_default.underline.blue(
|
|
23712
23802
|
const name2 = value.config.name;
|
23713
23803
|
let indexColumns = columns2.map((it) => {
|
23714
23804
|
if (is(it, SQL)) {
|
23715
|
-
|
23805
|
+
const sql2 = dialect6.sqlToQuery(it, "indexes").sql;
|
23806
|
+
if (typeof internal.indexes[name2] === "undefined") {
|
23807
|
+
internal.indexes[name2] = {
|
23808
|
+
columns: {
|
23809
|
+
[sql2]: {
|
23810
|
+
isExpression: true
|
23811
|
+
}
|
23812
|
+
}
|
23813
|
+
};
|
23814
|
+
} else {
|
23815
|
+
if (typeof internal.indexes[name2]?.columns[sql2] === "undefined") {
|
23816
|
+
internal.indexes[name2].columns[sql2] = {
|
23817
|
+
isExpression: true
|
23818
|
+
};
|
23819
|
+
} else {
|
23820
|
+
internal.indexes[name2].columns[sql2].isExpression = true;
|
23821
|
+
}
|
23822
|
+
}
|
23823
|
+
return sql2;
|
23716
23824
|
} else {
|
23717
|
-
return it.name
|
23825
|
+
return `${it.name}`;
|
23718
23826
|
}
|
23719
23827
|
});
|
23720
23828
|
if (value.config.unique) {
|
@@ -23781,12 +23889,13 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
23781
23889
|
_meta: {
|
23782
23890
|
tables: {},
|
23783
23891
|
columns: {}
|
23784
|
-
}
|
23892
|
+
},
|
23893
|
+
internal
|
23785
23894
|
};
|
23786
23895
|
};
|
23787
23896
|
fromDatabase3 = async (db, inputSchema, tablesFilter = (table4) => true, progressCallback) => {
|
23788
23897
|
const result = {};
|
23789
|
-
const internals = { tables: {} };
|
23898
|
+
const internals = { tables: {}, indexes: {} };
|
23790
23899
|
const columns = await db.query(`select * from information_schema.columns
|
23791
23900
|
where table_schema = '${inputSchema}' and table_name != '__drizzle_migrations'
|
23792
23901
|
order by table_name, ordinal_position;`);
|
@@ -25329,7 +25438,9 @@ var generateSQLiteMigration = async (prev, cur) => {
|
|
25329
25438
|
squashedPrev,
|
25330
25439
|
squashedCur,
|
25331
25440
|
tablesResolver,
|
25332
|
-
columnsResolver
|
25441
|
+
columnsResolver,
|
25442
|
+
validatedPrev,
|
25443
|
+
validatedCur
|
25333
25444
|
);
|
25334
25445
|
return sqlStatements;
|
25335
25446
|
};
|
@@ -25358,7 +25469,9 @@ var pushSQLiteSchema = async (imports, drizzleInstance) => {
|
|
25358
25469
|
squashedPrev,
|
25359
25470
|
squashedCur,
|
25360
25471
|
tablesResolver,
|
25361
|
-
columnsResolver
|
25472
|
+
columnsResolver,
|
25473
|
+
validatedPrev,
|
25474
|
+
validatedCur
|
25362
25475
|
);
|
25363
25476
|
const { shouldAskForApprove, statementsToExecute, infoToPrint } = await logSuggestionsAndReturn(
|
25364
25477
|
db,
|