drizzle-kit 0.25.0-5a1c5d3 → 0.25.0-605ef48

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. package/api.d.mts +0 -82
  2. package/api.d.ts +0 -82
  3. package/api.js +170 -687
  4. package/api.mjs +170 -687
  5. package/bin.cjs +103 -757
  6. package/package.json +1 -1
  7. package/utils.js +6 -24
  8. package/utils.mjs +6 -24
package/api.mjs CHANGED
@@ -7219,7 +7219,7 @@ var init_lib = __esm({
7219
7219
  });
7220
7220
 
7221
7221
  // src/serializer/mysqlSchema.ts
7222
- var index, fk, column, tableV3, compositePK, uniqueConstraint, checkConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
7222
+ var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
7223
7223
  var init_mysqlSchema = __esm({
7224
7224
  "src/serializer/mysqlSchema.ts"() {
7225
7225
  "use strict";
@@ -7269,10 +7269,6 @@ var init_mysqlSchema = __esm({
7269
7269
  name: stringType(),
7270
7270
  columns: stringType().array()
7271
7271
  }).strict();
7272
- checkConstraint = objectType({
7273
- name: stringType(),
7274
- value: stringType()
7275
- }).strict();
7276
7272
  tableV4 = objectType({
7277
7273
  name: stringType(),
7278
7274
  schema: stringType().optional(),
@@ -7286,8 +7282,7 @@ var init_mysqlSchema = __esm({
7286
7282
  indexes: recordType(stringType(), index),
7287
7283
  foreignKeys: recordType(stringType(), fk),
7288
7284
  compositePrimaryKeys: recordType(stringType(), compositePK),
7289
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
7290
- checkConstraint: recordType(stringType(), checkConstraint).default({})
7285
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
7291
7286
  }).strict();
7292
7287
  kitInternals = objectType({
7293
7288
  tables: recordType(
@@ -7364,8 +7359,7 @@ var init_mysqlSchema = __esm({
7364
7359
  indexes: recordType(stringType(), stringType()),
7365
7360
  foreignKeys: recordType(stringType(), stringType()),
7366
7361
  compositePrimaryKeys: recordType(stringType(), stringType()),
7367
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
7368
- checkConstraints: recordType(stringType(), stringType()).default({})
7362
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
7369
7363
  }).strict();
7370
7364
  schemaSquashed = objectType({
7371
7365
  version: literalType("5"),
@@ -7432,13 +7426,6 @@ var init_mysqlSchema = __esm({
7432
7426
  onDelete
7433
7427
  });
7434
7428
  return result;
7435
- },
7436
- squashCheck: (input) => {
7437
- return `${input.name};${input.value}`;
7438
- },
7439
- unsquashCheck: (input) => {
7440
- const [name2, value] = input.split(";");
7441
- return { name: name2, value };
7442
7429
  }
7443
7430
  };
7444
7431
  squashMysqlScheme = (json) => {
@@ -7459,9 +7446,6 @@ var init_mysqlSchema = __esm({
7459
7446
  return MySqlSquasher.squashUnique(unq);
7460
7447
  }
7461
7448
  );
7462
- const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check) => {
7463
- return MySqlSquasher.squashCheck(check);
7464
- });
7465
7449
  return [
7466
7450
  it[0],
7467
7451
  {
@@ -7470,8 +7454,7 @@ var init_mysqlSchema = __esm({
7470
7454
  indexes: squashedIndexes,
7471
7455
  foreignKeys: squashedFKs,
7472
7456
  compositePrimaryKeys: squashedPKs,
7473
- uniqueConstraints: squashedUniqueConstraints,
7474
- checkConstraints: squashedCheckConstraints
7457
+ uniqueConstraints: squashedUniqueConstraints
7475
7458
  }
7476
7459
  ];
7477
7460
  })
@@ -7521,7 +7504,7 @@ var init_vector = __esm({
7521
7504
  });
7522
7505
 
7523
7506
  // src/serializer/pgSchema.ts
7524
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
7507
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
7525
7508
  var init_pgSchema = __esm({
7526
7509
  "src/serializer/pgSchema.ts"() {
7527
7510
  "use strict";
@@ -7685,10 +7668,6 @@ var init_pgSchema = __esm({
7685
7668
  }).optional(),
7686
7669
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
7687
7670
  }).strict();
7688
- checkConstraint2 = objectType({
7689
- name: stringType(),
7690
- value: stringType()
7691
- }).strict();
7692
7671
  columnSquashed = objectType({
7693
7672
  name: stringType(),
7694
7673
  type: stringType(),
@@ -7761,8 +7740,7 @@ var init_pgSchema = __esm({
7761
7740
  indexes: recordType(stringType(), index2),
7762
7741
  foreignKeys: recordType(stringType(), fk2),
7763
7742
  compositePrimaryKeys: recordType(stringType(), compositePK2),
7764
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
7765
- checkConstraints: recordType(stringType(), checkConstraint2).default({})
7743
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
7766
7744
  }).strict();
7767
7745
  schemaHash2 = objectType({
7768
7746
  id: stringType(),
@@ -7870,8 +7848,7 @@ var init_pgSchema = __esm({
7870
7848
  indexes: recordType(stringType(), stringType()),
7871
7849
  foreignKeys: recordType(stringType(), stringType()),
7872
7850
  compositePrimaryKeys: recordType(stringType(), stringType()),
7873
- uniqueConstraints: recordType(stringType(), stringType()),
7874
- checkConstraints: recordType(stringType(), stringType())
7851
+ uniqueConstraints: recordType(stringType(), stringType())
7875
7852
  }).strict();
7876
7853
  tableSquashedV42 = objectType({
7877
7854
  name: stringType(),
@@ -8053,16 +8030,6 @@ var init_pgSchema = __esm({
8053
8030
  cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
8054
8031
  cycle: splitted[7] === "true"
8055
8032
  };
8056
- },
8057
- squashCheck: (check) => {
8058
- return `${check.name};${check.value}`;
8059
- },
8060
- unsquashCheck: (input) => {
8061
- const [
8062
- name2,
8063
- value
8064
- ] = input.split(";");
8065
- return { name: name2, value };
8066
8033
  }
8067
8034
  };
8068
8035
  squashPgScheme = (json, action) => {
@@ -8095,12 +8062,6 @@ var init_pgSchema = __esm({
8095
8062
  return PgSquasher.squashUnique(unq);
8096
8063
  }
8097
8064
  );
8098
- const squashedChecksContraints = mapValues(
8099
- it[1].checkConstraints,
8100
- (check) => {
8101
- return PgSquasher.squashCheck(check);
8102
- }
8103
- );
8104
8065
  return [
8105
8066
  it[0],
8106
8067
  {
@@ -8110,8 +8071,7 @@ var init_pgSchema = __esm({
8110
8071
  indexes: squashedIndexes,
8111
8072
  foreignKeys: squashedFKs,
8112
8073
  compositePrimaryKeys: squashedPKs,
8113
- uniqueConstraints: squashedUniqueConstraints,
8114
- checkConstraints: squashedChecksContraints
8074
+ uniqueConstraints: squashedUniqueConstraints
8115
8075
  }
8116
8076
  ];
8117
8077
  })
@@ -8156,7 +8116,7 @@ var init_pgSchema = __esm({
8156
8116
  });
8157
8117
 
8158
8118
  // src/serializer/sqliteSchema.ts
8159
- var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, checkConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
8119
+ 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;
8160
8120
  var init_sqliteSchema = __esm({
8161
8121
  "src/serializer/sqliteSchema.ts"() {
8162
8122
  "use strict";
@@ -8203,18 +8163,13 @@ var init_sqliteSchema = __esm({
8203
8163
  name: stringType(),
8204
8164
  columns: stringType().array()
8205
8165
  }).strict();
8206
- checkConstraint3 = objectType({
8207
- name: stringType(),
8208
- value: stringType()
8209
- }).strict();
8210
8166
  table3 = objectType({
8211
8167
  name: stringType(),
8212
8168
  columns: recordType(stringType(), column3),
8213
8169
  indexes: recordType(stringType(), index3),
8214
8170
  foreignKeys: recordType(stringType(), fk3),
8215
8171
  compositePrimaryKeys: recordType(stringType(), compositePK3),
8216
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
8217
- checkConstraints: recordType(stringType(), checkConstraint3).default({})
8172
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
8218
8173
  }).strict();
8219
8174
  dialect2 = enumType(["sqlite"]);
8220
8175
  schemaHash3 = objectType({
@@ -8276,8 +8231,7 @@ var init_sqliteSchema = __esm({
8276
8231
  indexes: recordType(stringType(), stringType()),
8277
8232
  foreignKeys: recordType(stringType(), stringType()),
8278
8233
  compositePrimaryKeys: recordType(stringType(), stringType()),
8279
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
8280
- checkConstraints: recordType(stringType(), stringType()).default({})
8234
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
8281
8235
  }).strict();
8282
8236
  schemaSquashed2 = objectType({
8283
8237
  version: latestVersion,
@@ -8359,16 +8313,6 @@ var init_sqliteSchema = __esm({
8359
8313
  },
8360
8314
  unsquashPK: (pk) => {
8361
8315
  return pk.split(",");
8362
- },
8363
- squashCheck: (check) => {
8364
- return `${check.name};${check.value}`;
8365
- },
8366
- unsquashCheck: (input) => {
8367
- const [
8368
- name2,
8369
- value
8370
- ] = input.split(";");
8371
- return { name: name2, value };
8372
8316
  }
8373
8317
  };
8374
8318
  squashSqliteScheme = (json, action) => {
@@ -8395,12 +8339,6 @@ var init_sqliteSchema = __esm({
8395
8339
  return SQLiteSquasher.squashUnique(unq);
8396
8340
  }
8397
8341
  );
8398
- const squashedCheckConstraints = mapValues(
8399
- it[1].checkConstraints,
8400
- (check) => {
8401
- return SQLiteSquasher.squashCheck(check);
8402
- }
8403
- );
8404
8342
  return [
8405
8343
  it[0],
8406
8344
  {
@@ -8409,8 +8347,7 @@ var init_sqliteSchema = __esm({
8409
8347
  indexes: squashedIndexes,
8410
8348
  foreignKeys: squashedFKs,
8411
8349
  compositePrimaryKeys: squashedPKs,
8412
- uniqueConstraints: squashedUniqueConstraints,
8413
- checkConstraints: squashedCheckConstraints
8350
+ uniqueConstraints: squashedUniqueConstraints
8414
8351
  }
8415
8352
  ];
8416
8353
  })
@@ -11284,21 +11221,6 @@ var init_jsonDiffer = __esm({
11284
11221
  return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
11285
11222
  })
11286
11223
  );
11287
- const addedCheckConstraints = Object.fromEntries(
11288
- Object.entries(table4.checkConstraints || {}).filter((it) => {
11289
- return it[0].endsWith("__added");
11290
- })
11291
- );
11292
- const deletedCheckConstraints = Object.fromEntries(
11293
- Object.entries(table4.checkConstraints || {}).filter((it) => {
11294
- return it[0].endsWith("__deleted");
11295
- })
11296
- );
11297
- const alteredCheckConstraints = Object.fromEntries(
11298
- Object.entries(table4.checkConstraints || {}).filter((it) => {
11299
- return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
11300
- })
11301
- );
11302
11224
  const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
11303
11225
  return {
11304
11226
  name: table4.name,
@@ -11315,10 +11237,7 @@ var init_jsonDiffer = __esm({
11315
11237
  alteredCompositePKs,
11316
11238
  addedUniqueConstraints,
11317
11239
  deletedUniqueConstraints,
11318
- alteredUniqueConstraints,
11319
- addedCheckConstraints,
11320
- deletedCheckConstraints,
11321
- alteredCheckConstraints
11240
+ alteredUniqueConstraints
11322
11241
  };
11323
11242
  };
11324
11243
  alternationsInColumn = (column4) => {
@@ -11572,32 +11491,6 @@ var init_jsonDiffer = __esm({
11572
11491
  };
11573
11492
  }
11574
11493
  return it;
11575
- }).map((it) => {
11576
- if ("" in it) {
11577
- return {
11578
- ...it,
11579
- autoincrement: {
11580
- type: "changed",
11581
- old: it.autoincrement.__old,
11582
- new: it.autoincrement.__new
11583
- }
11584
- };
11585
- }
11586
- if ("autoincrement__added" in it) {
11587
- const { autoincrement__added, ...others } = it;
11588
- return {
11589
- ...others,
11590
- autoincrement: { type: "added", value: it.autoincrement__added }
11591
- };
11592
- }
11593
- if ("autoincrement__deleted" in it) {
11594
- const { autoincrement__deleted, ...others } = it;
11595
- return {
11596
- ...others,
11597
- autoincrement: { type: "deleted", value: it.autoincrement__deleted }
11598
- };
11599
- }
11600
- return it;
11601
11494
  }).filter(Boolean);
11602
11495
  return result[0];
11603
11496
  };
@@ -11618,7 +11511,7 @@ function fromJson(statements, dialect7, action, json2) {
11618
11511
  }).filter((it) => it !== "");
11619
11512
  return result;
11620
11513
  }
11621
- var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
11514
+ var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
11622
11515
  var init_sqlgenerator = __esm({
11623
11516
  "src/sqlgenerator.ts"() {
11624
11517
  "use strict";
@@ -11679,7 +11572,7 @@ var init_sqlgenerator = __esm({
11679
11572
  return statement.type === "create_table" && dialect7 === "postgresql";
11680
11573
  }
11681
11574
  convert(st) {
11682
- const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints, checkConstraints } = st;
11575
+ const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
11683
11576
  let statement = "";
11684
11577
  const name2 = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
11685
11578
  statement += `CREATE TABLE IF NOT EXISTS ${name2} (
@@ -11712,13 +11605,6 @@ var init_sqlgenerator = __esm({
11712
11605
  statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
11713
11606
  }
11714
11607
  }
11715
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
11716
- for (const checkConstraint4 of checkConstraints) {
11717
- statement += ",\n";
11718
- const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
11719
- statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
11720
- }
11721
- }
11722
11608
  statement += `
11723
11609
  );`;
11724
11610
  statement += `
@@ -11735,7 +11621,6 @@ var init_sqlgenerator = __esm({
11735
11621
  tableName,
11736
11622
  columns,
11737
11623
  schema: schema4,
11738
- checkConstraints,
11739
11624
  compositePKs,
11740
11625
  uniqueConstraints,
11741
11626
  internals
@@ -11769,13 +11654,6 @@ var init_sqlgenerator = __esm({
11769
11654
  statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
11770
11655
  }
11771
11656
  }
11772
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
11773
- for (const checkConstraint4 of checkConstraints) {
11774
- statement += ",\n";
11775
- const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
11776
- statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
11777
- }
11778
- }
11779
11657
  statement += `
11780
11658
  );`;
11781
11659
  statement += `
@@ -11793,8 +11671,7 @@ var init_sqlgenerator = __esm({
11793
11671
  columns,
11794
11672
  referenceData,
11795
11673
  compositePKs,
11796
- uniqueConstraints,
11797
- checkConstraints
11674
+ uniqueConstraints
11798
11675
  } = st;
11799
11676
  let statement = "";
11800
11677
  statement += `CREATE TABLE \`${tableName}\` (
@@ -11835,17 +11712,10 @@ var init_sqlgenerator = __esm({
11835
11712
  if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
11836
11713
  for (const uniqueConstraint4 of uniqueConstraints) {
11837
11714
  statement += ",\n";
11838
- const unsquashedUnique = SQLiteSquasher.unsquashUnique(uniqueConstraint4);
11715
+ const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
11839
11716
  statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
11840
11717
  }
11841
11718
  }
11842
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
11843
- for (const check of checkConstraints) {
11844
- statement += ",\n";
11845
- const { value, name: name2 } = SQLiteSquasher.unsquashCheck(check);
11846
- statement += ` CONSTRAINT "${name2}" CHECK(${value})`;
11847
- }
11848
- }
11849
11719
  statement += `
11850
11720
  `;
11851
11721
  statement += `);`;
@@ -11945,25 +11815,6 @@ var init_sqlgenerator = __esm({
11945
11815
  return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
11946
11816
  }
11947
11817
  };
11948
- PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
11949
- can(statement, dialect7) {
11950
- return statement.type === "create_check_constraint" && dialect7 === "postgresql";
11951
- }
11952
- convert(statement) {
11953
- const unsquashed = PgSquasher.unsquashCheck(statement.data);
11954
- const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
11955
- return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
11956
- }
11957
- };
11958
- PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
11959
- can(statement, dialect7) {
11960
- return statement.type === "delete_check_constraint" && dialect7 === "postgresql";
11961
- }
11962
- convert(statement) {
11963
- const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
11964
- return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
11965
- }
11966
- };
11967
11818
  MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
11968
11819
  can(statement, dialect7) {
11969
11820
  return statement.type === "create_unique_constraint" && dialect7 === "mysql";
@@ -11982,25 +11833,6 @@ var init_sqlgenerator = __esm({
11982
11833
  return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
11983
11834
  }
11984
11835
  };
11985
- MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
11986
- can(statement, dialect7) {
11987
- return statement.type === "create_check_constraint" && dialect7 === "mysql";
11988
- }
11989
- convert(statement) {
11990
- const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
11991
- const { tableName } = statement;
11992
- return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
11993
- }
11994
- };
11995
- MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
11996
- can(statement, dialect7) {
11997
- return statement.type === "delete_check_constraint" && dialect7 === "mysql";
11998
- }
11999
- convert(statement) {
12000
- const { tableName } = statement;
12001
- return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
12002
- }
12003
- };
12004
11836
  CreatePgSequenceConvertor = class extends Convertor {
12005
11837
  can(statement, dialect7) {
12006
11838
  return statement.type === "create_sequence" && dialect7 === "postgresql";
@@ -12555,7 +12387,7 @@ var init_sqlgenerator = __esm({
12555
12387
  };
12556
12388
  LibSQLModifyColumn = class extends Convertor {
12557
12389
  can(statement, dialect7) {
12558
- return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") && dialect7 === "turso";
12390
+ return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect7 === "turso";
12559
12391
  }
12560
12392
  convert(statement, json2) {
12561
12393
  const { tableName, columnName } = statement;
@@ -13142,22 +12974,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13142
12974
  return statement.type === "recreate_table" && dialect7 === "sqlite";
13143
12975
  }
13144
12976
  convert(statement) {
13145
- const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
12977
+ const { tableName, columns, compositePKs, referenceData } = statement;
13146
12978
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
13147
12979
  const newTableName = `__new_${tableName}`;
13148
12980
  const sqlStatements = [];
13149
12981
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
13150
- const mappedCheckConstraints = checkConstraints.map(
13151
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
13152
- );
13153
12982
  sqlStatements.push(
13154
12983
  new SQLiteCreateTableConvertor().convert({
13155
12984
  type: "sqlite_create_table",
13156
12985
  tableName: newTableName,
13157
12986
  columns,
13158
12987
  referenceData,
13159
- compositePKs,
13160
- checkConstraints: mappedCheckConstraints
12988
+ compositePKs
13161
12989
  })
13162
12990
  );
13163
12991
  sqlStatements.push(
@@ -13188,13 +13016,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13188
13016
  return statement.type === "recreate_table" && dialect7 === "turso";
13189
13017
  }
13190
13018
  convert(statement) {
13191
- const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
13019
+ const { tableName, columns, compositePKs, referenceData } = statement;
13192
13020
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
13193
13021
  const newTableName = `__new_${tableName}`;
13194
13022
  const sqlStatements = [];
13195
- const mappedCheckConstraints = checkConstraints.map(
13196
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
13197
- );
13198
13023
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
13199
13024
  sqlStatements.push(
13200
13025
  new SQLiteCreateTableConvertor().convert({
@@ -13202,8 +13027,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13202
13027
  tableName: newTableName,
13203
13028
  columns,
13204
13029
  referenceData,
13205
- compositePKs,
13206
- checkConstraints: mappedCheckConstraints
13030
+ compositePKs
13207
13031
  })
13208
13032
  );
13209
13033
  sqlStatements.push(
@@ -13259,10 +13083,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13259
13083
  convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
13260
13084
  convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
13261
13085
  convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
13262
- convertors.push(new PgAlterTableAddCheckConstraintConvertor());
13263
- convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
13264
- convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
13265
- convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
13266
13086
  convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
13267
13087
  convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
13268
13088
  convertors.push(new CreatePgIndexConvertor());
@@ -13353,10 +13173,6 @@ var init_sqlitePushUtils = __esm({
13353
13173
  const compositePKs = Object.values(
13354
13174
  json.tables[tableName].compositePrimaryKeys
13355
13175
  ).map((it) => SQLiteSquasher.unsquashPK(it));
13356
- const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
13357
- const mappedCheckConstraints = checkConstraints.map(
13358
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
13359
- );
13360
13176
  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
13361
13177
  statements.push(
13362
13178
  new SQLiteCreateTableConvertor().convert({
@@ -13364,8 +13180,7 @@ var init_sqlitePushUtils = __esm({
13364
13180
  tableName: newTableName,
13365
13181
  columns: tableColumns,
13366
13182
  referenceData: fks,
13367
- compositePKs,
13368
- checkConstraints: mappedCheckConstraints
13183
+ compositePKs
13369
13184
  })
13370
13185
  );
13371
13186
  if (!dataLoss) {
@@ -13577,7 +13392,7 @@ var init_sqlitePushUtils = __esm({
13577
13392
  });
13578
13393
 
13579
13394
  // src/jsonStatements.ts
13580
- var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
13395
+ var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
13581
13396
  var init_jsonStatements = __esm({
13582
13397
  "src/jsonStatements.ts"() {
13583
13398
  "use strict";
@@ -13588,7 +13403,7 @@ var init_jsonStatements = __esm({
13588
13403
  init_pgSchema();
13589
13404
  init_sqliteSchema();
13590
13405
  preparePgCreateTableJson = (table4, json2) => {
13591
- const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
13406
+ const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13592
13407
  const tableKey2 = `${schema4 || "public"}.${name2}`;
13593
13408
  const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
13594
13409
  return {
@@ -13598,12 +13413,11 @@ var init_jsonStatements = __esm({
13598
13413
  columns: Object.values(columns),
13599
13414
  compositePKs: Object.values(compositePrimaryKeys),
13600
13415
  compositePkName,
13601
- uniqueConstraints: Object.values(uniqueConstraints),
13602
- checkConstraints: Object.values(checkConstraints)
13416
+ uniqueConstraints: Object.values(uniqueConstraints)
13603
13417
  };
13604
13418
  };
13605
13419
  prepareMySqlCreateTableJson = (table4, json2, internals) => {
13606
- const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
13420
+ const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13607
13421
  return {
13608
13422
  type: "create_table",
13609
13423
  tableName: name2,
@@ -13612,12 +13426,11 @@ var init_jsonStatements = __esm({
13612
13426
  compositePKs: Object.values(compositePrimaryKeys),
13613
13427
  compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
13614
13428
  uniqueConstraints: Object.values(uniqueConstraints),
13615
- internals,
13616
- checkConstraints: Object.values(checkConstraints)
13429
+ internals
13617
13430
  };
13618
13431
  };
13619
13432
  prepareSQLiteCreateTable = (table4, action) => {
13620
- const { name: name2, columns, uniqueConstraints, checkConstraints } = table4;
13433
+ const { name: name2, columns, uniqueConstraints } = table4;
13621
13434
  const references2 = Object.values(table4.foreignKeys);
13622
13435
  const composites = Object.values(table4.compositePrimaryKeys).map(
13623
13436
  (it) => SQLiteSquasher.unsquashPK(it)
@@ -13631,8 +13444,7 @@ var init_jsonStatements = __esm({
13631
13444
  columns: Object.values(columns),
13632
13445
  referenceData: fks,
13633
13446
  compositePKs: composites,
13634
- uniqueConstraints: Object.values(uniqueConstraints),
13635
- checkConstraints: Object.values(checkConstraints)
13447
+ uniqueConstraints: Object.values(uniqueConstraints)
13636
13448
  };
13637
13449
  };
13638
13450
  prepareDropTableJson = (table4) => {
@@ -14875,26 +14687,6 @@ var init_jsonStatements = __esm({
14875
14687
  };
14876
14688
  });
14877
14689
  };
14878
- prepareAddCheckConstraint = (tableName, schema4, check) => {
14879
- return Object.values(check).map((it) => {
14880
- return {
14881
- type: "create_check_constraint",
14882
- tableName,
14883
- data: it,
14884
- schema: schema4
14885
- };
14886
- });
14887
- };
14888
- prepareDeleteCheckConstraint = (tableName, schema4, check) => {
14889
- return Object.values(check).map((it) => {
14890
- return {
14891
- type: "delete_check_constraint",
14892
- tableName,
14893
- constraintName: PgSquasher.unsquashCheck(it).name,
14894
- schema: schema4
14895
- };
14896
- });
14897
- };
14898
14690
  prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
14899
14691
  const res = [];
14900
14692
  for (const it of Object.values(pks)) {
@@ -14944,7 +14736,7 @@ var init_statementCombiner = __esm({
14944
14736
  init_jsonStatements();
14945
14737
  init_sqliteSchema();
14946
14738
  prepareLibSQLRecreateTable = (table4, action) => {
14947
- const { name: name2, columns, uniqueConstraints, indexes, checkConstraints } = table4;
14739
+ const { name: name2, columns, uniqueConstraints, indexes } = table4;
14948
14740
  const composites = Object.values(table4.compositePrimaryKeys).map(
14949
14741
  (it) => SQLiteSquasher.unsquashPK(it)
14950
14742
  );
@@ -14959,8 +14751,7 @@ var init_statementCombiner = __esm({
14959
14751
  columns: Object.values(columns),
14960
14752
  compositePKs: composites,
14961
14753
  referenceData: fks,
14962
- uniqueConstraints: Object.values(uniqueConstraints),
14963
- checkConstraints: Object.values(checkConstraints)
14754
+ uniqueConstraints: Object.values(uniqueConstraints)
14964
14755
  }
14965
14756
  ];
14966
14757
  if (Object.keys(indexes).length) {
@@ -14969,7 +14760,7 @@ var init_statementCombiner = __esm({
14969
14760
  return statements;
14970
14761
  };
14971
14762
  prepareSQLiteRecreateTable = (table4, action) => {
14972
- const { name: name2, columns, uniqueConstraints, indexes, checkConstraints } = table4;
14763
+ const { name: name2, columns, uniqueConstraints, indexes } = table4;
14973
14764
  const composites = Object.values(table4.compositePrimaryKeys).map(
14974
14765
  (it) => SQLiteSquasher.unsquashPK(it)
14975
14766
  );
@@ -14984,8 +14775,7 @@ var init_statementCombiner = __esm({
14984
14775
  columns: Object.values(columns),
14985
14776
  compositePKs: composites,
14986
14777
  referenceData: fks,
14987
- uniqueConstraints: Object.values(uniqueConstraints),
14988
- checkConstraints: Object.values(checkConstraints)
14778
+ uniqueConstraints: Object.values(uniqueConstraints)
14989
14779
  }
14990
14780
  ];
14991
14781
  if (Object.keys(indexes).length) {
@@ -14996,7 +14786,7 @@ var init_statementCombiner = __esm({
14996
14786
  libSQLCombineStatements = (statements, json2, action) => {
14997
14787
  const newStatements = {};
14998
14788
  for (const statement of statements) {
14999
- if (statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") {
14789
+ if (statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk") {
15000
14790
  const tableName2 = statement.tableName;
15001
14791
  const statementsForTable2 = newStatements[tableName2];
15002
14792
  if (!statementsForTable2) {
@@ -15137,16 +14927,16 @@ var init_statementCombiner = __esm({
15137
14927
  sqliteCombineStatements = (statements, json2, action) => {
15138
14928
  const newStatements = {};
15139
14929
  for (const statement of statements) {
15140
- if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") {
14930
+ if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
15141
14931
  const tableName2 = statement.tableName;
15142
14932
  const statementsForTable2 = newStatements[tableName2];
15143
14933
  if (!statementsForTable2) {
15144
- newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
14934
+ newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
15145
14935
  continue;
15146
14936
  }
15147
14937
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15148
14938
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15149
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
14939
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
15150
14940
  if (wasRename) {
15151
14941
  newStatements[tableName2].push(...preparedStatements);
15152
14942
  } else {
@@ -15160,12 +14950,12 @@ var init_statementCombiner = __esm({
15160
14950
  const tableName2 = statement.tableName;
15161
14951
  const statementsForTable2 = newStatements[tableName2];
15162
14952
  if (!statementsForTable2) {
15163
- newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
14953
+ newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
15164
14954
  continue;
15165
14955
  }
15166
14956
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15167
14957
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15168
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
14958
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
15169
14959
  if (wasRename) {
15170
14960
  newStatements[tableName2].push(...preparedStatements);
15171
14961
  } else {
@@ -15190,7 +14980,7 @@ var init_statementCombiner = __esm({
15190
14980
  }
15191
14981
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15192
14982
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15193
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
14983
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
15194
14984
  if (wasRename) {
15195
14985
  newStatements[tableName2].push(...preparedStatements);
15196
14986
  } else {
@@ -15359,8 +15149,7 @@ var init_snapshotsDiffer = __esm({
15359
15149
  indexes: recordType(stringType(), stringType()),
15360
15150
  foreignKeys: recordType(stringType(), stringType()),
15361
15151
  compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
15362
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
15363
- checkConstraints: recordType(stringType(), stringType()).default({})
15152
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
15364
15153
  }).strict();
15365
15154
  alteredTableScheme = objectType({
15366
15155
  name: stringType(),
@@ -15401,21 +15190,6 @@ var init_snapshotsDiffer = __esm({
15401
15190
  __new: stringType(),
15402
15191
  __old: stringType()
15403
15192
  })
15404
- ),
15405
- addedCheckConstraints: recordType(
15406
- stringType(),
15407
- stringType()
15408
- ),
15409
- deletedCheckConstraints: recordType(
15410
- stringType(),
15411
- stringType()
15412
- ),
15413
- alteredCheckConstraints: recordType(
15414
- stringType(),
15415
- objectType({
15416
- __new: stringType(),
15417
- __old: stringType()
15418
- })
15419
15193
  )
15420
15194
  }).strict();
15421
15195
  diffResultScheme = objectType({
@@ -15756,8 +15530,6 @@ var init_snapshotsDiffer = __esm({
15756
15530
  schemaTo: it.schemaTo || "public"
15757
15531
  });
15758
15532
  }
15759
- const jsonDeletedCheckConstraints = [];
15760
- const jsonCreatedCheckConstraints = [];
15761
15533
  for (let it of alteredTables) {
15762
15534
  let addedColumns = [];
15763
15535
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -15797,8 +15569,6 @@ var init_snapshotsDiffer = __esm({
15797
15569
  let addedUniqueConstraints = [];
15798
15570
  let deletedUniqueConstraints = [];
15799
15571
  let alteredUniqueConstraints = [];
15800
- let createCheckConstraints = [];
15801
- let deleteCheckConstraints = [];
15802
15572
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
15803
15573
  it.name,
15804
15574
  it.schema,
@@ -15823,24 +15593,6 @@ var init_snapshotsDiffer = __esm({
15823
15593
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
15824
15594
  );
15825
15595
  }
15826
- createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
15827
- deleteCheckConstraints = prepareDeleteCheckConstraint(
15828
- it.name,
15829
- it.schema,
15830
- it.deletedCheckConstraints
15831
- );
15832
- if (it.alteredCheckConstraints && action !== "push") {
15833
- const added = {};
15834
- const deleted = {};
15835
- for (const k6 of Object.keys(it.alteredCheckConstraints)) {
15836
- added[k6] = it.alteredCheckConstraints[k6].__new;
15837
- deleted[k6] = it.alteredCheckConstraints[k6].__old;
15838
- }
15839
- createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
15840
- deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
15841
- }
15842
- jsonCreatedCheckConstraints.push(...createCheckConstraints);
15843
- jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
15844
15596
  jsonAddedCompositePKs.push(...addedCompositePKs);
15845
15597
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
15846
15598
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
@@ -15994,7 +15746,6 @@ var init_snapshotsDiffer = __esm({
15994
15746
  jsonStatements.push(...jsonRenameTables);
15995
15747
  jsonStatements.push(...jsonRenameColumnsStatements);
15996
15748
  jsonStatements.push(...jsonDeletedUniqueConstraints);
15997
- jsonStatements.push(...jsonDeletedCheckConstraints);
15998
15749
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
15999
15750
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16000
15751
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -16008,7 +15759,6 @@ var init_snapshotsDiffer = __esm({
16008
15759
  jsonStatements.push(...jsonDropColumnsStatemets);
16009
15760
  jsonStatements.push(...jsonAlteredCompositePKs);
16010
15761
  jsonStatements.push(...jsonAddedUniqueConstraints);
16011
- jsonStatements.push(...jsonCreatedCheckConstraints);
16012
15762
  jsonStatements.push(...jsonAlteredUniqueConstraints);
16013
15763
  jsonStatements.push(...dropEnums);
16014
15764
  jsonStatements.push(...dropSequences);
@@ -16172,8 +15922,6 @@ var init_snapshotsDiffer = __esm({
16172
15922
  const jsonAddedUniqueConstraints = [];
16173
15923
  const jsonDeletedUniqueConstraints = [];
16174
15924
  const jsonAlteredUniqueConstraints = [];
16175
- const jsonCreatedCheckConstraints = [];
16176
- const jsonDeletedCheckConstraints = [];
16177
15925
  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
16178
15926
  const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
16179
15927
  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
@@ -16212,8 +15960,6 @@ var init_snapshotsDiffer = __esm({
16212
15960
  let addedUniqueConstraints = [];
16213
15961
  let deletedUniqueConstraints = [];
16214
15962
  let alteredUniqueConstraints = [];
16215
- let createdCheckConstraints = [];
16216
- let deletedCheckConstraints = [];
16217
15963
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
16218
15964
  it.name,
16219
15965
  it.schema,
@@ -16238,30 +15984,12 @@ var init_snapshotsDiffer = __esm({
16238
15984
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16239
15985
  );
16240
15986
  }
16241
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16242
- deletedCheckConstraints = prepareDeleteCheckConstraint(
16243
- it.name,
16244
- it.schema,
16245
- it.deletedCheckConstraints
16246
- );
16247
- if (it.alteredCheckConstraints && action !== "push") {
16248
- const added = {};
16249
- const deleted = {};
16250
- for (const k6 of Object.keys(it.alteredCheckConstraints)) {
16251
- added[k6] = it.alteredCheckConstraints[k6].__new;
16252
- deleted[k6] = it.alteredCheckConstraints[k6].__old;
16253
- }
16254
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16255
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16256
- }
16257
15987
  jsonAddedCompositePKs.push(...addedCompositePKs);
16258
15988
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16259
15989
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16260
15990
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16261
15991
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16262
15992
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
16263
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
16264
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16265
15993
  });
16266
15994
  const rColumns = jsonRenameColumnsStatements.map((it) => {
16267
15995
  const tableName = it.tableName;
@@ -16357,7 +16085,6 @@ var init_snapshotsDiffer = __esm({
16357
16085
  jsonStatements.push(...jsonRenameTables);
16358
16086
  jsonStatements.push(...jsonRenameColumnsStatements);
16359
16087
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16360
- jsonStatements.push(...jsonDeletedCheckConstraints);
16361
16088
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16362
16089
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16363
16090
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -16368,11 +16095,11 @@ var init_snapshotsDiffer = __esm({
16368
16095
  jsonStatements.push(...jsonAddColumnsStatemets);
16369
16096
  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
16370
16097
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16371
- jsonStatements.push(...jsonCreatedCheckConstraints);
16372
16098
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16373
16099
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16374
16100
  jsonStatements.push(...jsonDropColumnsStatemets);
16375
16101
  jsonStatements.push(...jsonAlteredCompositePKs);
16102
+ jsonStatements.push(...jsonAddedUniqueConstraints);
16376
16103
  jsonStatements.push(...jsonAlteredUniqueConstraints);
16377
16104
  const sqlStatements = fromJson(jsonStatements, "mysql");
16378
16105
  const uniqueSqlStatements = [];
@@ -16500,8 +16227,6 @@ var init_snapshotsDiffer = __esm({
16500
16227
  const jsonAddedUniqueConstraints = [];
16501
16228
  const jsonDeletedUniqueConstraints = [];
16502
16229
  const jsonAlteredUniqueConstraints = [];
16503
- const jsonDeletedCheckConstraints = [];
16504
- const jsonCreatedCheckConstraints = [];
16505
16230
  allAltered.forEach((it) => {
16506
16231
  let addedColumns = [];
16507
16232
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -16558,56 +16283,12 @@ var init_snapshotsDiffer = __esm({
16558
16283
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16559
16284
  );
16560
16285
  }
16561
- let createdCheckConstraints = [];
16562
- let deletedCheckConstraints = [];
16563
- addedUniqueConstraints = prepareAddUniqueConstraintPg(
16564
- it.name,
16565
- it.schema,
16566
- it.addedUniqueConstraints
16567
- );
16568
- deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
16569
- it.name,
16570
- it.schema,
16571
- it.deletedUniqueConstraints
16572
- );
16573
- if (it.alteredUniqueConstraints) {
16574
- const added = {};
16575
- const deleted = {};
16576
- for (const k6 of Object.keys(it.alteredUniqueConstraints)) {
16577
- added[k6] = it.alteredUniqueConstraints[k6].__new;
16578
- deleted[k6] = it.alteredUniqueConstraints[k6].__old;
16579
- }
16580
- addedUniqueConstraints.push(
16581
- ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
16582
- );
16583
- deletedUniqueConstraints.push(
16584
- ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16585
- );
16586
- }
16587
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16588
- deletedCheckConstraints = prepareDeleteCheckConstraint(
16589
- it.name,
16590
- it.schema,
16591
- it.deletedCheckConstraints
16592
- );
16593
- if (it.alteredCheckConstraints && action !== "push") {
16594
- const added = {};
16595
- const deleted = {};
16596
- for (const k6 of Object.keys(it.alteredCheckConstraints)) {
16597
- added[k6] = it.alteredCheckConstraints[k6].__new;
16598
- deleted[k6] = it.alteredCheckConstraints[k6].__old;
16599
- }
16600
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16601
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16602
- }
16603
16286
  jsonAddedCompositePKs.push(...addedCompositePKs);
16604
16287
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16605
16288
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16606
16289
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16607
16290
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16608
16291
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
16609
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
16610
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16611
16292
  });
16612
16293
  const rColumns = jsonRenameColumnsStatements.map((it) => {
16613
16294
  const tableName = it.tableName;
@@ -16692,7 +16373,6 @@ var init_snapshotsDiffer = __esm({
16692
16373
  jsonStatements.push(...jsonRenameTables);
16693
16374
  jsonStatements.push(...jsonRenameColumnsStatements);
16694
16375
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16695
- jsonStatements.push(...jsonDeletedCheckConstraints);
16696
16376
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16697
16377
  jsonStatements.push(...jsonDeletedCompositePKs);
16698
16378
  jsonStatements.push(...jsonTableAlternations);
@@ -16700,7 +16380,6 @@ var init_snapshotsDiffer = __esm({
16700
16380
  jsonStatements.push(...jsonAddColumnsStatemets);
16701
16381
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16702
16382
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16703
- jsonStatements.push(...jsonCreatedCheckConstraints);
16704
16383
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16705
16384
  jsonStatements.push(...jsonDropColumnsStatemets);
16706
16385
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -16844,8 +16523,6 @@ var init_snapshotsDiffer = __esm({
16844
16523
  const jsonAddedUniqueConstraints = [];
16845
16524
  const jsonDeletedUniqueConstraints = [];
16846
16525
  const jsonAlteredUniqueConstraints = [];
16847
- const jsonDeletedCheckConstraints = [];
16848
- const jsonCreatedCheckConstraints = [];
16849
16526
  allAltered.forEach((it) => {
16850
16527
  let addedColumns = [];
16851
16528
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -16878,8 +16555,6 @@ var init_snapshotsDiffer = __esm({
16878
16555
  let addedUniqueConstraints = [];
16879
16556
  let deletedUniqueConstraints = [];
16880
16557
  let alteredUniqueConstraints = [];
16881
- let createdCheckConstraints = [];
16882
- let deletedCheckConstraints = [];
16883
16558
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
16884
16559
  it.name,
16885
16560
  it.schema,
@@ -16904,30 +16579,12 @@ var init_snapshotsDiffer = __esm({
16904
16579
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16905
16580
  );
16906
16581
  }
16907
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16908
- deletedCheckConstraints = prepareDeleteCheckConstraint(
16909
- it.name,
16910
- it.schema,
16911
- it.deletedCheckConstraints
16912
- );
16913
- if (it.alteredCheckConstraints && action !== "push") {
16914
- const added = {};
16915
- const deleted = {};
16916
- for (const k6 of Object.keys(it.alteredCheckConstraints)) {
16917
- added[k6] = it.alteredCheckConstraints[k6].__new;
16918
- deleted[k6] = it.alteredCheckConstraints[k6].__old;
16919
- }
16920
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16921
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16922
- }
16923
16582
  jsonAddedCompositePKs.push(...addedCompositePKs);
16924
16583
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16925
16584
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16926
16585
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16927
16586
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16928
16587
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
16929
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
16930
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16931
16588
  });
16932
16589
  const jsonTableAlternations = allAltered.map((it) => {
16933
16590
  return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
@@ -17005,7 +16662,6 @@ var init_snapshotsDiffer = __esm({
17005
16662
  jsonStatements.push(...jsonRenameTables);
17006
16663
  jsonStatements.push(...jsonRenameColumnsStatements);
17007
16664
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
17008
- jsonStatements.push(...jsonDeletedCheckConstraints);
17009
16665
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
17010
16666
  jsonStatements.push(...jsonDeletedCompositePKs);
17011
16667
  jsonStatements.push(...jsonTableAlternations);
@@ -17013,7 +16669,6 @@ var init_snapshotsDiffer = __esm({
17013
16669
  jsonStatements.push(...jsonAddColumnsStatemets);
17014
16670
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
17015
16671
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
17016
- jsonStatements.push(...jsonCreatedCheckConstraints);
17017
16672
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
17018
16673
  jsonStatements.push(...jsonDropColumnsStatemets);
17019
16674
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -27191,6 +26846,46 @@ var init_dialect = __esm({
27191
26846
  });
27192
26847
  return sql.join(chunks);
27193
26848
  }
26849
+ buildOptimizedSelection(fields, { isSingleTable = false } = {}) {
26850
+ const columnsLen = fields.length;
26851
+ const chunks = fields.flatMap(({ field }, i5) => {
26852
+ const chunk = [];
26853
+ if (is(field, SQL.Aliased) && field.isSelectionField) {
26854
+ chunk.push(sql.identifier(field.fieldAlias));
26855
+ } else if (is(field, SQL.Aliased) || is(field, SQL)) {
26856
+ const query = is(field, SQL.Aliased) ? field.sql : field;
26857
+ if (isSingleTable) {
26858
+ const parts = [];
26859
+ for (const c5 of query.queryChunks) {
26860
+ if (is(c5, PgColumn)) {
26861
+ parts.push(sql.raw(c5.name), sql`, `, sql.identifier(c5.name));
26862
+ continue;
26863
+ }
26864
+ parts.push(c5);
26865
+ }
26866
+ chunk.push(new SQL(parts));
26867
+ } else {
26868
+ chunk.push(query);
26869
+ }
26870
+ if (is(field, SQL.Aliased)) {
26871
+ chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
26872
+ }
26873
+ } else if (is(field, Column2)) {
26874
+ if (isSingleTable) {
26875
+ chunk.push(sql`'${sql.raw(field.name)}', ${sql.identifier(field.name)}`);
26876
+ } else {
26877
+ chunk.push(field);
26878
+ }
26879
+ }
26880
+ if (i5 < columnsLen - 1) {
26881
+ chunk.push(sql`, `);
26882
+ }
26883
+ return chunk;
26884
+ });
26885
+ chunks.unshift(sql`json_build_object(`);
26886
+ chunks.push(sql`)`);
26887
+ return sql.join(chunks);
26888
+ }
27194
26889
  buildSelectQuery({
27195
26890
  withList,
27196
26891
  fields,
@@ -27205,7 +26900,8 @@ var init_dialect = __esm({
27205
26900
  offset,
27206
26901
  lockingClause,
27207
26902
  distinct,
27208
- setOperators
26903
+ setOperators,
26904
+ optimize
27209
26905
  }) {
27210
26906
  const fieldsList = fieldsFlat ?? orderSelectedFields(fields);
27211
26907
  for (const f5 of fieldsList) {
@@ -27224,7 +26920,9 @@ var init_dialect = __esm({
27224
26920
  if (distinct) {
27225
26921
  distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
27226
26922
  }
27227
- const selection = this.buildSelection(fieldsList, { isSingleTable });
26923
+ const selection = optimize ? this.buildOptimizedSelection(fieldsList, {
26924
+ isSingleTable
26925
+ }) : this.buildSelection(fieldsList, { isSingleTable });
27228
26926
  const tableSql = (() => {
27229
26927
  if (is(table4, Table2) && table4[Table2.Symbol.OriginalName] !== table4[Table2.Symbol.Name]) {
27230
26928
  let fullName = sql`${sql.identifier(table4[Table2.Symbol.OriginalName])}`;
@@ -28905,6 +28603,10 @@ var init_select2 = __esm({
28905
28603
  $dynamic() {
28906
28604
  return this;
28907
28605
  }
28606
+ $optimize() {
28607
+ this.config.optimize = true;
28608
+ return this;
28609
+ }
28908
28610
  };
28909
28611
  __publicField(PgSelectQueryBuilderBase, _a130, "PgSelectQueryBuilder");
28910
28612
  PgSelectBase = class extends (_b101 = PgSelectQueryBuilderBase, _a131 = entityKind, _b101) {
@@ -28924,7 +28626,7 @@ var init_select2 = __esm({
28924
28626
  }
28925
28627
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
28926
28628
  const fieldsList = orderSelectedFields(config.fields);
28927
- const query = session.prepareQuery(dialect7.sqlToQuery(this.getSQL()), fieldsList, name2, true);
28629
+ const query = session.prepareQuery(dialect7.sqlToQuery(this.getSQL()), fieldsList, name2, true, void 0, config.optimize);
28928
28630
  query.joinsNotNullableMap = joinsNotNullableMap;
28929
28631
  return query;
28930
28632
  });
@@ -30400,7 +30102,7 @@ var init_session2 = __esm({
30400
30102
  init_utils2();
30401
30103
  ({ Pool } = import_pg.default);
30402
30104
  NodePgPreparedQuery = class extends (_b114 = PgPreparedQuery, _a159 = entityKind, _b114) {
30403
- constructor(client, queryString, params, logger2, fields, name2, _isResponseInArrayMode, customResultMapper) {
30105
+ constructor(client, queryString, params, logger2, fields, name2, _isResponseInArrayMode, customResultMapper, isOptimized) {
30404
30106
  super({ sql: queryString, params });
30405
30107
  __publicField(this, "rawQueryConfig");
30406
30108
  __publicField(this, "queryConfig");
@@ -30410,6 +30112,7 @@ var init_session2 = __esm({
30410
30112
  this.fields = fields;
30411
30113
  this._isResponseInArrayMode = _isResponseInArrayMode;
30412
30114
  this.customResultMapper = customResultMapper;
30115
+ this.isOptimized = isOptimized;
30413
30116
  this.rawQueryConfig = {
30414
30117
  name: name2,
30415
30118
  text: queryString
@@ -30424,7 +30127,15 @@ var init_session2 = __esm({
30424
30127
  return tracer.startActiveSpan("drizzle.execute", async () => {
30425
30128
  const params = fillPlaceholders(this.params, placeholderValues);
30426
30129
  this.logger.logQuery(this.rawQueryConfig.text, params);
30427
- const { fields, rawQueryConfig: rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
30130
+ const {
30131
+ fields,
30132
+ rawQueryConfig: rawQuery,
30133
+ client,
30134
+ queryConfig: query,
30135
+ joinsNotNullableMap,
30136
+ customResultMapper,
30137
+ isOptimized
30138
+ } = this;
30428
30139
  if (!fields && !customResultMapper) {
30429
30140
  return tracer.startActiveSpan("drizzle.driver.execute", async (span) => {
30430
30141
  span?.setAttributes({
@@ -30444,7 +30155,7 @@ var init_session2 = __esm({
30444
30155
  return client.query(query, params);
30445
30156
  });
30446
30157
  return tracer.startActiveSpan("drizzle.mapResponse", () => {
30447
- return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
30158
+ return isOptimized ? result.rows.flat(1) : customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
30448
30159
  });
30449
30160
  });
30450
30161
  }
@@ -30477,7 +30188,7 @@ var init_session2 = __esm({
30477
30188
  this.options = options;
30478
30189
  this.logger = options.logger ?? new NoopLogger();
30479
30190
  }
30480
- prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper) {
30191
+ prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, isOptimized) {
30481
30192
  return new NodePgPreparedQuery(
30482
30193
  this.client,
30483
30194
  query.sql,
@@ -30486,7 +30197,8 @@ var init_session2 = __esm({
30486
30197
  fields,
30487
30198
  name2,
30488
30199
  isResponseInArrayMode,
30489
- customResultMapper
30200
+ customResultMapper,
30201
+ isOptimized
30490
30202
  );
30491
30203
  }
30492
30204
  async transaction(transaction, config) {
@@ -48964,6 +48676,7 @@ var init_session3 = __esm({
48964
48676
  database: options.database
48965
48677
  };
48966
48678
  }
48679
+ // @ts-ignore
48967
48680
  prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, transactionId) {
48968
48681
  return new AwsDataApiPreparedQuery(
48969
48682
  this.client,
@@ -48984,6 +48697,8 @@ var init_session3 = __esm({
48984
48697
  void 0,
48985
48698
  false,
48986
48699
  void 0,
48700
+ void 0,
48701
+ // @ts-ignore
48987
48702
  this.transactionId
48988
48703
  ).execute();
48989
48704
  }
@@ -94868,7 +94583,7 @@ var init_session14 = __esm({
94868
94583
  init_tracing();
94869
94584
  init_utils2();
94870
94585
  PostgresJsPreparedQuery = class extends (_b213 = PgPreparedQuery, _a299 = entityKind, _b213) {
94871
- constructor(client, queryString, params, logger2, fields, _isResponseInArrayMode, customResultMapper) {
94586
+ constructor(client, queryString, params, logger2, fields, _isResponseInArrayMode, customResultMapper, isOptimized) {
94872
94587
  super({ sql: queryString, params });
94873
94588
  this.client = client;
94874
94589
  this.queryString = queryString;
@@ -94877,6 +94592,7 @@ var init_session14 = __esm({
94877
94592
  this.fields = fields;
94878
94593
  this._isResponseInArrayMode = _isResponseInArrayMode;
94879
94594
  this.customResultMapper = customResultMapper;
94595
+ this.isOptimized = isOptimized;
94880
94596
  }
94881
94597
  async execute(placeholderValues = {}) {
94882
94598
  return tracer.startActiveSpan("drizzle.execute", async (span) => {
@@ -94886,7 +94602,7 @@ var init_session14 = __esm({
94886
94602
  "drizzle.query.params": JSON.stringify(params)
94887
94603
  });
94888
94604
  this.logger.logQuery(this.queryString, params);
94889
- const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
94605
+ const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper, isOptimized } = this;
94890
94606
  if (!fields && !customResultMapper) {
94891
94607
  return tracer.startActiveSpan("drizzle.driver.execute", () => {
94892
94608
  return client.unsafe(query, params);
@@ -94900,7 +94616,7 @@ var init_session14 = __esm({
94900
94616
  return client.unsafe(query, params).values();
94901
94617
  });
94902
94618
  return tracer.startActiveSpan("drizzle.mapResponse", () => {
94903
- return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
94619
+ return isOptimized ? rows.flat(1) : customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
94904
94620
  });
94905
94621
  });
94906
94622
  }
@@ -94936,7 +94652,7 @@ var init_session14 = __esm({
94936
94652
  this.options = options;
94937
94653
  this.logger = options.logger ?? new NoopLogger();
94938
94654
  }
94939
- prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper) {
94655
+ prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, isOptimized) {
94940
94656
  return new PostgresJsPreparedQuery(
94941
94657
  this.client,
94942
94658
  query.sql,
@@ -94944,7 +94660,8 @@ var init_session14 = __esm({
94944
94660
  this.logger,
94945
94661
  fields,
94946
94662
  isResponseInArrayMode,
94947
- customResultMapper
94663
+ customResultMapper,
94664
+ isOptimized
94948
94665
  );
94949
94666
  }
94950
94667
  query(query, params) {
@@ -105682,7 +105399,6 @@ var init_pgSerializer = __esm({
105682
105399
  const sequencesToReturn = {};
105683
105400
  const indexesInSchema = {};
105684
105401
  for (const table4 of tables) {
105685
- const checksInTable = {};
105686
105402
  const {
105687
105403
  name: tableName,
105688
105404
  columns,
@@ -105698,7 +105414,6 @@ var init_pgSerializer = __esm({
105698
105414
  }
105699
105415
  const columnsObject = {};
105700
105416
  const indexesObject = {};
105701
- const checksObject = {};
105702
105417
  const foreignKeysObject = {};
105703
105418
  const primaryKeysObject = {};
105704
105419
  const uniqueConstraintObject = {};
@@ -105945,33 +105660,6 @@ ${withStyle.errorWarning(
105945
105660
  with: value.config.with ?? {}
105946
105661
  };
105947
105662
  });
105948
- checks.forEach((check) => {
105949
- const checkName = check.name;
105950
- if (typeof checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] !== "undefined") {
105951
- if (checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].includes(check.name)) {
105952
- console.log(
105953
- `
105954
- ${withStyle.errorWarning(
105955
- `We've found duplicated check constraint name across ${source_default.underline.blue(
105956
- schema4 ?? "public"
105957
- )} schema in ${source_default.underline.blue(
105958
- tableName
105959
- )}. Please rename your check constraint in either the ${source_default.underline.blue(
105960
- tableName
105961
- )} table or the table with the duplicated check contraint name`
105962
- )}`
105963
- );
105964
- process.exit(1);
105965
- }
105966
- checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].push(checkName);
105967
- } else {
105968
- checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] = [check.name];
105969
- }
105970
- checksObject[checkName] = {
105971
- name: checkName,
105972
- value: dialect4.sqlToQuery(check.value).sql
105973
- };
105974
- });
105975
105663
  const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
105976
105664
  result[tableKey2] = {
105977
105665
  name: tableName,
@@ -105980,8 +105668,7 @@ ${withStyle.errorWarning(
105980
105668
  indexes: indexesObject,
105981
105669
  foreignKeys: foreignKeysObject,
105982
105670
  compositePrimaryKeys: primaryKeysObject,
105983
- uniqueConstraints: uniqueConstraintObject,
105984
- checkConstraints: checksObject
105671
+ uniqueConstraints: uniqueConstraintObject
105985
105672
  };
105986
105673
  }
105987
105674
  for (const sequence of sequences) {
@@ -106070,7 +105757,6 @@ ${withStyle.errorWarning(
106070
105757
  let indexesCount = 0;
106071
105758
  let foreignKeysCount = 0;
106072
105759
  let tableCount = 0;
106073
- let checksCount = 0;
106074
105760
  const sequencesToReturn = {};
106075
105761
  const seqWhere = schemaFilters.map((t5) => `schemaname = '${t5}'`).join(" or ");
106076
105762
  const allSequences = await db2.query(
@@ -106140,8 +105826,7 @@ ${withStyle.errorWarning(
106140
105826
  const indexToReturn = {};
106141
105827
  const foreignKeysToReturn = {};
106142
105828
  const primaryKeys = {};
106143
- const uniqueConstraints = {};
106144
- const checkConstraints = {};
105829
+ const uniqueConstrains = {};
106145
105830
  const tableResponse = await db2.query(
106146
105831
  `SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
106147
105832
  , CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
@@ -106179,97 +105864,55 @@ ${withStyle.errorWarning(
106179
105864
  ORDER BY a.attnum;`
106180
105865
  );
106181
105866
  const tableConstraints = await db2.query(
106182
- `SELECT c.column_name,
106183
- c.data_type,
106184
- tc.constraint_type,
106185
- tc.constraint_name,
106186
- tc.constraint_schema,
106187
- pg_get_constraintdef(con.oid) AS check_constraint_definition
106188
- FROM information_schema.table_constraints tc
106189
- JOIN information_schema.constraint_column_usage AS ccu
106190
- USING (constraint_schema, constraint_name)
106191
- JOIN information_schema.columns AS c
106192
- ON c.table_schema = tc.constraint_schema
106193
- AND tc.table_name = c.table_name
106194
- AND ccu.column_name = c.column_name
106195
- JOIN pg_constraint con
106196
- ON con.conname = tc.constraint_name
106197
- AND con.conrelid = (
106198
- SELECT oid
106199
- FROM pg_class
106200
- WHERE relname = tc.table_name
106201
- AND relnamespace = (
106202
- SELECT oid
106203
- FROM pg_namespace
106204
- WHERE nspname = tc.constraint_schema
106205
- )
106206
- )
106207
- WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
105867
+ `SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
105868
+ FROM information_schema.table_constraints tc
105869
+ JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
105870
+ JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
105871
+ AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
105872
+ WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
106208
105873
  );
106209
- const tableChecks = await db2.query(`SELECT
106210
- tc.constraint_name,
106211
- tc.constraint_type,
106212
- pg_get_constraintdef(con.oid) AS constraint_definition
106213
- FROM
106214
- information_schema.table_constraints AS tc
106215
- JOIN pg_constraint AS con
106216
- ON tc.constraint_name = con.conname
106217
- AND con.conrelid = (
106218
- SELECT oid
106219
- FROM pg_class
106220
- WHERE relname = tc.table_name
106221
- AND relnamespace = (
106222
- SELECT oid
106223
- FROM pg_namespace
106224
- WHERE nspname = tc.constraint_schema
106225
- )
106226
- )
106227
- WHERE
106228
- tc.table_name = '${tableName}'
106229
- AND tc.constraint_schema = '${tableSchema}'
106230
- AND tc.constraint_type = 'CHECK';`);
106231
105874
  columnsCount += tableResponse.length;
106232
105875
  if (progressCallback) {
106233
105876
  progressCallback("columns", columnsCount, "fetching");
106234
105877
  }
106235
105878
  const tableForeignKeys = await db2.query(
106236
105879
  `SELECT
106237
- con.contype AS constraint_type,
106238
- nsp.nspname AS constraint_schema,
106239
- con.conname AS constraint_name,
106240
- rel.relname AS table_name,
106241
- att.attname AS column_name,
106242
- fnsp.nspname AS foreign_table_schema,
106243
- frel.relname AS foreign_table_name,
106244
- fatt.attname AS foreign_column_name,
106245
- CASE con.confupdtype
106246
- WHEN 'a' THEN 'NO ACTION'
106247
- WHEN 'r' THEN 'RESTRICT'
106248
- WHEN 'n' THEN 'SET NULL'
106249
- WHEN 'c' THEN 'CASCADE'
106250
- WHEN 'd' THEN 'SET DEFAULT'
106251
- END AS update_rule,
106252
- CASE con.confdeltype
106253
- WHEN 'a' THEN 'NO ACTION'
106254
- WHEN 'r' THEN 'RESTRICT'
106255
- WHEN 'n' THEN 'SET NULL'
106256
- WHEN 'c' THEN 'CASCADE'
106257
- WHEN 'd' THEN 'SET DEFAULT'
106258
- END AS delete_rule
106259
- FROM
106260
- pg_catalog.pg_constraint con
106261
- JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
106262
- JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
106263
- LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
106264
- AND att.attrelid = con.conrelid
106265
- LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
106266
- LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
106267
- LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
106268
- AND fatt.attrelid = con.confrelid
106269
- WHERE
106270
- nsp.nspname = '${tableSchema}'
106271
- AND rel.relname = '${tableName}'
106272
- AND con.contype IN ('f');`
105880
+ con.contype AS constraint_type,
105881
+ nsp.nspname AS constraint_schema,
105882
+ con.conname AS constraint_name,
105883
+ rel.relname AS table_name,
105884
+ att.attname AS column_name,
105885
+ fnsp.nspname AS foreign_table_schema,
105886
+ frel.relname AS foreign_table_name,
105887
+ fatt.attname AS foreign_column_name,
105888
+ CASE con.confupdtype
105889
+ WHEN 'a' THEN 'NO ACTION'
105890
+ WHEN 'r' THEN 'RESTRICT'
105891
+ WHEN 'n' THEN 'SET NULL'
105892
+ WHEN 'c' THEN 'CASCADE'
105893
+ WHEN 'd' THEN 'SET DEFAULT'
105894
+ END AS update_rule,
105895
+ CASE con.confdeltype
105896
+ WHEN 'a' THEN 'NO ACTION'
105897
+ WHEN 'r' THEN 'RESTRICT'
105898
+ WHEN 'n' THEN 'SET NULL'
105899
+ WHEN 'c' THEN 'CASCADE'
105900
+ WHEN 'd' THEN 'SET DEFAULT'
105901
+ END AS delete_rule
105902
+ FROM
105903
+ pg_catalog.pg_constraint con
105904
+ JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
105905
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
105906
+ LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
105907
+ AND att.attrelid = con.conrelid
105908
+ LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
105909
+ LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
105910
+ LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
105911
+ AND fatt.attrelid = con.confrelid
105912
+ WHERE
105913
+ nsp.nspname = '${tableSchema}'
105914
+ AND rel.relname = '${tableName}'
105915
+ AND con.contype IN ('f');`
106273
105916
  );
106274
105917
  foreignKeysCount += tableForeignKeys.length;
106275
105918
  if (progressCallback) {
@@ -106311,29 +105954,16 @@ ${withStyle.errorWarning(
106311
105954
  for (const unqs of uniqueConstrainsRows) {
106312
105955
  const columnName = unqs.column_name;
106313
105956
  const constraintName = unqs.constraint_name;
106314
- if (typeof uniqueConstraints[constraintName] !== "undefined") {
106315
- uniqueConstraints[constraintName].columns.push(columnName);
105957
+ if (typeof uniqueConstrains[constraintName] !== "undefined") {
105958
+ uniqueConstrains[constraintName].columns.push(columnName);
106316
105959
  } else {
106317
- uniqueConstraints[constraintName] = {
105960
+ uniqueConstrains[constraintName] = {
106318
105961
  columns: [columnName],
106319
105962
  nullsNotDistinct: false,
106320
105963
  name: constraintName
106321
105964
  };
106322
105965
  }
106323
105966
  }
106324
- checksCount += tableChecks.length;
106325
- if (progressCallback) {
106326
- progressCallback("checks", checksCount, "fetching");
106327
- }
106328
- for (const checks of tableChecks) {
106329
- let checkValue = checks.constraint_definition;
106330
- const constraintName = checks.constraint_name;
106331
- checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
106332
- checkConstraints[constraintName] = {
106333
- name: constraintName,
106334
- value: checkValue
106335
- };
106336
- }
106337
105967
  for (const columnResponse of tableResponse) {
106338
105968
  const columnName = columnResponse.attname;
106339
105969
  const columnAdditionalDT = columnResponse.additional_dt;
@@ -106577,8 +106207,7 @@ ${withStyle.errorWarning(
106577
106207
  indexes: indexToReturn,
106578
106208
  foreignKeys: foreignKeysToReturn,
106579
106209
  compositePrimaryKeys: primaryKeys,
106580
- uniqueConstraints,
106581
- checkConstraints
106210
+ uniqueConstraints: uniqueConstrains
106582
106211
  };
106583
106212
  } catch (e5) {
106584
106213
  rej(e5);
@@ -106596,7 +106225,6 @@ ${withStyle.errorWarning(
106596
106225
  progressCallback("columns", columnsCount, "done");
106597
106226
  progressCallback("indexes", indexesCount, "done");
106598
106227
  progressCallback("fks", foreignKeysCount, "done");
106599
- progressCallback("checks", checksCount, "done");
106600
106228
  }
106601
106229
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
106602
106230
  return {
@@ -106801,13 +106429,10 @@ var init_sqliteSerializer = __esm({
106801
106429
  const foreignKeysObject = {};
106802
106430
  const primaryKeysObject = {};
106803
106431
  const uniqueConstraintObject = {};
106804
- const checkConstraintObject = {};
106805
- const checksInTable = {};
106806
106432
  const {
106807
106433
  name: tableName,
106808
106434
  columns,
106809
106435
  indexes,
106810
- checks,
106811
106436
  foreignKeys: tableForeignKeys,
106812
106437
  primaryKeys,
106813
106438
  uniqueConstraints
@@ -106964,39 +106589,13 @@ The unique constraint ${source_default.underline.blue(
106964
106589
  columnsObject[it.columns[0].name].primaryKey = true;
106965
106590
  }
106966
106591
  });
106967
- checks.forEach((check) => {
106968
- const checkName = check.name;
106969
- if (typeof checksInTable[tableName] !== "undefined") {
106970
- if (checksInTable[tableName].includes(check.name)) {
106971
- console.log(
106972
- `
106973
- ${withStyle.errorWarning(
106974
- `We've found duplicated check constraint name in ${source_default.underline.blue(
106975
- tableName
106976
- )}. Please rename your check constraint in the ${source_default.underline.blue(
106977
- tableName
106978
- )} table`
106979
- )}`
106980
- );
106981
- process.exit(1);
106982
- }
106983
- checksInTable[tableName].push(checkName);
106984
- } else {
106985
- checksInTable[tableName] = [check.name];
106986
- }
106987
- checkConstraintObject[checkName] = {
106988
- name: checkName,
106989
- value: dialect5.sqlToQuery(check.value).sql
106990
- };
106991
- });
106992
106592
  result[tableName] = {
106993
106593
  name: tableName,
106994
106594
  columns: columnsObject,
106995
106595
  indexes: indexesObject,
106996
106596
  foreignKeys: foreignKeysObject,
106997
106597
  compositePrimaryKeys: primaryKeysObject,
106998
- uniqueConstraints: uniqueConstraintObject,
106999
- checkConstraints: checkConstraintObject
106598
+ uniqueConstraints: uniqueConstraintObject
107000
106599
  };
107001
106600
  }
107002
106601
  return {
@@ -107043,7 +106642,6 @@ ${withStyle.errorWarning(
107043
106642
  let tablesCount = /* @__PURE__ */ new Set();
107044
106643
  let indexesCount = 0;
107045
106644
  let foreignKeysCount = 0;
107046
- let checksCount = 0;
107047
106645
  const tableToPk = {};
107048
106646
  let tableToGeneratedColumnsInfo = {};
107049
106647
  for (const column4 of columns) {
@@ -107101,8 +106699,7 @@ ${withStyle.errorWarning(
107101
106699
  compositePrimaryKeys: {},
107102
106700
  indexes: {},
107103
106701
  foreignKeys: {},
107104
- uniqueConstraints: {},
107105
- checkConstraints: {}
106702
+ uniqueConstraints: {}
107106
106703
  };
107107
106704
  } else {
107108
106705
  result[tableName].columns[columnName] = newColumn;
@@ -107216,56 +106813,6 @@ WHERE
107216
106813
  progressCallback("indexes", indexesCount, "done");
107217
106814
  progressCallback("enums", 0, "done");
107218
106815
  }
107219
- const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
107220
- const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
107221
- let checkCounter = 0;
107222
- const checkConstraints = {};
107223
- const checks = await db2.query(`SELECT name as "tableName", sql as "sql"
107224
- FROM sqlite_master
107225
- WHERE type = 'table' AND name != 'sqlite_sequence';`);
107226
- for (const check of checks) {
107227
- if (!tablesFilter(check.tableName)) continue;
107228
- const { tableName, sql: sql3 } = check;
107229
- let namedChecks = [...sql3.matchAll(namedCheckPattern)];
107230
- if (namedChecks.length > 0) {
107231
- namedChecks.forEach(([_3, checkName, checkValue]) => {
107232
- checkConstraints[checkName] = {
107233
- name: checkName,
107234
- value: checkValue.trim()
107235
- };
107236
- });
107237
- } else {
107238
- let unnamedChecks = [...sql3.matchAll(unnamedCheckPattern)];
107239
- unnamedChecks.forEach(([_3, checkValue]) => {
107240
- let checkName = `${tableName}_check_${++checkCounter}`;
107241
- checkConstraints[checkName] = {
107242
- name: checkName,
107243
- value: checkValue.trim()
107244
- };
107245
- });
107246
- }
107247
- checksCount += Object.values(checkConstraints).length;
107248
- if (progressCallback) {
107249
- progressCallback("checks", checksCount, "fetching");
107250
- }
107251
- const table4 = result[tableName];
107252
- if (!table4) {
107253
- result[tableName] = {
107254
- name: tableName,
107255
- columns: {},
107256
- compositePrimaryKeys: {},
107257
- indexes: {},
107258
- foreignKeys: {},
107259
- uniqueConstraints: {},
107260
- checkConstraints
107261
- };
107262
- } else {
107263
- result[tableName].checkConstraints = checkConstraints;
107264
- }
107265
- }
107266
- if (progressCallback) {
107267
- progressCallback("checks", checksCount, "done");
107268
- }
107269
106816
  return {
107270
106817
  version: "6",
107271
106818
  dialect: "sqlite",
@@ -108707,7 +108254,6 @@ var init_mysqlSerializer = __esm({
108707
108254
  indexes,
108708
108255
  foreignKeys,
108709
108256
  schema: schema4,
108710
- checks,
108711
108257
  primaryKeys,
108712
108258
  uniqueConstraints
108713
108259
  } = getTableConfig3(table4);
@@ -108716,8 +108262,6 @@ var init_mysqlSerializer = __esm({
108716
108262
  const foreignKeysObject = {};
108717
108263
  const primaryKeysObject = {};
108718
108264
  const uniqueConstraintObject = {};
108719
- const checkConstraintObject = {};
108720
- let checksInTable = {};
108721
108265
  columns.forEach((column4) => {
108722
108266
  const notNull = column4.notNull;
108723
108267
  const sqlTypeLowered = column4.getSQLType().toLowerCase();
@@ -108930,32 +108474,6 @@ We have encountered a collision between the index name on columns ${source_defau
108930
108474
  lock: value.config.lock
108931
108475
  };
108932
108476
  });
108933
- checks.forEach((check) => {
108934
- check;
108935
- const checkName = check.name;
108936
- if (typeof checksInTable[tableName] !== "undefined") {
108937
- if (checksInTable[tableName].includes(check.name)) {
108938
- console.log(
108939
- `
108940
- ${withStyle.errorWarning(
108941
- `We've found duplicated check constraint name in ${source_default.underline.blue(
108942
- tableName
108943
- )}. Please rename your check constraint in the ${source_default.underline.blue(
108944
- tableName
108945
- )} table`
108946
- )}`
108947
- );
108948
- process.exit(1);
108949
- }
108950
- checksInTable[tableName].push(checkName);
108951
- } else {
108952
- checksInTable[tableName] = [check.name];
108953
- }
108954
- checkConstraintObject[checkName] = {
108955
- name: checkName,
108956
- value: dialect6.sqlToQuery(check.value).sql
108957
- };
108958
- });
108959
108477
  if (!schema4) {
108960
108478
  result[tableName] = {
108961
108479
  name: tableName,
@@ -108963,8 +108481,7 @@ ${withStyle.errorWarning(
108963
108481
  indexes: indexesObject,
108964
108482
  foreignKeys: foreignKeysObject,
108965
108483
  compositePrimaryKeys: primaryKeysObject,
108966
- uniqueConstraints: uniqueConstraintObject,
108967
- checkConstraint: checkConstraintObject
108484
+ uniqueConstraints: uniqueConstraintObject
108968
108485
  };
108969
108486
  }
108970
108487
  }
@@ -108991,7 +108508,6 @@ ${withStyle.errorWarning(
108991
108508
  let tablesCount = /* @__PURE__ */ new Set();
108992
108509
  let indexesCount = 0;
108993
108510
  let foreignKeysCount = 0;
108994
- let checksCount = 0;
108995
108511
  const idxs = await db2.query(
108996
108512
  `select * from INFORMATION_SCHEMA.STATISTICS
108997
108513
  WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
@@ -109086,8 +108602,7 @@ ${withStyle.errorWarning(
109086
108602
  compositePrimaryKeys: {},
109087
108603
  indexes: {},
109088
108604
  foreignKeys: {},
109089
- uniqueConstraints: {},
109090
- checkConstraint: {}
108605
+ uniqueConstraints: {}
109091
108606
  };
109092
108607
  } else {
109093
108608
  result[tableName].columns[columnName] = newColumn;
@@ -109236,38 +108751,6 @@ ${withStyle.errorWarning(
109236
108751
  progressCallback("indexes", indexesCount, "done");
109237
108752
  progressCallback("enums", 0, "done");
109238
108753
  }
109239
- const checkConstraints = await db2.query(
109240
- `SELECT
109241
- tc.table_name,
109242
- tc.constraint_name,
109243
- cc.check_clause
109244
- FROM
109245
- information_schema.table_constraints tc
109246
- JOIN
109247
- information_schema.check_constraints cc
109248
- ON tc.constraint_name = cc.constraint_name
109249
- WHERE
109250
- tc.constraint_schema = '${inputSchema}'
109251
- AND
109252
- tc.constraint_type = 'CHECK';`
109253
- );
109254
- checksCount += checkConstraints.length;
109255
- if (progressCallback) {
109256
- progressCallback("checks", checksCount, "fetching");
109257
- }
109258
- for (const checkConstraintRow of checkConstraints) {
109259
- const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
109260
- const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
109261
- const tableName = checkConstraintRow["TABLE_NAME"];
109262
- const tableInResult = result[tableName];
109263
- tableInResult.checkConstraint[constraintName] = {
109264
- name: constraintName,
109265
- value: constraintValue
109266
- };
109267
- }
109268
- if (progressCallback) {
109269
- progressCallback("checks", checksCount, "done");
109270
- }
109271
108754
  return {
109272
108755
  version: "5",
109273
108756
  dialect: "mysql",