drizzle-kit 0.21.1-ce37d6c → 0.21.2-1ddc155

Sign up to get free protection for your applications and to get access to all the features.
package/utils-studio.js CHANGED
@@ -569,7 +569,7 @@ var init_global = __esm({
569
569
  "src/global.ts"() {
570
570
  "use strict";
571
571
  originUUID = "00000000-0000-0000-0000-000000000000";
572
- snapshotVersion = "6";
572
+ snapshotVersion = "7";
573
573
  }
574
574
  });
575
575
 
@@ -4498,7 +4498,7 @@ var init_mysqlSchema = __esm({
4498
4498
  });
4499
4499
 
4500
4500
  // src/serializer/pgSchema.ts
4501
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
4501
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
4502
4502
  var init_pgSchema = __esm({
4503
4503
  "src/serializer/pgSchema.ts"() {
4504
4504
  "use strict";
@@ -4566,10 +4566,48 @@ var init_pgSchema = __esm({
4566
4566
  tables: recordType(stringType(), tableV1),
4567
4567
  enums: recordType(stringType(), enumSchemaV1)
4568
4568
  }).strict();
4569
+ indexColumn = objectType({
4570
+ expression: stringType(),
4571
+ isExpression: booleanType(),
4572
+ asc: booleanType(),
4573
+ nulls: stringType().optional(),
4574
+ opclass: stringType().optional()
4575
+ });
4569
4576
  index2 = objectType({
4577
+ name: stringType(),
4578
+ columns: indexColumn.array(),
4579
+ isUnique: booleanType(),
4580
+ with: recordType(stringType(), anyType()).optional(),
4581
+ method: stringType().default("btree"),
4582
+ where: stringType().optional(),
4583
+ concurrently: booleanType().default(false)
4584
+ }).strict();
4585
+ indexV4 = objectType({
4570
4586
  name: stringType(),
4571
4587
  columns: stringType().array(),
4572
- isUnique: booleanType()
4588
+ isUnique: booleanType(),
4589
+ with: recordType(stringType(), stringType()).optional(),
4590
+ method: stringType().default("btree"),
4591
+ where: stringType().optional(),
4592
+ concurrently: booleanType().default(false)
4593
+ }).strict();
4594
+ indexV5 = objectType({
4595
+ name: stringType(),
4596
+ columns: stringType().array(),
4597
+ isUnique: booleanType(),
4598
+ with: recordType(stringType(), stringType()).optional(),
4599
+ method: stringType().default("btree"),
4600
+ where: stringType().optional(),
4601
+ concurrently: booleanType().default(false)
4602
+ }).strict();
4603
+ indexV6 = objectType({
4604
+ name: stringType(),
4605
+ columns: stringType().array(),
4606
+ isUnique: booleanType(),
4607
+ with: recordType(stringType(), stringType()).optional(),
4608
+ method: stringType().default("btree"),
4609
+ where: stringType().optional(),
4610
+ concurrently: booleanType().default(false)
4573
4611
  }).strict();
4574
4612
  fk2 = objectType({
4575
4613
  name: stringType(),
@@ -4611,9 +4649,27 @@ var init_pgSchema = __esm({
4611
4649
  name: stringType(),
4612
4650
  schema: stringType(),
4613
4651
  columns: recordType(stringType(), column2),
4614
- indexes: recordType(stringType(), index2),
4652
+ indexes: recordType(stringType(), indexV4),
4615
4653
  foreignKeys: recordType(stringType(), fk2)
4616
4654
  }).strict();
4655
+ tableV6 = objectType({
4656
+ name: stringType(),
4657
+ schema: stringType(),
4658
+ columns: recordType(stringType(), column2),
4659
+ indexes: recordType(stringType(), indexV6),
4660
+ foreignKeys: recordType(stringType(), fk2),
4661
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4662
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4663
+ }).strict();
4664
+ tableV5 = objectType({
4665
+ name: stringType(),
4666
+ schema: stringType(),
4667
+ columns: recordType(stringType(), column2),
4668
+ indexes: recordType(stringType(), indexV5),
4669
+ foreignKeys: recordType(stringType(), fk2),
4670
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4671
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4672
+ }).strict();
4617
4673
  table2 = objectType({
4618
4674
  name: stringType(),
4619
4675
  schema: stringType(),
@@ -4658,7 +4714,7 @@ var init_pgSchema = __esm({
4658
4714
  pgSchemaInternalV5 = objectType({
4659
4715
  version: literalType("5"),
4660
4716
  dialect: literalType("pg"),
4661
- tables: recordType(stringType(), table2),
4717
+ tables: recordType(stringType(), tableV5),
4662
4718
  enums: recordType(stringType(), enumSchemaV1),
4663
4719
  schemas: recordType(stringType(), stringType()),
4664
4720
  _meta: objectType({
@@ -4668,6 +4724,19 @@ var init_pgSchema = __esm({
4668
4724
  }),
4669
4725
  internal: kitInternals2
4670
4726
  }).strict();
4727
+ pgSchemaInternalV6 = objectType({
4728
+ version: literalType("6"),
4729
+ dialect: literalType("postgresql"),
4730
+ tables: recordType(stringType(), tableV6),
4731
+ enums: recordType(stringType(), enumSchema),
4732
+ schemas: recordType(stringType(), stringType()),
4733
+ _meta: objectType({
4734
+ schemas: recordType(stringType(), stringType()),
4735
+ tables: recordType(stringType(), stringType()),
4736
+ columns: recordType(stringType(), stringType())
4737
+ }),
4738
+ internal: kitInternals2
4739
+ }).strict();
4671
4740
  pgSchemaExternal = objectType({
4672
4741
  version: literalType("5"),
4673
4742
  dialect: literalType("pg"),
@@ -4681,7 +4750,7 @@ var init_pgSchema = __esm({
4681
4750
  })
4682
4751
  }).strict();
4683
4752
  pgSchemaInternal = objectType({
4684
- version: literalType("6"),
4753
+ version: literalType("7"),
4685
4754
  dialect: literalType("postgresql"),
4686
4755
  tables: recordType(stringType(), table2),
4687
4756
  enums: recordType(stringType(), enumSchema),
@@ -4716,18 +4785,30 @@ var init_pgSchema = __esm({
4716
4785
  enums: recordType(stringType(), enumSchemaV1),
4717
4786
  schemas: recordType(stringType(), stringType())
4718
4787
  }).strict();
4719
- pgSchemaSquashed = objectType({
4788
+ pgSchemaSquashedV6 = objectType({
4720
4789
  version: literalType("6"),
4721
4790
  dialect: literalType("postgresql"),
4722
4791
  tables: recordType(stringType(), tableSquashed2),
4723
4792
  enums: recordType(stringType(), enumSchema),
4724
4793
  schemas: recordType(stringType(), stringType())
4725
4794
  }).strict();
4795
+ pgSchemaSquashed = objectType({
4796
+ version: literalType("7"),
4797
+ dialect: literalType("postgresql"),
4798
+ tables: recordType(stringType(), tableSquashed2),
4799
+ enums: recordType(stringType(), enumSchema),
4800
+ schemas: recordType(stringType(), stringType())
4801
+ }).strict();
4726
4802
  pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4727
4803
  pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4728
4804
  pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4805
+ pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
4729
4806
  pgSchema2 = pgSchemaInternal.merge(schemaHash2);
4730
- backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4807
+ backwardCompatiblePgSchema = unionType([
4808
+ pgSchemaV5,
4809
+ pgSchemaV6,
4810
+ pgSchema2
4811
+ ]);
4731
4812
  dryPg = pgSchema2.parse({
4732
4813
  version: snapshotVersion,
4733
4814
  dialect: "postgresql",
@@ -5639,7 +5720,10 @@ var init_pgSerializer = __esm({
5639
5720
  columnTypeMapped = trimChar(columnTypeMapped, '"');
5640
5721
  columnToReturn[columnName] = {
5641
5722
  name: columnName,
5642
- type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
5723
+ type: (
5724
+ // filter vectors, but in future we should filter any extension that was installed by user
5725
+ columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
5726
+ ),
5643
5727
  typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
5644
5728
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
5645
5729
  // default: isSerial ? undefined : defaultValue,
@@ -5650,15 +5734,42 @@ var init_pgSerializer = __esm({
5650
5734
  }
5651
5735
  }
5652
5736
  const dbIndexes = await db.query(
5653
- `SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
5654
- FROM pg_class t
5655
- JOIN pg_index ix ON t.oid = ix.indrelid
5656
- JOIN pg_class i ON i.oid = ix.indexrelid
5657
- JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
5658
- JOIN pg_namespace ns ON ns.oid = t.relnamespace
5659
- WHERE ns.nspname = '${tableSchema}'
5660
- AND t.relname = '${tableName}'
5661
- and ix.indisprimary = false;`
5737
+ `SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
5738
+ k.i AS index_order,
5739
+ i.indisunique as is_unique,
5740
+ am.amname as method,
5741
+ ic.reloptions as with,
5742
+ coalesce(a.attname,
5743
+ (('{' || pg_get_expr(
5744
+ i.indexprs,
5745
+ i.indrelid
5746
+ )
5747
+ || '}')::text[]
5748
+ )[k.i]
5749
+ ) AS column_name,
5750
+ CASE
5751
+ WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
5752
+ ELSE 0
5753
+ END AS is_expression,
5754
+ i.indoption[k.i-1] & 1 = 1 AS descending,
5755
+ i.indoption[k.i-1] & 2 = 2 AS nulls_first,
5756
+ pg_get_expr(
5757
+ i.indpred,
5758
+ i.indrelid
5759
+ ) as where,
5760
+ opc.opcname
5761
+ FROM pg_class t
5762
+ LEFT JOIN pg_index i ON t.oid = i.indrelid
5763
+ LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
5764
+ CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
5765
+ LEFT JOIN pg_attribute AS a
5766
+ ON i.indrelid = a.attrelid AND k.attnum = a.attnum
5767
+ JOIN pg_namespace c on c.oid = t.relnamespace
5768
+ LEFT JOIN pg_am AS am ON ic.relam = am.oid
5769
+ JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
5770
+ WHERE
5771
+ c.nspname = '${tableSchema}' AND
5772
+ t.relname = '${tableName}';`
5662
5773
  );
5663
5774
  const dbIndexFromConstraint = await db.query(
5664
5775
  `SELECT
@@ -5675,18 +5786,51 @@ var init_pgSerializer = __esm({
5675
5786
  );
5676
5787
  const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
5677
5788
  for (const dbIndex of dbIndexes) {
5678
- const indexName = dbIndex.index_name;
5789
+ const indexName = dbIndex.indexname;
5679
5790
  const indexColumnName = dbIndex.column_name;
5680
5791
  const indexIsUnique = dbIndex.is_unique;
5792
+ const indexMethod = dbIndex.method;
5793
+ const indexWith = dbIndex.with;
5794
+ const indexWhere = dbIndex.where;
5795
+ const opclass = dbIndex.opcname;
5796
+ const isExpression = dbIndex.is_expression === 1;
5797
+ const desc = dbIndex.descending;
5798
+ const nullsFirst = dbIndex.nulls_first;
5799
+ const mappedWith = {};
5800
+ if (indexWith !== null) {
5801
+ indexWith.forEach((it) => {
5802
+ const splitted = it.split("=");
5803
+ mappedWith[splitted[0]] = splitted[1];
5804
+ });
5805
+ }
5681
5806
  if (idxsInConsteraint.includes(indexName))
5682
5807
  continue;
5683
5808
  if (typeof indexToReturn[indexName] !== "undefined") {
5684
- indexToReturn[indexName].columns.push(indexColumnName);
5809
+ indexToReturn[indexName].columns.push({
5810
+ expression: indexColumnName,
5811
+ asc: !desc,
5812
+ nulls: nullsFirst ? "first" : "last",
5813
+ opclass,
5814
+ isExpression
5815
+ });
5685
5816
  } else {
5686
5817
  indexToReturn[indexName] = {
5687
5818
  name: indexName,
5688
- columns: [indexColumnName],
5689
- isUnique: indexIsUnique
5819
+ columns: [
5820
+ {
5821
+ expression: indexColumnName,
5822
+ asc: !desc,
5823
+ nulls: nullsFirst ? "first" : "last",
5824
+ opclass,
5825
+ isExpression
5826
+ }
5827
+ ],
5828
+ isUnique: indexIsUnique,
5829
+ // should not be a part of diff detecs
5830
+ concurrently: false,
5831
+ method: indexMethod,
5832
+ where: indexWhere === null ? void 0 : indexWhere,
5833
+ with: mappedWith
5690
5834
  };
5691
5835
  }
5692
5836
  }
@@ -5722,7 +5866,7 @@ var init_pgSerializer = __esm({
5722
5866
  }
5723
5867
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
5724
5868
  return {
5725
- version: "6",
5869
+ version: "7",
5726
5870
  dialect: "postgresql",
5727
5871
  tables: result,
5728
5872
  enums: enumsToReturn,
package/utils-studio.mjs CHANGED
@@ -570,7 +570,7 @@ var init_global = __esm({
570
570
  "src/global.ts"() {
571
571
  "use strict";
572
572
  originUUID = "00000000-0000-0000-0000-000000000000";
573
- snapshotVersion = "6";
573
+ snapshotVersion = "7";
574
574
  }
575
575
  });
576
576
 
@@ -4499,7 +4499,7 @@ var init_mysqlSchema = __esm({
4499
4499
  });
4500
4500
 
4501
4501
  // src/serializer/pgSchema.ts
4502
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
4502
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
4503
4503
  var init_pgSchema = __esm({
4504
4504
  "src/serializer/pgSchema.ts"() {
4505
4505
  "use strict";
@@ -4567,10 +4567,48 @@ var init_pgSchema = __esm({
4567
4567
  tables: recordType(stringType(), tableV1),
4568
4568
  enums: recordType(stringType(), enumSchemaV1)
4569
4569
  }).strict();
4570
+ indexColumn = objectType({
4571
+ expression: stringType(),
4572
+ isExpression: booleanType(),
4573
+ asc: booleanType(),
4574
+ nulls: stringType().optional(),
4575
+ opclass: stringType().optional()
4576
+ });
4570
4577
  index2 = objectType({
4578
+ name: stringType(),
4579
+ columns: indexColumn.array(),
4580
+ isUnique: booleanType(),
4581
+ with: recordType(stringType(), anyType()).optional(),
4582
+ method: stringType().default("btree"),
4583
+ where: stringType().optional(),
4584
+ concurrently: booleanType().default(false)
4585
+ }).strict();
4586
+ indexV4 = objectType({
4571
4587
  name: stringType(),
4572
4588
  columns: stringType().array(),
4573
- isUnique: booleanType()
4589
+ isUnique: booleanType(),
4590
+ with: recordType(stringType(), stringType()).optional(),
4591
+ method: stringType().default("btree"),
4592
+ where: stringType().optional(),
4593
+ concurrently: booleanType().default(false)
4594
+ }).strict();
4595
+ indexV5 = objectType({
4596
+ name: stringType(),
4597
+ columns: stringType().array(),
4598
+ isUnique: booleanType(),
4599
+ with: recordType(stringType(), stringType()).optional(),
4600
+ method: stringType().default("btree"),
4601
+ where: stringType().optional(),
4602
+ concurrently: booleanType().default(false)
4603
+ }).strict();
4604
+ indexV6 = objectType({
4605
+ name: stringType(),
4606
+ columns: stringType().array(),
4607
+ isUnique: booleanType(),
4608
+ with: recordType(stringType(), stringType()).optional(),
4609
+ method: stringType().default("btree"),
4610
+ where: stringType().optional(),
4611
+ concurrently: booleanType().default(false)
4574
4612
  }).strict();
4575
4613
  fk2 = objectType({
4576
4614
  name: stringType(),
@@ -4612,9 +4650,27 @@ var init_pgSchema = __esm({
4612
4650
  name: stringType(),
4613
4651
  schema: stringType(),
4614
4652
  columns: recordType(stringType(), column2),
4615
- indexes: recordType(stringType(), index2),
4653
+ indexes: recordType(stringType(), indexV4),
4616
4654
  foreignKeys: recordType(stringType(), fk2)
4617
4655
  }).strict();
4656
+ tableV6 = objectType({
4657
+ name: stringType(),
4658
+ schema: stringType(),
4659
+ columns: recordType(stringType(), column2),
4660
+ indexes: recordType(stringType(), indexV6),
4661
+ foreignKeys: recordType(stringType(), fk2),
4662
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4663
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4664
+ }).strict();
4665
+ tableV5 = objectType({
4666
+ name: stringType(),
4667
+ schema: stringType(),
4668
+ columns: recordType(stringType(), column2),
4669
+ indexes: recordType(stringType(), indexV5),
4670
+ foreignKeys: recordType(stringType(), fk2),
4671
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
4672
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4673
+ }).strict();
4618
4674
  table2 = objectType({
4619
4675
  name: stringType(),
4620
4676
  schema: stringType(),
@@ -4659,7 +4715,7 @@ var init_pgSchema = __esm({
4659
4715
  pgSchemaInternalV5 = objectType({
4660
4716
  version: literalType("5"),
4661
4717
  dialect: literalType("pg"),
4662
- tables: recordType(stringType(), table2),
4718
+ tables: recordType(stringType(), tableV5),
4663
4719
  enums: recordType(stringType(), enumSchemaV1),
4664
4720
  schemas: recordType(stringType(), stringType()),
4665
4721
  _meta: objectType({
@@ -4669,6 +4725,19 @@ var init_pgSchema = __esm({
4669
4725
  }),
4670
4726
  internal: kitInternals2
4671
4727
  }).strict();
4728
+ pgSchemaInternalV6 = objectType({
4729
+ version: literalType("6"),
4730
+ dialect: literalType("postgresql"),
4731
+ tables: recordType(stringType(), tableV6),
4732
+ enums: recordType(stringType(), enumSchema),
4733
+ schemas: recordType(stringType(), stringType()),
4734
+ _meta: objectType({
4735
+ schemas: recordType(stringType(), stringType()),
4736
+ tables: recordType(stringType(), stringType()),
4737
+ columns: recordType(stringType(), stringType())
4738
+ }),
4739
+ internal: kitInternals2
4740
+ }).strict();
4672
4741
  pgSchemaExternal = objectType({
4673
4742
  version: literalType("5"),
4674
4743
  dialect: literalType("pg"),
@@ -4682,7 +4751,7 @@ var init_pgSchema = __esm({
4682
4751
  })
4683
4752
  }).strict();
4684
4753
  pgSchemaInternal = objectType({
4685
- version: literalType("6"),
4754
+ version: literalType("7"),
4686
4755
  dialect: literalType("postgresql"),
4687
4756
  tables: recordType(stringType(), table2),
4688
4757
  enums: recordType(stringType(), enumSchema),
@@ -4717,18 +4786,30 @@ var init_pgSchema = __esm({
4717
4786
  enums: recordType(stringType(), enumSchemaV1),
4718
4787
  schemas: recordType(stringType(), stringType())
4719
4788
  }).strict();
4720
- pgSchemaSquashed = objectType({
4789
+ pgSchemaSquashedV6 = objectType({
4721
4790
  version: literalType("6"),
4722
4791
  dialect: literalType("postgresql"),
4723
4792
  tables: recordType(stringType(), tableSquashed2),
4724
4793
  enums: recordType(stringType(), enumSchema),
4725
4794
  schemas: recordType(stringType(), stringType())
4726
4795
  }).strict();
4796
+ pgSchemaSquashed = objectType({
4797
+ version: literalType("7"),
4798
+ dialect: literalType("postgresql"),
4799
+ tables: recordType(stringType(), tableSquashed2),
4800
+ enums: recordType(stringType(), enumSchema),
4801
+ schemas: recordType(stringType(), stringType())
4802
+ }).strict();
4727
4803
  pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4728
4804
  pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4729
4805
  pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4806
+ pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
4730
4807
  pgSchema2 = pgSchemaInternal.merge(schemaHash2);
4731
- backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4808
+ backwardCompatiblePgSchema = unionType([
4809
+ pgSchemaV5,
4810
+ pgSchemaV6,
4811
+ pgSchema2
4812
+ ]);
4732
4813
  dryPg = pgSchema2.parse({
4733
4814
  version: snapshotVersion,
4734
4815
  dialect: "postgresql",
@@ -5648,7 +5729,10 @@ var init_pgSerializer = __esm({
5648
5729
  columnTypeMapped = trimChar(columnTypeMapped, '"');
5649
5730
  columnToReturn[columnName] = {
5650
5731
  name: columnName,
5651
- type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
5732
+ type: (
5733
+ // filter vectors, but in future we should filter any extension that was installed by user
5734
+ columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
5735
+ ),
5652
5736
  typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
5653
5737
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
5654
5738
  // default: isSerial ? undefined : defaultValue,
@@ -5659,15 +5743,42 @@ var init_pgSerializer = __esm({
5659
5743
  }
5660
5744
  }
5661
5745
  const dbIndexes = await db.query(
5662
- `SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
5663
- FROM pg_class t
5664
- JOIN pg_index ix ON t.oid = ix.indrelid
5665
- JOIN pg_class i ON i.oid = ix.indexrelid
5666
- JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
5667
- JOIN pg_namespace ns ON ns.oid = t.relnamespace
5668
- WHERE ns.nspname = '${tableSchema}'
5669
- AND t.relname = '${tableName}'
5670
- and ix.indisprimary = false;`
5746
+ `SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
5747
+ k.i AS index_order,
5748
+ i.indisunique as is_unique,
5749
+ am.amname as method,
5750
+ ic.reloptions as with,
5751
+ coalesce(a.attname,
5752
+ (('{' || pg_get_expr(
5753
+ i.indexprs,
5754
+ i.indrelid
5755
+ )
5756
+ || '}')::text[]
5757
+ )[k.i]
5758
+ ) AS column_name,
5759
+ CASE
5760
+ WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
5761
+ ELSE 0
5762
+ END AS is_expression,
5763
+ i.indoption[k.i-1] & 1 = 1 AS descending,
5764
+ i.indoption[k.i-1] & 2 = 2 AS nulls_first,
5765
+ pg_get_expr(
5766
+ i.indpred,
5767
+ i.indrelid
5768
+ ) as where,
5769
+ opc.opcname
5770
+ FROM pg_class t
5771
+ LEFT JOIN pg_index i ON t.oid = i.indrelid
5772
+ LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
5773
+ CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
5774
+ LEFT JOIN pg_attribute AS a
5775
+ ON i.indrelid = a.attrelid AND k.attnum = a.attnum
5776
+ JOIN pg_namespace c on c.oid = t.relnamespace
5777
+ LEFT JOIN pg_am AS am ON ic.relam = am.oid
5778
+ JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
5779
+ WHERE
5780
+ c.nspname = '${tableSchema}' AND
5781
+ t.relname = '${tableName}';`
5671
5782
  );
5672
5783
  const dbIndexFromConstraint = await db.query(
5673
5784
  `SELECT
@@ -5684,18 +5795,51 @@ var init_pgSerializer = __esm({
5684
5795
  );
5685
5796
  const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
5686
5797
  for (const dbIndex of dbIndexes) {
5687
- const indexName = dbIndex.index_name;
5798
+ const indexName = dbIndex.indexname;
5688
5799
  const indexColumnName = dbIndex.column_name;
5689
5800
  const indexIsUnique = dbIndex.is_unique;
5801
+ const indexMethod = dbIndex.method;
5802
+ const indexWith = dbIndex.with;
5803
+ const indexWhere = dbIndex.where;
5804
+ const opclass = dbIndex.opcname;
5805
+ const isExpression = dbIndex.is_expression === 1;
5806
+ const desc = dbIndex.descending;
5807
+ const nullsFirst = dbIndex.nulls_first;
5808
+ const mappedWith = {};
5809
+ if (indexWith !== null) {
5810
+ indexWith.forEach((it) => {
5811
+ const splitted = it.split("=");
5812
+ mappedWith[splitted[0]] = splitted[1];
5813
+ });
5814
+ }
5690
5815
  if (idxsInConsteraint.includes(indexName))
5691
5816
  continue;
5692
5817
  if (typeof indexToReturn[indexName] !== "undefined") {
5693
- indexToReturn[indexName].columns.push(indexColumnName);
5818
+ indexToReturn[indexName].columns.push({
5819
+ expression: indexColumnName,
5820
+ asc: !desc,
5821
+ nulls: nullsFirst ? "first" : "last",
5822
+ opclass,
5823
+ isExpression
5824
+ });
5694
5825
  } else {
5695
5826
  indexToReturn[indexName] = {
5696
5827
  name: indexName,
5697
- columns: [indexColumnName],
5698
- isUnique: indexIsUnique
5828
+ columns: [
5829
+ {
5830
+ expression: indexColumnName,
5831
+ asc: !desc,
5832
+ nulls: nullsFirst ? "first" : "last",
5833
+ opclass,
5834
+ isExpression
5835
+ }
5836
+ ],
5837
+ isUnique: indexIsUnique,
5838
+ // should not be a part of diff detecs
5839
+ concurrently: false,
5840
+ method: indexMethod,
5841
+ where: indexWhere === null ? void 0 : indexWhere,
5842
+ with: mappedWith
5699
5843
  };
5700
5844
  }
5701
5845
  }
@@ -5731,7 +5875,7 @@ var init_pgSerializer = __esm({
5731
5875
  }
5732
5876
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
5733
5877
  return {
5734
- version: "6",
5878
+ version: "7",
5735
5879
  dialect: "postgresql",
5736
5880
  tables: result,
5737
5881
  enums: enumsToReturn,