drizzle-kit 0.20.14-a77266f → 0.20.14-f5f86f6

Sign up to get free protection for your applications and to get access to all the features.
package/payload.js CHANGED
@@ -2090,7 +2090,7 @@ ${withStyle.errorWarning(
2090
2090
  --end;
2091
2091
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
2092
2092
  };
2093
- fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
2093
+ fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
2094
2094
  const result = {};
2095
2095
  const internals = { tables: {} };
2096
2096
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -6160,6 +6160,226 @@ var init_lib = __esm({
6160
6160
  }
6161
6161
  });
6162
6162
 
6163
+ // src/cli/validations/common.ts
6164
+ var init_common = __esm({
6165
+ "src/cli/validations/common.ts"() {
6166
+ init_outputs();
6167
+ }
6168
+ });
6169
+
6170
+ // src/cli/validations/mysql.ts
6171
+ var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams;
6172
+ var init_mysql = __esm({
6173
+ "src/cli/validations/mysql.ts"() {
6174
+ init_lib();
6175
+ init_utils();
6176
+ init_common();
6177
+ init_outputs();
6178
+ mysqlConnectionCli = unionType([
6179
+ objectType({
6180
+ driver: literalType("mysql2"),
6181
+ host: stringType(),
6182
+ port: coerce.number().optional(),
6183
+ user: stringType().default("mysql"),
6184
+ password: stringType().optional(),
6185
+ database: stringType()
6186
+ }),
6187
+ objectType({
6188
+ driver: literalType("mysql2"),
6189
+ uri: stringType()
6190
+ // TODO: change docs
6191
+ })
6192
+ ]);
6193
+ mysql2credentials = unionType([
6194
+ objectType({
6195
+ host: stringType(),
6196
+ port: coerce.number().optional(),
6197
+ user: stringType().default("mysql"),
6198
+ password: stringType().optional(),
6199
+ database: stringType()
6200
+ }),
6201
+ objectType({
6202
+ uri: stringType()
6203
+ // TODO: change docs
6204
+ })
6205
+ ]);
6206
+ mysqlConnectionConfig = objectType({
6207
+ driver: literalType("mysql2"),
6208
+ dbCredentials: mysql2credentials
6209
+ });
6210
+ mysqlConfigIntrospectSchema = intersectionType(
6211
+ configIntrospectSchema,
6212
+ mysqlConnectionConfig
6213
+ );
6214
+ mysqlCliIntrospectParams = intersectionType(
6215
+ configIntrospectCliSchema,
6216
+ mysqlConnectionCli
6217
+ );
6218
+ mysqlCliPushParams = intersectionType(
6219
+ configPushSchema,
6220
+ mysqlConnectionCli
6221
+ );
6222
+ mysqlConfigPushParams = intersectionType(
6223
+ configPushSchema,
6224
+ mysqlConnectionConfig
6225
+ );
6226
+ }
6227
+ });
6228
+
6229
+ // src/cli/validations/pg.ts
6230
+ var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, pgCliPushParams, pgConfigPushParams;
6231
+ var init_pg = __esm({
6232
+ "src/cli/validations/pg.ts"() {
6233
+ init_lib();
6234
+ init_utils();
6235
+ init_common();
6236
+ init_outputs();
6237
+ pgConnectionCli = unionType([
6238
+ objectType({
6239
+ driver: literalType("pg"),
6240
+ host: stringType(),
6241
+ port: coerce.number().optional(),
6242
+ user: stringType().default("postgres"),
6243
+ password: stringType().optional(),
6244
+ database: stringType(),
6245
+ ssl: coerce.boolean().optional(),
6246
+ type: literalType("params").default("params")
6247
+ }),
6248
+ objectType({
6249
+ driver: literalType("pg"),
6250
+ connectionString: stringType(),
6251
+ type: literalType("url").default("url")
6252
+ })
6253
+ ]);
6254
+ pgConnectionConfig = unionType([
6255
+ objectType({
6256
+ driver: literalType("pg"),
6257
+ dbCredentials: objectType({
6258
+ host: stringType(),
6259
+ port: coerce.number().optional(),
6260
+ user: stringType().default("postgres"),
6261
+ password: stringType().optional(),
6262
+ database: stringType(),
6263
+ ssl: coerce.boolean().optional(),
6264
+ type: literalType("params").default("params").optional()
6265
+ })
6266
+ }),
6267
+ objectType({
6268
+ driver: literalType("pg"),
6269
+ dbCredentials: objectType({
6270
+ connectionString: stringType(),
6271
+ type: literalType("url").default("url").optional()
6272
+ })
6273
+ })
6274
+ ]);
6275
+ pgConfigIntrospectSchema = intersectionType(
6276
+ configIntrospectSchema,
6277
+ pgConnectionConfig
6278
+ );
6279
+ pgCliIntrospectParams = intersectionType(
6280
+ configIntrospectCliSchema,
6281
+ pgConnectionCli
6282
+ );
6283
+ pgCliPushParams = intersectionType(
6284
+ configPushSchema,
6285
+ pgConnectionCli
6286
+ );
6287
+ pgConfigPushParams = intersectionType(
6288
+ configPushSchema,
6289
+ pgConnectionConfig
6290
+ );
6291
+ }
6292
+ });
6293
+
6294
+ // src/cli/commands/sqliteUtils.ts
6295
+ var sqliteConnectionSchema, sqliteCliConfigSchema;
6296
+ var init_sqliteUtils = __esm({
6297
+ "src/cli/commands/sqliteUtils.ts"() {
6298
+ init_lib();
6299
+ init_utils();
6300
+ sqliteConnectionSchema = unionType([
6301
+ objectType({
6302
+ driver: literalType("turso"),
6303
+ dbCredentials: objectType({
6304
+ url: stringType(),
6305
+ authToken: stringType().optional()
6306
+ })
6307
+ }),
6308
+ objectType({
6309
+ driver: literalType("libsql"),
6310
+ dbCredentials: objectType({
6311
+ url: stringType()
6312
+ })
6313
+ }),
6314
+ objectType({
6315
+ driver: literalType("better-sqlite"),
6316
+ dbCredentials: objectType({
6317
+ url: stringType()
6318
+ })
6319
+ })
6320
+ ]);
6321
+ sqliteCliConfigSchema = intersectionType(
6322
+ configIntrospectSchema,
6323
+ sqliteConnectionSchema
6324
+ );
6325
+ }
6326
+ });
6327
+
6328
+ // src/cli/validations/sqlite.ts
6329
+ var sqliteConnectionCli, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams;
6330
+ var init_sqlite = __esm({
6331
+ "src/cli/validations/sqlite.ts"() {
6332
+ init_lib();
6333
+ init_sqliteUtils();
6334
+ init_utils();
6335
+ init_common();
6336
+ init_outputs();
6337
+ sqliteConnectionCli = unionType([
6338
+ objectType({
6339
+ driver: literalType("turso"),
6340
+ url: stringType(),
6341
+ authToken: stringType()
6342
+ }),
6343
+ objectType({
6344
+ driver: literalType("better-sqlite"),
6345
+ url: stringType()
6346
+ }),
6347
+ objectType({
6348
+ driver: literalType("libsql"),
6349
+ url: stringType()
6350
+ })
6351
+ ]);
6352
+ sqliteCliIntrospectParams = intersectionType(
6353
+ configIntrospectCliSchema,
6354
+ sqliteConnectionCli
6355
+ );
6356
+ sqliteCliPushParams = intersectionType(
6357
+ configPushSchema,
6358
+ sqliteConnectionCli
6359
+ );
6360
+ sqliteConfigPushParams = intersectionType(
6361
+ configPushSchema,
6362
+ sqliteConnectionSchema
6363
+ );
6364
+ }
6365
+ });
6366
+
6367
+ // src/global.ts
6368
+ var originUUID, snapshotVersion, mapValues;
6369
+ var init_global = __esm({
6370
+ "src/global.ts"() {
6371
+ originUUID = "00000000-0000-0000-0000-000000000000";
6372
+ snapshotVersion = "5";
6373
+ mapValues = (obj, map) => {
6374
+ const result = Object.keys(obj).reduce(function(result2, key) {
6375
+ result2[key] = map(obj[key]);
6376
+ return result2;
6377
+ }, {});
6378
+ return result;
6379
+ };
6380
+ }
6381
+ });
6382
+
6163
6383
  // src/cli/commands/_es5.ts
6164
6384
  var es5_exports = {};
6165
6385
  __export(es5_exports, {
@@ -11787,6 +12007,13 @@ var init_utils = __esm({
11787
12007
  init_source();
11788
12008
  init_views();
11789
12009
  import_hanji2 = __toESM(require_hanji());
12010
+ init_mysql();
12011
+ init_pg();
12012
+ init_sqlite();
12013
+ init_outputs();
12014
+ init_pg();
12015
+ init_sqlite();
12016
+ init_global();
11790
12017
  assertES5 = async (unregister) => {
11791
12018
  try {
11792
12019
  init_es5();
@@ -11953,22 +12180,6 @@ var init_pgImports = __esm({
11953
12180
  }
11954
12181
  });
11955
12182
 
11956
- // src/global.ts
11957
- var originUUID, snapshotVersion, mapValues;
11958
- var init_global = __esm({
11959
- "src/global.ts"() {
11960
- originUUID = "00000000-0000-0000-0000-000000000000";
11961
- snapshotVersion = "5";
11962
- mapValues = (obj, map) => {
11963
- const result = Object.keys(obj).reduce(function(result2, key) {
11964
- result2[key] = map(obj[key]);
11965
- return result2;
11966
- }, {});
11967
- return result;
11968
- };
11969
- }
11970
- });
11971
-
11972
12183
  // src/serializer/pgSchema.ts
11973
12184
  var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, schemaHash, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals, pgSchemaInternal, tableSquashed, tableSquashedV4, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
11974
12185
  var init_pgSchema = __esm({
@@ -12462,9 +12673,12 @@ var init_sqliteSchema = __esm({
12462
12673
  const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12463
12674
  return SQLiteSquasher.squashPK(pk);
12464
12675
  });
12465
- const squashedUniqueConstraints = mapValues(it[1].uniqueConstraints, (unq) => {
12466
- return SQLiteSquasher.squashUnique(unq);
12467
- });
12676
+ const squashedUniqueConstraints = mapValues(
12677
+ it[1].uniqueConstraints,
12678
+ (unq) => {
12679
+ return SQLiteSquasher.squashUnique(unq);
12680
+ }
12681
+ );
12468
12682
  return [
12469
12683
  it[0],
12470
12684
  {
@@ -12498,7 +12712,11 @@ var init_sqliteSchema = __esm({
12498
12712
  }
12499
12713
  });
12500
12714
  sqliteSchema = schema2;
12501
- backwardCompatibleSqliteSchema = unionType([schemaV3, schemaV4, schema2]);
12715
+ backwardCompatibleSqliteSchema = unionType([
12716
+ schemaV3,
12717
+ schemaV4,
12718
+ schema2
12719
+ ]);
12502
12720
  }
12503
12721
  });
12504
12722
 
@@ -16142,60 +16360,50 @@ var init_migrate = __esm({
16142
16360
  return { sqlStatements, statements, validatedCur, validatedPrev };
16143
16361
  } catch (e) {
16144
16362
  console.error(e);
16363
+ process.exit(1);
16145
16364
  }
16146
16365
  };
16147
16366
  prepareSQLitePush = async (config, snapshot) => {
16148
16367
  const schemaPath = config.schema;
16149
- try {
16150
- const { prev, cur } = await prepareSQLiteDbPushSnapshot(
16151
- snapshot,
16152
- schemaPath
16153
- );
16154
- const validatedPrev = sqliteSchema.parse(prev);
16155
- const validatedCur = sqliteSchema.parse(cur);
16156
- const squashedPrev = squashSqliteScheme(validatedPrev);
16157
- const squashedCur = squashSqliteScheme(validatedCur);
16158
- const { sqlStatements, statements, _meta } = await prepareSQL(
16159
- squashedPrev,
16160
- squashedCur,
16161
- "sqlite",
16162
- validatedPrev,
16163
- validatedCur
16164
- );
16165
- return {
16166
- sqlStatements,
16167
- statements,
16168
- squashedPrev,
16169
- squashedCur,
16170
- meta: _meta
16171
- };
16172
- } catch (e) {
16173
- console.error(e);
16174
- }
16368
+ const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
16369
+ const validatedPrev = sqliteSchema.parse(prev);
16370
+ const validatedCur = sqliteSchema.parse(cur);
16371
+ const squashedPrev = squashSqliteScheme(validatedPrev);
16372
+ const squashedCur = squashSqliteScheme(validatedCur);
16373
+ const { sqlStatements, statements, _meta } = await prepareSQL(
16374
+ squashedPrev,
16375
+ squashedCur,
16376
+ "sqlite",
16377
+ validatedPrev,
16378
+ validatedCur
16379
+ );
16380
+ return {
16381
+ sqlStatements,
16382
+ statements,
16383
+ squashedPrev,
16384
+ squashedCur,
16385
+ meta: _meta
16386
+ };
16175
16387
  };
16176
16388
  preparePgPush = async (config, snapshot, schemaFilter) => {
16177
16389
  const schemaPath = config.schema;
16178
- try {
16179
- const { prev, cur } = await preparePgDbPushSnapshot(
16180
- snapshot,
16181
- schemaPath,
16182
- schemaFilter
16183
- );
16184
- const validatedPrev = pgSchema.parse(prev);
16185
- const validatedCur = pgSchema.parse(cur);
16186
- const squashedPrev = squashPgScheme(validatedPrev);
16187
- const squashedCur = squashPgScheme(validatedCur);
16188
- const { sqlStatements, statements } = await prepareSQL(
16189
- squashedPrev,
16190
- squashedCur,
16191
- "pg",
16192
- validatedPrev,
16193
- validatedCur
16194
- );
16195
- return { sqlStatements, statements, squashedPrev, squashedCur };
16196
- } catch (e) {
16197
- console.error(e);
16198
- }
16390
+ const { prev, cur } = await preparePgDbPushSnapshot(
16391
+ snapshot,
16392
+ schemaPath,
16393
+ schemaFilter
16394
+ );
16395
+ const validatedPrev = pgSchema.parse(prev);
16396
+ const validatedCur = pgSchema.parse(cur);
16397
+ const squashedPrev = squashPgScheme(validatedPrev);
16398
+ const squashedCur = squashPgScheme(validatedCur);
16399
+ const { sqlStatements, statements } = await prepareSQL(
16400
+ squashedPrev,
16401
+ squashedCur,
16402
+ "pg",
16403
+ validatedPrev,
16404
+ validatedCur
16405
+ );
16406
+ return { sqlStatements, statements, squashedPrev, squashedCur };
16199
16407
  };
16200
16408
  prepareAndMigrateMySql = async (config) => {
16201
16409
  const outFolder = config.out;