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