drizzle-kit 0.20.17-2132ef8 → 0.20.17-388fa1b

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  import { TypeOf, ZodTypeAny } from "zod";
2
2
  import { JsonStatement } from "./jsonStatements";
3
- import { SQLiteSchemaSquashed } from "./serializer/sqliteSchema";
3
+ import { SQLiteSchema, SQLiteSchemaSquashed } from "./serializer/sqliteSchema";
4
4
  import { MySqlSchema, MySqlSchemaSquashed } from "./serializer/mysqlSchema";
5
5
  import { PgSchema, PgSchemaSquashed } from "./serializer/pgSchema";
6
6
  import { Named } from "./cli/commands/migrate";
@@ -3906,6 +3906,7 @@ export interface ColumnsResolverOutput<T extends {
3906
3906
  }[];
3907
3907
  deleted: T[];
3908
3908
  }
3909
+ export type SchemaFrom<D> = D extends "pg" ? PgSchema : D extends "mysql" ? MySqlSchema : D extends "sqlite" ? SQLiteSchema : undefined;
3909
3910
  export declare const applyPgSnapshotsDiff: (json1: PgSchemaSquashed, json2: PgSchemaSquashed, schemasResolver: (input: ResolverInput<Named>) => Promise<ResolverOutput<Named>>, enumsResolver: (input: ResolverInput<Enum>) => Promise<ResolverOutputWithMoved<Enum>>, tablesResolver: (input: ResolverInput<Table>) => Promise<ResolverOutputWithMoved<Table>>, columnsResolver: (input: ColumnsResolverInput<Column>) => Promise<ColumnsResolverOutput<Column>>, prevFull: PgSchema, curFull: PgSchema) => Promise<{
3910
3911
  statements: JsonStatement[];
3911
3912
  sqlStatements: string[];
package/utils-studio.js CHANGED
@@ -4567,7 +4567,7 @@ var init_pgSchema = __esm({
4567
4567
  }).strict();
4568
4568
  pgSchemaInternal = objectType({
4569
4569
  version: literalType("6"),
4570
- dialect: literalType("postgresql"),
4570
+ dialect: literalType("pg"),
4571
4571
  tables: recordType(stringType(), table2),
4572
4572
  enums: recordType(stringType(), enumSchema),
4573
4573
  schemas: recordType(stringType(), stringType()),
@@ -4596,14 +4596,14 @@ var init_pgSchema = __esm({
4596
4596
  }).strict();
4597
4597
  pgSchemaSquashedV4 = objectType({
4598
4598
  version: literalType("4"),
4599
- dialect: literalType("pg"),
4599
+ dialect: enumType(["pg"]),
4600
4600
  tables: recordType(stringType(), tableSquashedV42),
4601
4601
  enums: recordType(stringType(), enumSchemaV1),
4602
4602
  schemas: recordType(stringType(), stringType())
4603
4603
  }).strict();
4604
4604
  pgSchemaSquashed = objectType({
4605
4605
  version: literalType("6"),
4606
- dialect: literalType("postgresql"),
4606
+ dialect: enumType(["pg"]),
4607
4607
  tables: recordType(stringType(), tableSquashed2),
4608
4608
  enums: recordType(stringType(), enumSchema),
4609
4609
  schemas: recordType(stringType(), stringType())
@@ -4615,7 +4615,7 @@ var init_pgSchema = __esm({
4615
4615
  backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4616
4616
  dryPg = pgSchema2.parse({
4617
4617
  version: snapshotVersion,
4618
- dialect: "postgresql",
4618
+ dialect: "pg",
4619
4619
  id: originUUID,
4620
4620
  prevId: "",
4621
4621
  tables: {},
@@ -5451,7 +5451,7 @@ var init_pgSerializer = __esm({
5451
5451
  const columnName = columnResponse.attname;
5452
5452
  const columnAdditionalDT = columnResponse.additional_dt;
5453
5453
  const columnDimensions = columnResponse.array_dimensions;
5454
- const enumType3 = columnResponse.enum_name;
5454
+ const enumType2 = columnResponse.enum_name;
5455
5455
  let columnType = columnResponse.data_type;
5456
5456
  const primaryKey = tableConstraints.filter(
5457
5457
  (mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
@@ -5515,8 +5515,8 @@ var init_pgSerializer = __esm({
5515
5515
  columnTypeMapped = trimChar(columnTypeMapped, '"');
5516
5516
  columnToReturn[columnName] = {
5517
5517
  name: columnName,
5518
- type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
5519
- typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
5518
+ type: columnAdditionalDT === "USER-DEFINED" ? enumType2 : columnTypeMapped,
5519
+ typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
5520
5520
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
5521
5521
  // default: isSerial ? undefined : defaultValue,
5522
5522
  notNull: columnResponse.is_nullable === "NO"
@@ -5599,7 +5599,7 @@ var init_pgSerializer = __esm({
5599
5599
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
5600
5600
  return {
5601
5601
  version: "6",
5602
- dialect: "postgresql",
5602
+ dialect: "pg",
5603
5603
  tables: result,
5604
5604
  enums: enumsToReturn,
5605
5605
  schemas: schemasObject,
package/utils-studio.mjs CHANGED
@@ -4568,7 +4568,7 @@ var init_pgSchema = __esm({
4568
4568
  }).strict();
4569
4569
  pgSchemaInternal = objectType({
4570
4570
  version: literalType("6"),
4571
- dialect: literalType("postgresql"),
4571
+ dialect: literalType("pg"),
4572
4572
  tables: recordType(stringType(), table2),
4573
4573
  enums: recordType(stringType(), enumSchema),
4574
4574
  schemas: recordType(stringType(), stringType()),
@@ -4597,14 +4597,14 @@ var init_pgSchema = __esm({
4597
4597
  }).strict();
4598
4598
  pgSchemaSquashedV4 = objectType({
4599
4599
  version: literalType("4"),
4600
- dialect: literalType("pg"),
4600
+ dialect: enumType(["pg"]),
4601
4601
  tables: recordType(stringType(), tableSquashedV42),
4602
4602
  enums: recordType(stringType(), enumSchemaV1),
4603
4603
  schemas: recordType(stringType(), stringType())
4604
4604
  }).strict();
4605
4605
  pgSchemaSquashed = objectType({
4606
4606
  version: literalType("6"),
4607
- dialect: literalType("postgresql"),
4607
+ dialect: enumType(["pg"]),
4608
4608
  tables: recordType(stringType(), tableSquashed2),
4609
4609
  enums: recordType(stringType(), enumSchema),
4610
4610
  schemas: recordType(stringType(), stringType())
@@ -4616,7 +4616,7 @@ var init_pgSchema = __esm({
4616
4616
  backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4617
4617
  dryPg = pgSchema2.parse({
4618
4618
  version: snapshotVersion,
4619
- dialect: "postgresql",
4619
+ dialect: "pg",
4620
4620
  id: originUUID,
4621
4621
  prevId: "",
4622
4622
  tables: {},
@@ -5460,7 +5460,7 @@ var init_pgSerializer = __esm({
5460
5460
  const columnName = columnResponse.attname;
5461
5461
  const columnAdditionalDT = columnResponse.additional_dt;
5462
5462
  const columnDimensions = columnResponse.array_dimensions;
5463
- const enumType3 = columnResponse.enum_name;
5463
+ const enumType2 = columnResponse.enum_name;
5464
5464
  let columnType = columnResponse.data_type;
5465
5465
  const primaryKey = tableConstraints.filter(
5466
5466
  (mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "PRIMARY KEY"
@@ -5524,8 +5524,8 @@ var init_pgSerializer = __esm({
5524
5524
  columnTypeMapped = trimChar(columnTypeMapped, '"');
5525
5525
  columnToReturn[columnName] = {
5526
5526
  name: columnName,
5527
- type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
5528
- typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
5527
+ type: columnAdditionalDT === "USER-DEFINED" ? enumType2 : columnTypeMapped,
5528
+ typeSchema: enumsToReturn[`${tableSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType2}`].schema : void 0,
5529
5529
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
5530
5530
  // default: isSerial ? undefined : defaultValue,
5531
5531
  notNull: columnResponse.is_nullable === "NO"
@@ -5608,7 +5608,7 @@ var init_pgSerializer = __esm({
5608
5608
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
5609
5609
  return {
5610
5610
  version: "6",
5611
- dialect: "postgresql",
5611
+ dialect: "pg",
5612
5612
  tables: result,
5613
5613
  enums: enumsToReturn,
5614
5614
  schemas: schemasObject,
package/utils.js CHANGED
@@ -4548,7 +4548,7 @@ var pgSchemaExternal = objectType({
4548
4548
  }).strict();
4549
4549
  var pgSchemaInternal = objectType({
4550
4550
  version: literalType("6"),
4551
- dialect: literalType("postgresql"),
4551
+ dialect: literalType("pg"),
4552
4552
  tables: recordType(stringType(), table2),
4553
4553
  enums: recordType(stringType(), enumSchema),
4554
4554
  schemas: recordType(stringType(), stringType()),
@@ -4577,14 +4577,14 @@ var tableSquashedV42 = objectType({
4577
4577
  }).strict();
4578
4578
  var pgSchemaSquashedV4 = objectType({
4579
4579
  version: literalType("4"),
4580
- dialect: literalType("pg"),
4580
+ dialect: enumType(["pg"]),
4581
4581
  tables: recordType(stringType(), tableSquashedV42),
4582
4582
  enums: recordType(stringType(), enumSchemaV1),
4583
4583
  schemas: recordType(stringType(), stringType())
4584
4584
  }).strict();
4585
4585
  var pgSchemaSquashed = objectType({
4586
4586
  version: literalType("6"),
4587
- dialect: literalType("postgresql"),
4587
+ dialect: enumType(["pg"]),
4588
4588
  tables: recordType(stringType(), tableSquashed2),
4589
4589
  enums: recordType(stringType(), enumSchema),
4590
4590
  schemas: recordType(stringType(), stringType())
@@ -4596,7 +4596,7 @@ var pgSchema = pgSchemaInternal.merge(schemaHash2);
4596
4596
  var backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
4597
4597
  var dryPg = pgSchema.parse({
4598
4598
  version: snapshotVersion,
4599
- dialect: "postgresql",
4599
+ dialect: "pg",
4600
4600
  id: originUUID,
4601
4601
  prevId: "",
4602
4602
  tables: {},
@@ -4758,7 +4758,7 @@ var prepareOutFolder = (out, dialect3) => {
4758
4758
  };
4759
4759
  var validatorForDialect = (dialect3) => {
4760
4760
  switch (dialect3) {
4761
- case "postgresql":
4761
+ case "pg":
4762
4762
  return { validator: backwardCompatiblePgSchema, version: 6 };
4763
4763
  case "sqlite":
4764
4764
  return { validator: backwardCompatibleSqliteSchema, version: 5 };
package/utils.mjs CHANGED
@@ -4539,7 +4539,7 @@ var pgSchemaExternal = objectType({
4539
4539
  }).strict();
4540
4540
  var pgSchemaInternal = objectType({
4541
4541
  version: literalType("6"),
4542
- dialect: literalType("postgresql"),
4542
+ dialect: literalType("pg"),
4543
4543
  tables: recordType(stringType(), table2),
4544
4544
  enums: recordType(stringType(), enumSchema),
4545
4545
  schemas: recordType(stringType(), stringType()),
@@ -4568,14 +4568,14 @@ var tableSquashedV42 = objectType({
4568
4568
  }).strict();
4569
4569
  var pgSchemaSquashedV4 = objectType({
4570
4570
  version: literalType("4"),
4571
- dialect: literalType("pg"),
4571
+ dialect: enumType(["pg"]),
4572
4572
  tables: recordType(stringType(), tableSquashedV42),
4573
4573
  enums: recordType(stringType(), enumSchemaV1),
4574
4574
  schemas: recordType(stringType(), stringType())
4575
4575
  }).strict();
4576
4576
  var pgSchemaSquashed = objectType({
4577
4577
  version: literalType("6"),
4578
- dialect: literalType("postgresql"),
4578
+ dialect: enumType(["pg"]),
4579
4579
  tables: recordType(stringType(), tableSquashed2),
4580
4580
  enums: recordType(stringType(), enumSchema),
4581
4581
  schemas: recordType(stringType(), stringType())
@@ -4587,7 +4587,7 @@ var pgSchema = pgSchemaInternal.merge(schemaHash2);
4587
4587
  var backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
4588
4588
  var dryPg = pgSchema.parse({
4589
4589
  version: snapshotVersion,
4590
- dialect: "postgresql",
4590
+ dialect: "pg",
4591
4591
  id: originUUID,
4592
4592
  prevId: "",
4593
4593
  tables: {},
@@ -4749,7 +4749,7 @@ var prepareOutFolder = (out, dialect3) => {
4749
4749
  };
4750
4750
  var validatorForDialect = (dialect3) => {
4751
4751
  switch (dialect3) {
4752
- case "postgresql":
4752
+ case "pg":
4753
4753
  return { validator: backwardCompatiblePgSchema, version: 6 };
4754
4754
  case "sqlite":
4755
4755
  return { validator: backwardCompatibleSqliteSchema, version: 5 };