drizzle-kit 0.25.0-1f15bfd → 0.25.0-20acc2f

Sign up to get free protection for your applications and to get access to all the features.
package/api.mjs CHANGED
@@ -7381,7 +7381,7 @@ var init_lib = __esm({
7381
7381
  });
7382
7382
 
7383
7383
  // src/serializer/mysqlSchema.ts
7384
- 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;
7384
+ 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;
7385
7385
  var init_mysqlSchema = __esm({
7386
7386
  "src/serializer/mysqlSchema.ts"() {
7387
7387
  "use strict";
@@ -7431,6 +7431,10 @@ var init_mysqlSchema = __esm({
7431
7431
  name: stringType(),
7432
7432
  columns: stringType().array()
7433
7433
  }).strict();
7434
+ checkConstraint = objectType({
7435
+ name: stringType(),
7436
+ value: stringType()
7437
+ }).strict();
7434
7438
  tableV4 = objectType({
7435
7439
  name: stringType(),
7436
7440
  schema: stringType().optional(),
@@ -7444,7 +7448,8 @@ var init_mysqlSchema = __esm({
7444
7448
  indexes: recordType(stringType(), index),
7445
7449
  foreignKeys: recordType(stringType(), fk),
7446
7450
  compositePrimaryKeys: recordType(stringType(), compositePK),
7447
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
7451
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
7452
+ checkConstraint: recordType(stringType(), checkConstraint).default({})
7448
7453
  }).strict();
7449
7454
  kitInternals = objectType({
7450
7455
  tables: recordType(
@@ -7521,7 +7526,8 @@ var init_mysqlSchema = __esm({
7521
7526
  indexes: recordType(stringType(), stringType()),
7522
7527
  foreignKeys: recordType(stringType(), stringType()),
7523
7528
  compositePrimaryKeys: recordType(stringType(), stringType()),
7524
- uniqueConstraints: recordType(stringType(), stringType()).default({})
7529
+ uniqueConstraints: recordType(stringType(), stringType()).default({}),
7530
+ checkConstraints: recordType(stringType(), stringType()).default({})
7525
7531
  }).strict();
7526
7532
  schemaSquashed = objectType({
7527
7533
  version: literalType("5"),
@@ -7588,6 +7594,13 @@ var init_mysqlSchema = __esm({
7588
7594
  onDelete
7589
7595
  });
7590
7596
  return result;
7597
+ },
7598
+ squashCheck: (input) => {
7599
+ return `${input.name};${input.value}`;
7600
+ },
7601
+ unsquashCheck: (input) => {
7602
+ const [name2, value] = input.split(";");
7603
+ return { name: name2, value };
7591
7604
  }
7592
7605
  };
7593
7606
  squashMysqlScheme = (json3) => {
@@ -7608,6 +7621,9 @@ var init_mysqlSchema = __esm({
7608
7621
  return MySqlSquasher.squashUnique(unq);
7609
7622
  }
7610
7623
  );
7624
+ const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check) => {
7625
+ return MySqlSquasher.squashCheck(check);
7626
+ });
7611
7627
  return [
7612
7628
  it[0],
7613
7629
  {
@@ -7616,7 +7632,8 @@ var init_mysqlSchema = __esm({
7616
7632
  indexes: squashedIndexes,
7617
7633
  foreignKeys: squashedFKs,
7618
7634
  compositePrimaryKeys: squashedPKs,
7619
- uniqueConstraints: squashedUniqueConstraints
7635
+ uniqueConstraints: squashedUniqueConstraints,
7636
+ checkConstraints: squashedCheckConstraints
7620
7637
  }
7621
7638
  ];
7622
7639
  })
@@ -7666,7 +7683,7 @@ var init_vector = __esm({
7666
7683
  });
7667
7684
 
7668
7685
  // src/serializer/pgSchema.ts
7669
- 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;
7686
+ 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;
7670
7687
  var init_pgSchema = __esm({
7671
7688
  "src/serializer/pgSchema.ts"() {
7672
7689
  "use strict";
@@ -7830,6 +7847,10 @@ var init_pgSchema = __esm({
7830
7847
  }).optional(),
7831
7848
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
7832
7849
  }).strict();
7850
+ checkConstraint2 = objectType({
7851
+ name: stringType(),
7852
+ value: stringType()
7853
+ }).strict();
7833
7854
  columnSquashed = objectType({
7834
7855
  name: stringType(),
7835
7856
  type: stringType(),
@@ -7902,7 +7923,8 @@ var init_pgSchema = __esm({
7902
7923
  indexes: recordType(stringType(), index2),
7903
7924
  foreignKeys: recordType(stringType(), fk2),
7904
7925
  compositePrimaryKeys: recordType(stringType(), compositePK2),
7905
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
7926
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
7927
+ checkConstraints: recordType(stringType(), checkConstraint2).default({})
7906
7928
  }).strict();
7907
7929
  schemaHash2 = objectType({
7908
7930
  id: stringType(),
@@ -8010,7 +8032,8 @@ var init_pgSchema = __esm({
8010
8032
  indexes: recordType(stringType(), stringType()),
8011
8033
  foreignKeys: recordType(stringType(), stringType()),
8012
8034
  compositePrimaryKeys: recordType(stringType(), stringType()),
8013
- uniqueConstraints: recordType(stringType(), stringType())
8035
+ uniqueConstraints: recordType(stringType(), stringType()),
8036
+ checkConstraints: recordType(stringType(), stringType())
8014
8037
  }).strict();
8015
8038
  tableSquashedV42 = objectType({
8016
8039
  name: stringType(),
@@ -8192,6 +8215,16 @@ var init_pgSchema = __esm({
8192
8215
  cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
8193
8216
  cycle: splitted[7] === "true"
8194
8217
  };
8218
+ },
8219
+ squashCheck: (check) => {
8220
+ return `${check.name};${check.value}`;
8221
+ },
8222
+ unsquashCheck: (input) => {
8223
+ const [
8224
+ name2,
8225
+ value
8226
+ ] = input.split(";");
8227
+ return { name: name2, value };
8195
8228
  }
8196
8229
  };
8197
8230
  squashPgScheme = (json3, action) => {
@@ -8224,6 +8257,12 @@ var init_pgSchema = __esm({
8224
8257
  return PgSquasher.squashUnique(unq);
8225
8258
  }
8226
8259
  );
8260
+ const squashedChecksContraints = mapValues(
8261
+ it[1].checkConstraints,
8262
+ (check) => {
8263
+ return PgSquasher.squashCheck(check);
8264
+ }
8265
+ );
8227
8266
  return [
8228
8267
  it[0],
8229
8268
  {
@@ -8233,7 +8272,8 @@ var init_pgSchema = __esm({
8233
8272
  indexes: squashedIndexes,
8234
8273
  foreignKeys: squashedFKs,
8235
8274
  compositePrimaryKeys: squashedPKs,
8236
- uniqueConstraints: squashedUniqueConstraints
8275
+ uniqueConstraints: squashedUniqueConstraints,
8276
+ checkConstraints: squashedChecksContraints
8237
8277
  }
8238
8278
  ];
8239
8279
  })
@@ -8278,7 +8318,7 @@ var init_pgSchema = __esm({
8278
8318
  });
8279
8319
 
8280
8320
  // src/serializer/sqliteSchema.ts
8281
- 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;
8321
+ 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;
8282
8322
  var init_sqliteSchema = __esm({
8283
8323
  "src/serializer/sqliteSchema.ts"() {
8284
8324
  "use strict";
@@ -8325,13 +8365,18 @@ var init_sqliteSchema = __esm({
8325
8365
  name: stringType(),
8326
8366
  columns: stringType().array()
8327
8367
  }).strict();
8368
+ checkConstraint3 = objectType({
8369
+ name: stringType(),
8370
+ value: stringType()
8371
+ }).strict();
8328
8372
  table3 = objectType({
8329
8373
  name: stringType(),
8330
8374
  columns: recordType(stringType(), column3),
8331
8375
  indexes: recordType(stringType(), index3),
8332
8376
  foreignKeys: recordType(stringType(), fk3),
8333
8377
  compositePrimaryKeys: recordType(stringType(), compositePK3),
8334
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
8378
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
8379
+ checkConstraints: recordType(stringType(), checkConstraint3).default({})
8335
8380
  }).strict();
8336
8381
  dialect2 = enumType(["sqlite"]);
8337
8382
  schemaHash3 = objectType({
@@ -8393,7 +8438,8 @@ var init_sqliteSchema = __esm({
8393
8438
  indexes: recordType(stringType(), stringType()),
8394
8439
  foreignKeys: recordType(stringType(), stringType()),
8395
8440
  compositePrimaryKeys: recordType(stringType(), stringType()),
8396
- uniqueConstraints: recordType(stringType(), stringType()).default({})
8441
+ uniqueConstraints: recordType(stringType(), stringType()).default({}),
8442
+ checkConstraints: recordType(stringType(), stringType()).default({})
8397
8443
  }).strict();
8398
8444
  schemaSquashed2 = objectType({
8399
8445
  version: latestVersion,
@@ -8475,6 +8521,16 @@ var init_sqliteSchema = __esm({
8475
8521
  },
8476
8522
  unsquashPK: (pk) => {
8477
8523
  return pk.split(",");
8524
+ },
8525
+ squashCheck: (check) => {
8526
+ return `${check.name};${check.value}`;
8527
+ },
8528
+ unsquashCheck: (input) => {
8529
+ const [
8530
+ name2,
8531
+ value
8532
+ ] = input.split(";");
8533
+ return { name: name2, value };
8478
8534
  }
8479
8535
  };
8480
8536
  squashSqliteScheme = (json3, action) => {
@@ -8501,6 +8557,12 @@ var init_sqliteSchema = __esm({
8501
8557
  return SQLiteSquasher.squashUnique(unq);
8502
8558
  }
8503
8559
  );
8560
+ const squashedCheckConstraints = mapValues(
8561
+ it[1].checkConstraints,
8562
+ (check) => {
8563
+ return SQLiteSquasher.squashCheck(check);
8564
+ }
8565
+ );
8504
8566
  return [
8505
8567
  it[0],
8506
8568
  {
@@ -8509,7 +8571,8 @@ var init_sqliteSchema = __esm({
8509
8571
  indexes: squashedIndexes,
8510
8572
  foreignKeys: squashedFKs,
8511
8573
  compositePrimaryKeys: squashedPKs,
8512
- uniqueConstraints: squashedUniqueConstraints
8574
+ uniqueConstraints: squashedUniqueConstraints,
8575
+ checkConstraints: squashedCheckConstraints
8513
8576
  }
8514
8577
  ];
8515
8578
  })
@@ -11390,6 +11453,21 @@ var init_jsonDiffer = __esm({
11390
11453
  return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
11391
11454
  })
11392
11455
  );
11456
+ const addedCheckConstraints = Object.fromEntries(
11457
+ Object.entries(table4.checkConstraints || {}).filter((it) => {
11458
+ return it[0].endsWith("__added");
11459
+ })
11460
+ );
11461
+ const deletedCheckConstraints = Object.fromEntries(
11462
+ Object.entries(table4.checkConstraints || {}).filter((it) => {
11463
+ return it[0].endsWith("__deleted");
11464
+ })
11465
+ );
11466
+ const alteredCheckConstraints = Object.fromEntries(
11467
+ Object.entries(table4.checkConstraints || {}).filter((it) => {
11468
+ return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
11469
+ })
11470
+ );
11393
11471
  const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
11394
11472
  return {
11395
11473
  name: table4.name,
@@ -11406,7 +11484,10 @@ var init_jsonDiffer = __esm({
11406
11484
  alteredCompositePKs,
11407
11485
  addedUniqueConstraints,
11408
11486
  deletedUniqueConstraints,
11409
- alteredUniqueConstraints
11487
+ alteredUniqueConstraints,
11488
+ addedCheckConstraints,
11489
+ deletedCheckConstraints,
11490
+ alteredCheckConstraints
11410
11491
  };
11411
11492
  };
11412
11493
  alternationsInColumn = (column4) => {
@@ -11660,6 +11741,32 @@ var init_jsonDiffer = __esm({
11660
11741
  };
11661
11742
  }
11662
11743
  return it;
11744
+ }).map((it) => {
11745
+ if ("" in it) {
11746
+ return {
11747
+ ...it,
11748
+ autoincrement: {
11749
+ type: "changed",
11750
+ old: it.autoincrement.__old,
11751
+ new: it.autoincrement.__new
11752
+ }
11753
+ };
11754
+ }
11755
+ if ("autoincrement__added" in it) {
11756
+ const { autoincrement__added, ...others } = it;
11757
+ return {
11758
+ ...others,
11759
+ autoincrement: { type: "added", value: it.autoincrement__added }
11760
+ };
11761
+ }
11762
+ if ("autoincrement__deleted" in it) {
11763
+ const { autoincrement__deleted, ...others } = it;
11764
+ return {
11765
+ ...others,
11766
+ autoincrement: { type: "deleted", value: it.autoincrement__deleted }
11767
+ };
11768
+ }
11769
+ return it;
11663
11770
  }).filter(Boolean);
11664
11771
  return result[0];
11665
11772
  };
@@ -11680,7 +11787,7 @@ function fromJson(statements, dialect4, action, json22) {
11680
11787
  }).filter((it) => it !== "");
11681
11788
  return result;
11682
11789
  }
11683
- var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, 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;
11790
+ var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, 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;
11684
11791
  var init_sqlgenerator = __esm({
11685
11792
  "src/sqlgenerator.ts"() {
11686
11793
  "use strict";
@@ -11741,7 +11848,7 @@ var init_sqlgenerator = __esm({
11741
11848
  return statement.type === "create_table" && dialect4 === "postgresql";
11742
11849
  }
11743
11850
  convert(st) {
11744
- const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
11851
+ const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints, checkConstraints } = st;
11745
11852
  let statement = "";
11746
11853
  const name2 = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
11747
11854
  statement += `CREATE TABLE IF NOT EXISTS ${name2} (
@@ -11774,6 +11881,13 @@ var init_sqlgenerator = __esm({
11774
11881
  statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
11775
11882
  }
11776
11883
  }
11884
+ if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
11885
+ for (const checkConstraint4 of checkConstraints) {
11886
+ statement += ",\n";
11887
+ const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
11888
+ statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
11889
+ }
11890
+ }
11777
11891
  statement += `
11778
11892
  );`;
11779
11893
  statement += `
@@ -11790,6 +11904,7 @@ var init_sqlgenerator = __esm({
11790
11904
  tableName,
11791
11905
  columns,
11792
11906
  schema: schema4,
11907
+ checkConstraints,
11793
11908
  compositePKs,
11794
11909
  uniqueConstraints,
11795
11910
  internals
@@ -11823,6 +11938,13 @@ var init_sqlgenerator = __esm({
11823
11938
  statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
11824
11939
  }
11825
11940
  }
11941
+ if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
11942
+ for (const checkConstraint4 of checkConstraints) {
11943
+ statement += ",\n";
11944
+ const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
11945
+ statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
11946
+ }
11947
+ }
11826
11948
  statement += `
11827
11949
  );`;
11828
11950
  statement += `
@@ -11840,7 +11962,8 @@ var init_sqlgenerator = __esm({
11840
11962
  columns,
11841
11963
  referenceData,
11842
11964
  compositePKs,
11843
- uniqueConstraints
11965
+ uniqueConstraints,
11966
+ checkConstraints
11844
11967
  } = st;
11845
11968
  let statement = "";
11846
11969
  statement += `CREATE TABLE \`${tableName}\` (
@@ -11881,10 +12004,17 @@ var init_sqlgenerator = __esm({
11881
12004
  if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
11882
12005
  for (const uniqueConstraint4 of uniqueConstraints) {
11883
12006
  statement += ",\n";
11884
- const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
12007
+ const unsquashedUnique = SQLiteSquasher.unsquashUnique(uniqueConstraint4);
11885
12008
  statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
11886
12009
  }
11887
12010
  }
12011
+ if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
12012
+ for (const check of checkConstraints) {
12013
+ statement += ",\n";
12014
+ const { value, name: name2 } = SQLiteSquasher.unsquashCheck(check);
12015
+ statement += ` CONSTRAINT "${name2}" CHECK(${value})`;
12016
+ }
12017
+ }
11888
12018
  statement += `
11889
12019
  `;
11890
12020
  statement += `);`;
@@ -11984,6 +12114,25 @@ var init_sqlgenerator = __esm({
11984
12114
  return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
11985
12115
  }
11986
12116
  };
12117
+ PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
12118
+ can(statement, dialect4) {
12119
+ return statement.type === "create_check_constraint" && dialect4 === "postgresql";
12120
+ }
12121
+ convert(statement) {
12122
+ const unsquashed = PgSquasher.unsquashCheck(statement.data);
12123
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12124
+ return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
12125
+ }
12126
+ };
12127
+ PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
12128
+ can(statement, dialect4) {
12129
+ return statement.type === "delete_check_constraint" && dialect4 === "postgresql";
12130
+ }
12131
+ convert(statement) {
12132
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12133
+ return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
12134
+ }
12135
+ };
11987
12136
  MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
11988
12137
  can(statement, dialect4) {
11989
12138
  return statement.type === "create_unique_constraint" && dialect4 === "mysql";
@@ -12002,6 +12151,25 @@ var init_sqlgenerator = __esm({
12002
12151
  return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
12003
12152
  }
12004
12153
  };
12154
+ MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
12155
+ can(statement, dialect4) {
12156
+ return statement.type === "create_check_constraint" && dialect4 === "mysql";
12157
+ }
12158
+ convert(statement) {
12159
+ const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
12160
+ const { tableName } = statement;
12161
+ return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
12162
+ }
12163
+ };
12164
+ MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
12165
+ can(statement, dialect4) {
12166
+ return statement.type === "delete_check_constraint" && dialect4 === "mysql";
12167
+ }
12168
+ convert(statement) {
12169
+ const { tableName } = statement;
12170
+ return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
12171
+ }
12172
+ };
12005
12173
  CreatePgSequenceConvertor = class extends Convertor {
12006
12174
  can(statement, dialect4) {
12007
12175
  return statement.type === "create_sequence" && dialect4 === "postgresql";
@@ -12076,7 +12244,7 @@ var init_sqlgenerator = __esm({
12076
12244
  convert(st) {
12077
12245
  const { name: name2, schema: schema4 } = st;
12078
12246
  const enumNameWithSchema = schema4 ? `"${schema4}"."${name2}"` : `"${name2}"`;
12079
- let statement = `DROP TYPE ${enumNameWithSchema} CASCADE;`;
12247
+ let statement = `DROP TYPE ${enumNameWithSchema};`;
12080
12248
  return statement;
12081
12249
  }
12082
12250
  };
@@ -12605,7 +12773,7 @@ var init_sqlgenerator = __esm({
12605
12773
  };
12606
12774
  LibSQLModifyColumn = class extends Convertor {
12607
12775
  can(statement, dialect4) {
12608
- 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") && dialect4 === "turso";
12776
+ 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") && dialect4 === "turso";
12609
12777
  }
12610
12778
  convert(statement, json22) {
12611
12779
  const { tableName, columnName } = statement;
@@ -13192,18 +13360,22 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13192
13360
  return statement.type === "recreate_table" && dialect4 === "sqlite";
13193
13361
  }
13194
13362
  convert(statement) {
13195
- const { tableName, columns, compositePKs, referenceData } = statement;
13363
+ const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
13196
13364
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
13197
13365
  const newTableName = `__new_${tableName}`;
13198
13366
  const sqlStatements = [];
13199
13367
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
13368
+ const mappedCheckConstraints = checkConstraints.map(
13369
+ (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
13370
+ );
13200
13371
  sqlStatements.push(
13201
13372
  new SQLiteCreateTableConvertor().convert({
13202
13373
  type: "sqlite_create_table",
13203
13374
  tableName: newTableName,
13204
13375
  columns,
13205
13376
  referenceData,
13206
- compositePKs
13377
+ compositePKs,
13378
+ checkConstraints: mappedCheckConstraints
13207
13379
  })
13208
13380
  );
13209
13381
  sqlStatements.push(
@@ -13234,10 +13406,13 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13234
13406
  return statement.type === "recreate_table" && dialect4 === "turso";
13235
13407
  }
13236
13408
  convert(statement) {
13237
- const { tableName, columns, compositePKs, referenceData } = statement;
13409
+ const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
13238
13410
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
13239
13411
  const newTableName = `__new_${tableName}`;
13240
13412
  const sqlStatements = [];
13413
+ const mappedCheckConstraints = checkConstraints.map(
13414
+ (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
13415
+ );
13241
13416
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
13242
13417
  sqlStatements.push(
13243
13418
  new SQLiteCreateTableConvertor().convert({
@@ -13245,7 +13420,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13245
13420
  tableName: newTableName,
13246
13421
  columns,
13247
13422
  referenceData,
13248
- compositePKs
13423
+ compositePKs,
13424
+ checkConstraints: mappedCheckConstraints
13249
13425
  })
13250
13426
  );
13251
13427
  sqlStatements.push(
@@ -13306,6 +13482,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
13306
13482
  convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
13307
13483
  convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
13308
13484
  convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
13485
+ convertors.push(new PgAlterTableAddCheckConstraintConvertor());
13486
+ convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
13487
+ convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
13488
+ convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
13309
13489
  convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
13310
13490
  convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
13311
13491
  convertors.push(new CreatePgIndexConvertor());
@@ -13395,6 +13575,10 @@ var init_sqlitePushUtils = __esm({
13395
13575
  const compositePKs = Object.values(
13396
13576
  json3.tables[tableName].compositePrimaryKeys
13397
13577
  ).map((it) => SQLiteSquasher.unsquashPK(it));
13578
+ const checkConstraints = Object.values(json3.tables[tableName].checkConstraints);
13579
+ const mappedCheckConstraints = checkConstraints.map(
13580
+ (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
13581
+ );
13398
13582
  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
13399
13583
  statements.push(
13400
13584
  new SQLiteCreateTableConvertor().convert({
@@ -13402,7 +13586,8 @@ var init_sqlitePushUtils = __esm({
13402
13586
  tableName: newTableName,
13403
13587
  columns: tableColumns,
13404
13588
  referenceData: fks,
13405
- compositePKs
13589
+ compositePKs,
13590
+ checkConstraints: mappedCheckConstraints
13406
13591
  })
13407
13592
  );
13408
13593
  if (!dataLoss) {
@@ -13614,7 +13799,7 @@ var init_sqlitePushUtils = __esm({
13614
13799
  });
13615
13800
 
13616
13801
  // src/jsonStatements.ts
13617
- var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, 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;
13802
+ var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, 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;
13618
13803
  var init_jsonStatements = __esm({
13619
13804
  "src/jsonStatements.ts"() {
13620
13805
  "use strict";
@@ -13625,7 +13810,7 @@ var init_jsonStatements = __esm({
13625
13810
  init_pgSchema();
13626
13811
  init_sqliteSchema();
13627
13812
  preparePgCreateTableJson = (table4, json22) => {
13628
- const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13813
+ const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
13629
13814
  const tableKey2 = `${schema4 || "public"}.${name2}`;
13630
13815
  const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json22.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
13631
13816
  return {
@@ -13635,11 +13820,12 @@ var init_jsonStatements = __esm({
13635
13820
  columns: Object.values(columns),
13636
13821
  compositePKs: Object.values(compositePrimaryKeys),
13637
13822
  compositePkName,
13638
- uniqueConstraints: Object.values(uniqueConstraints)
13823
+ uniqueConstraints: Object.values(uniqueConstraints),
13824
+ checkConstraints: Object.values(checkConstraints)
13639
13825
  };
13640
13826
  };
13641
13827
  prepareMySqlCreateTableJson = (table4, json22, internals) => {
13642
- const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13828
+ const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
13643
13829
  return {
13644
13830
  type: "create_table",
13645
13831
  tableName: name2,
@@ -13648,11 +13834,12 @@ var init_jsonStatements = __esm({
13648
13834
  compositePKs: Object.values(compositePrimaryKeys),
13649
13835
  compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json22.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
13650
13836
  uniqueConstraints: Object.values(uniqueConstraints),
13651
- internals
13837
+ internals,
13838
+ checkConstraints: Object.values(checkConstraints)
13652
13839
  };
13653
13840
  };
13654
13841
  prepareSQLiteCreateTable = (table4, action) => {
13655
- const { name: name2, columns, uniqueConstraints } = table4;
13842
+ const { name: name2, columns, uniqueConstraints, checkConstraints } = table4;
13656
13843
  const references2 = Object.values(table4.foreignKeys);
13657
13844
  const composites = Object.values(table4.compositePrimaryKeys).map(
13658
13845
  (it) => SQLiteSquasher.unsquashPK(it)
@@ -13666,7 +13853,8 @@ var init_jsonStatements = __esm({
13666
13853
  columns: Object.values(columns),
13667
13854
  referenceData: fks,
13668
13855
  compositePKs: composites,
13669
- uniqueConstraints: Object.values(uniqueConstraints)
13856
+ uniqueConstraints: Object.values(uniqueConstraints),
13857
+ checkConstraints: Object.values(checkConstraints)
13670
13858
  };
13671
13859
  };
13672
13860
  prepareDropTableJson = (table4) => {
@@ -14930,6 +15118,26 @@ var init_jsonStatements = __esm({
14930
15118
  };
14931
15119
  });
14932
15120
  };
15121
+ prepareAddCheckConstraint = (tableName, schema4, check) => {
15122
+ return Object.values(check).map((it) => {
15123
+ return {
15124
+ type: "create_check_constraint",
15125
+ tableName,
15126
+ data: it,
15127
+ schema: schema4
15128
+ };
15129
+ });
15130
+ };
15131
+ prepareDeleteCheckConstraint = (tableName, schema4, check) => {
15132
+ return Object.values(check).map((it) => {
15133
+ return {
15134
+ type: "delete_check_constraint",
15135
+ tableName,
15136
+ constraintName: PgSquasher.unsquashCheck(it).name,
15137
+ schema: schema4
15138
+ };
15139
+ });
15140
+ };
14933
15141
  prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json22) => {
14934
15142
  const res = [];
14935
15143
  for (const it of Object.values(pks)) {
@@ -14979,7 +15187,7 @@ var init_statementCombiner = __esm({
14979
15187
  init_jsonStatements();
14980
15188
  init_sqliteSchema();
14981
15189
  prepareLibSQLRecreateTable = (table4, action) => {
14982
- const { name: name2, columns, uniqueConstraints, indexes } = table4;
15190
+ const { name: name2, columns, uniqueConstraints, indexes, checkConstraints } = table4;
14983
15191
  const composites = Object.values(table4.compositePrimaryKeys).map(
14984
15192
  (it) => SQLiteSquasher.unsquashPK(it)
14985
15193
  );
@@ -14994,7 +15202,8 @@ var init_statementCombiner = __esm({
14994
15202
  columns: Object.values(columns),
14995
15203
  compositePKs: composites,
14996
15204
  referenceData: fks,
14997
- uniqueConstraints: Object.values(uniqueConstraints)
15205
+ uniqueConstraints: Object.values(uniqueConstraints),
15206
+ checkConstraints: Object.values(checkConstraints)
14998
15207
  }
14999
15208
  ];
15000
15209
  if (Object.keys(indexes).length) {
@@ -15003,7 +15212,7 @@ var init_statementCombiner = __esm({
15003
15212
  return statements;
15004
15213
  };
15005
15214
  prepareSQLiteRecreateTable = (table4, action) => {
15006
- const { name: name2, columns, uniqueConstraints, indexes } = table4;
15215
+ const { name: name2, columns, uniqueConstraints, indexes, checkConstraints } = table4;
15007
15216
  const composites = Object.values(table4.compositePrimaryKeys).map(
15008
15217
  (it) => SQLiteSquasher.unsquashPK(it)
15009
15218
  );
@@ -15018,7 +15227,8 @@ var init_statementCombiner = __esm({
15018
15227
  columns: Object.values(columns),
15019
15228
  compositePKs: composites,
15020
15229
  referenceData: fks,
15021
- uniqueConstraints: Object.values(uniqueConstraints)
15230
+ uniqueConstraints: Object.values(uniqueConstraints),
15231
+ checkConstraints: Object.values(checkConstraints)
15022
15232
  }
15023
15233
  ];
15024
15234
  if (Object.keys(indexes).length) {
@@ -15029,7 +15239,7 @@ var init_statementCombiner = __esm({
15029
15239
  libSQLCombineStatements = (statements, json22, action) => {
15030
15240
  const newStatements = {};
15031
15241
  for (const statement of statements) {
15032
- 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") {
15242
+ 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") {
15033
15243
  const tableName2 = statement.tableName;
15034
15244
  const statementsForTable2 = newStatements[tableName2];
15035
15245
  if (!statementsForTable2) {
@@ -15170,16 +15380,16 @@ var init_statementCombiner = __esm({
15170
15380
  sqliteCombineStatements = (statements, json22, action) => {
15171
15381
  const newStatements = {};
15172
15382
  for (const statement of statements) {
15173
- 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") {
15383
+ 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") {
15174
15384
  const tableName2 = statement.tableName;
15175
15385
  const statementsForTable2 = newStatements[tableName2];
15176
15386
  if (!statementsForTable2) {
15177
- newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
15387
+ newStatements[tableName2] = prepareSQLiteRecreateTable(json22.tables[tableName2], action);
15178
15388
  continue;
15179
15389
  }
15180
15390
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15181
15391
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15182
- const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
15392
+ const preparedStatements = prepareSQLiteRecreateTable(json22.tables[tableName2], action);
15183
15393
  if (wasRename) {
15184
15394
  newStatements[tableName2].push(...preparedStatements);
15185
15395
  } else {
@@ -15193,12 +15403,12 @@ var init_statementCombiner = __esm({
15193
15403
  const tableName2 = statement.tableName;
15194
15404
  const statementsForTable2 = newStatements[tableName2];
15195
15405
  if (!statementsForTable2) {
15196
- newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
15406
+ newStatements[tableName2] = prepareSQLiteRecreateTable(json22.tables[tableName2], action);
15197
15407
  continue;
15198
15408
  }
15199
15409
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15200
15410
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15201
- const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
15411
+ const preparedStatements = prepareSQLiteRecreateTable(json22.tables[tableName2], action);
15202
15412
  if (wasRename) {
15203
15413
  newStatements[tableName2].push(...preparedStatements);
15204
15414
  } else {
@@ -15223,7 +15433,7 @@ var init_statementCombiner = __esm({
15223
15433
  }
15224
15434
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
15225
15435
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
15226
- const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
15436
+ const preparedStatements = prepareSQLiteRecreateTable(json22.tables[tableName2], action);
15227
15437
  if (wasRename) {
15228
15438
  newStatements[tableName2].push(...preparedStatements);
15229
15439
  } else {
@@ -15392,7 +15602,8 @@ var init_snapshotsDiffer = __esm({
15392
15602
  indexes: recordType(stringType(), stringType()),
15393
15603
  foreignKeys: recordType(stringType(), stringType()),
15394
15604
  compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
15395
- uniqueConstraints: recordType(stringType(), stringType()).default({})
15605
+ uniqueConstraints: recordType(stringType(), stringType()).default({}),
15606
+ checkConstraints: recordType(stringType(), stringType()).default({})
15396
15607
  }).strict();
15397
15608
  alteredTableScheme = objectType({
15398
15609
  name: stringType(),
@@ -15433,6 +15644,21 @@ var init_snapshotsDiffer = __esm({
15433
15644
  __new: stringType(),
15434
15645
  __old: stringType()
15435
15646
  })
15647
+ ),
15648
+ addedCheckConstraints: recordType(
15649
+ stringType(),
15650
+ stringType()
15651
+ ),
15652
+ deletedCheckConstraints: recordType(
15653
+ stringType(),
15654
+ stringType()
15655
+ ),
15656
+ alteredCheckConstraints: recordType(
15657
+ stringType(),
15658
+ objectType({
15659
+ __new: stringType(),
15660
+ __old: stringType()
15661
+ })
15436
15662
  )
15437
15663
  }).strict();
15438
15664
  diffResultScheme = objectType({
@@ -15773,6 +15999,8 @@ var init_snapshotsDiffer = __esm({
15773
15999
  schemaTo: it.schemaTo || "public"
15774
16000
  });
15775
16001
  }
16002
+ const jsonDeletedCheckConstraints = [];
16003
+ const jsonCreatedCheckConstraints = [];
15776
16004
  for (let it of alteredTables) {
15777
16005
  let addedColumns = [];
15778
16006
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -15812,6 +16040,8 @@ var init_snapshotsDiffer = __esm({
15812
16040
  let addedUniqueConstraints = [];
15813
16041
  let deletedUniqueConstraints = [];
15814
16042
  let alteredUniqueConstraints = [];
16043
+ let createCheckConstraints = [];
16044
+ let deleteCheckConstraints = [];
15815
16045
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
15816
16046
  it.name,
15817
16047
  it.schema,
@@ -15836,6 +16066,24 @@ var init_snapshotsDiffer = __esm({
15836
16066
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
15837
16067
  );
15838
16068
  }
16069
+ createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16070
+ deleteCheckConstraints = prepareDeleteCheckConstraint(
16071
+ it.name,
16072
+ it.schema,
16073
+ it.deletedCheckConstraints
16074
+ );
16075
+ if (it.alteredCheckConstraints && action !== "push") {
16076
+ const added = {};
16077
+ const deleted = {};
16078
+ for (const k of Object.keys(it.alteredCheckConstraints)) {
16079
+ added[k] = it.alteredCheckConstraints[k].__new;
16080
+ deleted[k] = it.alteredCheckConstraints[k].__old;
16081
+ }
16082
+ createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16083
+ deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16084
+ }
16085
+ jsonCreatedCheckConstraints.push(...createCheckConstraints);
16086
+ jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
15839
16087
  jsonAddedCompositePKs.push(...addedCompositePKs);
15840
16088
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
15841
16089
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
@@ -15992,6 +16240,7 @@ var init_snapshotsDiffer = __esm({
15992
16240
  jsonStatements.push(...jsonRenameTables);
15993
16241
  jsonStatements.push(...jsonRenameColumnsStatements);
15994
16242
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16243
+ jsonStatements.push(...jsonDeletedCheckConstraints);
15995
16244
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
15996
16245
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
15997
16246
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -16005,6 +16254,7 @@ var init_snapshotsDiffer = __esm({
16005
16254
  jsonStatements.push(...jsonDropColumnsStatemets);
16006
16255
  jsonStatements.push(...jsonAlteredCompositePKs);
16007
16256
  jsonStatements.push(...jsonAddedUniqueConstraints);
16257
+ jsonStatements.push(...jsonCreatedCheckConstraints);
16008
16258
  jsonStatements.push(...jsonAlteredUniqueConstraints);
16009
16259
  jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
16010
16260
  jsonStatements.push(...dropEnums);
@@ -16027,7 +16277,17 @@ var init_snapshotsDiffer = __esm({
16027
16277
  }
16028
16278
  return true;
16029
16279
  });
16030
- const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
16280
+ const filteredEnumsJsonStatements = filteredJsonStatements.filter((st) => {
16281
+ if (st.type === "alter_type_add_value") {
16282
+ if (jsonStatements.find(
16283
+ (it) => it.type === "alter_type_drop_value" && it.name === st.name && it.schema === st.schema
16284
+ )) {
16285
+ return false;
16286
+ }
16287
+ }
16288
+ return true;
16289
+ });
16290
+ const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
16031
16291
  const uniqueSqlStatements = [];
16032
16292
  sqlStatements.forEach((ss) => {
16033
16293
  if (!uniqueSqlStatements.includes(ss)) {
@@ -16043,7 +16303,7 @@ var init_snapshotsDiffer = __esm({
16043
16303
  });
16044
16304
  const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
16045
16305
  return {
16046
- statements: filteredJsonStatements,
16306
+ statements: filteredEnumsJsonStatements,
16047
16307
  sqlStatements: uniqueSqlStatements,
16048
16308
  _meta
16049
16309
  };
@@ -16169,6 +16429,8 @@ var init_snapshotsDiffer = __esm({
16169
16429
  const jsonAddedUniqueConstraints = [];
16170
16430
  const jsonDeletedUniqueConstraints = [];
16171
16431
  const jsonAlteredUniqueConstraints = [];
16432
+ const jsonCreatedCheckConstraints = [];
16433
+ const jsonDeletedCheckConstraints = [];
16172
16434
  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
16173
16435
  const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
16174
16436
  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
@@ -16207,6 +16469,8 @@ var init_snapshotsDiffer = __esm({
16207
16469
  let addedUniqueConstraints = [];
16208
16470
  let deletedUniqueConstraints = [];
16209
16471
  let alteredUniqueConstraints = [];
16472
+ let createdCheckConstraints = [];
16473
+ let deletedCheckConstraints = [];
16210
16474
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
16211
16475
  it.name,
16212
16476
  it.schema,
@@ -16231,12 +16495,30 @@ var init_snapshotsDiffer = __esm({
16231
16495
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16232
16496
  );
16233
16497
  }
16498
+ createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16499
+ deletedCheckConstraints = prepareDeleteCheckConstraint(
16500
+ it.name,
16501
+ it.schema,
16502
+ it.deletedCheckConstraints
16503
+ );
16504
+ if (it.alteredCheckConstraints && action !== "push") {
16505
+ const added = {};
16506
+ const deleted = {};
16507
+ for (const k of Object.keys(it.alteredCheckConstraints)) {
16508
+ added[k] = it.alteredCheckConstraints[k].__new;
16509
+ deleted[k] = it.alteredCheckConstraints[k].__old;
16510
+ }
16511
+ createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16512
+ deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16513
+ }
16234
16514
  jsonAddedCompositePKs.push(...addedCompositePKs);
16235
16515
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16236
16516
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16237
16517
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16238
16518
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16239
16519
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
16520
+ jsonCreatedCheckConstraints.push(...createdCheckConstraints);
16521
+ jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16240
16522
  });
16241
16523
  const rColumns = jsonRenameColumnsStatements.map((it) => {
16242
16524
  const tableName = it.tableName;
@@ -16332,6 +16614,7 @@ var init_snapshotsDiffer = __esm({
16332
16614
  jsonStatements.push(...jsonRenameTables);
16333
16615
  jsonStatements.push(...jsonRenameColumnsStatements);
16334
16616
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16617
+ jsonStatements.push(...jsonDeletedCheckConstraints);
16335
16618
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16336
16619
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16337
16620
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -16342,11 +16625,11 @@ var init_snapshotsDiffer = __esm({
16342
16625
  jsonStatements.push(...jsonAddColumnsStatemets);
16343
16626
  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
16344
16627
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16628
+ jsonStatements.push(...jsonCreatedCheckConstraints);
16345
16629
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16346
16630
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16347
16631
  jsonStatements.push(...jsonDropColumnsStatemets);
16348
16632
  jsonStatements.push(...jsonAlteredCompositePKs);
16349
- jsonStatements.push(...jsonAddedUniqueConstraints);
16350
16633
  jsonStatements.push(...jsonAlteredUniqueConstraints);
16351
16634
  const sqlStatements = fromJson(jsonStatements, "mysql");
16352
16635
  const uniqueSqlStatements = [];
@@ -16474,6 +16757,8 @@ var init_snapshotsDiffer = __esm({
16474
16757
  const jsonAddedUniqueConstraints = [];
16475
16758
  const jsonDeletedUniqueConstraints = [];
16476
16759
  const jsonAlteredUniqueConstraints = [];
16760
+ const jsonDeletedCheckConstraints = [];
16761
+ const jsonCreatedCheckConstraints = [];
16477
16762
  allAltered.forEach((it) => {
16478
16763
  let addedColumns = [];
16479
16764
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -16530,12 +16815,56 @@ var init_snapshotsDiffer = __esm({
16530
16815
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16531
16816
  );
16532
16817
  }
16818
+ let createdCheckConstraints = [];
16819
+ let deletedCheckConstraints = [];
16820
+ addedUniqueConstraints = prepareAddUniqueConstraintPg(
16821
+ it.name,
16822
+ it.schema,
16823
+ it.addedUniqueConstraints
16824
+ );
16825
+ deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
16826
+ it.name,
16827
+ it.schema,
16828
+ it.deletedUniqueConstraints
16829
+ );
16830
+ if (it.alteredUniqueConstraints) {
16831
+ const added = {};
16832
+ const deleted = {};
16833
+ for (const k of Object.keys(it.alteredUniqueConstraints)) {
16834
+ added[k] = it.alteredUniqueConstraints[k].__new;
16835
+ deleted[k] = it.alteredUniqueConstraints[k].__old;
16836
+ }
16837
+ addedUniqueConstraints.push(
16838
+ ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
16839
+ );
16840
+ deletedUniqueConstraints.push(
16841
+ ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16842
+ );
16843
+ }
16844
+ createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
16845
+ deletedCheckConstraints = prepareDeleteCheckConstraint(
16846
+ it.name,
16847
+ it.schema,
16848
+ it.deletedCheckConstraints
16849
+ );
16850
+ if (it.alteredCheckConstraints && action !== "push") {
16851
+ const added = {};
16852
+ const deleted = {};
16853
+ for (const k of Object.keys(it.alteredCheckConstraints)) {
16854
+ added[k] = it.alteredCheckConstraints[k].__new;
16855
+ deleted[k] = it.alteredCheckConstraints[k].__old;
16856
+ }
16857
+ createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
16858
+ deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
16859
+ }
16533
16860
  jsonAddedCompositePKs.push(...addedCompositePKs);
16534
16861
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16535
16862
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16536
16863
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16537
16864
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16538
16865
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
16866
+ jsonCreatedCheckConstraints.push(...createdCheckConstraints);
16867
+ jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16539
16868
  });
16540
16869
  const rColumns = jsonRenameColumnsStatements.map((it) => {
16541
16870
  const tableName = it.tableName;
@@ -16620,6 +16949,7 @@ var init_snapshotsDiffer = __esm({
16620
16949
  jsonStatements.push(...jsonRenameTables);
16621
16950
  jsonStatements.push(...jsonRenameColumnsStatements);
16622
16951
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
16952
+ jsonStatements.push(...jsonDeletedCheckConstraints);
16623
16953
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16624
16954
  jsonStatements.push(...jsonDeletedCompositePKs);
16625
16955
  jsonStatements.push(...jsonTableAlternations);
@@ -16627,6 +16957,7 @@ var init_snapshotsDiffer = __esm({
16627
16957
  jsonStatements.push(...jsonAddColumnsStatemets);
16628
16958
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16629
16959
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16960
+ jsonStatements.push(...jsonCreatedCheckConstraints);
16630
16961
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16631
16962
  jsonStatements.push(...jsonDropColumnsStatemets);
16632
16963
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -16770,6 +17101,8 @@ var init_snapshotsDiffer = __esm({
16770
17101
  const jsonAddedUniqueConstraints = [];
16771
17102
  const jsonDeletedUniqueConstraints = [];
16772
17103
  const jsonAlteredUniqueConstraints = [];
17104
+ const jsonDeletedCheckConstraints = [];
17105
+ const jsonCreatedCheckConstraints = [];
16773
17106
  allAltered.forEach((it) => {
16774
17107
  let addedColumns = [];
16775
17108
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -16802,6 +17135,8 @@ var init_snapshotsDiffer = __esm({
16802
17135
  let addedUniqueConstraints = [];
16803
17136
  let deletedUniqueConstraints = [];
16804
17137
  let alteredUniqueConstraints = [];
17138
+ let createdCheckConstraints = [];
17139
+ let deletedCheckConstraints = [];
16805
17140
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
16806
17141
  it.name,
16807
17142
  it.schema,
@@ -16826,12 +17161,30 @@ var init_snapshotsDiffer = __esm({
16826
17161
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
16827
17162
  );
16828
17163
  }
17164
+ createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
17165
+ deletedCheckConstraints = prepareDeleteCheckConstraint(
17166
+ it.name,
17167
+ it.schema,
17168
+ it.deletedCheckConstraints
17169
+ );
17170
+ if (it.alteredCheckConstraints && action !== "push") {
17171
+ const added = {};
17172
+ const deleted = {};
17173
+ for (const k of Object.keys(it.alteredCheckConstraints)) {
17174
+ added[k] = it.alteredCheckConstraints[k].__new;
17175
+ deleted[k] = it.alteredCheckConstraints[k].__old;
17176
+ }
17177
+ createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
17178
+ deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
17179
+ }
16829
17180
  jsonAddedCompositePKs.push(...addedCompositePKs);
16830
17181
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
16831
17182
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
16832
17183
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
16833
17184
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
16834
17185
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
17186
+ jsonCreatedCheckConstraints.push(...createdCheckConstraints);
17187
+ jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
16835
17188
  });
16836
17189
  const jsonTableAlternations = allAltered.map((it) => {
16837
17190
  return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json22);
@@ -16909,6 +17262,7 @@ var init_snapshotsDiffer = __esm({
16909
17262
  jsonStatements.push(...jsonRenameTables);
16910
17263
  jsonStatements.push(...jsonRenameColumnsStatements);
16911
17264
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
17265
+ jsonStatements.push(...jsonDeletedCheckConstraints);
16912
17266
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
16913
17267
  jsonStatements.push(...jsonDeletedCompositePKs);
16914
17268
  jsonStatements.push(...jsonTableAlternations);
@@ -16916,6 +17270,7 @@ var init_snapshotsDiffer = __esm({
16916
17270
  jsonStatements.push(...jsonAddColumnsStatemets);
16917
17271
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16918
17272
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
17273
+ jsonStatements.push(...jsonCreatedCheckConstraints);
16919
17274
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16920
17275
  jsonStatements.push(...jsonDropColumnsStatemets);
16921
17276
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -26033,6 +26388,7 @@ var init_pgSerializer = __esm({
26033
26388
  const sequencesToReturn = {};
26034
26389
  const indexesInSchema = {};
26035
26390
  for (const table4 of tables) {
26391
+ const checksInTable = {};
26036
26392
  const {
26037
26393
  name: tableName,
26038
26394
  columns,
@@ -26048,6 +26404,7 @@ var init_pgSerializer = __esm({
26048
26404
  }
26049
26405
  const columnsObject = {};
26050
26406
  const indexesObject = {};
26407
+ const checksObject = {};
26051
26408
  const foreignKeysObject = {};
26052
26409
  const primaryKeysObject = {};
26053
26410
  const uniqueConstraintObject = {};
@@ -26313,6 +26670,33 @@ ${withStyle.errorWarning(
26313
26670
  with: value.config.with ?? {}
26314
26671
  };
26315
26672
  });
26673
+ checks.forEach((check) => {
26674
+ const checkName = check.name;
26675
+ if (typeof checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] !== "undefined") {
26676
+ if (checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].includes(check.name)) {
26677
+ console.log(
26678
+ `
26679
+ ${withStyle.errorWarning(
26680
+ `We've found duplicated check constraint name across ${source_default.underline.blue(
26681
+ schema4 ?? "public"
26682
+ )} schema in ${source_default.underline.blue(
26683
+ tableName
26684
+ )}. Please rename your check constraint in either the ${source_default.underline.blue(
26685
+ tableName
26686
+ )} table or the table with the duplicated check contraint name`
26687
+ )}`
26688
+ );
26689
+ process.exit(1);
26690
+ }
26691
+ checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].push(checkName);
26692
+ } else {
26693
+ checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] = [check.name];
26694
+ }
26695
+ checksObject[checkName] = {
26696
+ name: checkName,
26697
+ value: dialect4.sqlToQuery(check.value).sql
26698
+ };
26699
+ });
26316
26700
  const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
26317
26701
  result[tableKey2] = {
26318
26702
  name: tableName,
@@ -26321,7 +26705,8 @@ ${withStyle.errorWarning(
26321
26705
  indexes: indexesObject,
26322
26706
  foreignKeys: foreignKeysObject,
26323
26707
  compositePrimaryKeys: primaryKeysObject,
26324
- uniqueConstraints: uniqueConstraintObject
26708
+ uniqueConstraints: uniqueConstraintObject,
26709
+ checkConstraints: checksObject
26325
26710
  };
26326
26711
  }
26327
26712
  for (const sequence of sequences) {
@@ -26410,6 +26795,7 @@ ${withStyle.errorWarning(
26410
26795
  let indexesCount = 0;
26411
26796
  let foreignKeysCount = 0;
26412
26797
  let tableCount = 0;
26798
+ let checksCount = 0;
26413
26799
  const sequencesToReturn = {};
26414
26800
  const seqWhere = schemaFilters.map((t) => `schemaname = '${t}'`).join(" or ");
26415
26801
  const allSequences = await db.query(
@@ -26479,7 +26865,8 @@ ${withStyle.errorWarning(
26479
26865
  const indexToReturn = {};
26480
26866
  const foreignKeysToReturn = {};
26481
26867
  const primaryKeys = {};
26482
- const uniqueConstrains = {};
26868
+ const uniqueConstraints = {};
26869
+ const checkConstraints = {};
26483
26870
  const tableResponse = await db.query(
26484
26871
  `SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
26485
26872
  , CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
@@ -26517,55 +26904,97 @@ ${withStyle.errorWarning(
26517
26904
  ORDER BY a.attnum;`
26518
26905
  );
26519
26906
  const tableConstraints = await db.query(
26520
- `SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
26521
- FROM information_schema.table_constraints tc
26522
- JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
26523
- JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
26524
- AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
26525
- WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
26907
+ `SELECT c.column_name,
26908
+ c.data_type,
26909
+ tc.constraint_type,
26910
+ tc.constraint_name,
26911
+ tc.constraint_schema,
26912
+ pg_get_constraintdef(con.oid) AS check_constraint_definition
26913
+ FROM information_schema.table_constraints tc
26914
+ JOIN information_schema.constraint_column_usage AS ccu
26915
+ USING (constraint_schema, constraint_name)
26916
+ JOIN information_schema.columns AS c
26917
+ ON c.table_schema = tc.constraint_schema
26918
+ AND tc.table_name = c.table_name
26919
+ AND ccu.column_name = c.column_name
26920
+ JOIN pg_constraint con
26921
+ ON con.conname = tc.constraint_name
26922
+ AND con.conrelid = (
26923
+ SELECT oid
26924
+ FROM pg_class
26925
+ WHERE relname = tc.table_name
26926
+ AND relnamespace = (
26927
+ SELECT oid
26928
+ FROM pg_namespace
26929
+ WHERE nspname = tc.constraint_schema
26930
+ )
26931
+ )
26932
+ WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
26526
26933
  );
26934
+ const tableChecks = await db.query(`SELECT
26935
+ tc.constraint_name,
26936
+ tc.constraint_type,
26937
+ pg_get_constraintdef(con.oid) AS constraint_definition
26938
+ FROM
26939
+ information_schema.table_constraints AS tc
26940
+ JOIN pg_constraint AS con
26941
+ ON tc.constraint_name = con.conname
26942
+ AND con.conrelid = (
26943
+ SELECT oid
26944
+ FROM pg_class
26945
+ WHERE relname = tc.table_name
26946
+ AND relnamespace = (
26947
+ SELECT oid
26948
+ FROM pg_namespace
26949
+ WHERE nspname = tc.constraint_schema
26950
+ )
26951
+ )
26952
+ WHERE
26953
+ tc.table_name = '${tableName}'
26954
+ AND tc.constraint_schema = '${tableSchema}'
26955
+ AND tc.constraint_type = 'CHECK';`);
26527
26956
  columnsCount += tableResponse.length;
26528
26957
  if (progressCallback) {
26529
26958
  progressCallback("columns", columnsCount, "fetching");
26530
26959
  }
26531
26960
  const tableForeignKeys = await db.query(
26532
26961
  `SELECT
26533
- con.contype AS constraint_type,
26534
- nsp.nspname AS constraint_schema,
26535
- con.conname AS constraint_name,
26536
- rel.relname AS table_name,
26537
- att.attname AS column_name,
26538
- fnsp.nspname AS foreign_table_schema,
26539
- frel.relname AS foreign_table_name,
26540
- fatt.attname AS foreign_column_name,
26541
- CASE con.confupdtype
26542
- WHEN 'a' THEN 'NO ACTION'
26543
- WHEN 'r' THEN 'RESTRICT'
26544
- WHEN 'n' THEN 'SET NULL'
26545
- WHEN 'c' THEN 'CASCADE'
26546
- WHEN 'd' THEN 'SET DEFAULT'
26547
- END AS update_rule,
26548
- CASE con.confdeltype
26549
- WHEN 'a' THEN 'NO ACTION'
26550
- WHEN 'r' THEN 'RESTRICT'
26551
- WHEN 'n' THEN 'SET NULL'
26552
- WHEN 'c' THEN 'CASCADE'
26553
- WHEN 'd' THEN 'SET DEFAULT'
26554
- END AS delete_rule
26555
- FROM
26556
- pg_catalog.pg_constraint con
26557
- JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
26558
- JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
26559
- LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
26560
- AND att.attrelid = con.conrelid
26561
- LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
26562
- LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
26563
- LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
26564
- AND fatt.attrelid = con.confrelid
26565
- WHERE
26566
- nsp.nspname = '${tableSchema}'
26567
- AND rel.relname = '${tableName}'
26568
- AND con.contype IN ('f');`
26962
+ con.contype AS constraint_type,
26963
+ nsp.nspname AS constraint_schema,
26964
+ con.conname AS constraint_name,
26965
+ rel.relname AS table_name,
26966
+ att.attname AS column_name,
26967
+ fnsp.nspname AS foreign_table_schema,
26968
+ frel.relname AS foreign_table_name,
26969
+ fatt.attname AS foreign_column_name,
26970
+ CASE con.confupdtype
26971
+ WHEN 'a' THEN 'NO ACTION'
26972
+ WHEN 'r' THEN 'RESTRICT'
26973
+ WHEN 'n' THEN 'SET NULL'
26974
+ WHEN 'c' THEN 'CASCADE'
26975
+ WHEN 'd' THEN 'SET DEFAULT'
26976
+ END AS update_rule,
26977
+ CASE con.confdeltype
26978
+ WHEN 'a' THEN 'NO ACTION'
26979
+ WHEN 'r' THEN 'RESTRICT'
26980
+ WHEN 'n' THEN 'SET NULL'
26981
+ WHEN 'c' THEN 'CASCADE'
26982
+ WHEN 'd' THEN 'SET DEFAULT'
26983
+ END AS delete_rule
26984
+ FROM
26985
+ pg_catalog.pg_constraint con
26986
+ JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
26987
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
26988
+ LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
26989
+ AND att.attrelid = con.conrelid
26990
+ LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
26991
+ LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
26992
+ LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
26993
+ AND fatt.attrelid = con.confrelid
26994
+ WHERE
26995
+ nsp.nspname = '${tableSchema}'
26996
+ AND rel.relname = '${tableName}'
26997
+ AND con.contype IN ('f');`
26569
26998
  );
26570
26999
  foreignKeysCount += tableForeignKeys.length;
26571
27000
  if (progressCallback) {
@@ -26607,16 +27036,29 @@ ${withStyle.errorWarning(
26607
27036
  for (const unqs of uniqueConstrainsRows) {
26608
27037
  const columnName = unqs.column_name;
26609
27038
  const constraintName = unqs.constraint_name;
26610
- if (typeof uniqueConstrains[constraintName] !== "undefined") {
26611
- uniqueConstrains[constraintName].columns.push(columnName);
27039
+ if (typeof uniqueConstraints[constraintName] !== "undefined") {
27040
+ uniqueConstraints[constraintName].columns.push(columnName);
26612
27041
  } else {
26613
- uniqueConstrains[constraintName] = {
27042
+ uniqueConstraints[constraintName] = {
26614
27043
  columns: [columnName],
26615
27044
  nullsNotDistinct: false,
26616
27045
  name: constraintName
26617
27046
  };
26618
27047
  }
26619
27048
  }
27049
+ checksCount += tableChecks.length;
27050
+ if (progressCallback) {
27051
+ progressCallback("checks", checksCount, "fetching");
27052
+ }
27053
+ for (const checks of tableChecks) {
27054
+ let checkValue = checks.constraint_definition;
27055
+ const constraintName = checks.constraint_name;
27056
+ checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
27057
+ checkConstraints[constraintName] = {
27058
+ name: constraintName,
27059
+ value: checkValue
27060
+ };
27061
+ }
26620
27062
  for (const columnResponse of tableResponse) {
26621
27063
  const columnName = columnResponse.attname;
26622
27064
  const columnAdditionalDT = columnResponse.additional_dt;
@@ -26860,7 +27302,8 @@ ${withStyle.errorWarning(
26860
27302
  indexes: indexToReturn,
26861
27303
  foreignKeys: foreignKeysToReturn,
26862
27304
  compositePrimaryKeys: primaryKeys,
26863
- uniqueConstraints: uniqueConstrains
27305
+ uniqueConstraints,
27306
+ checkConstraints
26864
27307
  };
26865
27308
  } catch (e) {
26866
27309
  rej(e);
@@ -26878,6 +27321,7 @@ ${withStyle.errorWarning(
26878
27321
  progressCallback("columns", columnsCount, "done");
26879
27322
  progressCallback("indexes", indexesCount, "done");
26880
27323
  progressCallback("fks", foreignKeysCount, "done");
27324
+ progressCallback("checks", checksCount, "done");
26881
27325
  }
26882
27326
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
26883
27327
  return {
@@ -26949,6 +27393,8 @@ ${withStyle.errorWarning(
26949
27393
  }
26950
27394
  return columnDefaultAsString;
26951
27395
  }
27396
+ } else if (column4.data_type.includes("numeric")) {
27397
+ return columnDefaultAsString.includes("'") ? columnDefaultAsString : `'${columnDefaultAsString}'`;
26952
27398
  } else if (column4.data_type === "json" || column4.data_type === "jsonb") {
26953
27399
  const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
26954
27400
  return `'${jsonWithoutSpaces}'::${column4.data_type}`;
@@ -30475,10 +30921,13 @@ var init_sqliteSerializer = __esm({
30475
30921
  const foreignKeysObject = {};
30476
30922
  const primaryKeysObject = {};
30477
30923
  const uniqueConstraintObject = {};
30924
+ const checkConstraintObject = {};
30925
+ const checksInTable = {};
30478
30926
  const {
30479
30927
  name: tableName,
30480
30928
  columns,
30481
30929
  indexes,
30930
+ checks,
30482
30931
  foreignKeys: tableForeignKeys,
30483
30932
  primaryKeys,
30484
30933
  uniqueConstraints
@@ -30654,13 +31103,39 @@ The unique constraint ${source_default.underline.blue(
30654
31103
  columnsObject[getColumnCasing(it.columns[0], casing2)].primaryKey = true;
30655
31104
  }
30656
31105
  });
31106
+ checks.forEach((check) => {
31107
+ const checkName = check.name;
31108
+ if (typeof checksInTable[tableName] !== "undefined") {
31109
+ if (checksInTable[tableName].includes(check.name)) {
31110
+ console.log(
31111
+ `
31112
+ ${withStyle.errorWarning(
31113
+ `We've found duplicated check constraint name in ${source_default.underline.blue(
31114
+ tableName
31115
+ )}. Please rename your check constraint in the ${source_default.underline.blue(
31116
+ tableName
31117
+ )} table`
31118
+ )}`
31119
+ );
31120
+ process.exit(1);
31121
+ }
31122
+ checksInTable[tableName].push(checkName);
31123
+ } else {
31124
+ checksInTable[tableName] = [check.name];
31125
+ }
31126
+ checkConstraintObject[checkName] = {
31127
+ name: checkName,
31128
+ value: dialect4.sqlToQuery(check.value).sql
31129
+ };
31130
+ });
30657
31131
  result[tableName] = {
30658
31132
  name: tableName,
30659
31133
  columns: columnsObject,
30660
31134
  indexes: indexesObject,
30661
31135
  foreignKeys: foreignKeysObject,
30662
31136
  compositePrimaryKeys: primaryKeysObject,
30663
- uniqueConstraints: uniqueConstraintObject
31137
+ uniqueConstraints: uniqueConstraintObject,
31138
+ checkConstraints: checkConstraintObject
30664
31139
  };
30665
31140
  }
30666
31141
  return {
@@ -30707,6 +31182,7 @@ The unique constraint ${source_default.underline.blue(
30707
31182
  let tablesCount = /* @__PURE__ */ new Set();
30708
31183
  let indexesCount = 0;
30709
31184
  let foreignKeysCount = 0;
31185
+ let checksCount = 0;
30710
31186
  const tableToPk = {};
30711
31187
  let tableToGeneratedColumnsInfo = {};
30712
31188
  for (const column4 of columns) {
@@ -30764,7 +31240,8 @@ The unique constraint ${source_default.underline.blue(
30764
31240
  compositePrimaryKeys: {},
30765
31241
  indexes: {},
30766
31242
  foreignKeys: {},
30767
- uniqueConstraints: {}
31243
+ uniqueConstraints: {},
31244
+ checkConstraints: {}
30768
31245
  };
30769
31246
  } else {
30770
31247
  result[tableName].columns[columnName] = newColumn;
@@ -30878,6 +31355,56 @@ WHERE
30878
31355
  progressCallback("indexes", indexesCount, "done");
30879
31356
  progressCallback("enums", 0, "done");
30880
31357
  }
31358
+ const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
31359
+ const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
31360
+ let checkCounter = 0;
31361
+ const checkConstraints = {};
31362
+ const checks = await db.query(`SELECT name as "tableName", sql as "sql"
31363
+ FROM sqlite_master
31364
+ WHERE type = 'table' AND name != 'sqlite_sequence';`);
31365
+ for (const check of checks) {
31366
+ if (!tablesFilter(check.tableName)) continue;
31367
+ const { tableName, sql: sql2 } = check;
31368
+ let namedChecks = [...sql2.matchAll(namedCheckPattern)];
31369
+ if (namedChecks.length > 0) {
31370
+ namedChecks.forEach(([_2, checkName, checkValue]) => {
31371
+ checkConstraints[checkName] = {
31372
+ name: checkName,
31373
+ value: checkValue.trim()
31374
+ };
31375
+ });
31376
+ } else {
31377
+ let unnamedChecks = [...sql2.matchAll(unnamedCheckPattern)];
31378
+ unnamedChecks.forEach(([_2, checkValue]) => {
31379
+ let checkName = `${tableName}_check_${++checkCounter}`;
31380
+ checkConstraints[checkName] = {
31381
+ name: checkName,
31382
+ value: checkValue.trim()
31383
+ };
31384
+ });
31385
+ }
31386
+ checksCount += Object.values(checkConstraints).length;
31387
+ if (progressCallback) {
31388
+ progressCallback("checks", checksCount, "fetching");
31389
+ }
31390
+ const table4 = result[tableName];
31391
+ if (!table4) {
31392
+ result[tableName] = {
31393
+ name: tableName,
31394
+ columns: {},
31395
+ compositePrimaryKeys: {},
31396
+ indexes: {},
31397
+ foreignKeys: {},
31398
+ uniqueConstraints: {},
31399
+ checkConstraints
31400
+ };
31401
+ } else {
31402
+ result[tableName].checkConstraints = checkConstraints;
31403
+ }
31404
+ }
31405
+ if (progressCallback) {
31406
+ progressCallback("checks", checksCount, "done");
31407
+ }
30881
31408
  return {
30882
31409
  version: "6",
30883
31410
  dialect: "sqlite",
@@ -35173,6 +35700,7 @@ var init_mysqlSerializer = __esm({
35173
35700
  indexes,
35174
35701
  foreignKeys,
35175
35702
  schema: schema4,
35703
+ checks,
35176
35704
  primaryKeys,
35177
35705
  uniqueConstraints
35178
35706
  } = getTableConfig3(table4);
@@ -35181,6 +35709,8 @@ var init_mysqlSerializer = __esm({
35181
35709
  const foreignKeysObject = {};
35182
35710
  const primaryKeysObject = {};
35183
35711
  const uniqueConstraintObject = {};
35712
+ const checkConstraintObject = {};
35713
+ let checksInTable = {};
35184
35714
  columns.forEach((column4) => {
35185
35715
  const name2 = getColumnCasing(column4, casing2);
35186
35716
  const notNull = column4.notNull;
@@ -35411,6 +35941,32 @@ We have encountered a collision between the index name on columns ${source_defau
35411
35941
  lock: value.config.lock
35412
35942
  };
35413
35943
  });
35944
+ checks.forEach((check) => {
35945
+ check;
35946
+ const checkName = check.name;
35947
+ if (typeof checksInTable[tableName] !== "undefined") {
35948
+ if (checksInTable[tableName].includes(check.name)) {
35949
+ console.log(
35950
+ `
35951
+ ${withStyle.errorWarning(
35952
+ `We've found duplicated check constraint name in ${source_default.underline.blue(
35953
+ tableName
35954
+ )}. Please rename your check constraint in the ${source_default.underline.blue(
35955
+ tableName
35956
+ )} table`
35957
+ )}`
35958
+ );
35959
+ process.exit(1);
35960
+ }
35961
+ checksInTable[tableName].push(checkName);
35962
+ } else {
35963
+ checksInTable[tableName] = [check.name];
35964
+ }
35965
+ checkConstraintObject[checkName] = {
35966
+ name: checkName,
35967
+ value: dialect4.sqlToQuery(check.value).sql
35968
+ };
35969
+ });
35414
35970
  if (!schema4) {
35415
35971
  result[tableName] = {
35416
35972
  name: tableName,
@@ -35418,7 +35974,8 @@ We have encountered a collision between the index name on columns ${source_defau
35418
35974
  indexes: indexesObject,
35419
35975
  foreignKeys: foreignKeysObject,
35420
35976
  compositePrimaryKeys: primaryKeysObject,
35421
- uniqueConstraints: uniqueConstraintObject
35977
+ uniqueConstraints: uniqueConstraintObject,
35978
+ checkConstraint: checkConstraintObject
35422
35979
  };
35423
35980
  }
35424
35981
  }
@@ -35445,6 +36002,7 @@ We have encountered a collision between the index name on columns ${source_defau
35445
36002
  let tablesCount = /* @__PURE__ */ new Set();
35446
36003
  let indexesCount = 0;
35447
36004
  let foreignKeysCount = 0;
36005
+ let checksCount = 0;
35448
36006
  const idxs = await db.query(
35449
36007
  `select * from INFORMATION_SCHEMA.STATISTICS
35450
36008
  WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
@@ -35539,7 +36097,8 @@ We have encountered a collision between the index name on columns ${source_defau
35539
36097
  compositePrimaryKeys: {},
35540
36098
  indexes: {},
35541
36099
  foreignKeys: {},
35542
- uniqueConstraints: {}
36100
+ uniqueConstraints: {},
36101
+ checkConstraint: {}
35543
36102
  };
35544
36103
  } else {
35545
36104
  result[tableName].columns[columnName] = newColumn;
@@ -35688,6 +36247,38 @@ We have encountered a collision between the index name on columns ${source_defau
35688
36247
  progressCallback("indexes", indexesCount, "done");
35689
36248
  progressCallback("enums", 0, "done");
35690
36249
  }
36250
+ const checkConstraints = await db.query(
36251
+ `SELECT
36252
+ tc.table_name,
36253
+ tc.constraint_name,
36254
+ cc.check_clause
36255
+ FROM
36256
+ information_schema.table_constraints tc
36257
+ JOIN
36258
+ information_schema.check_constraints cc
36259
+ ON tc.constraint_name = cc.constraint_name
36260
+ WHERE
36261
+ tc.constraint_schema = '${inputSchema}'
36262
+ AND
36263
+ tc.constraint_type = 'CHECK';`
36264
+ );
36265
+ checksCount += checkConstraints.length;
36266
+ if (progressCallback) {
36267
+ progressCallback("checks", checksCount, "fetching");
36268
+ }
36269
+ for (const checkConstraintRow of checkConstraints) {
36270
+ const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
36271
+ const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
36272
+ const tableName = checkConstraintRow["TABLE_NAME"];
36273
+ const tableInResult = result[tableName];
36274
+ tableInResult.checkConstraint[constraintName] = {
36275
+ name: constraintName,
36276
+ value: constraintValue
36277
+ };
36278
+ }
36279
+ if (progressCallback) {
36280
+ progressCallback("checks", checksCount, "done");
36281
+ }
35691
36282
  return {
35692
36283
  version: "5",
35693
36284
  dialect: "mysql",