drizzle-kit 0.20.14-6ce9d1f → 0.20.14-a183d8b

Sign up to get free protection for your applications and to get access to all the features.
package/utils.js CHANGED
@@ -4241,6 +4241,717 @@ var init_lib = __esm({
4241
4241
  }
4242
4242
  });
4243
4243
 
4244
+ // src/serializer/mysqlSchema.ts
4245
+ var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, kitInternals, schemaInternal, schemaV3, schemaV4, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, mysqlSchema, backwardCompatibleMysqlSchema, dryMySql;
4246
+ var init_mysqlSchema = __esm({
4247
+ "src/serializer/mysqlSchema.ts"() {
4248
+ init_global();
4249
+ init_lib();
4250
+ index = objectType({
4251
+ name: stringType(),
4252
+ columns: stringType().array(),
4253
+ isUnique: booleanType(),
4254
+ using: enumType(["btree", "hash"]).optional(),
4255
+ algorithm: enumType(["default", "inplace", "copy"]).optional(),
4256
+ lock: enumType(["default", "none", "shared", "exclusive"]).optional()
4257
+ }).strict();
4258
+ fk = objectType({
4259
+ name: stringType(),
4260
+ tableFrom: stringType(),
4261
+ columnsFrom: stringType().array(),
4262
+ tableTo: stringType(),
4263
+ columnsTo: stringType().array(),
4264
+ onUpdate: stringType().optional(),
4265
+ onDelete: stringType().optional()
4266
+ }).strict();
4267
+ column = objectType({
4268
+ name: stringType(),
4269
+ type: stringType(),
4270
+ primaryKey: booleanType(),
4271
+ notNull: booleanType(),
4272
+ autoincrement: booleanType().optional(),
4273
+ default: anyType().optional(),
4274
+ onUpdate: anyType().optional()
4275
+ }).strict();
4276
+ tableV3 = objectType({
4277
+ name: stringType(),
4278
+ columns: recordType(stringType(), column),
4279
+ indexes: recordType(stringType(), index),
4280
+ foreignKeys: recordType(stringType(), fk)
4281
+ }).strict();
4282
+ compositePK = objectType({
4283
+ name: stringType(),
4284
+ columns: stringType().array()
4285
+ }).strict();
4286
+ uniqueConstraint = objectType({
4287
+ name: stringType(),
4288
+ columns: stringType().array()
4289
+ }).strict();
4290
+ tableV4 = objectType({
4291
+ name: stringType(),
4292
+ schema: stringType().optional(),
4293
+ columns: recordType(stringType(), column),
4294
+ indexes: recordType(stringType(), index),
4295
+ foreignKeys: recordType(stringType(), fk)
4296
+ }).strict();
4297
+ table = objectType({
4298
+ name: stringType(),
4299
+ schema: stringType().optional(),
4300
+ columns: recordType(stringType(), column),
4301
+ indexes: recordType(stringType(), index),
4302
+ foreignKeys: recordType(stringType(), fk),
4303
+ compositePrimaryKeys: recordType(stringType(), compositePK),
4304
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4305
+ }).strict();
4306
+ dialect = literalType("mysql");
4307
+ schemaHash = objectType({
4308
+ id: stringType(),
4309
+ prevId: stringType()
4310
+ });
4311
+ schemaInternalV3 = objectType({
4312
+ version: literalType("3"),
4313
+ dialect,
4314
+ tables: recordType(stringType(), tableV3)
4315
+ }).strict();
4316
+ schemaInternalV4 = objectType({
4317
+ version: literalType("4"),
4318
+ dialect,
4319
+ tables: recordType(stringType(), tableV4),
4320
+ schemas: recordType(stringType(), stringType())
4321
+ }).strict();
4322
+ kitInternals = objectType({
4323
+ tables: recordType(
4324
+ stringType(),
4325
+ objectType({
4326
+ columns: recordType(
4327
+ stringType(),
4328
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4329
+ )
4330
+ }).optional()
4331
+ )
4332
+ }).optional();
4333
+ schemaInternal = objectType({
4334
+ version: literalType("5"),
4335
+ dialect,
4336
+ tables: recordType(stringType(), table),
4337
+ schemas: recordType(stringType(), stringType()),
4338
+ _meta: objectType({
4339
+ schemas: recordType(stringType(), stringType()),
4340
+ tables: recordType(stringType(), stringType()),
4341
+ columns: recordType(stringType(), stringType())
4342
+ }),
4343
+ internal: kitInternals
4344
+ }).strict();
4345
+ schemaV3 = schemaInternalV3.merge(schemaHash);
4346
+ schemaV4 = schemaInternalV4.merge(schemaHash);
4347
+ schema = schemaInternal.merge(schemaHash);
4348
+ tableSquashedV4 = objectType({
4349
+ name: stringType(),
4350
+ schema: stringType().optional(),
4351
+ columns: recordType(stringType(), column),
4352
+ indexes: recordType(stringType(), stringType()),
4353
+ foreignKeys: recordType(stringType(), stringType())
4354
+ }).strict();
4355
+ tableSquashed = objectType({
4356
+ name: stringType(),
4357
+ schema: stringType().optional(),
4358
+ columns: recordType(stringType(), column),
4359
+ indexes: recordType(stringType(), stringType()),
4360
+ foreignKeys: recordType(stringType(), stringType()),
4361
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4362
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4363
+ }).strict();
4364
+ schemaSquashed = objectType({
4365
+ version: literalType("5"),
4366
+ dialect,
4367
+ tables: recordType(stringType(), tableSquashed),
4368
+ schemas: recordType(stringType(), stringType())
4369
+ }).strict();
4370
+ schemaSquashedV4 = objectType({
4371
+ version: literalType("4"),
4372
+ dialect,
4373
+ tables: recordType(stringType(), tableSquashedV4),
4374
+ schemas: recordType(stringType(), stringType())
4375
+ }).strict();
4376
+ MySqlSquasher = {
4377
+ squashIdx: (idx) => {
4378
+ index.parse(idx);
4379
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
4380
+ },
4381
+ unsquashIdx: (input) => {
4382
+ const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
4383
+ const destructed = {
4384
+ name,
4385
+ columns: columnsString.split(","),
4386
+ isUnique: isUnique === "true",
4387
+ using: using ? using : void 0,
4388
+ algorithm: algorithm ? algorithm : void 0,
4389
+ lock: lock ? lock : void 0
4390
+ };
4391
+ return index.parse(destructed);
4392
+ },
4393
+ squashPK: (pk) => {
4394
+ return `${pk.name};${pk.columns.join(",")}`;
4395
+ },
4396
+ unsquashPK: (pk) => {
4397
+ const splitted = pk.split(";");
4398
+ return { name: splitted[0], columns: splitted[1].split(",") };
4399
+ },
4400
+ squashUnique: (unq) => {
4401
+ return `${unq.name};${unq.columns.join(",")}`;
4402
+ },
4403
+ unsquashUnique: (unq) => {
4404
+ const [name, columns] = unq.split(";");
4405
+ return { name, columns: columns.split(",") };
4406
+ },
4407
+ squashFK: (fk4) => {
4408
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4409
+ },
4410
+ unsquashFK: (input) => {
4411
+ const [
4412
+ name,
4413
+ tableFrom,
4414
+ columnsFromStr,
4415
+ tableTo,
4416
+ columnsToStr,
4417
+ onUpdate,
4418
+ onDelete
4419
+ ] = input.split(";");
4420
+ const result = fk.parse({
4421
+ name,
4422
+ tableFrom,
4423
+ columnsFrom: columnsFromStr.split(","),
4424
+ tableTo,
4425
+ columnsTo: columnsToStr.split(","),
4426
+ onUpdate,
4427
+ onDelete
4428
+ });
4429
+ return result;
4430
+ }
4431
+ };
4432
+ mysqlSchema = schema;
4433
+ backwardCompatibleMysqlSchema = unionType([
4434
+ schemaV3,
4435
+ schemaV4,
4436
+ schema
4437
+ ]);
4438
+ dryMySql = mysqlSchema.parse({
4439
+ version: snapshotVersion,
4440
+ dialect: "mysql",
4441
+ id: originUUID,
4442
+ prevId: "",
4443
+ tables: {},
4444
+ schemas: {},
4445
+ _meta: {
4446
+ schemas: {},
4447
+ tables: {},
4448
+ columns: {}
4449
+ }
4450
+ });
4451
+ }
4452
+ });
4453
+
4454
+ // src/serializer/pgSchema.ts
4455
+ var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals2, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
4456
+ var init_pgSchema = __esm({
4457
+ "src/serializer/pgSchema.ts"() {
4458
+ init_global();
4459
+ init_lib();
4460
+ indexV2 = objectType({
4461
+ name: stringType(),
4462
+ columns: recordType(
4463
+ stringType(),
4464
+ objectType({
4465
+ name: stringType()
4466
+ })
4467
+ ),
4468
+ isUnique: booleanType()
4469
+ }).strict();
4470
+ columnV2 = objectType({
4471
+ name: stringType(),
4472
+ type: stringType(),
4473
+ primaryKey: booleanType(),
4474
+ notNull: booleanType(),
4475
+ default: anyType().optional(),
4476
+ references: stringType().optional()
4477
+ }).strict();
4478
+ tableV2 = objectType({
4479
+ name: stringType(),
4480
+ columns: recordType(stringType(), columnV2),
4481
+ indexes: recordType(stringType(), indexV2)
4482
+ }).strict();
4483
+ enumSchema = objectType({
4484
+ name: stringType(),
4485
+ values: recordType(stringType(), stringType())
4486
+ }).strict();
4487
+ pgSchemaV2 = objectType({
4488
+ version: literalType("2"),
4489
+ tables: recordType(stringType(), tableV2),
4490
+ enums: recordType(stringType(), enumSchema)
4491
+ }).strict();
4492
+ references = objectType({
4493
+ foreignKeyName: stringType(),
4494
+ table: stringType(),
4495
+ column: stringType(),
4496
+ onDelete: stringType().optional(),
4497
+ onUpdate: stringType().optional()
4498
+ }).strict();
4499
+ columnV1 = objectType({
4500
+ name: stringType(),
4501
+ type: stringType(),
4502
+ primaryKey: booleanType(),
4503
+ notNull: booleanType(),
4504
+ default: anyType().optional(),
4505
+ references: references.optional()
4506
+ }).strict();
4507
+ tableV1 = objectType({
4508
+ name: stringType(),
4509
+ columns: recordType(stringType(), columnV1),
4510
+ indexes: recordType(stringType(), indexV2)
4511
+ }).strict();
4512
+ pgSchemaV1 = objectType({
4513
+ version: literalType("1"),
4514
+ tables: recordType(stringType(), tableV1),
4515
+ enums: recordType(stringType(), enumSchema)
4516
+ }).strict();
4517
+ index2 = objectType({
4518
+ name: stringType(),
4519
+ columns: stringType().array(),
4520
+ isUnique: booleanType()
4521
+ }).strict();
4522
+ fk2 = objectType({
4523
+ name: stringType(),
4524
+ tableFrom: stringType(),
4525
+ columnsFrom: stringType().array(),
4526
+ tableTo: stringType(),
4527
+ schemaTo: stringType().optional(),
4528
+ columnsTo: stringType().array(),
4529
+ onUpdate: stringType().optional(),
4530
+ onDelete: stringType().optional()
4531
+ }).strict();
4532
+ column2 = objectType({
4533
+ name: stringType(),
4534
+ type: stringType(),
4535
+ primaryKey: booleanType(),
4536
+ notNull: booleanType(),
4537
+ default: anyType().optional(),
4538
+ isUnique: anyType().optional(),
4539
+ uniqueName: stringType().optional(),
4540
+ nullsNotDistinct: booleanType().optional()
4541
+ }).strict();
4542
+ tableV32 = objectType({
4543
+ name: stringType(),
4544
+ columns: recordType(stringType(), column2),
4545
+ indexes: recordType(stringType(), index2),
4546
+ foreignKeys: recordType(stringType(), fk2)
4547
+ }).strict();
4548
+ compositePK2 = objectType({
4549
+ name: stringType(),
4550
+ columns: stringType().array()
4551
+ }).strict();
4552
+ uniqueConstraint2 = objectType({
4553
+ name: stringType(),
4554
+ columns: stringType().array(),
4555
+ nullsNotDistinct: booleanType()
4556
+ }).strict();
4557
+ tableV42 = objectType({
4558
+ name: stringType(),
4559
+ schema: stringType(),
4560
+ columns: recordType(stringType(), column2),
4561
+ indexes: recordType(stringType(), index2),
4562
+ foreignKeys: recordType(stringType(), fk2)
4563
+ }).strict();
4564
+ table2 = objectType({
4565
+ name: stringType(),
4566
+ schema: stringType(),
4567
+ columns: recordType(stringType(), column2),
4568
+ indexes: recordType(stringType(), index2),
4569
+ foreignKeys: recordType(stringType(), fk2),
4570
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4571
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4572
+ }).strict();
4573
+ schemaHash2 = objectType({
4574
+ id: stringType(),
4575
+ prevId: stringType()
4576
+ });
4577
+ pgSchemaInternalV3 = objectType({
4578
+ version: literalType("3"),
4579
+ dialect: literalType("pg"),
4580
+ tables: recordType(stringType(), tableV32),
4581
+ enums: recordType(stringType(), enumSchema)
4582
+ }).strict();
4583
+ pgSchemaInternalV4 = objectType({
4584
+ version: literalType("4"),
4585
+ dialect: literalType("pg"),
4586
+ tables: recordType(stringType(), tableV42),
4587
+ enums: recordType(stringType(), enumSchema),
4588
+ schemas: recordType(stringType(), stringType())
4589
+ }).strict();
4590
+ pgSchemaExternal = objectType({
4591
+ version: literalType("5"),
4592
+ dialect: literalType("pg"),
4593
+ tables: arrayType(table2),
4594
+ enums: arrayType(enumSchema),
4595
+ schemas: arrayType(objectType({ name: stringType() })),
4596
+ _meta: objectType({
4597
+ schemas: recordType(stringType(), stringType()),
4598
+ tables: recordType(stringType(), stringType()),
4599
+ columns: recordType(stringType(), stringType())
4600
+ })
4601
+ }).strict();
4602
+ kitInternals2 = objectType({
4603
+ tables: recordType(
4604
+ stringType(),
4605
+ objectType({
4606
+ columns: recordType(
4607
+ stringType(),
4608
+ objectType({
4609
+ isArray: booleanType().optional(),
4610
+ dimensions: numberType().optional(),
4611
+ rawType: stringType().optional()
4612
+ }).optional()
4613
+ )
4614
+ }).optional()
4615
+ )
4616
+ }).optional();
4617
+ pgSchemaInternal = objectType({
4618
+ version: literalType("5"),
4619
+ dialect: literalType("pg"),
4620
+ tables: recordType(stringType(), table2),
4621
+ enums: recordType(stringType(), enumSchema),
4622
+ schemas: recordType(stringType(), stringType()),
4623
+ _meta: objectType({
4624
+ schemas: recordType(stringType(), stringType()),
4625
+ tables: recordType(stringType(), stringType()),
4626
+ columns: recordType(stringType(), stringType())
4627
+ }),
4628
+ internal: kitInternals2
4629
+ }).strict();
4630
+ tableSquashed2 = objectType({
4631
+ name: stringType(),
4632
+ schema: stringType(),
4633
+ columns: recordType(stringType(), column2),
4634
+ indexes: recordType(stringType(), stringType()),
4635
+ foreignKeys: recordType(stringType(), stringType()),
4636
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4637
+ uniqueConstraints: recordType(stringType(), stringType())
4638
+ }).strict();
4639
+ tableSquashedV42 = objectType({
4640
+ name: stringType(),
4641
+ schema: stringType(),
4642
+ columns: recordType(stringType(), column2),
4643
+ indexes: recordType(stringType(), stringType()),
4644
+ foreignKeys: recordType(stringType(), stringType())
4645
+ }).strict();
4646
+ pgSchemaSquashedV4 = objectType({
4647
+ version: literalType("4"),
4648
+ dialect: enumType(["pg"]),
4649
+ tables: recordType(stringType(), tableSquashedV42),
4650
+ enums: recordType(stringType(), enumSchema),
4651
+ schemas: recordType(stringType(), stringType())
4652
+ }).strict();
4653
+ pgSchemaSquashed = objectType({
4654
+ version: literalType("5"),
4655
+ dialect: enumType(["pg"]),
4656
+ tables: recordType(stringType(), tableSquashed2),
4657
+ enums: recordType(stringType(), enumSchema),
4658
+ schemas: recordType(stringType(), stringType())
4659
+ }).strict();
4660
+ pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4661
+ pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4662
+ pgSchema = pgSchemaInternal.merge(schemaHash2);
4663
+ backwardCompatiblePgSchema = unionType([
4664
+ pgSchemaV1,
4665
+ pgSchemaV2,
4666
+ pgSchemaV3,
4667
+ pgSchemaV4,
4668
+ pgSchema
4669
+ ]);
4670
+ PgSquasher = {
4671
+ squashIdx: (idx) => {
4672
+ index2.parse(idx);
4673
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
4674
+ },
4675
+ unsquashIdx: (input) => {
4676
+ const [name, columnsString, isUnique] = input.split(";");
4677
+ const result = index2.parse({
4678
+ name,
4679
+ columns: columnsString.split(","),
4680
+ isUnique: isUnique === "true"
4681
+ });
4682
+ return result;
4683
+ },
4684
+ squashFK: (fk4) => {
4685
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
4686
+ },
4687
+ squashPK: (pk) => {
4688
+ return `${pk.columns.join(",")};${pk.name}`;
4689
+ },
4690
+ unsquashPK: (pk) => {
4691
+ const splitted = pk.split(";");
4692
+ return { name: splitted[1], columns: splitted[0].split(",") };
4693
+ },
4694
+ squashUnique: (unq) => {
4695
+ return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
4696
+ },
4697
+ unsquashUnique: (unq) => {
4698
+ const [name, columns, nullsNotDistinct] = unq.split(";");
4699
+ return {
4700
+ name,
4701
+ columns: columns.split(","),
4702
+ nullsNotDistinct: nullsNotDistinct === "true"
4703
+ };
4704
+ },
4705
+ unsquashFK: (input) => {
4706
+ const [
4707
+ name,
4708
+ tableFrom,
4709
+ columnsFromStr,
4710
+ tableTo,
4711
+ columnsToStr,
4712
+ onUpdate,
4713
+ onDelete,
4714
+ schemaTo
4715
+ ] = input.split(";");
4716
+ const result = fk2.parse({
4717
+ name,
4718
+ tableFrom,
4719
+ columnsFrom: columnsFromStr.split(","),
4720
+ schemaTo,
4721
+ tableTo,
4722
+ columnsTo: columnsToStr.split(","),
4723
+ onUpdate,
4724
+ onDelete
4725
+ });
4726
+ return result;
4727
+ }
4728
+ };
4729
+ squashPgScheme = (json) => {
4730
+ const mappedTables = Object.fromEntries(
4731
+ Object.entries(json.tables).map((it) => {
4732
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
4733
+ return PgSquasher.squashIdx(index4);
4734
+ });
4735
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
4736
+ return PgSquasher.squashFK(fk4);
4737
+ });
4738
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
4739
+ return PgSquasher.squashPK(pk);
4740
+ });
4741
+ const squashedUniqueConstraints = mapValues(
4742
+ it[1].uniqueConstraints,
4743
+ (unq) => {
4744
+ return PgSquasher.squashUnique(unq);
4745
+ }
4746
+ );
4747
+ return [
4748
+ it[0],
4749
+ {
4750
+ name: it[1].name,
4751
+ schema: it[1].schema,
4752
+ columns: it[1].columns,
4753
+ indexes: squashedIndexes,
4754
+ foreignKeys: squashedFKs,
4755
+ compositePrimaryKeys: squashedPKs,
4756
+ uniqueConstraints: squashedUniqueConstraints
4757
+ }
4758
+ ];
4759
+ })
4760
+ );
4761
+ return {
4762
+ version: "5",
4763
+ dialect: json.dialect,
4764
+ tables: mappedTables,
4765
+ enums: json.enums,
4766
+ schemas: json.schemas
4767
+ };
4768
+ };
4769
+ dryPg = pgSchema.parse({
4770
+ version: snapshotVersion,
4771
+ dialect: "pg",
4772
+ id: originUUID,
4773
+ prevId: "",
4774
+ tables: {},
4775
+ enums: {},
4776
+ schemas: {},
4777
+ _meta: {
4778
+ schemas: {},
4779
+ tables: {},
4780
+ columns: {}
4781
+ }
4782
+ });
4783
+ }
4784
+ });
4785
+
4786
+ // src/serializer/sqliteSchema.ts
4787
+ var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, drySQLite, backwardCompatibleSqliteSchema;
4788
+ var init_sqliteSchema = __esm({
4789
+ "src/serializer/sqliteSchema.ts"() {
4790
+ init_global();
4791
+ init_lib();
4792
+ index3 = objectType({
4793
+ name: stringType(),
4794
+ columns: stringType().array(),
4795
+ where: stringType().optional(),
4796
+ isUnique: booleanType()
4797
+ }).strict();
4798
+ fk3 = objectType({
4799
+ name: stringType(),
4800
+ tableFrom: stringType(),
4801
+ columnsFrom: stringType().array(),
4802
+ tableTo: stringType(),
4803
+ columnsTo: stringType().array(),
4804
+ onUpdate: stringType().optional(),
4805
+ onDelete: stringType().optional()
4806
+ }).strict();
4807
+ compositePK3 = objectType({
4808
+ columns: stringType().array(),
4809
+ name: stringType().optional()
4810
+ }).strict();
4811
+ column3 = objectType({
4812
+ name: stringType(),
4813
+ type: stringType(),
4814
+ primaryKey: booleanType(),
4815
+ notNull: booleanType(),
4816
+ autoincrement: booleanType().optional(),
4817
+ default: anyType().optional()
4818
+ }).strict();
4819
+ tableV33 = objectType({
4820
+ name: stringType(),
4821
+ columns: recordType(stringType(), column3),
4822
+ indexes: recordType(stringType(), index3),
4823
+ foreignKeys: recordType(stringType(), fk3)
4824
+ }).strict();
4825
+ uniqueConstraint3 = objectType({
4826
+ name: stringType(),
4827
+ columns: stringType().array()
4828
+ }).strict();
4829
+ table3 = objectType({
4830
+ name: stringType(),
4831
+ columns: recordType(stringType(), column3),
4832
+ indexes: recordType(stringType(), index3),
4833
+ foreignKeys: recordType(stringType(), fk3),
4834
+ compositePrimaryKeys: recordType(stringType(), compositePK3),
4835
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
4836
+ }).strict();
4837
+ dialect2 = enumType(["sqlite"]);
4838
+ schemaHash3 = objectType({
4839
+ id: stringType(),
4840
+ prevId: stringType()
4841
+ }).strict();
4842
+ schemaInternalV32 = objectType({
4843
+ version: literalType("3"),
4844
+ dialect: dialect2,
4845
+ tables: recordType(stringType(), tableV33),
4846
+ enums: objectType({})
4847
+ }).strict();
4848
+ schemaInternalV42 = objectType({
4849
+ version: literalType("4"),
4850
+ dialect: dialect2,
4851
+ tables: recordType(stringType(), table3),
4852
+ enums: objectType({})
4853
+ }).strict();
4854
+ latestVersion = literalType("5");
4855
+ schemaInternal2 = objectType({
4856
+ version: latestVersion,
4857
+ dialect: dialect2,
4858
+ tables: recordType(stringType(), table3),
4859
+ enums: objectType({}),
4860
+ _meta: objectType({
4861
+ tables: recordType(stringType(), stringType()),
4862
+ columns: recordType(stringType(), stringType())
4863
+ })
4864
+ }).strict();
4865
+ schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
4866
+ schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
4867
+ schema2 = schemaInternal2.merge(schemaHash3).strict();
4868
+ tableSquashed3 = objectType({
4869
+ name: stringType(),
4870
+ columns: recordType(stringType(), column3),
4871
+ indexes: recordType(stringType(), stringType()),
4872
+ foreignKeys: recordType(stringType(), stringType()),
4873
+ compositePrimaryKeys: recordType(stringType(), stringType()),
4874
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4875
+ }).strict();
4876
+ schemaSquashed2 = objectType({
4877
+ version: latestVersion,
4878
+ dialect: dialect2,
4879
+ tables: recordType(stringType(), tableSquashed3),
4880
+ enums: anyType()
4881
+ }).strict();
4882
+ SQLiteSquasher = {
4883
+ squashIdx: (idx) => {
4884
+ index3.parse(idx);
4885
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
4886
+ },
4887
+ unsquashIdx: (input) => {
4888
+ const [name, columnsString, isUnique, where] = input.split(";");
4889
+ const result = index3.parse({
4890
+ name,
4891
+ columns: columnsString.split(","),
4892
+ isUnique: isUnique === "true",
4893
+ where: where ?? void 0
4894
+ });
4895
+ return result;
4896
+ },
4897
+ squashUnique: (unq) => {
4898
+ return `${unq.name};${unq.columns.join(",")}`;
4899
+ },
4900
+ unsquashUnique: (unq) => {
4901
+ const [name, columns] = unq.split(";");
4902
+ return { name, columns: columns.split(",") };
4903
+ },
4904
+ squashFK: (fk4) => {
4905
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4906
+ },
4907
+ unsquashFK: (input) => {
4908
+ const [
4909
+ name,
4910
+ tableFrom,
4911
+ columnsFromStr,
4912
+ tableTo,
4913
+ columnsToStr,
4914
+ onUpdate,
4915
+ onDelete
4916
+ ] = input.split(";");
4917
+ const result = fk3.parse({
4918
+ name,
4919
+ tableFrom,
4920
+ columnsFrom: columnsFromStr.split(","),
4921
+ tableTo,
4922
+ columnsTo: columnsToStr.split(","),
4923
+ onUpdate,
4924
+ onDelete
4925
+ });
4926
+ return result;
4927
+ },
4928
+ squashPK: (pk) => {
4929
+ return pk.columns.join(",");
4930
+ },
4931
+ unsquashPK: (pk) => {
4932
+ return pk.split(",");
4933
+ }
4934
+ };
4935
+ drySQLite = schema2.parse({
4936
+ version: snapshotVersion,
4937
+ dialect: "sqlite",
4938
+ id: originUUID,
4939
+ prevId: "",
4940
+ tables: {},
4941
+ enums: {},
4942
+ _meta: {
4943
+ tables: {},
4944
+ columns: {}
4945
+ }
4946
+ });
4947
+ backwardCompatibleSqliteSchema = unionType([
4948
+ schemaV32,
4949
+ schemaV42,
4950
+ schema2
4951
+ ]);
4952
+ }
4953
+ });
4954
+
4244
4955
  // src/serializer/index.ts
4245
4956
  var glob;
4246
4957
  var init_serializer = __esm({
@@ -4277,704 +4988,9 @@ __export(utils_exports, {
4277
4988
  module.exports = __toCommonJS(utils_exports);
4278
4989
  var import_fs = require("fs");
4279
4990
  init_views();
4280
-
4281
- // src/serializer/mysqlSchema.ts
4282
- init_global();
4283
- init_lib();
4284
- var index = objectType({
4285
- name: stringType(),
4286
- columns: stringType().array(),
4287
- isUnique: booleanType(),
4288
- using: enumType(["btree", "hash"]).optional(),
4289
- algorithm: enumType(["default", "inplace", "copy"]).optional(),
4290
- lock: enumType(["default", "none", "shared", "exclusive"]).optional()
4291
- }).strict();
4292
- var fk = objectType({
4293
- name: stringType(),
4294
- tableFrom: stringType(),
4295
- columnsFrom: stringType().array(),
4296
- tableTo: stringType(),
4297
- columnsTo: stringType().array(),
4298
- onUpdate: stringType().optional(),
4299
- onDelete: stringType().optional()
4300
- }).strict();
4301
- var column = objectType({
4302
- name: stringType(),
4303
- type: stringType(),
4304
- primaryKey: booleanType(),
4305
- notNull: booleanType(),
4306
- autoincrement: booleanType().optional(),
4307
- default: anyType().optional(),
4308
- onUpdate: anyType().optional()
4309
- }).strict();
4310
- var tableV3 = objectType({
4311
- name: stringType(),
4312
- columns: recordType(stringType(), column),
4313
- indexes: recordType(stringType(), index),
4314
- foreignKeys: recordType(stringType(), fk)
4315
- }).strict();
4316
- var compositePK = objectType({
4317
- name: stringType(),
4318
- columns: stringType().array()
4319
- }).strict();
4320
- var uniqueConstraint = objectType({
4321
- name: stringType(),
4322
- columns: stringType().array()
4323
- }).strict();
4324
- var tableV4 = objectType({
4325
- name: stringType(),
4326
- schema: stringType().optional(),
4327
- columns: recordType(stringType(), column),
4328
- indexes: recordType(stringType(), index),
4329
- foreignKeys: recordType(stringType(), fk)
4330
- }).strict();
4331
- var table = objectType({
4332
- name: stringType(),
4333
- schema: stringType().optional(),
4334
- columns: recordType(stringType(), column),
4335
- indexes: recordType(stringType(), index),
4336
- foreignKeys: recordType(stringType(), fk),
4337
- compositePrimaryKeys: recordType(stringType(), compositePK),
4338
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4339
- }).strict();
4340
- var dialect = literalType("mysql");
4341
- var schemaHash = objectType({
4342
- id: stringType(),
4343
- prevId: stringType()
4344
- });
4345
- var schemaInternalV3 = objectType({
4346
- version: literalType("3"),
4347
- dialect,
4348
- tables: recordType(stringType(), tableV3)
4349
- }).strict();
4350
- var schemaInternalV4 = objectType({
4351
- version: literalType("4"),
4352
- dialect,
4353
- tables: recordType(stringType(), tableV4),
4354
- schemas: recordType(stringType(), stringType())
4355
- }).strict();
4356
- var kitInternals = objectType({
4357
- tables: recordType(
4358
- stringType(),
4359
- objectType({
4360
- columns: recordType(
4361
- stringType(),
4362
- objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4363
- )
4364
- }).optional()
4365
- )
4366
- }).optional();
4367
- var schemaInternal = objectType({
4368
- version: literalType("5"),
4369
- dialect,
4370
- tables: recordType(stringType(), table),
4371
- schemas: recordType(stringType(), stringType()),
4372
- _meta: objectType({
4373
- schemas: recordType(stringType(), stringType()),
4374
- tables: recordType(stringType(), stringType()),
4375
- columns: recordType(stringType(), stringType())
4376
- }),
4377
- internal: kitInternals
4378
- }).strict();
4379
- var schemaV3 = schemaInternalV3.merge(schemaHash);
4380
- var schemaV4 = schemaInternalV4.merge(schemaHash);
4381
- var schema = schemaInternal.merge(schemaHash);
4382
- var tableSquashedV4 = objectType({
4383
- name: stringType(),
4384
- schema: stringType().optional(),
4385
- columns: recordType(stringType(), column),
4386
- indexes: recordType(stringType(), stringType()),
4387
- foreignKeys: recordType(stringType(), stringType())
4388
- }).strict();
4389
- var tableSquashed = objectType({
4390
- name: stringType(),
4391
- schema: stringType().optional(),
4392
- columns: recordType(stringType(), column),
4393
- indexes: recordType(stringType(), stringType()),
4394
- foreignKeys: recordType(stringType(), stringType()),
4395
- compositePrimaryKeys: recordType(stringType(), stringType()),
4396
- uniqueConstraints: recordType(stringType(), stringType()).default({})
4397
- }).strict();
4398
- var schemaSquashed = objectType({
4399
- version: literalType("5"),
4400
- dialect,
4401
- tables: recordType(stringType(), tableSquashed),
4402
- schemas: recordType(stringType(), stringType())
4403
- }).strict();
4404
- var schemaSquashedV4 = objectType({
4405
- version: literalType("4"),
4406
- dialect,
4407
- tables: recordType(stringType(), tableSquashedV4),
4408
- schemas: recordType(stringType(), stringType())
4409
- }).strict();
4410
- var MySqlSquasher = {
4411
- squashIdx: (idx) => {
4412
- index.parse(idx);
4413
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
4414
- },
4415
- unsquashIdx: (input) => {
4416
- const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
4417
- const destructed = {
4418
- name,
4419
- columns: columnsString.split(","),
4420
- isUnique: isUnique === "true",
4421
- using: using ? using : void 0,
4422
- algorithm: algorithm ? algorithm : void 0,
4423
- lock: lock ? lock : void 0
4424
- };
4425
- return index.parse(destructed);
4426
- },
4427
- squashPK: (pk) => {
4428
- return `${pk.name};${pk.columns.join(",")}`;
4429
- },
4430
- unsquashPK: (pk) => {
4431
- const splitted = pk.split(";");
4432
- return { name: splitted[0], columns: splitted[1].split(",") };
4433
- },
4434
- squashUnique: (unq) => {
4435
- return `${unq.name};${unq.columns.join(",")}`;
4436
- },
4437
- unsquashUnique: (unq) => {
4438
- const [name, columns] = unq.split(";");
4439
- return { name, columns: columns.split(",") };
4440
- },
4441
- squashFK: (fk4) => {
4442
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4443
- },
4444
- unsquashFK: (input) => {
4445
- const [
4446
- name,
4447
- tableFrom,
4448
- columnsFromStr,
4449
- tableTo,
4450
- columnsToStr,
4451
- onUpdate,
4452
- onDelete
4453
- ] = input.split(";");
4454
- const result = fk.parse({
4455
- name,
4456
- tableFrom,
4457
- columnsFrom: columnsFromStr.split(","),
4458
- tableTo,
4459
- columnsTo: columnsToStr.split(","),
4460
- onUpdate,
4461
- onDelete
4462
- });
4463
- return result;
4464
- }
4465
- };
4466
- var mysqlSchema = schema;
4467
- var backwardCompatibleMysqlSchema = unionType([
4468
- schemaV3,
4469
- schemaV4,
4470
- schema
4471
- ]);
4472
- var dryMySql = mysqlSchema.parse({
4473
- version: snapshotVersion,
4474
- dialect: "mysql",
4475
- id: originUUID,
4476
- prevId: "",
4477
- tables: {},
4478
- schemas: {},
4479
- _meta: {
4480
- schemas: {},
4481
- tables: {},
4482
- columns: {}
4483
- }
4484
- });
4485
-
4486
- // src/serializer/pgSchema.ts
4487
- init_global();
4488
- init_lib();
4489
- var indexV2 = objectType({
4490
- name: stringType(),
4491
- columns: recordType(
4492
- stringType(),
4493
- objectType({
4494
- name: stringType()
4495
- })
4496
- ),
4497
- isUnique: booleanType()
4498
- }).strict();
4499
- var columnV2 = objectType({
4500
- name: stringType(),
4501
- type: stringType(),
4502
- primaryKey: booleanType(),
4503
- notNull: booleanType(),
4504
- default: anyType().optional(),
4505
- references: stringType().optional()
4506
- }).strict();
4507
- var tableV2 = objectType({
4508
- name: stringType(),
4509
- columns: recordType(stringType(), columnV2),
4510
- indexes: recordType(stringType(), indexV2)
4511
- }).strict();
4512
- var enumSchema = objectType({
4513
- name: stringType(),
4514
- values: recordType(stringType(), stringType())
4515
- }).strict();
4516
- var pgSchemaV2 = objectType({
4517
- version: literalType("2"),
4518
- tables: recordType(stringType(), tableV2),
4519
- enums: recordType(stringType(), enumSchema)
4520
- }).strict();
4521
- var references = objectType({
4522
- foreignKeyName: stringType(),
4523
- table: stringType(),
4524
- column: stringType(),
4525
- onDelete: stringType().optional(),
4526
- onUpdate: stringType().optional()
4527
- }).strict();
4528
- var columnV1 = objectType({
4529
- name: stringType(),
4530
- type: stringType(),
4531
- primaryKey: booleanType(),
4532
- notNull: booleanType(),
4533
- default: anyType().optional(),
4534
- references: references.optional()
4535
- }).strict();
4536
- var tableV1 = objectType({
4537
- name: stringType(),
4538
- columns: recordType(stringType(), columnV1),
4539
- indexes: recordType(stringType(), indexV2)
4540
- }).strict();
4541
- var pgSchemaV1 = objectType({
4542
- version: literalType("1"),
4543
- tables: recordType(stringType(), tableV1),
4544
- enums: recordType(stringType(), enumSchema)
4545
- }).strict();
4546
- var index2 = objectType({
4547
- name: stringType(),
4548
- columns: stringType().array(),
4549
- isUnique: booleanType()
4550
- }).strict();
4551
- var fk2 = objectType({
4552
- name: stringType(),
4553
- tableFrom: stringType(),
4554
- columnsFrom: stringType().array(),
4555
- tableTo: stringType(),
4556
- schemaTo: stringType().optional(),
4557
- columnsTo: stringType().array(),
4558
- onUpdate: stringType().optional(),
4559
- onDelete: stringType().optional()
4560
- }).strict();
4561
- var column2 = objectType({
4562
- name: stringType(),
4563
- type: stringType(),
4564
- primaryKey: booleanType(),
4565
- notNull: booleanType(),
4566
- default: anyType().optional(),
4567
- isUnique: anyType().optional(),
4568
- uniqueName: stringType().optional(),
4569
- nullsNotDistinct: booleanType().optional()
4570
- }).strict();
4571
- var tableV32 = objectType({
4572
- name: stringType(),
4573
- columns: recordType(stringType(), column2),
4574
- indexes: recordType(stringType(), index2),
4575
- foreignKeys: recordType(stringType(), fk2)
4576
- }).strict();
4577
- var compositePK2 = objectType({
4578
- name: stringType(),
4579
- columns: stringType().array()
4580
- }).strict();
4581
- var uniqueConstraint2 = objectType({
4582
- name: stringType(),
4583
- columns: stringType().array(),
4584
- nullsNotDistinct: booleanType()
4585
- }).strict();
4586
- var tableV42 = objectType({
4587
- name: stringType(),
4588
- schema: stringType(),
4589
- columns: recordType(stringType(), column2),
4590
- indexes: recordType(stringType(), index2),
4591
- foreignKeys: recordType(stringType(), fk2)
4592
- }).strict();
4593
- var table2 = objectType({
4594
- name: stringType(),
4595
- schema: stringType(),
4596
- columns: recordType(stringType(), column2),
4597
- indexes: recordType(stringType(), index2),
4598
- foreignKeys: recordType(stringType(), fk2),
4599
- compositePrimaryKeys: recordType(stringType(), compositePK2),
4600
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4601
- }).strict();
4602
- var schemaHash2 = objectType({
4603
- id: stringType(),
4604
- prevId: stringType()
4605
- });
4606
- var pgSchemaInternalV3 = objectType({
4607
- version: literalType("3"),
4608
- dialect: literalType("pg"),
4609
- tables: recordType(stringType(), tableV32),
4610
- enums: recordType(stringType(), enumSchema)
4611
- }).strict();
4612
- var pgSchemaInternalV4 = objectType({
4613
- version: literalType("4"),
4614
- dialect: literalType("pg"),
4615
- tables: recordType(stringType(), tableV42),
4616
- enums: recordType(stringType(), enumSchema),
4617
- schemas: recordType(stringType(), stringType())
4618
- }).strict();
4619
- var pgSchemaExternal = objectType({
4620
- version: literalType("5"),
4621
- dialect: literalType("pg"),
4622
- tables: arrayType(table2),
4623
- enums: arrayType(enumSchema),
4624
- schemas: arrayType(objectType({ name: stringType() })),
4625
- _meta: objectType({
4626
- schemas: recordType(stringType(), stringType()),
4627
- tables: recordType(stringType(), stringType()),
4628
- columns: recordType(stringType(), stringType())
4629
- })
4630
- }).strict();
4631
- var kitInternals2 = objectType({
4632
- tables: recordType(
4633
- stringType(),
4634
- objectType({
4635
- columns: recordType(
4636
- stringType(),
4637
- objectType({
4638
- isArray: booleanType().optional(),
4639
- dimensions: numberType().optional(),
4640
- rawType: stringType().optional()
4641
- }).optional()
4642
- )
4643
- }).optional()
4644
- )
4645
- }).optional();
4646
- var pgSchemaInternal = objectType({
4647
- version: literalType("5"),
4648
- dialect: literalType("pg"),
4649
- tables: recordType(stringType(), table2),
4650
- enums: recordType(stringType(), enumSchema),
4651
- schemas: recordType(stringType(), stringType()),
4652
- _meta: objectType({
4653
- schemas: recordType(stringType(), stringType()),
4654
- tables: recordType(stringType(), stringType()),
4655
- columns: recordType(stringType(), stringType())
4656
- }),
4657
- internal: kitInternals2
4658
- }).strict();
4659
- var tableSquashed2 = objectType({
4660
- name: stringType(),
4661
- schema: stringType(),
4662
- columns: recordType(stringType(), column2),
4663
- indexes: recordType(stringType(), stringType()),
4664
- foreignKeys: recordType(stringType(), stringType()),
4665
- compositePrimaryKeys: recordType(stringType(), stringType()),
4666
- uniqueConstraints: recordType(stringType(), stringType())
4667
- }).strict();
4668
- var tableSquashedV42 = objectType({
4669
- name: stringType(),
4670
- schema: stringType(),
4671
- columns: recordType(stringType(), column2),
4672
- indexes: recordType(stringType(), stringType()),
4673
- foreignKeys: recordType(stringType(), stringType())
4674
- }).strict();
4675
- var pgSchemaSquashedV4 = objectType({
4676
- version: literalType("4"),
4677
- dialect: enumType(["pg"]),
4678
- tables: recordType(stringType(), tableSquashedV42),
4679
- enums: recordType(stringType(), enumSchema),
4680
- schemas: recordType(stringType(), stringType())
4681
- }).strict();
4682
- var pgSchemaSquashed = objectType({
4683
- version: literalType("5"),
4684
- dialect: enumType(["pg"]),
4685
- tables: recordType(stringType(), tableSquashed2),
4686
- enums: recordType(stringType(), enumSchema),
4687
- schemas: recordType(stringType(), stringType())
4688
- }).strict();
4689
- var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4690
- var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4691
- var pgSchema = pgSchemaInternal.merge(schemaHash2);
4692
- var backwardCompatiblePgSchema = unionType([
4693
- pgSchemaV1,
4694
- pgSchemaV2,
4695
- pgSchemaV3,
4696
- pgSchemaV4,
4697
- pgSchema
4698
- ]);
4699
- var PgSquasher = {
4700
- squashIdx: (idx) => {
4701
- index2.parse(idx);
4702
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
4703
- },
4704
- unsquashIdx: (input) => {
4705
- const [name, columnsString, isUnique] = input.split(";");
4706
- const result = index2.parse({
4707
- name,
4708
- columns: columnsString.split(","),
4709
- isUnique: isUnique === "true"
4710
- });
4711
- return result;
4712
- },
4713
- squashFK: (fk4) => {
4714
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
4715
- },
4716
- squashPK: (pk) => {
4717
- return `${pk.columns.join(",")};${pk.name}`;
4718
- },
4719
- unsquashPK: (pk) => {
4720
- const splitted = pk.split(";");
4721
- return { name: splitted[1], columns: splitted[0].split(",") };
4722
- },
4723
- squashUnique: (unq) => {
4724
- return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
4725
- },
4726
- unsquashUnique: (unq) => {
4727
- const [name, columns, nullsNotDistinct] = unq.split(";");
4728
- return {
4729
- name,
4730
- columns: columns.split(","),
4731
- nullsNotDistinct: nullsNotDistinct === "true"
4732
- };
4733
- },
4734
- unsquashFK: (input) => {
4735
- const [
4736
- name,
4737
- tableFrom,
4738
- columnsFromStr,
4739
- tableTo,
4740
- columnsToStr,
4741
- onUpdate,
4742
- onDelete,
4743
- schemaTo
4744
- ] = input.split(";");
4745
- const result = fk2.parse({
4746
- name,
4747
- tableFrom,
4748
- columnsFrom: columnsFromStr.split(","),
4749
- schemaTo,
4750
- tableTo,
4751
- columnsTo: columnsToStr.split(","),
4752
- onUpdate,
4753
- onDelete
4754
- });
4755
- return result;
4756
- }
4757
- };
4758
- var squashPgScheme = (json) => {
4759
- const mappedTables = Object.fromEntries(
4760
- Object.entries(json.tables).map((it) => {
4761
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
4762
- return PgSquasher.squashIdx(index4);
4763
- });
4764
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
4765
- return PgSquasher.squashFK(fk4);
4766
- });
4767
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
4768
- return PgSquasher.squashPK(pk);
4769
- });
4770
- const squashedUniqueConstraints = mapValues(
4771
- it[1].uniqueConstraints,
4772
- (unq) => {
4773
- return PgSquasher.squashUnique(unq);
4774
- }
4775
- );
4776
- return [
4777
- it[0],
4778
- {
4779
- name: it[1].name,
4780
- schema: it[1].schema,
4781
- columns: it[1].columns,
4782
- indexes: squashedIndexes,
4783
- foreignKeys: squashedFKs,
4784
- compositePrimaryKeys: squashedPKs,
4785
- uniqueConstraints: squashedUniqueConstraints
4786
- }
4787
- ];
4788
- })
4789
- );
4790
- return {
4791
- version: "5",
4792
- dialect: json.dialect,
4793
- tables: mappedTables,
4794
- enums: json.enums,
4795
- schemas: json.schemas
4796
- };
4797
- };
4798
- var dryPg = pgSchema.parse({
4799
- version: snapshotVersion,
4800
- dialect: "pg",
4801
- id: originUUID,
4802
- prevId: "",
4803
- tables: {},
4804
- enums: {},
4805
- schemas: {},
4806
- _meta: {
4807
- schemas: {},
4808
- tables: {},
4809
- columns: {}
4810
- }
4811
- });
4812
-
4813
- // src/serializer/sqliteSchema.ts
4814
- init_global();
4815
- init_lib();
4816
- var index3 = objectType({
4817
- name: stringType(),
4818
- columns: stringType().array(),
4819
- where: stringType().optional(),
4820
- isUnique: booleanType()
4821
- }).strict();
4822
- var fk3 = objectType({
4823
- name: stringType(),
4824
- tableFrom: stringType(),
4825
- columnsFrom: stringType().array(),
4826
- tableTo: stringType(),
4827
- columnsTo: stringType().array(),
4828
- onUpdate: stringType().optional(),
4829
- onDelete: stringType().optional()
4830
- }).strict();
4831
- var compositePK3 = objectType({
4832
- columns: stringType().array(),
4833
- name: stringType().optional()
4834
- }).strict();
4835
- var column3 = objectType({
4836
- name: stringType(),
4837
- type: stringType(),
4838
- primaryKey: booleanType(),
4839
- notNull: booleanType(),
4840
- autoincrement: booleanType().optional(),
4841
- default: anyType().optional()
4842
- }).strict();
4843
- var tableV33 = objectType({
4844
- name: stringType(),
4845
- columns: recordType(stringType(), column3),
4846
- indexes: recordType(stringType(), index3),
4847
- foreignKeys: recordType(stringType(), fk3)
4848
- }).strict();
4849
- var uniqueConstraint3 = objectType({
4850
- name: stringType(),
4851
- columns: stringType().array()
4852
- }).strict();
4853
- var table3 = objectType({
4854
- name: stringType(),
4855
- columns: recordType(stringType(), column3),
4856
- indexes: recordType(stringType(), index3),
4857
- foreignKeys: recordType(stringType(), fk3),
4858
- compositePrimaryKeys: recordType(stringType(), compositePK3),
4859
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
4860
- }).strict();
4861
- var dialect2 = enumType(["sqlite"]);
4862
- var schemaHash3 = objectType({
4863
- id: stringType(),
4864
- prevId: stringType()
4865
- }).strict();
4866
- var schemaInternalV32 = objectType({
4867
- version: literalType("3"),
4868
- dialect: dialect2,
4869
- tables: recordType(stringType(), tableV33),
4870
- enums: objectType({})
4871
- }).strict();
4872
- var schemaInternalV42 = objectType({
4873
- version: literalType("4"),
4874
- dialect: dialect2,
4875
- tables: recordType(stringType(), table3),
4876
- enums: objectType({})
4877
- }).strict();
4878
- var latestVersion = literalType("5");
4879
- var schemaInternal2 = objectType({
4880
- version: latestVersion,
4881
- dialect: dialect2,
4882
- tables: recordType(stringType(), table3),
4883
- enums: objectType({}),
4884
- _meta: objectType({
4885
- tables: recordType(stringType(), stringType()),
4886
- columns: recordType(stringType(), stringType())
4887
- })
4888
- }).strict();
4889
- var schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
4890
- var schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
4891
- var schema2 = schemaInternal2.merge(schemaHash3).strict();
4892
- var tableSquashed3 = objectType({
4893
- name: stringType(),
4894
- columns: recordType(stringType(), column3),
4895
- indexes: recordType(stringType(), stringType()),
4896
- foreignKeys: recordType(stringType(), stringType()),
4897
- compositePrimaryKeys: recordType(stringType(), stringType()),
4898
- uniqueConstraints: recordType(stringType(), stringType()).default({})
4899
- }).strict();
4900
- var schemaSquashed2 = objectType({
4901
- version: latestVersion,
4902
- dialect: dialect2,
4903
- tables: recordType(stringType(), tableSquashed3),
4904
- enums: anyType()
4905
- }).strict();
4906
- var SQLiteSquasher = {
4907
- squashIdx: (idx) => {
4908
- index3.parse(idx);
4909
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
4910
- },
4911
- unsquashIdx: (input) => {
4912
- const [name, columnsString, isUnique, where] = input.split(";");
4913
- const result = index3.parse({
4914
- name,
4915
- columns: columnsString.split(","),
4916
- isUnique: isUnique === "true",
4917
- where: where ?? void 0
4918
- });
4919
- return result;
4920
- },
4921
- squashUnique: (unq) => {
4922
- return `${unq.name};${unq.columns.join(",")}`;
4923
- },
4924
- unsquashUnique: (unq) => {
4925
- const [name, columns] = unq.split(";");
4926
- return { name, columns: columns.split(",") };
4927
- },
4928
- squashFK: (fk4) => {
4929
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
4930
- },
4931
- unsquashFK: (input) => {
4932
- const [
4933
- name,
4934
- tableFrom,
4935
- columnsFromStr,
4936
- tableTo,
4937
- columnsToStr,
4938
- onUpdate,
4939
- onDelete
4940
- ] = input.split(";");
4941
- const result = fk3.parse({
4942
- name,
4943
- tableFrom,
4944
- columnsFrom: columnsFromStr.split(","),
4945
- tableTo,
4946
- columnsTo: columnsToStr.split(","),
4947
- onUpdate,
4948
- onDelete
4949
- });
4950
- return result;
4951
- },
4952
- squashPK: (pk) => {
4953
- return pk.columns.join(",");
4954
- },
4955
- unsquashPK: (pk) => {
4956
- return pk.split(",");
4957
- }
4958
- };
4959
- var drySQLite = schema2.parse({
4960
- version: snapshotVersion,
4961
- dialect: "sqlite",
4962
- id: originUUID,
4963
- prevId: "",
4964
- tables: {},
4965
- enums: {},
4966
- _meta: {
4967
- tables: {},
4968
- columns: {}
4969
- }
4970
- });
4971
- var backwardCompatibleSqliteSchema = unionType([
4972
- schemaV32,
4973
- schemaV42,
4974
- schema2
4975
- ]);
4976
-
4977
- // src/utils.ts
4991
+ init_mysqlSchema();
4992
+ init_pgSchema();
4993
+ init_sqliteSchema();
4978
4994
  init_source();
4979
4995
  var import_path = require("path");
4980
4996
  init_global();
@@ -5219,17 +5235,30 @@ var alternationsInColumn = (column4) => {
5219
5235
  return result[0];
5220
5236
  };
5221
5237
 
5238
+ // src/cli/commands/upFolders.ts
5239
+ init_mysqlSchema();
5240
+ init_sqliteSchema();
5241
+
5222
5242
  // src/migrationPreparator.ts
5223
5243
  init_serializer();
5244
+ init_pgSchema();
5245
+ init_sqliteSchema();
5246
+ init_mysqlSchema();
5224
5247
 
5225
5248
  // src/cli/commands/migrate.ts
5226
5249
  var import_hanji2 = __toESM(require_hanji());
5227
5250
  init_views();
5228
5251
  init_source();
5252
+ init_pgSchema();
5253
+ init_sqliteSchema();
5254
+ init_mysqlSchema();
5229
5255
  init_outputs();
5230
5256
  var BREAKPOINT = "--> statement-breakpoint\n";
5231
5257
 
5232
5258
  // src/sqlgenerator.ts
5259
+ init_mysqlSchema();
5260
+ init_pgSchema();
5261
+ init_sqliteSchema();
5233
5262
  var pgNativeTypes = /* @__PURE__ */ new Set([
5234
5263
  "uuid",
5235
5264
  "smallint",
@@ -6541,6 +6570,9 @@ drop type __venum;
6541
6570
  init_lib();
6542
6571
 
6543
6572
  // src/jsonStatements.ts
6573
+ init_mysqlSchema();
6574
+ init_pgSchema();
6575
+ init_sqliteSchema();
6544
6576
  var preparePgCreateTableJson = (table4, json2) => {
6545
6577
  const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
6546
6578
  return {
@@ -7114,6 +7146,8 @@ var prepareAlterCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
7114
7146
  };
7115
7147
 
7116
7148
  // src/snapshotsDiffer.ts
7149
+ init_sqliteSchema();
7150
+ init_mysqlSchema();
7117
7151
  var makeChanged = (schema4) => {
7118
7152
  return objectType({
7119
7153
  type: enumType(["changed"]),
@@ -7725,9 +7759,14 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7725
7759
  // src/cli/commands/pgUp.ts
7726
7760
  init_source();
7727
7761
  init_global();
7762
+ init_pgSchema();
7763
+
7764
+ // src/cli/commands/upFolders.ts
7765
+ init_pgSchema();
7728
7766
 
7729
7767
  // src/cli/commands/mysqlUp.ts
7730
7768
  init_source();
7769
+ init_mysqlSchema();
7731
7770
 
7732
7771
  // src/cli/commands/upFolders.ts
7733
7772
  var resolveSchemas = (missingSchemas, newSchemas, predicate) => {