drizzle-kit 0.17.0-6323eb6 → 0.17.0-c637bb8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +110 -12
  2. package/package.json +3 -3
  3. package/utils.js +43 -2
package/index.js CHANGED
@@ -6345,7 +6345,7 @@ var init_global = __esm({
6345
6345
  });
6346
6346
 
6347
6347
  // src/serializer/mysqlSchema.ts
6348
- var index, fk, column, tableV3, compositePK, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV4, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
6348
+ var index, fk, column, tableV3, compositePK, tableV4, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternal, schemaV3, schemaV4, schema2, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlSchemeV4, squashMysqlScheme, mysqlSchema, mysqlSchemaV4, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
6349
6349
  var init_mysqlSchema = __esm({
6350
6350
  "src/serializer/mysqlSchema.ts"() {
6351
6351
  "use strict";
@@ -6388,6 +6388,13 @@ var init_mysqlSchema = __esm({
6388
6388
  name: stringType(),
6389
6389
  columns: stringType().array()
6390
6390
  }).strict();
6391
+ tableV4 = objectType({
6392
+ name: stringType(),
6393
+ schema: stringType().optional(),
6394
+ columns: recordType(stringType(), column),
6395
+ indexes: recordType(stringType(), index),
6396
+ foreignKeys: recordType(stringType(), fk)
6397
+ }).strict();
6391
6398
  table = objectType({
6392
6399
  name: stringType(),
6393
6400
  schema: stringType().optional(),
@@ -6409,7 +6416,7 @@ var init_mysqlSchema = __esm({
6409
6416
  schemaInternalV4 = objectType({
6410
6417
  version: literalType("4"),
6411
6418
  dialect,
6412
- tables: recordType(stringType(), table),
6419
+ tables: recordType(stringType(), tableV4),
6413
6420
  schemas: recordType(stringType(), stringType())
6414
6421
  }).strict();
6415
6422
  schemaInternal = objectType({
@@ -6426,6 +6433,13 @@ var init_mysqlSchema = __esm({
6426
6433
  schemaV3 = schemaInternalV3.merge(schemaHash);
6427
6434
  schemaV4 = schemaInternalV4.merge(schemaHash);
6428
6435
  schema2 = schemaInternal.merge(schemaHash);
6436
+ tableSquashedV4 = objectType({
6437
+ name: stringType(),
6438
+ schema: stringType().optional(),
6439
+ columns: recordType(stringType(), column),
6440
+ indexes: recordType(stringType(), stringType()),
6441
+ foreignKeys: recordType(stringType(), stringType())
6442
+ }).strict();
6429
6443
  tableSquashed = objectType({
6430
6444
  name: stringType(),
6431
6445
  schema: stringType().optional(),
@@ -6440,6 +6454,12 @@ var init_mysqlSchema = __esm({
6440
6454
  tables: recordType(stringType(), tableSquashed),
6441
6455
  schemas: recordType(stringType(), stringType())
6442
6456
  }).strict();
6457
+ schemaSquashedV4 = objectType({
6458
+ version: literalType("4"),
6459
+ dialect,
6460
+ tables: recordType(stringType(), tableSquashedV4),
6461
+ schemas: recordType(stringType(), stringType())
6462
+ }).strict();
6443
6463
  MySqlSquasher = {
6444
6464
  squashIdx: (idx) => {
6445
6465
  var _a, _b, _c;
@@ -6491,6 +6511,34 @@ var init_mysqlSchema = __esm({
6491
6511
  return result;
6492
6512
  }
6493
6513
  };
6514
+ squashMysqlSchemeV4 = (json) => {
6515
+ const mappedTables = Object.fromEntries(
6516
+ Object.entries(json.tables).map((it) => {
6517
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6518
+ return MySqlSquasher.squashIdx(index4);
6519
+ });
6520
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6521
+ return MySqlSquasher.squashFK(fk4);
6522
+ });
6523
+ return [
6524
+ it[0],
6525
+ {
6526
+ name: it[1].name,
6527
+ schema: it[1].schema,
6528
+ columns: it[1].columns,
6529
+ indexes: squashedIndexes,
6530
+ foreignKeys: squashedFKs
6531
+ }
6532
+ ];
6533
+ })
6534
+ );
6535
+ return {
6536
+ version: "4",
6537
+ dialect: json.dialect,
6538
+ tables: mappedTables,
6539
+ schemas: json.schemas
6540
+ };
6541
+ };
6494
6542
  squashMysqlScheme = (json) => {
6495
6543
  const mappedTables = Object.fromEntries(
6496
6544
  Object.entries(json.tables).map((it) => {
@@ -6544,7 +6592,7 @@ var init_mysqlSchema = __esm({
6544
6592
  });
6545
6593
 
6546
6594
  // src/serializer/pgSchema.ts
6547
- var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternal, tableSquashed2, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
6595
+ var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, tableV42, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgSchemeV4, squashPgScheme, dryPg;
6548
6596
  var init_pgSchema = __esm({
6549
6597
  "src/serializer/pgSchema.ts"() {
6550
6598
  "use strict";
@@ -6639,6 +6687,13 @@ var init_pgSchema = __esm({
6639
6687
  name: stringType(),
6640
6688
  columns: stringType().array()
6641
6689
  }).strict();
6690
+ tableV42 = objectType({
6691
+ name: stringType(),
6692
+ schema: stringType(),
6693
+ columns: recordType(stringType(), column2),
6694
+ indexes: recordType(stringType(), index2),
6695
+ foreignKeys: recordType(stringType(), fk2)
6696
+ }).strict();
6642
6697
  table2 = objectType({
6643
6698
  name: stringType(),
6644
6699
  schema: stringType(),
@@ -6660,7 +6715,7 @@ var init_pgSchema = __esm({
6660
6715
  pgSchemaInternalV4 = objectType({
6661
6716
  version: literalType("4"),
6662
6717
  dialect: literalType("pg"),
6663
- tables: recordType(stringType(), table2),
6718
+ tables: recordType(stringType(), tableV42),
6664
6719
  enums: recordType(stringType(), enumSchema),
6665
6720
  schemas: recordType(stringType(), stringType())
6666
6721
  }).strict();
@@ -6684,6 +6739,20 @@ var init_pgSchema = __esm({
6684
6739
  foreignKeys: recordType(stringType(), stringType()),
6685
6740
  compositePrimaryKeys: recordType(stringType(), stringType())
6686
6741
  }).strict();
6742
+ tableSquashedV42 = objectType({
6743
+ name: stringType(),
6744
+ schema: stringType(),
6745
+ columns: recordType(stringType(), column2),
6746
+ indexes: recordType(stringType(), stringType()),
6747
+ foreignKeys: recordType(stringType(), stringType())
6748
+ }).strict();
6749
+ pgSchemaSquashedV4 = objectType({
6750
+ version: literalType("4"),
6751
+ dialect: enumType(["pg"]),
6752
+ tables: recordType(stringType(), tableSquashedV42),
6753
+ enums: recordType(stringType(), enumSchema),
6754
+ schemas: recordType(stringType(), stringType())
6755
+ }).strict();
6687
6756
  pgSchemaSquashed = objectType({
6688
6757
  version: literalType("5"),
6689
6758
  dialect: enumType(["pg"]),
@@ -6747,6 +6816,35 @@ var init_pgSchema = __esm({
6747
6816
  return result;
6748
6817
  }
6749
6818
  };
6819
+ squashPgSchemeV4 = (json) => {
6820
+ const mappedTables = Object.fromEntries(
6821
+ Object.entries(json.tables).map((it) => {
6822
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6823
+ return PgSquasher.squashIdx(index4);
6824
+ });
6825
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6826
+ return PgSquasher.squashFK(fk4);
6827
+ });
6828
+ return [
6829
+ it[0],
6830
+ {
6831
+ name: it[1].name,
6832
+ schema: it[1].schema,
6833
+ columns: it[1].columns,
6834
+ indexes: squashedIndexes,
6835
+ foreignKeys: squashedFKs
6836
+ }
6837
+ ];
6838
+ })
6839
+ );
6840
+ return {
6841
+ version: "4",
6842
+ dialect: json.dialect,
6843
+ tables: mappedTables,
6844
+ enums: json.enums,
6845
+ schemas: json.schemas
6846
+ };
6847
+ };
6750
6848
  squashPgScheme = (json) => {
6751
6849
  const mappedTables = Object.fromEntries(
6752
6850
  Object.entries(json.tables).map((it) => {
@@ -16712,7 +16810,7 @@ var init_pgUp = __esm({
16712
16810
  }
16713
16811
  mappedColumns[ckey] = { ...column6, default: newDefault, type: newType };
16714
16812
  }
16715
- mappedTables[key] = { ...table4, columns: mappedColumns };
16813
+ mappedTables[key] = { ...table4, columns: mappedColumns, compositePrimaryKeys: {} };
16716
16814
  }
16717
16815
  return {
16718
16816
  version: "5",
@@ -16972,7 +17070,7 @@ var init_mysqlUp = __esm({
16972
17070
  autoincrement: newAutoIncrement
16973
17071
  };
16974
17072
  }
16975
- mappedTables[key] = { ...table4, columns: mappedColumns };
17073
+ mappedTables[key] = { ...table4, columns: mappedColumns, compositePrimaryKeys: {} };
16976
17074
  }
16977
17075
  return {
16978
17076
  version: "5",
@@ -17229,8 +17327,8 @@ var init_upFolders = __esm({
17229
17327
  return upPgHandlerV4toV5(b);
17230
17328
  }
17231
17329
  const a = pgSchemaV4.parse(prev);
17232
- const json1 = squashPgScheme(a);
17233
- const json2 = squashPgScheme(b);
17330
+ const json1 = squashPgSchemeV4(a);
17331
+ const json2 = squashPgSchemeV4(b);
17234
17332
  const diffResult = applyJsonDiff(json1, json2);
17235
17333
  const parseResult = diffResultScheme.safeParse(diffResult);
17236
17334
  if (!parseResult.success) {
@@ -17301,8 +17399,8 @@ var init_upFolders = __esm({
17301
17399
  return upMySqlHandlerV4toV5(b);
17302
17400
  }
17303
17401
  const a = mysqlSchemaV4.parse(prev);
17304
- const json1 = squashMysqlScheme(a);
17305
- const json2 = squashMysqlScheme(b);
17402
+ const json1 = squashMysqlSchemeV4(a);
17403
+ const json2 = squashMysqlSchemeV4(b);
17306
17404
  const diffResult = applyJsonDiff(json1, json2);
17307
17405
  const parseResult = diffResultScheme.safeParse(diffResult);
17308
17406
  if (!parseResult.success) {
@@ -49199,8 +49297,8 @@ var package_default = {
49199
49297
  scripts: {
49200
49298
  "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
49201
49299
  "migrate:old:mysql": "drizzle-kit generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
49202
- "start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/introspect-pg --schema ./dev/introspect-pg/schema.ts",
49203
- "start:mysql": "node -r esbuild-register ./src/cli/index.ts generate:mysql --out ./dev/introspect-mysql --schema ./dev/introspect-mysql/schema.ts",
49300
+ "start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
49301
+ "start:mysql": "node -r esbuild-register ./src/cli/index.ts generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
49204
49302
  "check:pg": "node -r esbuild-register ./src/cli/index.ts check --out ./dev/migrations --dialect pg",
49205
49303
  "introspect:mysql": "node -r esbuild-register ./src/cli/index.ts introspect:mysql --out ./dev/introspect-mysql --connectionString",
49206
49304
  "introspect:pg": "node -r esbuild-register ./src/cli/index.ts introspect:pg --out ./dev/introspect-pg --connectionString=postgresql://postgres@localhost:5432/introspect",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.17.0-6323eb6",
3
+ "version": "0.17.0-c637bb8",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -10,8 +10,8 @@
10
10
  "scripts": {
11
11
  "migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
12
12
  "migrate:old:mysql": "drizzle-kit generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
13
- "start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/introspect-pg --schema ./dev/introspect-pg/schema.ts",
14
- "start:mysql": "node -r esbuild-register ./src/cli/index.ts generate:mysql --out ./dev/introspect-mysql --schema ./dev/introspect-mysql/schema.ts",
13
+ "start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
14
+ "start:mysql": "node -r esbuild-register ./src/cli/index.ts generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
15
15
  "check:pg": "node -r esbuild-register ./src/cli/index.ts check --out ./dev/migrations --dialect pg",
16
16
  "introspect:mysql": "node -r esbuild-register ./src/cli/index.ts introspect:mysql --out ./dev/introspect-mysql --connectionString",
17
17
  "introspect:pg": "node -r esbuild-register ./src/cli/index.ts introspect:pg --out ./dev/introspect-pg --connectionString=postgresql://postgres@localhost:5432/introspect",
package/utils.js CHANGED
@@ -10358,6 +10358,13 @@ var compositePK = objectType({
10358
10358
  name: stringType(),
10359
10359
  columns: stringType().array()
10360
10360
  }).strict();
10361
+ var tableV4 = objectType({
10362
+ name: stringType(),
10363
+ schema: stringType().optional(),
10364
+ columns: recordType(stringType(), column),
10365
+ indexes: recordType(stringType(), index),
10366
+ foreignKeys: recordType(stringType(), fk)
10367
+ }).strict();
10361
10368
  var table = objectType({
10362
10369
  name: stringType(),
10363
10370
  schema: stringType().optional(),
@@ -10379,7 +10386,7 @@ var schemaInternalV3 = objectType({
10379
10386
  var schemaInternalV4 = objectType({
10380
10387
  version: literalType("4"),
10381
10388
  dialect,
10382
- tables: recordType(stringType(), table),
10389
+ tables: recordType(stringType(), tableV4),
10383
10390
  schemas: recordType(stringType(), stringType())
10384
10391
  }).strict();
10385
10392
  var schemaInternal = objectType({
@@ -10396,6 +10403,13 @@ var schemaInternal = objectType({
10396
10403
  var schemaV3 = schemaInternalV3.merge(schemaHash);
10397
10404
  var schemaV4 = schemaInternalV4.merge(schemaHash);
10398
10405
  var schema = schemaInternal.merge(schemaHash);
10406
+ var tableSquashedV4 = objectType({
10407
+ name: stringType(),
10408
+ schema: stringType().optional(),
10409
+ columns: recordType(stringType(), column),
10410
+ indexes: recordType(stringType(), stringType()),
10411
+ foreignKeys: recordType(stringType(), stringType())
10412
+ }).strict();
10399
10413
  var tableSquashed = objectType({
10400
10414
  name: stringType(),
10401
10415
  schema: stringType().optional(),
@@ -10410,6 +10424,12 @@ var schemaSquashed = objectType({
10410
10424
  tables: recordType(stringType(), tableSquashed),
10411
10425
  schemas: recordType(stringType(), stringType())
10412
10426
  }).strict();
10427
+ var schemaSquashedV4 = objectType({
10428
+ version: literalType("4"),
10429
+ dialect,
10430
+ tables: recordType(stringType(), tableSquashedV4),
10431
+ schemas: recordType(stringType(), stringType())
10432
+ }).strict();
10413
10433
  var MySqlSquasher = {
10414
10434
  squashIdx: (idx) => {
10415
10435
  var _a, _b, _c;
@@ -10566,6 +10586,13 @@ var compositePK2 = objectType({
10566
10586
  name: stringType(),
10567
10587
  columns: stringType().array()
10568
10588
  }).strict();
10589
+ var tableV42 = objectType({
10590
+ name: stringType(),
10591
+ schema: stringType(),
10592
+ columns: recordType(stringType(), column2),
10593
+ indexes: recordType(stringType(), index2),
10594
+ foreignKeys: recordType(stringType(), fk2)
10595
+ }).strict();
10569
10596
  var table2 = objectType({
10570
10597
  name: stringType(),
10571
10598
  schema: stringType(),
@@ -10587,7 +10614,7 @@ var pgSchemaInternalV3 = objectType({
10587
10614
  var pgSchemaInternalV4 = objectType({
10588
10615
  version: literalType("4"),
10589
10616
  dialect: literalType("pg"),
10590
- tables: recordType(stringType(), table2),
10617
+ tables: recordType(stringType(), tableV42),
10591
10618
  enums: recordType(stringType(), enumSchema),
10592
10619
  schemas: recordType(stringType(), stringType())
10593
10620
  }).strict();
@@ -10611,6 +10638,20 @@ var tableSquashed2 = objectType({
10611
10638
  foreignKeys: recordType(stringType(), stringType()),
10612
10639
  compositePrimaryKeys: recordType(stringType(), stringType())
10613
10640
  }).strict();
10641
+ var tableSquashedV42 = objectType({
10642
+ name: stringType(),
10643
+ schema: stringType(),
10644
+ columns: recordType(stringType(), column2),
10645
+ indexes: recordType(stringType(), stringType()),
10646
+ foreignKeys: recordType(stringType(), stringType())
10647
+ }).strict();
10648
+ var pgSchemaSquashedV4 = objectType({
10649
+ version: literalType("4"),
10650
+ dialect: enumType(["pg"]),
10651
+ tables: recordType(stringType(), tableSquashedV42),
10652
+ enums: recordType(stringType(), enumSchema),
10653
+ schemas: recordType(stringType(), stringType())
10654
+ }).strict();
10614
10655
  var pgSchemaSquashed = objectType({
10615
10656
  version: literalType("5"),
10616
10657
  dialect: enumType(["pg"]),