drizzle-kit 0.20.14-c82ab68 → 0.20.14-d8f1e46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/bin.cjs +7142 -7442
  2. package/cli/commands/migrate.d.ts +24 -24
  3. package/cli/commands/mysqlIntrospect.d.ts +8 -8
  4. package/cli/commands/mysqlPushUtils.d.ts +2 -2
  5. package/cli/commands/mysqlUp.d.ts +2 -2
  6. package/cli/commands/pgConnect.d.ts +1 -1
  7. package/cli/commands/pgIntrospect.d.ts +9 -12
  8. package/cli/commands/pgPushUtils.d.ts +2 -2
  9. package/cli/commands/pgUp.d.ts +2 -2
  10. package/cli/commands/sqliteIntrospect.d.ts +9 -9
  11. package/cli/commands/sqlitePushUtils.d.ts +3 -3
  12. package/cli/commands/sqliteUtils.d.ts +162 -0
  13. package/cli/commands/upFolders.d.ts +1 -1
  14. package/cli/commands/utils.d.ts +259 -14
  15. package/cli/validations/common.d.ts +7 -205
  16. package/cli/validations/mysql.d.ts +1 -6
  17. package/cli/validations/pg.d.ts +1 -6
  18. package/cli/views.d.ts +1 -1
  19. package/global.d.ts +1 -1
  20. package/index.d.mts +6 -8
  21. package/index.d.ts +6 -8
  22. package/index.js +0 -1
  23. package/introspect-mysql.d.ts +1 -1
  24. package/introspect-pg.d.ts +2 -5
  25. package/introspect-sqlite.d.ts +1 -1
  26. package/jsonStatements.d.ts +1 -1
  27. package/package.json +2 -3
  28. package/payload.d.mts +988 -18
  29. package/payload.d.ts +988 -18
  30. package/payload.js +1616 -13426
  31. package/payload.mjs +1538 -2213
  32. package/schemaValidator.d.ts +40 -40
  33. package/serializer/mysqlSchema.d.ts +616 -1854
  34. package/serializer/mysqlSerializer.d.ts +2 -2
  35. package/serializer/pgSchema.d.ts +684 -1009
  36. package/serializer/sqliteSchema.d.ts +570 -144
  37. package/serializer/sqliteSerializer.d.ts +2 -2
  38. package/snapshotsDiffer.d.ts +20 -24
  39. package/utils-studio.js +15 -390
  40. package/utils-studio.mjs +15 -389
  41. package/utils.d.ts +12 -12
  42. package/utils.js +735 -849
  43. package/utils.mjs +736 -849
  44. package/cli/validations/cli.d.ts +0 -104
  45. package/cli/validations/sqlite.d.ts +0 -382
package/utils.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1079,7 +1078,6 @@ var require_hanji = __commonJS({
1079
1078
  var import_hanji, info;
1080
1079
  var init_views = __esm({
1081
1080
  "src/cli/views.ts"() {
1082
- "use strict";
1083
1081
  init_source();
1084
1082
  import_hanji = __toESM(require_hanji());
1085
1083
  info = (msg, greyMsg = "") => {
@@ -1088,26 +1086,6 @@ var init_views = __esm({
1088
1086
  }
1089
1087
  });
1090
1088
 
1091
- // src/global.ts
1092
- function assertUnreachable(x) {
1093
- throw new Error("Didn't expect to get here");
1094
- }
1095
- var originUUID, snapshotVersion, mapValues;
1096
- var init_global = __esm({
1097
- "src/global.ts"() {
1098
- "use strict";
1099
- originUUID = "00000000-0000-0000-0000-000000000000";
1100
- snapshotVersion = "6";
1101
- mapValues = (obj, map) => {
1102
- const result = Object.keys(obj).reduce(function(result2, key) {
1103
- result2[key] = map(obj[key]);
1104
- return result2;
1105
- }, {});
1106
- return result;
1107
- };
1108
- }
1109
- });
1110
-
1111
1089
  // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
1112
1090
  function getErrorMap() {
1113
1091
  return overrideErrorMap;
@@ -4247,751 +4225,10 @@ var init_lib = __esm({
4247
4225
  }
4248
4226
  });
4249
4227
 
4250
- // src/serializer/mysqlSchema.ts
4251
- var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternalV6, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, mysqlSchema, mysqlSchemaV5, backwardCompatibleMysqlSchema, dryMySql;
4252
- var init_mysqlSchema = __esm({
4253
- "src/serializer/mysqlSchema.ts"() {
4254
- "use strict";
4255
- init_global();
4256
- init_lib();
4257
- index = objectType({
4258
- name: stringType(),
4259
- columns: stringType().array(),
4260
- isUnique: booleanType(),
4261
- using: enumType(["btree", "hash"]).optional(),
4262
- algorithm: enumType(["default", "inplace", "copy"]).optional(),
4263
- lock: enumType(["default", "none", "shared", "exclusive"]).optional()
4264
- }).strict();
4265
- fk = objectType({
4266
- name: stringType(),
4267
- tableFrom: stringType(),
4268
- columnsFrom: stringType().array(),
4269
- tableTo: stringType(),
4270
- columnsTo: stringType().array(),
4271
- onUpdate: stringType().optional(),
4272
- onDelete: stringType().optional()
4273
- }).strict();
4274
- column = objectType({
4275
- name: stringType(),
4276
- type: stringType(),
4277
- primaryKey: booleanType(),
4278
- notNull: booleanType(),
4279
- autoincrement: booleanType().optional(),
4280
- default: anyType().optional(),
4281
- onUpdate: anyType().optional()
4282
- }).strict();
4283
- tableV3 = objectType({
4284
- name: stringType(),
4285
- columns: recordType(stringType(), column),
4286
- indexes: recordType(stringType(), index),
4287
- foreignKeys: recordType(stringType(), fk)
4288
- }).strict();
4289
- compositePK = objectType({
4290
- name: stringType(),
4291
- columns: stringType().array()
4292
- }).strict();
4293
- uniqueConstraint = objectType({
4294
- name: stringType(),
4295
- columns: stringType().array()
4296
- }).strict();
4297
- tableV4 = objectType({
4298
- name: stringType(),
4299
- schema: stringType().optional(),
4300
- columns: recordType(stringType(), column),
4301
- indexes: recordType(stringType(), index),
4302
- foreignKeys: recordType(stringType(), fk)
4303
- }).strict();
4304
- table = objectType({
4305
- name: stringType(),
4306
- schema: stringType().optional(),
4307
- columns: recordType(stringType(), column),
4308
- indexes: recordType(stringType(), index),
4309
- foreignKeys: recordType(stringType(), fk),
4310
- compositePrimaryKeys: recordType(stringType(), compositePK),
4311
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4312
- }).strict();
4313
- kitInternals = objectType({
4314
- tables: recordType(
4315
- stringType(),
4316
- objectType({
4317
- columns: recordType(
4318
- stringType(),
4319
- objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4320
- )
4321
- }).optional()
4322
- )
4323
- }).optional();
4324
- dialect = literalType("mysql");
4325
- schemaHash = objectType({
4326
- id: stringType(),
4327
- prevId: stringType()
4328
- });
4329
- schemaInternalV3 = objectType({
4330
- version: literalType("3"),
4331
- dialect,
4332
- tables: recordType(stringType(), tableV3)
4333
- }).strict();
4334
- schemaInternalV4 = objectType({
4335
- version: literalType("4"),
4336
- dialect,
4337
- tables: recordType(stringType(), tableV4),
4338
- schemas: recordType(stringType(), stringType())
4339
- }).strict();
4340
- schemaInternalV5 = objectType({
4341
- version: literalType("5"),
4342
- dialect,
4343
- tables: recordType(stringType(), table),
4344
- schemas: recordType(stringType(), stringType()),
4345
- _meta: objectType({
4346
- schemas: recordType(stringType(), stringType()),
4347
- tables: recordType(stringType(), stringType()),
4348
- columns: recordType(stringType(), stringType())
4349
- }),
4350
- internal: kitInternals
4351
- }).strict();
4352
- schemaInternalV6 = objectType({
4353
- version: literalType("6"),
4354
- dialect,
4355
- tables: recordType(stringType(), table),
4356
- schemas: recordType(stringType(), stringType()),
4357
- _meta: objectType({
4358
- schemas: recordType(stringType(), stringType()),
4359
- tables: recordType(stringType(), stringType()),
4360
- columns: recordType(stringType(), stringType())
4361
- }),
4362
- internal: kitInternals
4363
- }).strict();
4364
- schemaInternal = objectType({
4365
- version: literalType("6"),
4366
- dialect,
4367
- tables: recordType(stringType(), table),
4368
- schemas: recordType(stringType(), stringType()),
4369
- _meta: objectType({
4370
- schemas: recordType(stringType(), stringType()),
4371
- tables: recordType(stringType(), stringType()),
4372
- columns: recordType(stringType(), stringType())
4373
- }),
4374
- internal: kitInternals
4375
- }).strict();
4376
- schemaV3 = schemaInternalV3.merge(schemaHash);
4377
- schemaV4 = schemaInternalV4.merge(schemaHash);
4378
- schemaV5 = schemaInternalV5.merge(schemaHash);
4379
- schema = schemaInternal.merge(schemaHash);
4380
- tableSquashedV4 = objectType({
4381
- name: stringType(),
4382
- schema: stringType().optional(),
4383
- columns: recordType(stringType(), column),
4384
- indexes: recordType(stringType(), stringType()),
4385
- foreignKeys: recordType(stringType(), stringType())
4386
- }).strict();
4387
- tableSquashed = objectType({
4388
- name: stringType(),
4389
- schema: stringType().optional(),
4390
- columns: recordType(stringType(), column),
4391
- indexes: recordType(stringType(), stringType()),
4392
- foreignKeys: recordType(stringType(), stringType()),
4393
- compositePrimaryKeys: recordType(stringType(), stringType()),
4394
- uniqueConstraints: recordType(stringType(), stringType()).default({})
4395
- }).strict();
4396
- schemaSquashed = objectType({
4397
- version: literalType("5"),
4398
- dialect,
4399
- tables: recordType(stringType(), tableSquashed),
4400
- schemas: recordType(stringType(), stringType())
4401
- }).strict();
4402
- schemaSquashedV4 = objectType({
4403
- version: literalType("4"),
4404
- dialect,
4405
- tables: recordType(stringType(), tableSquashedV4),
4406
- schemas: recordType(stringType(), stringType())
4407
- }).strict();
4408
- MySqlSquasher = {
4409
- squashIdx: (idx) => {
4410
- index.parse(idx);
4411
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
4412
- },
4413
- unsquashIdx: (input) => {
4414
- const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
4415
- const destructed = {
4416
- name,
4417
- columns: columnsString.split(","),
4418
- isUnique: isUnique === "true",
4419
- using: using ? using : void 0,
4420
- algorithm: algorithm ? algorithm : void 0,
4421
- lock: lock ? lock : void 0
4422
- };
4423
- return index.parse(destructed);
4424
- },
4425
- squashPK: (pk) => {
4426
- return `${pk.name};${pk.columns.join(",")}`;
4427
- },
4428
- unsquashPK: (pk) => {
4429
- const splitted = pk.split(";");
4430
- return { name: splitted[0], columns: splitted[1].split(",") };
4431
- },
4432
- squashUnique: (unq) => {
4433
- return `${unq.name};${unq.columns.join(",")}`;
4434
- },
4435
- unsquashUnique: (unq) => {
4436
- const [name, columns] = unq.split(";");
4437
- return { name, columns: columns.split(",") };
4438
- },
4439
- squashFK: (fk4) => {
4440
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4441
- },
4442
- unsquashFK: (input) => {
4443
- const [
4444
- name,
4445
- tableFrom,
4446
- columnsFromStr,
4447
- tableTo,
4448
- columnsToStr,
4449
- onUpdate,
4450
- onDelete
4451
- ] = input.split(";");
4452
- const result = fk.parse({
4453
- name,
4454
- tableFrom,
4455
- columnsFrom: columnsFromStr.split(","),
4456
- tableTo,
4457
- columnsTo: columnsToStr.split(","),
4458
- onUpdate,
4459
- onDelete
4460
- });
4461
- return result;
4462
- }
4463
- };
4464
- mysqlSchema = schema;
4465
- mysqlSchemaV5 = schemaV5;
4466
- backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema]);
4467
- dryMySql = mysqlSchema.parse({
4468
- version: snapshotVersion,
4469
- dialect: "mysql",
4470
- id: originUUID,
4471
- prevId: "",
4472
- tables: {},
4473
- schemas: {},
4474
- _meta: {
4475
- schemas: {},
4476
- tables: {},
4477
- columns: {}
4478
- }
4479
- });
4480
- }
4481
- });
4482
-
4483
- // src/serializer/pgSchema.ts
4484
- var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
4485
- var init_pgSchema = __esm({
4486
- "src/serializer/pgSchema.ts"() {
4487
- "use strict";
4488
- init_global();
4489
- init_lib();
4490
- indexV2 = objectType({
4491
- name: stringType(),
4492
- columns: recordType(
4493
- stringType(),
4494
- objectType({
4495
- name: stringType()
4496
- })
4497
- ),
4498
- isUnique: booleanType()
4499
- }).strict();
4500
- columnV2 = objectType({
4501
- name: stringType(),
4502
- type: stringType(),
4503
- primaryKey: booleanType(),
4504
- notNull: booleanType(),
4505
- default: anyType().optional(),
4506
- references: stringType().optional()
4507
- }).strict();
4508
- tableV2 = objectType({
4509
- name: stringType(),
4510
- columns: recordType(stringType(), columnV2),
4511
- indexes: recordType(stringType(), indexV2)
4512
- }).strict();
4513
- enumSchema = objectType({
4514
- name: stringType(),
4515
- values: recordType(stringType(), stringType())
4516
- }).strict();
4517
- pgSchemaV2 = objectType({
4518
- version: literalType("2"),
4519
- tables: recordType(stringType(), tableV2),
4520
- enums: recordType(stringType(), enumSchema)
4521
- }).strict();
4522
- references = objectType({
4523
- foreignKeyName: stringType(),
4524
- table: stringType(),
4525
- column: stringType(),
4526
- onDelete: stringType().optional(),
4527
- onUpdate: stringType().optional()
4528
- }).strict();
4529
- columnV1 = objectType({
4530
- name: stringType(),
4531
- type: stringType(),
4532
- primaryKey: booleanType(),
4533
- notNull: booleanType(),
4534
- default: anyType().optional(),
4535
- references: references.optional()
4536
- }).strict();
4537
- tableV1 = objectType({
4538
- name: stringType(),
4539
- columns: recordType(stringType(), columnV1),
4540
- indexes: recordType(stringType(), indexV2)
4541
- }).strict();
4542
- pgSchemaV1 = objectType({
4543
- version: literalType("1"),
4544
- tables: recordType(stringType(), tableV1),
4545
- enums: recordType(stringType(), enumSchema)
4546
- }).strict();
4547
- index2 = objectType({
4548
- name: stringType(),
4549
- columns: stringType().array(),
4550
- isUnique: booleanType()
4551
- }).strict();
4552
- fk2 = objectType({
4553
- name: stringType(),
4554
- tableFrom: stringType(),
4555
- columnsFrom: stringType().array(),
4556
- tableTo: stringType(),
4557
- schemaTo: stringType().optional(),
4558
- columnsTo: stringType().array(),
4559
- onUpdate: stringType().optional(),
4560
- onDelete: stringType().optional()
4561
- }).strict();
4562
- column2 = objectType({
4563
- name: stringType(),
4564
- type: stringType(),
4565
- primaryKey: booleanType(),
4566
- notNull: booleanType(),
4567
- default: anyType().optional(),
4568
- isUnique: anyType().optional(),
4569
- uniqueName: stringType().optional(),
4570
- nullsNotDistinct: booleanType().optional()
4571
- }).strict();
4572
- tableV32 = objectType({
4573
- name: stringType(),
4574
- columns: recordType(stringType(), column2),
4575
- indexes: recordType(stringType(), index2),
4576
- foreignKeys: recordType(stringType(), fk2)
4577
- }).strict();
4578
- compositePK2 = objectType({
4579
- name: stringType(),
4580
- columns: stringType().array()
4581
- }).strict();
4582
- uniqueConstraint2 = objectType({
4583
- name: stringType(),
4584
- columns: stringType().array(),
4585
- nullsNotDistinct: booleanType()
4586
- }).strict();
4587
- tableV42 = objectType({
4588
- name: stringType(),
4589
- schema: stringType(),
4590
- columns: recordType(stringType(), column2),
4591
- indexes: recordType(stringType(), index2),
4592
- foreignKeys: recordType(stringType(), fk2)
4593
- }).strict();
4594
- table2 = objectType({
4595
- name: stringType(),
4596
- schema: stringType(),
4597
- columns: recordType(stringType(), column2),
4598
- indexes: recordType(stringType(), index2),
4599
- foreignKeys: recordType(stringType(), fk2),
4600
- compositePrimaryKeys: recordType(stringType(), compositePK2),
4601
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4602
- }).strict();
4603
- schemaHash2 = objectType({
4604
- id: stringType(),
4605
- prevId: stringType()
4606
- });
4607
- kitInternals2 = objectType({
4608
- tables: recordType(
4609
- stringType(),
4610
- objectType({
4611
- columns: recordType(
4612
- stringType(),
4613
- objectType({
4614
- isArray: booleanType().optional(),
4615
- dimensions: numberType().optional(),
4616
- rawType: stringType().optional()
4617
- }).optional()
4618
- )
4619
- }).optional()
4620
- )
4621
- }).optional();
4622
- pgSchemaInternalV3 = objectType({
4623
- version: literalType("3"),
4624
- dialect: literalType("pg"),
4625
- tables: recordType(stringType(), tableV32),
4626
- enums: recordType(stringType(), enumSchema)
4627
- }).strict();
4628
- pgSchemaInternalV4 = objectType({
4629
- version: literalType("4"),
4630
- dialect: literalType("pg"),
4631
- tables: recordType(stringType(), tableV42),
4632
- enums: recordType(stringType(), enumSchema),
4633
- schemas: recordType(stringType(), stringType())
4634
- }).strict();
4635
- pgSchemaInternalV5 = objectType({
4636
- version: literalType("5"),
4637
- dialect: literalType("pg"),
4638
- tables: recordType(stringType(), table2),
4639
- enums: recordType(stringType(), enumSchema),
4640
- schemas: recordType(stringType(), stringType()),
4641
- _meta: objectType({
4642
- schemas: recordType(stringType(), stringType()),
4643
- tables: recordType(stringType(), stringType()),
4644
- columns: recordType(stringType(), stringType())
4645
- }),
4646
- internal: kitInternals2
4647
- }).strict();
4648
- pgSchemaExternal = objectType({
4649
- version: literalType("5"),
4650
- dialect: literalType("pg"),
4651
- tables: arrayType(table2),
4652
- enums: arrayType(enumSchema),
4653
- schemas: arrayType(objectType({ name: stringType() })),
4654
- _meta: objectType({
4655
- schemas: recordType(stringType(), stringType()),
4656
- tables: recordType(stringType(), stringType()),
4657
- columns: recordType(stringType(), stringType())
4658
- })
4659
- }).strict();
4660
- pgSchemaInternal = objectType({
4661
- version: literalType("6"),
4662
- dialect: literalType("pg"),
4663
- tables: recordType(stringType(), table2),
4664
- enums: recordType(stringType(), enumSchema),
4665
- schemas: recordType(stringType(), stringType()),
4666
- _meta: objectType({
4667
- schemas: recordType(stringType(), stringType()),
4668
- tables: recordType(stringType(), stringType()),
4669
- columns: recordType(stringType(), stringType())
4670
- }),
4671
- internal: kitInternals2
4672
- }).strict();
4673
- tableSquashed2 = objectType({
4674
- name: stringType(),
4675
- schema: stringType(),
4676
- columns: recordType(stringType(), column2),
4677
- indexes: recordType(stringType(), stringType()),
4678
- foreignKeys: recordType(stringType(), stringType()),
4679
- compositePrimaryKeys: recordType(stringType(), stringType()),
4680
- uniqueConstraints: recordType(stringType(), stringType())
4681
- }).strict();
4682
- tableSquashedV42 = objectType({
4683
- name: stringType(),
4684
- schema: stringType(),
4685
- columns: recordType(stringType(), column2),
4686
- indexes: recordType(stringType(), stringType()),
4687
- foreignKeys: recordType(stringType(), stringType())
4688
- }).strict();
4689
- pgSchemaSquashedV4 = objectType({
4690
- version: literalType("4"),
4691
- dialect: enumType(["pg"]),
4692
- tables: recordType(stringType(), tableSquashedV42),
4693
- enums: recordType(stringType(), enumSchema),
4694
- schemas: recordType(stringType(), stringType())
4695
- }).strict();
4696
- pgSchemaSquashed = objectType({
4697
- version: literalType("6"),
4698
- dialect: enumType(["pg"]),
4699
- tables: recordType(stringType(), tableSquashed2),
4700
- enums: recordType(stringType(), enumSchema),
4701
- schemas: recordType(stringType(), stringType())
4702
- }).strict();
4703
- pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4704
- pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4705
- pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4706
- pgSchema = pgSchemaInternal.merge(schemaHash2);
4707
- backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
4708
- PgSquasher = {
4709
- squashIdx: (idx) => {
4710
- index2.parse(idx);
4711
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
4712
- },
4713
- unsquashIdx: (input) => {
4714
- const [name, columnsString, isUnique] = input.split(";");
4715
- const result = index2.parse({
4716
- name,
4717
- columns: columnsString.split(","),
4718
- isUnique: isUnique === "true"
4719
- });
4720
- return result;
4721
- },
4722
- squashFK: (fk4) => {
4723
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
4724
- },
4725
- squashPK: (pk) => {
4726
- return `${pk.columns.join(",")};${pk.name}`;
4727
- },
4728
- unsquashPK: (pk) => {
4729
- const splitted = pk.split(";");
4730
- return { name: splitted[1], columns: splitted[0].split(",") };
4731
- },
4732
- squashUnique: (unq) => {
4733
- return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
4734
- },
4735
- unsquashUnique: (unq) => {
4736
- const [name, columns, nullsNotDistinct] = unq.split(";");
4737
- return {
4738
- name,
4739
- columns: columns.split(","),
4740
- nullsNotDistinct: nullsNotDistinct === "true"
4741
- };
4742
- },
4743
- unsquashFK: (input) => {
4744
- const [
4745
- name,
4746
- tableFrom,
4747
- columnsFromStr,
4748
- tableTo,
4749
- columnsToStr,
4750
- onUpdate,
4751
- onDelete,
4752
- schemaTo
4753
- ] = input.split(";");
4754
- const result = fk2.parse({
4755
- name,
4756
- tableFrom,
4757
- columnsFrom: columnsFromStr.split(","),
4758
- schemaTo,
4759
- tableTo,
4760
- columnsTo: columnsToStr.split(","),
4761
- onUpdate,
4762
- onDelete
4763
- });
4764
- return result;
4765
- }
4766
- };
4767
- squashPgScheme = (json) => {
4768
- const mappedTables = Object.fromEntries(
4769
- Object.entries(json.tables).map((it) => {
4770
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
4771
- return PgSquasher.squashIdx(index4);
4772
- });
4773
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
4774
- return PgSquasher.squashFK(fk4);
4775
- });
4776
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
4777
- return PgSquasher.squashPK(pk);
4778
- });
4779
- const squashedUniqueConstraints = mapValues(
4780
- it[1].uniqueConstraints,
4781
- (unq) => {
4782
- return PgSquasher.squashUnique(unq);
4783
- }
4784
- );
4785
- return [
4786
- it[0],
4787
- {
4788
- name: it[1].name,
4789
- schema: it[1].schema,
4790
- columns: it[1].columns,
4791
- indexes: squashedIndexes,
4792
- foreignKeys: squashedFKs,
4793
- compositePrimaryKeys: squashedPKs,
4794
- uniqueConstraints: squashedUniqueConstraints
4795
- }
4796
- ];
4797
- })
4798
- );
4799
- return {
4800
- version: "6",
4801
- dialect: json.dialect,
4802
- tables: mappedTables,
4803
- enums: json.enums,
4804
- schemas: json.schemas
4805
- };
4806
- };
4807
- dryPg = pgSchema.parse({
4808
- version: snapshotVersion,
4809
- dialect: "pg",
4810
- id: originUUID,
4811
- prevId: "",
4812
- tables: {},
4813
- enums: {},
4814
- schemas: {},
4815
- _meta: {
4816
- schemas: {},
4817
- tables: {},
4818
- columns: {}
4819
- }
4820
- });
4821
- }
4822
- });
4823
-
4824
- // src/serializer/sqliteSchema.ts
4825
- var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, drySQLite, backwardCompatibleSqliteSchema;
4826
- var init_sqliteSchema = __esm({
4827
- "src/serializer/sqliteSchema.ts"() {
4828
- "use strict";
4829
- init_global();
4830
- init_lib();
4831
- index3 = objectType({
4832
- name: stringType(),
4833
- columns: stringType().array(),
4834
- where: stringType().optional(),
4835
- isUnique: booleanType()
4836
- }).strict();
4837
- fk3 = objectType({
4838
- name: stringType(),
4839
- tableFrom: stringType(),
4840
- columnsFrom: stringType().array(),
4841
- tableTo: stringType(),
4842
- columnsTo: stringType().array(),
4843
- onUpdate: stringType().optional(),
4844
- onDelete: stringType().optional()
4845
- }).strict();
4846
- compositePK3 = objectType({
4847
- columns: stringType().array(),
4848
- name: stringType().optional()
4849
- }).strict();
4850
- column3 = objectType({
4851
- name: stringType(),
4852
- type: stringType(),
4853
- primaryKey: booleanType(),
4854
- notNull: booleanType(),
4855
- autoincrement: booleanType().optional(),
4856
- default: anyType().optional()
4857
- }).strict();
4858
- tableV33 = objectType({
4859
- name: stringType(),
4860
- columns: recordType(stringType(), column3),
4861
- indexes: recordType(stringType(), index3),
4862
- foreignKeys: recordType(stringType(), fk3)
4863
- }).strict();
4864
- uniqueConstraint3 = objectType({
4865
- name: stringType(),
4866
- columns: stringType().array()
4867
- }).strict();
4868
- table3 = objectType({
4869
- name: stringType(),
4870
- columns: recordType(stringType(), column3),
4871
- indexes: recordType(stringType(), index3),
4872
- foreignKeys: recordType(stringType(), fk3),
4873
- compositePrimaryKeys: recordType(stringType(), compositePK3),
4874
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
4875
- }).strict();
4876
- dialect2 = enumType(["sqlite"]);
4877
- schemaHash3 = objectType({
4878
- id: stringType(),
4879
- prevId: stringType()
4880
- }).strict();
4881
- schemaInternalV32 = objectType({
4882
- version: literalType("3"),
4883
- dialect: dialect2,
4884
- tables: recordType(stringType(), tableV33),
4885
- enums: objectType({})
4886
- }).strict();
4887
- schemaInternalV42 = objectType({
4888
- version: literalType("4"),
4889
- dialect: dialect2,
4890
- tables: recordType(stringType(), table3),
4891
- enums: objectType({})
4892
- }).strict();
4893
- latestVersion = literalType("5");
4894
- schemaInternal2 = objectType({
4895
- version: latestVersion,
4896
- dialect: dialect2,
4897
- tables: recordType(stringType(), table3),
4898
- enums: objectType({}),
4899
- _meta: objectType({
4900
- tables: recordType(stringType(), stringType()),
4901
- columns: recordType(stringType(), stringType())
4902
- })
4903
- }).strict();
4904
- schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
4905
- schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
4906
- schema2 = schemaInternal2.merge(schemaHash3).strict();
4907
- tableSquashed3 = objectType({
4908
- name: stringType(),
4909
- columns: recordType(stringType(), column3),
4910
- indexes: recordType(stringType(), stringType()),
4911
- foreignKeys: recordType(stringType(), stringType()),
4912
- compositePrimaryKeys: recordType(stringType(), stringType()),
4913
- uniqueConstraints: recordType(stringType(), stringType()).default({})
4914
- }).strict();
4915
- schemaSquashed2 = objectType({
4916
- version: latestVersion,
4917
- dialect: dialect2,
4918
- tables: recordType(stringType(), tableSquashed3),
4919
- enums: anyType()
4920
- }).strict();
4921
- SQLiteSquasher = {
4922
- squashIdx: (idx) => {
4923
- index3.parse(idx);
4924
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
4925
- },
4926
- unsquashIdx: (input) => {
4927
- const [name, columnsString, isUnique, where] = input.split(";");
4928
- const result = index3.parse({
4929
- name,
4930
- columns: columnsString.split(","),
4931
- isUnique: isUnique === "true",
4932
- where: where ?? void 0
4933
- });
4934
- return result;
4935
- },
4936
- squashUnique: (unq) => {
4937
- return `${unq.name};${unq.columns.join(",")}`;
4938
- },
4939
- unsquashUnique: (unq) => {
4940
- const [name, columns] = unq.split(";");
4941
- return { name, columns: columns.split(",") };
4942
- },
4943
- squashFK: (fk4) => {
4944
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4945
- },
4946
- unsquashFK: (input) => {
4947
- const [
4948
- name,
4949
- tableFrom,
4950
- columnsFromStr,
4951
- tableTo,
4952
- columnsToStr,
4953
- onUpdate,
4954
- onDelete
4955
- ] = input.split(";");
4956
- const result = fk3.parse({
4957
- name,
4958
- tableFrom,
4959
- columnsFrom: columnsFromStr.split(","),
4960
- tableTo,
4961
- columnsTo: columnsToStr.split(","),
4962
- onUpdate,
4963
- onDelete
4964
- });
4965
- return result;
4966
- },
4967
- squashPK: (pk) => {
4968
- return pk.columns.join(",");
4969
- },
4970
- unsquashPK: (pk) => {
4971
- return pk.split(",");
4972
- }
4973
- };
4974
- drySQLite = schema2.parse({
4975
- version: "5",
4976
- dialect: "sqlite",
4977
- id: originUUID,
4978
- prevId: "",
4979
- tables: {},
4980
- enums: {},
4981
- _meta: {
4982
- tables: {},
4983
- columns: {}
4984
- }
4985
- });
4986
- backwardCompatibleSqliteSchema = schema2;
4987
- }
4988
- });
4989
-
4990
4228
  // src/serializer/index.ts
4991
4229
  var glob;
4992
4230
  var init_serializer = __esm({
4993
4231
  "src/serializer/index.ts"() {
4994
- "use strict";
4995
4232
  glob = __toESM(require("glob"));
4996
4233
  init_source();
4997
4234
  init_views();
@@ -5001,7 +4238,6 @@ var init_serializer = __esm({
5001
4238
  // src/cli/validations/outputs.ts
5002
4239
  var init_outputs = __esm({
5003
4240
  "src/cli/validations/outputs.ts"() {
5004
- "use strict";
5005
4241
  init_source();
5006
4242
  }
5007
4243
  });
@@ -5015,7 +4251,7 @@ __export(utils_exports, {
5015
4251
  kloudMeta: () => kloudMeta,
5016
4252
  prepareMigrationFolder: () => prepareMigrationFolder,
5017
4253
  prepareMigrationMeta: () => prepareMigrationMeta,
5018
- prepareOutFolder: () => prepareOutFolder,
4254
+ prepareOutFolder: () => prepareOutFolder2,
5019
4255
  schemaRenameKey: () => schemaRenameKey,
5020
4256
  snapshotsPriorV4: () => snapshotsPriorV4,
5021
4257
  statementsForDiffs: () => statementsForDiffs,
@@ -5025,12 +4261,710 @@ __export(utils_exports, {
5025
4261
  module.exports = __toCommonJS(utils_exports);
5026
4262
  var import_fs = require("fs");
5027
4263
  init_views();
5028
- init_mysqlSchema();
5029
- init_pgSchema();
5030
- init_sqliteSchema();
4264
+
4265
+ // src/global.ts
4266
+ var originUUID = "00000000-0000-0000-0000-000000000000";
4267
+ var snapshotVersion = "5";
4268
+ var mapValues = (obj, map) => {
4269
+ const result = Object.keys(obj).reduce(function(result2, key) {
4270
+ result2[key] = map(obj[key]);
4271
+ return result2;
4272
+ }, {});
4273
+ return result;
4274
+ };
4275
+
4276
+ // src/serializer/mysqlSchema.ts
4277
+ init_lib();
4278
+ var index = objectType({
4279
+ name: stringType(),
4280
+ columns: stringType().array(),
4281
+ isUnique: booleanType(),
4282
+ using: enumType(["btree", "hash"]).optional(),
4283
+ algorithm: enumType(["default", "inplace", "copy"]).optional(),
4284
+ lock: enumType(["default", "none", "shared", "exclusive"]).optional()
4285
+ }).strict();
4286
+ var fk = objectType({
4287
+ name: stringType(),
4288
+ tableFrom: stringType(),
4289
+ columnsFrom: stringType().array(),
4290
+ tableTo: stringType(),
4291
+ columnsTo: stringType().array(),
4292
+ onUpdate: stringType().optional(),
4293
+ onDelete: stringType().optional()
4294
+ }).strict();
4295
+ var column = objectType({
4296
+ name: stringType(),
4297
+ type: stringType(),
4298
+ primaryKey: booleanType(),
4299
+ notNull: booleanType(),
4300
+ autoincrement: booleanType().optional(),
4301
+ default: anyType().optional(),
4302
+ onUpdate: anyType().optional()
4303
+ }).strict();
4304
+ var tableV3 = objectType({
4305
+ name: stringType(),
4306
+ columns: recordType(stringType(), column),
4307
+ indexes: recordType(stringType(), index),
4308
+ foreignKeys: recordType(stringType(), fk)
4309
+ }).strict();
4310
+ var compositePK = objectType({
4311
+ name: stringType(),
4312
+ columns: stringType().array()
4313
+ }).strict();
4314
+ var uniqueConstraint = objectType({
4315
+ name: stringType(),
4316
+ columns: stringType().array()
4317
+ }).strict();
4318
+ var tableV4 = objectType({
4319
+ name: stringType(),
4320
+ schema: stringType().optional(),
4321
+ columns: recordType(stringType(), column),
4322
+ indexes: recordType(stringType(), index),
4323
+ foreignKeys: recordType(stringType(), fk)
4324
+ }).strict();
4325
+ var table = objectType({
4326
+ name: stringType(),
4327
+ schema: stringType().optional(),
4328
+ columns: recordType(stringType(), column),
4329
+ indexes: recordType(stringType(), index),
4330
+ foreignKeys: recordType(stringType(), fk),
4331
+ compositePrimaryKeys: recordType(stringType(), compositePK),
4332
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4333
+ }).strict();
4334
+ var dialect = literalType("mysql");
4335
+ var schemaHash = objectType({
4336
+ id: stringType(),
4337
+ prevId: stringType()
4338
+ });
4339
+ var schemaInternalV3 = objectType({
4340
+ version: literalType("3"),
4341
+ dialect,
4342
+ tables: recordType(stringType(), tableV3)
4343
+ }).strict();
4344
+ var schemaInternalV4 = objectType({
4345
+ version: literalType("4"),
4346
+ dialect,
4347
+ tables: recordType(stringType(), tableV4),
4348
+ schemas: recordType(stringType(), stringType())
4349
+ }).strict();
4350
+ var kitInternals = objectType({
4351
+ tables: recordType(
4352
+ stringType(),
4353
+ objectType({
4354
+ columns: recordType(
4355
+ stringType(),
4356
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4357
+ )
4358
+ }).optional()
4359
+ )
4360
+ }).optional();
4361
+ var schemaInternal = objectType({
4362
+ version: literalType("5"),
4363
+ dialect,
4364
+ tables: recordType(stringType(), table),
4365
+ schemas: recordType(stringType(), stringType()),
4366
+ _meta: objectType({
4367
+ schemas: recordType(stringType(), stringType()),
4368
+ tables: recordType(stringType(), stringType()),
4369
+ columns: recordType(stringType(), stringType())
4370
+ }),
4371
+ internal: kitInternals
4372
+ }).strict();
4373
+ var schemaV3 = schemaInternalV3.merge(schemaHash);
4374
+ var schemaV4 = schemaInternalV4.merge(schemaHash);
4375
+ var schema = schemaInternal.merge(schemaHash);
4376
+ var tableSquashedV4 = objectType({
4377
+ name: stringType(),
4378
+ schema: stringType().optional(),
4379
+ columns: recordType(stringType(), column),
4380
+ indexes: recordType(stringType(), stringType()),
4381
+ foreignKeys: recordType(stringType(), stringType())
4382
+ }).strict();
4383
+ var tableSquashed = objectType({
4384
+ name: stringType(),
4385
+ schema: stringType().optional(),
4386
+ columns: recordType(stringType(), column),
4387
+ indexes: recordType(stringType(), stringType()),
4388
+ foreignKeys: recordType(stringType(), stringType()),
4389
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4390
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4391
+ }).strict();
4392
+ var schemaSquashed = objectType({
4393
+ version: literalType("5"),
4394
+ dialect,
4395
+ tables: recordType(stringType(), tableSquashed),
4396
+ schemas: recordType(stringType(), stringType())
4397
+ }).strict();
4398
+ var schemaSquashedV4 = objectType({
4399
+ version: literalType("4"),
4400
+ dialect,
4401
+ tables: recordType(stringType(), tableSquashedV4),
4402
+ schemas: recordType(stringType(), stringType())
4403
+ }).strict();
4404
+ var MySqlSquasher = {
4405
+ squashIdx: (idx) => {
4406
+ index.parse(idx);
4407
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
4408
+ },
4409
+ unsquashIdx: (input) => {
4410
+ const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
4411
+ const destructed = {
4412
+ name,
4413
+ columns: columnsString.split(","),
4414
+ isUnique: isUnique === "true",
4415
+ using: using ? using : void 0,
4416
+ algorithm: algorithm ? algorithm : void 0,
4417
+ lock: lock ? lock : void 0
4418
+ };
4419
+ return index.parse(destructed);
4420
+ },
4421
+ squashPK: (pk) => {
4422
+ return `${pk.name};${pk.columns.join(",")}`;
4423
+ },
4424
+ unsquashPK: (pk) => {
4425
+ const splitted = pk.split(";");
4426
+ return { name: splitted[0], columns: splitted[1].split(",") };
4427
+ },
4428
+ squashUnique: (unq) => {
4429
+ return `${unq.name};${unq.columns.join(",")}`;
4430
+ },
4431
+ unsquashUnique: (unq) => {
4432
+ const [name, columns] = unq.split(";");
4433
+ return { name, columns: columns.split(",") };
4434
+ },
4435
+ squashFK: (fk4) => {
4436
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4437
+ },
4438
+ unsquashFK: (input) => {
4439
+ const [
4440
+ name,
4441
+ tableFrom,
4442
+ columnsFromStr,
4443
+ tableTo,
4444
+ columnsToStr,
4445
+ onUpdate,
4446
+ onDelete
4447
+ ] = input.split(";");
4448
+ const result = fk.parse({
4449
+ name,
4450
+ tableFrom,
4451
+ columnsFrom: columnsFromStr.split(","),
4452
+ tableTo,
4453
+ columnsTo: columnsToStr.split(","),
4454
+ onUpdate,
4455
+ onDelete
4456
+ });
4457
+ return result;
4458
+ }
4459
+ };
4460
+ var mysqlSchema = schema;
4461
+ var backwardCompatibleMysqlSchema = unionType([
4462
+ schemaV3,
4463
+ schemaV4,
4464
+ schema
4465
+ ]);
4466
+ var dryMySql = mysqlSchema.parse({
4467
+ version: snapshotVersion,
4468
+ dialect: "mysql",
4469
+ id: originUUID,
4470
+ prevId: "",
4471
+ tables: {},
4472
+ schemas: {},
4473
+ _meta: {
4474
+ schemas: {},
4475
+ tables: {},
4476
+ columns: {}
4477
+ }
4478
+ });
4479
+
4480
+ // src/serializer/pgSchema.ts
4481
+ init_lib();
4482
+ var indexV2 = objectType({
4483
+ name: stringType(),
4484
+ columns: recordType(
4485
+ stringType(),
4486
+ objectType({
4487
+ name: stringType()
4488
+ })
4489
+ ),
4490
+ isUnique: booleanType()
4491
+ }).strict();
4492
+ var columnV2 = objectType({
4493
+ name: stringType(),
4494
+ type: stringType(),
4495
+ primaryKey: booleanType(),
4496
+ notNull: booleanType(),
4497
+ default: anyType().optional(),
4498
+ references: stringType().optional()
4499
+ }).strict();
4500
+ var tableV2 = objectType({
4501
+ name: stringType(),
4502
+ columns: recordType(stringType(), columnV2),
4503
+ indexes: recordType(stringType(), indexV2)
4504
+ }).strict();
4505
+ var enumSchema = objectType({
4506
+ name: stringType(),
4507
+ values: recordType(stringType(), stringType())
4508
+ }).strict();
4509
+ var pgSchemaV2 = objectType({
4510
+ version: literalType("2"),
4511
+ tables: recordType(stringType(), tableV2),
4512
+ enums: recordType(stringType(), enumSchema)
4513
+ }).strict();
4514
+ var references = objectType({
4515
+ foreignKeyName: stringType(),
4516
+ table: stringType(),
4517
+ column: stringType(),
4518
+ onDelete: stringType().optional(),
4519
+ onUpdate: stringType().optional()
4520
+ }).strict();
4521
+ var columnV1 = objectType({
4522
+ name: stringType(),
4523
+ type: stringType(),
4524
+ primaryKey: booleanType(),
4525
+ notNull: booleanType(),
4526
+ default: anyType().optional(),
4527
+ references: references.optional()
4528
+ }).strict();
4529
+ var tableV1 = objectType({
4530
+ name: stringType(),
4531
+ columns: recordType(stringType(), columnV1),
4532
+ indexes: recordType(stringType(), indexV2)
4533
+ }).strict();
4534
+ var pgSchemaV1 = objectType({
4535
+ version: literalType("1"),
4536
+ tables: recordType(stringType(), tableV1),
4537
+ enums: recordType(stringType(), enumSchema)
4538
+ }).strict();
4539
+ var index2 = objectType({
4540
+ name: stringType(),
4541
+ columns: stringType().array(),
4542
+ isUnique: booleanType()
4543
+ }).strict();
4544
+ var fk2 = objectType({
4545
+ name: stringType(),
4546
+ tableFrom: stringType(),
4547
+ columnsFrom: stringType().array(),
4548
+ tableTo: stringType(),
4549
+ schemaTo: stringType().optional(),
4550
+ columnsTo: stringType().array(),
4551
+ onUpdate: stringType().optional(),
4552
+ onDelete: stringType().optional()
4553
+ }).strict();
4554
+ var column2 = objectType({
4555
+ name: stringType(),
4556
+ type: stringType(),
4557
+ primaryKey: booleanType(),
4558
+ notNull: booleanType(),
4559
+ default: anyType().optional(),
4560
+ isUnique: anyType().optional(),
4561
+ uniqueName: stringType().optional(),
4562
+ nullsNotDistinct: booleanType().optional()
4563
+ }).strict();
4564
+ var tableV32 = objectType({
4565
+ name: stringType(),
4566
+ columns: recordType(stringType(), column2),
4567
+ indexes: recordType(stringType(), index2),
4568
+ foreignKeys: recordType(stringType(), fk2)
4569
+ }).strict();
4570
+ var compositePK2 = objectType({
4571
+ name: stringType(),
4572
+ columns: stringType().array()
4573
+ }).strict();
4574
+ var uniqueConstraint2 = objectType({
4575
+ name: stringType(),
4576
+ columns: stringType().array(),
4577
+ nullsNotDistinct: booleanType()
4578
+ }).strict();
4579
+ var tableV42 = objectType({
4580
+ name: stringType(),
4581
+ schema: stringType(),
4582
+ columns: recordType(stringType(), column2),
4583
+ indexes: recordType(stringType(), index2),
4584
+ foreignKeys: recordType(stringType(), fk2)
4585
+ }).strict();
4586
+ var table2 = objectType({
4587
+ name: stringType(),
4588
+ schema: stringType(),
4589
+ columns: recordType(stringType(), column2),
4590
+ indexes: recordType(stringType(), index2),
4591
+ foreignKeys: recordType(stringType(), fk2),
4592
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4593
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4594
+ }).strict();
4595
+ var schemaHash2 = objectType({
4596
+ id: stringType(),
4597
+ prevId: stringType()
4598
+ });
4599
+ var pgSchemaInternalV3 = objectType({
4600
+ version: literalType("3"),
4601
+ dialect: literalType("pg"),
4602
+ tables: recordType(stringType(), tableV32),
4603
+ enums: recordType(stringType(), enumSchema)
4604
+ }).strict();
4605
+ var pgSchemaInternalV4 = objectType({
4606
+ version: literalType("4"),
4607
+ dialect: literalType("pg"),
4608
+ tables: recordType(stringType(), tableV42),
4609
+ enums: recordType(stringType(), enumSchema),
4610
+ schemas: recordType(stringType(), stringType())
4611
+ }).strict();
4612
+ var pgSchemaExternal = objectType({
4613
+ version: literalType("5"),
4614
+ dialect: literalType("pg"),
4615
+ tables: arrayType(table2),
4616
+ enums: arrayType(enumSchema),
4617
+ schemas: arrayType(objectType({ name: stringType() })),
4618
+ _meta: objectType({
4619
+ schemas: recordType(stringType(), stringType()),
4620
+ tables: recordType(stringType(), stringType()),
4621
+ columns: recordType(stringType(), stringType())
4622
+ })
4623
+ }).strict();
4624
+ var kitInternals2 = objectType({
4625
+ tables: recordType(
4626
+ stringType(),
4627
+ objectType({
4628
+ columns: recordType(
4629
+ stringType(),
4630
+ objectType({
4631
+ isArray: booleanType().optional(),
4632
+ dimensions: numberType().optional(),
4633
+ rawType: stringType().optional()
4634
+ }).optional()
4635
+ )
4636
+ }).optional()
4637
+ )
4638
+ }).optional();
4639
+ var pgSchemaInternal = objectType({
4640
+ version: literalType("5"),
4641
+ dialect: literalType("pg"),
4642
+ tables: recordType(stringType(), table2),
4643
+ enums: recordType(stringType(), enumSchema),
4644
+ schemas: recordType(stringType(), stringType()),
4645
+ _meta: objectType({
4646
+ schemas: recordType(stringType(), stringType()),
4647
+ tables: recordType(stringType(), stringType()),
4648
+ columns: recordType(stringType(), stringType())
4649
+ }),
4650
+ internal: kitInternals2
4651
+ }).strict();
4652
+ var tableSquashed2 = objectType({
4653
+ name: stringType(),
4654
+ schema: stringType(),
4655
+ columns: recordType(stringType(), column2),
4656
+ indexes: recordType(stringType(), stringType()),
4657
+ foreignKeys: recordType(stringType(), stringType()),
4658
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4659
+ uniqueConstraints: recordType(stringType(), stringType())
4660
+ }).strict();
4661
+ var tableSquashedV42 = objectType({
4662
+ name: stringType(),
4663
+ schema: stringType(),
4664
+ columns: recordType(stringType(), column2),
4665
+ indexes: recordType(stringType(), stringType()),
4666
+ foreignKeys: recordType(stringType(), stringType())
4667
+ }).strict();
4668
+ var pgSchemaSquashedV4 = objectType({
4669
+ version: literalType("4"),
4670
+ dialect: enumType(["pg"]),
4671
+ tables: recordType(stringType(), tableSquashedV42),
4672
+ enums: recordType(stringType(), enumSchema),
4673
+ schemas: recordType(stringType(), stringType())
4674
+ }).strict();
4675
+ var pgSchemaSquashed = objectType({
4676
+ version: literalType("5"),
4677
+ dialect: enumType(["pg"]),
4678
+ tables: recordType(stringType(), tableSquashed2),
4679
+ enums: recordType(stringType(), enumSchema),
4680
+ schemas: recordType(stringType(), stringType())
4681
+ }).strict();
4682
+ var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4683
+ var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4684
+ var pgSchema = pgSchemaInternal.merge(schemaHash2);
4685
+ var backwardCompatiblePgSchema = unionType([
4686
+ pgSchemaV1,
4687
+ pgSchemaV2,
4688
+ pgSchemaV3,
4689
+ pgSchemaV4,
4690
+ pgSchema
4691
+ ]);
4692
+ var PgSquasher = {
4693
+ squashIdx: (idx) => {
4694
+ index2.parse(idx);
4695
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
4696
+ },
4697
+ unsquashIdx: (input) => {
4698
+ const [name, columnsString, isUnique] = input.split(";");
4699
+ const result = index2.parse({
4700
+ name,
4701
+ columns: columnsString.split(","),
4702
+ isUnique: isUnique === "true"
4703
+ });
4704
+ return result;
4705
+ },
4706
+ squashFK: (fk4) => {
4707
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
4708
+ },
4709
+ squashPK: (pk) => {
4710
+ return `${pk.columns.join(",")};${pk.name}`;
4711
+ },
4712
+ unsquashPK: (pk) => {
4713
+ const splitted = pk.split(";");
4714
+ return { name: splitted[1], columns: splitted[0].split(",") };
4715
+ },
4716
+ squashUnique: (unq) => {
4717
+ return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
4718
+ },
4719
+ unsquashUnique: (unq) => {
4720
+ const [name, columns, nullsNotDistinct] = unq.split(";");
4721
+ return {
4722
+ name,
4723
+ columns: columns.split(","),
4724
+ nullsNotDistinct: nullsNotDistinct === "true"
4725
+ };
4726
+ },
4727
+ unsquashFK: (input) => {
4728
+ const [
4729
+ name,
4730
+ tableFrom,
4731
+ columnsFromStr,
4732
+ tableTo,
4733
+ columnsToStr,
4734
+ onUpdate,
4735
+ onDelete,
4736
+ schemaTo
4737
+ ] = input.split(";");
4738
+ const result = fk2.parse({
4739
+ name,
4740
+ tableFrom,
4741
+ columnsFrom: columnsFromStr.split(","),
4742
+ schemaTo,
4743
+ tableTo,
4744
+ columnsTo: columnsToStr.split(","),
4745
+ onUpdate,
4746
+ onDelete
4747
+ });
4748
+ return result;
4749
+ }
4750
+ };
4751
+ var squashPgScheme = (json) => {
4752
+ const mappedTables = Object.fromEntries(
4753
+ Object.entries(json.tables).map((it) => {
4754
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
4755
+ return PgSquasher.squashIdx(index4);
4756
+ });
4757
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
4758
+ return PgSquasher.squashFK(fk4);
4759
+ });
4760
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
4761
+ return PgSquasher.squashPK(pk);
4762
+ });
4763
+ const squashedUniqueConstraints = mapValues(
4764
+ it[1].uniqueConstraints,
4765
+ (unq) => {
4766
+ return PgSquasher.squashUnique(unq);
4767
+ }
4768
+ );
4769
+ return [
4770
+ it[0],
4771
+ {
4772
+ name: it[1].name,
4773
+ schema: it[1].schema,
4774
+ columns: it[1].columns,
4775
+ indexes: squashedIndexes,
4776
+ foreignKeys: squashedFKs,
4777
+ compositePrimaryKeys: squashedPKs,
4778
+ uniqueConstraints: squashedUniqueConstraints
4779
+ }
4780
+ ];
4781
+ })
4782
+ );
4783
+ return {
4784
+ version: "5",
4785
+ dialect: json.dialect,
4786
+ tables: mappedTables,
4787
+ enums: json.enums,
4788
+ schemas: json.schemas
4789
+ };
4790
+ };
4791
+ var dryPg = pgSchema.parse({
4792
+ version: snapshotVersion,
4793
+ dialect: "pg",
4794
+ id: originUUID,
4795
+ prevId: "",
4796
+ tables: {},
4797
+ enums: {},
4798
+ schemas: {},
4799
+ _meta: {
4800
+ schemas: {},
4801
+ tables: {},
4802
+ columns: {}
4803
+ }
4804
+ });
4805
+
4806
+ // src/serializer/sqliteSchema.ts
4807
+ init_lib();
4808
+ var index3 = objectType({
4809
+ name: stringType(),
4810
+ columns: stringType().array(),
4811
+ where: stringType().optional(),
4812
+ isUnique: booleanType()
4813
+ }).strict();
4814
+ var fk3 = objectType({
4815
+ name: stringType(),
4816
+ tableFrom: stringType(),
4817
+ columnsFrom: stringType().array(),
4818
+ tableTo: stringType(),
4819
+ columnsTo: stringType().array(),
4820
+ onUpdate: stringType().optional(),
4821
+ onDelete: stringType().optional()
4822
+ }).strict();
4823
+ var compositePK3 = objectType({
4824
+ columns: stringType().array(),
4825
+ name: stringType().optional()
4826
+ }).strict();
4827
+ var column3 = objectType({
4828
+ name: stringType(),
4829
+ type: stringType(),
4830
+ primaryKey: booleanType(),
4831
+ notNull: booleanType(),
4832
+ autoincrement: booleanType().optional(),
4833
+ default: anyType().optional()
4834
+ }).strict();
4835
+ var tableV33 = objectType({
4836
+ name: stringType(),
4837
+ columns: recordType(stringType(), column3),
4838
+ indexes: recordType(stringType(), index3),
4839
+ foreignKeys: recordType(stringType(), fk3)
4840
+ }).strict();
4841
+ var uniqueConstraint3 = objectType({
4842
+ name: stringType(),
4843
+ columns: stringType().array()
4844
+ }).strict();
4845
+ var table3 = objectType({
4846
+ name: stringType(),
4847
+ columns: recordType(stringType(), column3),
4848
+ indexes: recordType(stringType(), index3),
4849
+ foreignKeys: recordType(stringType(), fk3),
4850
+ compositePrimaryKeys: recordType(stringType(), compositePK3),
4851
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
4852
+ }).strict();
4853
+ var dialect2 = enumType(["sqlite"]);
4854
+ var schemaHash3 = objectType({
4855
+ id: stringType(),
4856
+ prevId: stringType()
4857
+ }).strict();
4858
+ var schemaInternalV32 = objectType({
4859
+ version: literalType("3"),
4860
+ dialect: dialect2,
4861
+ tables: recordType(stringType(), tableV33),
4862
+ enums: objectType({})
4863
+ }).strict();
4864
+ var schemaInternalV42 = objectType({
4865
+ version: literalType("4"),
4866
+ dialect: dialect2,
4867
+ tables: recordType(stringType(), table3),
4868
+ enums: objectType({})
4869
+ }).strict();
4870
+ var latestVersion = literalType("5");
4871
+ var schemaInternal2 = objectType({
4872
+ version: latestVersion,
4873
+ dialect: dialect2,
4874
+ tables: recordType(stringType(), table3),
4875
+ enums: objectType({}),
4876
+ _meta: objectType({
4877
+ tables: recordType(stringType(), stringType()),
4878
+ columns: recordType(stringType(), stringType())
4879
+ })
4880
+ }).strict();
4881
+ var schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
4882
+ var schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
4883
+ var schema2 = schemaInternal2.merge(schemaHash3).strict();
4884
+ var tableSquashed3 = objectType({
4885
+ name: stringType(),
4886
+ columns: recordType(stringType(), column3),
4887
+ indexes: recordType(stringType(), stringType()),
4888
+ foreignKeys: recordType(stringType(), stringType()),
4889
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4890
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4891
+ }).strict();
4892
+ var schemaSquashed2 = objectType({
4893
+ version: latestVersion,
4894
+ dialect: dialect2,
4895
+ tables: recordType(stringType(), tableSquashed3),
4896
+ enums: anyType()
4897
+ }).strict();
4898
+ var SQLiteSquasher = {
4899
+ squashIdx: (idx) => {
4900
+ index3.parse(idx);
4901
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
4902
+ },
4903
+ unsquashIdx: (input) => {
4904
+ const [name, columnsString, isUnique, where] = input.split(";");
4905
+ const result = index3.parse({
4906
+ name,
4907
+ columns: columnsString.split(","),
4908
+ isUnique: isUnique === "true",
4909
+ where: where ?? void 0
4910
+ });
4911
+ return result;
4912
+ },
4913
+ squashUnique: (unq) => {
4914
+ return `${unq.name};${unq.columns.join(",")}`;
4915
+ },
4916
+ unsquashUnique: (unq) => {
4917
+ const [name, columns] = unq.split(";");
4918
+ return { name, columns: columns.split(",") };
4919
+ },
4920
+ squashFK: (fk4) => {
4921
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4922
+ },
4923
+ unsquashFK: (input) => {
4924
+ const [
4925
+ name,
4926
+ tableFrom,
4927
+ columnsFromStr,
4928
+ tableTo,
4929
+ columnsToStr,
4930
+ onUpdate,
4931
+ onDelete
4932
+ ] = input.split(";");
4933
+ const result = fk3.parse({
4934
+ name,
4935
+ tableFrom,
4936
+ columnsFrom: columnsFromStr.split(","),
4937
+ tableTo,
4938
+ columnsTo: columnsToStr.split(","),
4939
+ onUpdate,
4940
+ onDelete
4941
+ });
4942
+ return result;
4943
+ },
4944
+ squashPK: (pk) => {
4945
+ return pk.columns.join(",");
4946
+ },
4947
+ unsquashPK: (pk) => {
4948
+ return pk.split(",");
4949
+ }
4950
+ };
4951
+ var drySQLite = schema2.parse({
4952
+ version: snapshotVersion,
4953
+ dialect: "sqlite",
4954
+ id: originUUID,
4955
+ prevId: "",
4956
+ tables: {},
4957
+ enums: {},
4958
+ _meta: {
4959
+ tables: {},
4960
+ columns: {}
4961
+ }
4962
+ });
4963
+ var backwardCompatibleSqliteSchema = unionType([schemaV32, schemaV42, schema2]);
4964
+
4965
+ // src/utils.ts
5031
4966
  init_source();
5032
4967
  var import_path = require("path");
5033
- init_global();
5034
4968
 
5035
4969
  // src/jsonDiffer.js
5036
4970
  var import_json_diff = require("json-diff");
@@ -5272,30 +5206,17 @@ var alternationsInColumn = (column4) => {
5272
5206
  return result[0];
5273
5207
  };
5274
5208
 
5275
- // src/cli/commands/upFolders.ts
5276
- init_mysqlSchema();
5277
- init_sqliteSchema();
5278
-
5279
5209
  // src/migrationPreparator.ts
5280
5210
  init_serializer();
5281
- init_pgSchema();
5282
- init_sqliteSchema();
5283
- init_mysqlSchema();
5284
5211
 
5285
5212
  // src/cli/commands/migrate.ts
5286
5213
  var import_hanji2 = __toESM(require_hanji());
5287
5214
  init_views();
5288
5215
  init_source();
5289
- init_pgSchema();
5290
- init_sqliteSchema();
5291
- init_mysqlSchema();
5292
5216
  init_outputs();
5293
5217
  var BREAKPOINT = "--> statement-breakpoint\n";
5294
5218
 
5295
5219
  // src/sqlgenerator.ts
5296
- init_mysqlSchema();
5297
- init_pgSchema();
5298
- init_sqliteSchema();
5299
5220
  var pgNativeTypes = /* @__PURE__ */ new Set([
5300
5221
  "uuid",
5301
5222
  "smallint",
@@ -6607,20 +6528,17 @@ drop type __venum;
6607
6528
  init_lib();
6608
6529
 
6609
6530
  // src/jsonStatements.ts
6610
- init_mysqlSchema();
6611
- init_pgSchema();
6612
- init_sqliteSchema();
6613
6531
  var preparePgCreateTableJson = (table4, json2) => {
6614
6532
  const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
6615
- const tableKey = `${schema4 || "public"}.${name}`;
6616
- const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
6617
6533
  return {
6618
6534
  type: "create_table",
6619
6535
  tableName: name,
6620
6536
  schema: schema4,
6621
6537
  columns: Object.values(columns),
6622
6538
  compositePKs: Object.values(compositePrimaryKeys),
6623
- compositePkName,
6539
+ compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
6540
+ Object.values(compositePrimaryKeys)[0]
6541
+ ).name}`].name : "",
6624
6542
  uniqueConstraints: Object.values(uniqueConstraints)
6625
6543
  };
6626
6544
  };
@@ -6722,8 +6640,7 @@ var prepareRenameColumns = (tableName, schema4, pairs) => {
6722
6640
  var prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect3) => {
6723
6641
  const addColumns = [];
6724
6642
  const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
6725
- const tableKey = `${schema4 || "public"}.${tableName}`;
6726
- const alterColumns = _prepareAlterColumns(tableKey, schema4, altered, json2);
6643
+ const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
6727
6644
  if (dialect3 === "sqlite") {
6728
6645
  let jsonCreateFKStatements = Object.values(addedFk);
6729
6646
  const sqliteAddColumns = _prepareSQLiteAddColumns(
@@ -6773,22 +6690,19 @@ var _prepareSQLiteAddColumns = (tableName, columns, referenceData) => {
6773
6690
  };
6774
6691
  });
6775
6692
  };
6776
- var _prepareAlterColumns = (tableKey, schema4, columns, json2) => {
6693
+ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
6777
6694
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6778
6695
  let statements = [];
6779
6696
  let dropPkStatements = [];
6780
6697
  let setPkStatements = [];
6781
6698
  for (const column4 of columns) {
6782
6699
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
6783
- const table4 = json2.tables[tableKey];
6784
- const tableName = table4.name;
6785
- const snapshotColumn = table4.columns[columnName];
6786
- const columnType = snapshotColumn.type;
6787
- const columnDefault = snapshotColumn.default;
6788
- const columnOnUpdate = "onUpdate" in snapshotColumn ? snapshotColumn.onUpdate : void 0;
6789
- const columnNotNull = table4.columns[columnName].notNull;
6790
- const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
6791
- const columnPk = table4.columns[columnName].primaryKey;
6700
+ const columnType = json2.tables[tableName].columns[columnName].type;
6701
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
6702
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
6703
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
6704
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
6705
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
6792
6706
  if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
6793
6707
  statements.push({
6794
6708
  type: "alter_table_alter_column_set_autoincrement",
@@ -6835,14 +6749,13 @@ var _prepareAlterColumns = (tableKey, schema4, columns, json2) => {
6835
6749
  }
6836
6750
  for (const column4 of columns) {
6837
6751
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
6838
- const tableName = json2.tables[tableKey].name;
6839
- const columnType = json2.tables[tableKey].columns[columnName].type;
6840
- const columnDefault = json2.tables[tableKey].columns[columnName].default;
6841
- const columnOnUpdate = json2.tables[tableKey].columns[columnName].onUpdate;
6842
- const columnNotNull = json2.tables[tableKey].columns[columnName].notNull;
6843
- const columnAutoIncrement = json2.tables[tableKey].columns[columnName].autoincrement;
6844
- const columnPk = json2.tables[tableKey].columns[columnName].primaryKey;
6845
- const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
6752
+ const columnType = json2.tables[tableName].columns[columnName].type;
6753
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
6754
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
6755
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
6756
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
6757
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
6758
+ const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
6846
6759
  if (typeof column4.name !== "string") {
6847
6760
  statements.push({
6848
6761
  type: "alter_table_rename_column",
@@ -7188,9 +7101,6 @@ var prepareAlterCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
7188
7101
  };
7189
7102
 
7190
7103
  // src/snapshotsDiffer.ts
7191
- init_sqliteSchema();
7192
- init_mysqlSchema();
7193
- init_global();
7194
7104
  var makeChanged = (schema4) => {
7195
7105
  return objectType({
7196
7106
  type: enumType(["changed"]),
@@ -7229,7 +7139,7 @@ var makeSelfOrPatched = (schema4) => {
7229
7139
  return unionType([
7230
7140
  objectType({
7231
7141
  type: literalType("none"),
7232
- value: schema4
7142
+ value: schema4.optional()
7233
7143
  }),
7234
7144
  objectType({
7235
7145
  type: literalType("added"),
@@ -7353,6 +7263,7 @@ var diffResultScheme = objectType({
7353
7263
  }).strict();
7354
7264
  var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
7355
7265
  var _a, _b;
7266
+ let diffResult;
7356
7267
  if (dialect3 === "mysql") {
7357
7268
  for (const tableName in json1.tables) {
7358
7269
  const table4 = json1.tables[tableName];
@@ -7380,26 +7291,13 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7380
7291
  }
7381
7292
  }
7382
7293
  }
7294
+ diffResult = applyJsonDiff(json1, json2);
7383
7295
  }
7384
- const diffResult = applyJsonDiff(json1, json2);
7296
+ diffResult = applyJsonDiff(json1, json2);
7385
7297
  if (Object.keys(diffResult).length === 0) {
7386
7298
  return { statements: [], sqlStatements: [], _meta: void 0 };
7387
7299
  }
7388
7300
  const typedResult = diffResultScheme.parse(diffResult);
7389
- typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
7390
- let schemaToTrim;
7391
- if (it.schema.type === "none") {
7392
- schemaToTrim = it.schema.value || "public";
7393
- } else if (it.schema.type === "deleted") {
7394
- schemaToTrim = it.schema.value;
7395
- } else if (it.schema.type === "added") {
7396
- schemaToTrim = "public";
7397
- } else {
7398
- schemaToTrim = it.schema.old;
7399
- }
7400
- it.name = it.name.substring(schemaToTrim.length + 1);
7401
- return it;
7402
- });
7403
7301
  const {
7404
7302
  created: createdSchemas,
7405
7303
  deleted: deletedSchemas,
@@ -7551,7 +7449,7 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7551
7449
  prevFull,
7552
7450
  curFull
7553
7451
  );
7554
- } else if (dialect3 === "mysql") {
7452
+ } else {
7555
7453
  addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
7556
7454
  it.name,
7557
7455
  it.addedCompositePKs,
@@ -7569,8 +7467,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7569
7467
  prevFull,
7570
7468
  curFull
7571
7469
  );
7572
- } else {
7573
- assertUnreachable(dialect3);
7574
7470
  }
7575
7471
  let addedUniqueConstraints = [];
7576
7472
  let deletedUniqueConstraints = [];
@@ -7761,13 +7657,11 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7761
7657
  return preparePgCreateTableJson(it, curFull);
7762
7658
  });
7763
7659
  jsonStatements.push(...jsonPgCreateTables);
7764
- } else if (dialect3 === "mysql") {
7660
+ } else {
7765
7661
  const jsonMySqlCreateTables = created.map((it) => {
7766
7662
  return prepareMySqlCreateTableJson(it, curFull);
7767
7663
  });
7768
7664
  jsonStatements.push(...jsonMySqlCreateTables);
7769
- } else {
7770
- assertUnreachable(dialect3);
7771
7665
  }
7772
7666
  jsonStatements.push(...jsonDropTables);
7773
7667
  jsonStatements.push(...jsonRenameTables);
@@ -7817,15 +7711,9 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7817
7711
 
7818
7712
  // src/cli/commands/pgUp.ts
7819
7713
  init_source();
7820
- init_global();
7821
- init_pgSchema();
7822
-
7823
- // src/cli/commands/upFolders.ts
7824
- init_pgSchema();
7825
7714
 
7826
7715
  // src/cli/commands/mysqlUp.ts
7827
7716
  init_source();
7828
- init_mysqlSchema();
7829
7717
 
7830
7718
  // src/cli/commands/upFolders.ts
7831
7719
  var resolveSchemas = (missingSchemas, newSchemas, predicate) => {
@@ -7926,7 +7814,7 @@ var resolveColumns = (missingColumns, newColumns, predicate) => {
7926
7814
  };
7927
7815
 
7928
7816
  // src/utils.ts
7929
- var assertV1OutFolder = (out) => {
7817
+ var assertV1OutFolder = (out, dialect3) => {
7930
7818
  if (!(0, import_fs.existsSync)(out))
7931
7819
  return;
7932
7820
  const oldMigrationFolders = (0, import_fs.readdirSync)(out).filter(
@@ -7935,7 +7823,7 @@ var assertV1OutFolder = (out) => {
7935
7823
  if (oldMigrationFolders.length > 0) {
7936
7824
  console.log(
7937
7825
  `Your migrations folder format is outdated, please run ${source_default.green.bold(
7938
- `drizzle-kit up`
7826
+ `drizzle-kit up:${dialect3}`
7939
7827
  )}`
7940
7828
  );
7941
7829
  process.exit(1);
@@ -7959,7 +7847,7 @@ var snapshotsPriorV4 = (out) => {
7959
7847
  return pathJson;
7960
7848
  });
7961
7849
  };
7962
- var prepareOutFolder = (out, dialect3) => {
7850
+ var prepareOutFolder2 = (out, dialect3) => {
7963
7851
  const meta = (0, import_path.join)(out, "meta");
7964
7852
  const journalPath = (0, import_path.join)(meta, "_journal.json");
7965
7853
  if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta"))) {
@@ -7974,9 +7862,9 @@ var prepareOutFolder = (out, dialect3) => {
7974
7862
  var validatorForDialect = (dialect3) => {
7975
7863
  switch (dialect3) {
7976
7864
  case "pg":
7977
- return { validator: backwardCompatiblePgSchema, version: 6 };
7865
+ return { validator: backwardCompatiblePgSchema, version: 5 };
7978
7866
  case "sqlite":
7979
- return { validator: backwardCompatibleSqliteSchema, version: 6 };
7867
+ return { validator: backwardCompatibleSqliteSchema, version: 5 };
7980
7868
  case "mysql":
7981
7869
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
7982
7870
  }
@@ -8024,13 +7912,13 @@ var validateWithReport = (snapshots, dialect3) => {
8024
7912
  return result;
8025
7913
  };
8026
7914
  var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
8027
- const { snapshots, journal } = prepareOutFolder(outFolder, dialect3);
7915
+ const { snapshots, journal } = prepareOutFolder2(outFolder, dialect3);
8028
7916
  const report = validateWithReport(snapshots, dialect3);
8029
7917
  if (report.nonLatest.length > 0) {
8030
7918
  console.log(
8031
7919
  report.nonLatest.map((it) => {
8032
7920
  return `${it}/snapshot.json is not of the latest version`;
8033
- }).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
7921
+ }).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect3}`)}`).join("\n")
8034
7922
  );
8035
7923
  process.exit(0);
8036
7924
  }
@@ -8163,9 +8051,7 @@ var statementsForDiffs = async (in1, in2) => {
8163
8051
  "pg",
8164
8052
  schemasResolver,
8165
8053
  tablesResolver,
8166
- columnsResolver,
8167
- left,
8168
- right
8054
+ columnsResolver
8169
8055
  );
8170
8056
  return { ...result, left, right };
8171
8057
  };