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/bin.cjs +202 -271
- package/cli/commands/sqliteIntrospect.d.ts +1 -1
- package/cli/commands/utils.d.ts +5 -258
- package/cli/index.d.ts +41 -18
- package/cli/validations/common.d.ts +205 -7
- package/cli/validations/mysql.d.ts +6 -1
- package/cli/validations/pg.d.ts +6 -1
- package/cli/validations/sqlite.d.ts +165 -3
- package/introspect-mysql.d.ts +1 -1
- package/introspect-pg.d.ts +1 -1
- package/introspect-sqlite.d.ts +1 -1
- package/package.json +1 -1
- package/payload.js +6648 -6632
- package/payload.mjs +6638 -6622
- package/utils.js +737 -698
- package/utils.mjs +738 -699
- package/cli/commands/sqliteUtils.d.ts +0 -162
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
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4283
|
-
|
4284
|
-
|
4285
|
-
|
4286
|
-
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4290
|
-
|
4291
|
-
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4325
|
-
|
4326
|
-
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
|
4343
|
-
|
4344
|
-
|
4345
|
-
|
4346
|
-
|
4347
|
-
|
4348
|
-
|
4349
|
-
|
4350
|
-
objectType({
|
4351
|
-
|
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({
|
4327
|
+
objectType({
|
4328
|
+
columns: recordType(
|
4329
|
+
stringType(),
|
4330
|
+
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
4331
|
+
)
|
4332
|
+
}).optional()
|
4354
4333
|
)
|
4355
|
-
}).optional()
|
4356
|
-
|
4357
|
-
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4363
|
-
|
4364
|
-
|
4365
|
-
|
4366
|
-
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
4381
|
-
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4392
|
-
|
4393
|
-
|
4394
|
-
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4407
|
-
|
4408
|
-
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4413
|
-
|
4414
|
-
|
4415
|
-
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4422
|
-
|
4423
|
-
|
4424
|
-
|
4425
|
-
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
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
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
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
|
-
|
4630
|
-
|
4631
|
-
|
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
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4644
|
-
|
4645
|
-
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
4649
|
-
|
4650
|
-
|
4651
|
-
|
4652
|
-
|
4653
|
-
|
4654
|
-
|
4655
|
-
|
4656
|
-
|
4657
|
-
|
4658
|
-
|
4659
|
-
|
4660
|
-
|
4661
|
-
|
4662
|
-
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4666
|
-
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4692
|
-
|
4693
|
-
|
4694
|
-
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
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
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
4746
|
-
|
4747
|
-
|
4748
|
-
|
4749
|
-
|
4750
|
-
|
4751
|
-
|
4752
|
-
|
4753
|
-
|
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
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
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
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
|
4815
|
-
|
4816
|
-
|
4817
|
-
|
4818
|
-
|
4819
|
-
|
4820
|
-
|
4821
|
-
|
4822
|
-
|
4823
|
-
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4839
|
-
|
4840
|
-
|
4841
|
-
|
4842
|
-
|
4843
|
-
|
4844
|
-
|
4845
|
-
|
4846
|
-
|
4847
|
-
|
4848
|
-
|
4849
|
-
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
4860
|
-
|
4861
|
-
|
4862
|
-
|
4863
|
-
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
|
4871
|
-
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
4880
|
-
|
4881
|
-
|
4882
|
-
|
4883
|
-
|
4884
|
-
|
4885
|
-
|
4886
|
-
|
4887
|
-
|
4888
|
-
|
4889
|
-
|
4890
|
-
|
4891
|
-
|
4892
|
-
|
4893
|
-
|
4894
|
-
|
4895
|
-
|
4896
|
-
|
4897
|
-
|
4898
|
-
|
4899
|
-
|
4900
|
-
|
4901
|
-
|
4902
|
-
|
4903
|
-
|
4904
|
-
|
4905
|
-
|
4906
|
-
|
4907
|
-
|
4908
|
-
|
4909
|
-
|
4910
|
-
|
4911
|
-
|
4912
|
-
|
4913
|
-
|
4914
|
-
|
4915
|
-
|
4916
|
-
|
4917
|
-
|
4918
|
-
|
4919
|
-
|
4920
|
-
|
4921
|
-
|
4922
|
-
|
4923
|
-
|
4924
|
-
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4928
|
-
|
4929
|
-
|
4930
|
-
|
4931
|
-
|
4932
|
-
|
4933
|
-
|
4934
|
-
|
4935
|
-
|
4936
|
-
|
4937
|
-
|
4938
|
-
|
4939
|
-
|
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
|
-
|
4942
|
-
|
4943
|
-
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
4949
|
-
|
4950
|
-
|
4951
|
-
|
4952
|
-
|
4953
|
-
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
4957
|
-
|
4958
|
-
|
4959
|
-
|
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) => {
|