@anthonyalayo/drizzle-kit 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.d.mts CHANGED
@@ -571,7 +571,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
571
571
  name: zod.ZodString;
572
572
  type: zod.ZodString;
573
573
  typeSchema: zod.ZodOptional<zod.ZodString>;
574
- domainTypeSchema: zod.ZodOptional<zod.ZodString>;
575
574
  primaryKey: zod.ZodBoolean;
576
575
  notNull: zod.ZodBoolean;
577
576
  default: zod.ZodOptional<zod.ZodAny>;
@@ -632,7 +631,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
632
631
  as: string;
633
632
  } | undefined;
634
633
  typeSchema?: string | undefined;
635
- domainTypeSchema?: string | undefined;
636
634
  uniqueName?: string | undefined;
637
635
  nullsNotDistinct?: boolean | undefined;
638
636
  identity?: {
@@ -658,7 +656,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
658
656
  as: string;
659
657
  } | undefined;
660
658
  typeSchema?: string | undefined;
661
- domainTypeSchema?: string | undefined;
662
659
  uniqueName?: string | undefined;
663
660
  nullsNotDistinct?: boolean | undefined;
664
661
  identity?: {
@@ -832,7 +829,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
832
829
  as: string;
833
830
  } | undefined;
834
831
  typeSchema?: string | undefined;
835
- domainTypeSchema?: string | undefined;
836
832
  uniqueName?: string | undefined;
837
833
  nullsNotDistinct?: boolean | undefined;
838
834
  identity?: {
@@ -911,7 +907,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
911
907
  as: string;
912
908
  } | undefined;
913
909
  typeSchema?: string | undefined;
914
- domainTypeSchema?: string | undefined;
915
910
  uniqueName?: string | undefined;
916
911
  nullsNotDistinct?: boolean | undefined;
917
912
  identity?: {
@@ -1035,7 +1030,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1035
1030
  name: zod.ZodString;
1036
1031
  type: zod.ZodString;
1037
1032
  typeSchema: zod.ZodOptional<zod.ZodString>;
1038
- domainTypeSchema: zod.ZodOptional<zod.ZodString>;
1039
1033
  primaryKey: zod.ZodBoolean;
1040
1034
  notNull: zod.ZodBoolean;
1041
1035
  default: zod.ZodOptional<zod.ZodAny>;
@@ -1096,7 +1090,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1096
1090
  as: string;
1097
1091
  } | undefined;
1098
1092
  typeSchema?: string | undefined;
1099
- domainTypeSchema?: string | undefined;
1100
1093
  uniqueName?: string | undefined;
1101
1094
  nullsNotDistinct?: boolean | undefined;
1102
1095
  identity?: {
@@ -1122,7 +1115,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1122
1115
  as: string;
1123
1116
  } | undefined;
1124
1117
  typeSchema?: string | undefined;
1125
- domainTypeSchema?: string | undefined;
1126
1118
  uniqueName?: string | undefined;
1127
1119
  nullsNotDistinct?: boolean | undefined;
1128
1120
  identity?: {
@@ -1225,7 +1217,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1225
1217
  as: string;
1226
1218
  } | undefined;
1227
1219
  typeSchema?: string | undefined;
1228
- domainTypeSchema?: string | undefined;
1229
1220
  uniqueName?: string | undefined;
1230
1221
  nullsNotDistinct?: boolean | undefined;
1231
1222
  identity?: {
@@ -1284,7 +1275,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1284
1275
  as: string;
1285
1276
  } | undefined;
1286
1277
  typeSchema?: string | undefined;
1287
- domainTypeSchema?: string | undefined;
1288
1278
  uniqueName?: string | undefined;
1289
1279
  nullsNotDistinct?: boolean | undefined;
1290
1280
  identity?: {
@@ -1485,7 +1475,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1485
1475
  as: string;
1486
1476
  } | undefined;
1487
1477
  typeSchema?: string | undefined;
1488
- domainTypeSchema?: string | undefined;
1489
1478
  uniqueName?: string | undefined;
1490
1479
  nullsNotDistinct?: boolean | undefined;
1491
1480
  identity?: {
@@ -1575,7 +1564,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1575
1564
  as: string;
1576
1565
  } | undefined;
1577
1566
  typeSchema?: string | undefined;
1578
- domainTypeSchema?: string | undefined;
1579
1567
  uniqueName?: string | undefined;
1580
1568
  nullsNotDistinct?: boolean | undefined;
1581
1569
  identity?: {
@@ -1688,7 +1676,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1688
1676
  as: string;
1689
1677
  } | undefined;
1690
1678
  typeSchema?: string | undefined;
1691
- domainTypeSchema?: string | undefined;
1692
1679
  uniqueName?: string | undefined;
1693
1680
  nullsNotDistinct?: boolean | undefined;
1694
1681
  identity?: {
@@ -1804,7 +1791,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1804
1791
  as: string;
1805
1792
  } | undefined;
1806
1793
  typeSchema?: string | undefined;
1807
- domainTypeSchema?: string | undefined;
1808
1794
  uniqueName?: string | undefined;
1809
1795
  nullsNotDistinct?: boolean | undefined;
1810
1796
  identity?: {
@@ -2736,7 +2722,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => Record<string
2736
2722
  primaryKey: boolean;
2737
2723
  notNull: boolean;
2738
2724
  typeSchema?: string | undefined;
2739
- domainTypeSchema?: string | undefined;
2740
2725
  default?: any;
2741
2726
  isUnique?: any;
2742
2727
  uniqueName?: string | undefined;
@@ -2802,7 +2787,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => Record<string
2802
2787
  primaryKey: boolean;
2803
2788
  notNull: boolean;
2804
2789
  typeSchema?: string | undefined;
2805
- domainTypeSchema?: string | undefined;
2806
2790
  default?: any;
2807
2791
  isUnique?: any;
2808
2792
  uniqueName?: string | undefined;
package/api.d.ts CHANGED
@@ -571,7 +571,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
571
571
  name: zod.ZodString;
572
572
  type: zod.ZodString;
573
573
  typeSchema: zod.ZodOptional<zod.ZodString>;
574
- domainTypeSchema: zod.ZodOptional<zod.ZodString>;
575
574
  primaryKey: zod.ZodBoolean;
576
575
  notNull: zod.ZodBoolean;
577
576
  default: zod.ZodOptional<zod.ZodAny>;
@@ -632,7 +631,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
632
631
  as: string;
633
632
  } | undefined;
634
633
  typeSchema?: string | undefined;
635
- domainTypeSchema?: string | undefined;
636
634
  uniqueName?: string | undefined;
637
635
  nullsNotDistinct?: boolean | undefined;
638
636
  identity?: {
@@ -658,7 +656,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
658
656
  as: string;
659
657
  } | undefined;
660
658
  typeSchema?: string | undefined;
661
- domainTypeSchema?: string | undefined;
662
659
  uniqueName?: string | undefined;
663
660
  nullsNotDistinct?: boolean | undefined;
664
661
  identity?: {
@@ -832,7 +829,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
832
829
  as: string;
833
830
  } | undefined;
834
831
  typeSchema?: string | undefined;
835
- domainTypeSchema?: string | undefined;
836
832
  uniqueName?: string | undefined;
837
833
  nullsNotDistinct?: boolean | undefined;
838
834
  identity?: {
@@ -911,7 +907,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
911
907
  as: string;
912
908
  } | undefined;
913
909
  typeSchema?: string | undefined;
914
- domainTypeSchema?: string | undefined;
915
910
  uniqueName?: string | undefined;
916
911
  nullsNotDistinct?: boolean | undefined;
917
912
  identity?: {
@@ -1035,7 +1030,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1035
1030
  name: zod.ZodString;
1036
1031
  type: zod.ZodString;
1037
1032
  typeSchema: zod.ZodOptional<zod.ZodString>;
1038
- domainTypeSchema: zod.ZodOptional<zod.ZodString>;
1039
1033
  primaryKey: zod.ZodBoolean;
1040
1034
  notNull: zod.ZodBoolean;
1041
1035
  default: zod.ZodOptional<zod.ZodAny>;
@@ -1096,7 +1090,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1096
1090
  as: string;
1097
1091
  } | undefined;
1098
1092
  typeSchema?: string | undefined;
1099
- domainTypeSchema?: string | undefined;
1100
1093
  uniqueName?: string | undefined;
1101
1094
  nullsNotDistinct?: boolean | undefined;
1102
1095
  identity?: {
@@ -1122,7 +1115,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1122
1115
  as: string;
1123
1116
  } | undefined;
1124
1117
  typeSchema?: string | undefined;
1125
- domainTypeSchema?: string | undefined;
1126
1118
  uniqueName?: string | undefined;
1127
1119
  nullsNotDistinct?: boolean | undefined;
1128
1120
  identity?: {
@@ -1225,7 +1217,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1225
1217
  as: string;
1226
1218
  } | undefined;
1227
1219
  typeSchema?: string | undefined;
1228
- domainTypeSchema?: string | undefined;
1229
1220
  uniqueName?: string | undefined;
1230
1221
  nullsNotDistinct?: boolean | undefined;
1231
1222
  identity?: {
@@ -1284,7 +1275,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1284
1275
  as: string;
1285
1276
  } | undefined;
1286
1277
  typeSchema?: string | undefined;
1287
- domainTypeSchema?: string | undefined;
1288
1278
  uniqueName?: string | undefined;
1289
1279
  nullsNotDistinct?: boolean | undefined;
1290
1280
  identity?: {
@@ -1485,7 +1475,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1485
1475
  as: string;
1486
1476
  } | undefined;
1487
1477
  typeSchema?: string | undefined;
1488
- domainTypeSchema?: string | undefined;
1489
1478
  uniqueName?: string | undefined;
1490
1479
  nullsNotDistinct?: boolean | undefined;
1491
1480
  identity?: {
@@ -1575,7 +1564,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1575
1564
  as: string;
1576
1565
  } | undefined;
1577
1566
  typeSchema?: string | undefined;
1578
- domainTypeSchema?: string | undefined;
1579
1567
  uniqueName?: string | undefined;
1580
1568
  nullsNotDistinct?: boolean | undefined;
1581
1569
  identity?: {
@@ -1688,7 +1676,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1688
1676
  as: string;
1689
1677
  } | undefined;
1690
1678
  typeSchema?: string | undefined;
1691
- domainTypeSchema?: string | undefined;
1692
1679
  uniqueName?: string | undefined;
1693
1680
  nullsNotDistinct?: boolean | undefined;
1694
1681
  identity?: {
@@ -1804,7 +1791,6 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
1804
1791
  as: string;
1805
1792
  } | undefined;
1806
1793
  typeSchema?: string | undefined;
1807
- domainTypeSchema?: string | undefined;
1808
1794
  uniqueName?: string | undefined;
1809
1795
  nullsNotDistinct?: boolean | undefined;
1810
1796
  identity?: {
@@ -2736,7 +2722,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => Record<string
2736
2722
  primaryKey: boolean;
2737
2723
  notNull: boolean;
2738
2724
  typeSchema?: string | undefined;
2739
- domainTypeSchema?: string | undefined;
2740
2725
  default?: any;
2741
2726
  isUnique?: any;
2742
2727
  uniqueName?: string | undefined;
@@ -2802,7 +2787,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => Record<string
2802
2787
  primaryKey: boolean;
2803
2788
  notNull: boolean;
2804
2789
  typeSchema?: string | undefined;
2805
- domainTypeSchema?: string | undefined;
2806
2790
  default?: any;
2807
2791
  isUnique?: any;
2808
2792
  uniqueName?: string | undefined;
package/api.js CHANGED
@@ -7684,7 +7684,6 @@ var init_pgSchema = __esm({
7684
7684
  name: stringType(),
7685
7685
  type: stringType(),
7686
7686
  typeSchema: stringType().optional(),
7687
- domainTypeSchema: stringType().optional(),
7688
7687
  primaryKey: booleanType(),
7689
7688
  notNull: booleanType(),
7690
7689
  default: anyType().optional(),
@@ -7696,7 +7695,6 @@ var init_pgSchema = __esm({
7696
7695
  name: stringType(),
7697
7696
  type: stringType(),
7698
7697
  typeSchema: stringType().optional(),
7699
- domainTypeSchema: stringType().optional(),
7700
7698
  primaryKey: booleanType(),
7701
7699
  notNull: booleanType(),
7702
7700
  default: anyType().optional(),
@@ -7713,7 +7711,6 @@ var init_pgSchema = __esm({
7713
7711
  name: stringType(),
7714
7712
  type: stringType(),
7715
7713
  typeSchema: stringType().optional(),
7716
- domainTypeSchema: stringType().optional(),
7717
7714
  primaryKey: booleanType(),
7718
7715
  notNull: booleanType(),
7719
7716
  default: anyType().optional(),
@@ -22456,7 +22453,7 @@ var version;
22456
22453
  var init_version = __esm({
22457
22454
  "../drizzle-orm/dist/version.js"() {
22458
22455
  "use strict";
22459
- version = "1.0.4";
22456
+ version = "1.0.5";
22460
22457
  }
22461
22458
  });
22462
22459
 
@@ -30299,8 +30296,9 @@ var init_pgSerializer = __esm({
30299
30296
  const notNull = column5.notNull;
30300
30297
  const primaryKey = column5.primary;
30301
30298
  const sqlTypeLowered = column5.getSQLType().toLowerCase();
30302
- const typeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30303
- const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema : void 0;
30299
+ const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema || "public" : void 0;
30300
+ const enumTypeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30301
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
30304
30302
  const generated = column5.generated;
30305
30303
  const identity = column5.generatedIdentity;
30306
30304
  const increment = stringFromIdentityProperty(identity?.sequenceOptions?.increment) ?? "1";
@@ -30312,7 +30310,6 @@ var init_pgSerializer = __esm({
30312
30310
  name: name2,
30313
30311
  type: column5.getSQLType(),
30314
30312
  typeSchema,
30315
- domainTypeSchema,
30316
30313
  primaryKey,
30317
30314
  notNull,
30318
30315
  generated: generated ? {
@@ -30757,7 +30754,9 @@ ${withStyle.errorWarning(
30757
30754
  const notNull = column5.notNull;
30758
30755
  const primaryKey = column5.primary;
30759
30756
  const sqlTypeLowered = column5.getSQLType().toLowerCase();
30760
- const typeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30757
+ const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema || "public" : void 0;
30758
+ const enumTypeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30759
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
30761
30760
  const generated = column5.generated;
30762
30761
  const identity = column5.generatedIdentity;
30763
30762
  const increment = stringFromIdentityProperty(identity?.sequenceOptions?.increment) ?? "1";
@@ -31292,9 +31291,11 @@ WHERE
31292
31291
  const columnAdditionalDT = columnResponse.additional_dt;
31293
31292
  const columnDimensions = columnResponse.array_dimensions;
31294
31293
  const enumType2 = columnResponse.enum_name;
31295
- let columnType = columnResponse.data_type;
31296
- const typeSchema = columnResponse.type_schema;
31294
+ const enumSchema3 = columnResponse.enum_schema;
31295
+ const domainType = columnResponse.domain_name;
31296
+ const domainSchema3 = columnResponse.domain_schema;
31297
31297
  const defaultValueRes = columnResponse.column_default;
31298
+ let columnType = columnResponse.data_type;
31298
31299
  const isGenerated = columnResponse.is_generated === "ALWAYS";
31299
31300
  const generationExpression = columnResponse.generation_expression;
31300
31301
  const isIdentity = columnResponse.is_identity === "YES";
@@ -31376,16 +31377,18 @@ WHERE
31376
31377
  }
31377
31378
  columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char");
31378
31379
  columnTypeMapped = trimChar(columnTypeMapped, '"');
31380
+ let userDefinedType = columnTypeMapped, userDefinedTypeSchema;
31381
+ if (domainType && domainSchema3) {
31382
+ userDefinedType = domainType;
31383
+ userDefinedTypeSchema = domainSchema3;
31384
+ } else if (columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2)) {
31385
+ userDefinedType = enumType2;
31386
+ userDefinedTypeSchema = enumSchema3;
31387
+ }
31379
31388
  columnToReturn[columnName] = {
31380
31389
  name: columnName,
31381
- type: (
31382
- // First, check if it's a domain
31383
- columnAdditionalDT === "DOMAIN" && domainsToReturn[`${typeSchema}.${enumType2}`]?.name || columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
31384
- ),
31385
- typeSchema: (
31386
- // Check if it's a domain first
31387
- domainsToReturn[`${typeSchema}.${enumType2}`]?.schema || enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0
31388
- ),
31390
+ type: userDefinedType,
31391
+ typeSchema: userDefinedTypeSchema,
31389
31392
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
31390
31393
  // default: isSerial ? undefined : defaultValue,
31391
31394
  notNull: columnResponse.is_nullable === "NO",
@@ -31837,6 +31840,9 @@ WHERE
31837
31840
  c.column_default, -- Column default value
31838
31841
  c.data_type AS additional_dt, -- Data type from information_schema
31839
31842
  c.udt_name AS enum_name, -- Enum type (if applicable)
31843
+ c.udt_schema AS enum_schema, -- Enum schema (if applicable)
31844
+ c.domain_name, -- Domain type (if applicable)
31845
+ c.domain_schema, -- Domain schema (if applicable)
31840
31846
  c.is_generated, -- Is it a generated column?
31841
31847
  c.generation_expression, -- Generation expression (if generated)
31842
31848
  c.is_identity, -- Is it an identity column?
@@ -31845,8 +31851,7 @@ WHERE
31845
31851
  c.identity_increment, -- Increment for identity column
31846
31852
  c.identity_maximum, -- Maximum value for identity column
31847
31853
  c.identity_minimum, -- Minimum value for identity column
31848
- c.identity_cycle, -- Does the identity column cycle?
31849
- enum_ns.nspname AS type_schema -- Schema of the enum type
31854
+ c.identity_cycle -- Does the identity column cycle?
31850
31855
  FROM
31851
31856
  pg_attribute a
31852
31857
  JOIN
@@ -31857,10 +31862,6 @@ LEFT JOIN
31857
31862
  information_schema.columns c ON c.column_name = a.attname
31858
31863
  AND c.table_schema = ns.nspname
31859
31864
  AND c.table_name = cls.relname -- Match schema and table/view name
31860
- LEFT JOIN
31861
- pg_type enum_t ON enum_t.oid = a.atttypid -- Join to get the type info
31862
- LEFT JOIN
31863
- pg_namespace enum_ns ON enum_ns.oid = enum_t.typnamespace -- Join to get the enum schema
31864
31865
  WHERE
31865
31866
  a.attnum > 0 -- Valid column numbers only
31866
31867
  AND NOT a.attisdropped -- Skip dropped columns
package/api.mjs CHANGED
@@ -7689,7 +7689,6 @@ var init_pgSchema = __esm({
7689
7689
  name: stringType(),
7690
7690
  type: stringType(),
7691
7691
  typeSchema: stringType().optional(),
7692
- domainTypeSchema: stringType().optional(),
7693
7692
  primaryKey: booleanType(),
7694
7693
  notNull: booleanType(),
7695
7694
  default: anyType().optional(),
@@ -7701,7 +7700,6 @@ var init_pgSchema = __esm({
7701
7700
  name: stringType(),
7702
7701
  type: stringType(),
7703
7702
  typeSchema: stringType().optional(),
7704
- domainTypeSchema: stringType().optional(),
7705
7703
  primaryKey: booleanType(),
7706
7704
  notNull: booleanType(),
7707
7705
  default: anyType().optional(),
@@ -7718,7 +7716,6 @@ var init_pgSchema = __esm({
7718
7716
  name: stringType(),
7719
7717
  type: stringType(),
7720
7718
  typeSchema: stringType().optional(),
7721
- domainTypeSchema: stringType().optional(),
7722
7719
  primaryKey: booleanType(),
7723
7720
  notNull: booleanType(),
7724
7721
  default: anyType().optional(),
@@ -22461,7 +22458,7 @@ var version;
22461
22458
  var init_version = __esm({
22462
22459
  "../drizzle-orm/dist/version.js"() {
22463
22460
  "use strict";
22464
- version = "1.0.4";
22461
+ version = "1.0.5";
22465
22462
  }
22466
22463
  });
22467
22464
 
@@ -30304,8 +30301,9 @@ var init_pgSerializer = __esm({
30304
30301
  const notNull = column5.notNull;
30305
30302
  const primaryKey = column5.primary;
30306
30303
  const sqlTypeLowered = column5.getSQLType().toLowerCase();
30307
- const typeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30308
- const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema : void 0;
30304
+ const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema || "public" : void 0;
30305
+ const enumTypeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30306
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
30309
30307
  const generated = column5.generated;
30310
30308
  const identity = column5.generatedIdentity;
30311
30309
  const increment = stringFromIdentityProperty(identity?.sequenceOptions?.increment) ?? "1";
@@ -30317,7 +30315,6 @@ var init_pgSerializer = __esm({
30317
30315
  name: name2,
30318
30316
  type: column5.getSQLType(),
30319
30317
  typeSchema,
30320
- domainTypeSchema,
30321
30318
  primaryKey,
30322
30319
  notNull,
30323
30320
  generated: generated ? {
@@ -30762,7 +30759,9 @@ ${withStyle.errorWarning(
30762
30759
  const notNull = column5.notNull;
30763
30760
  const primaryKey = column5.primary;
30764
30761
  const sqlTypeLowered = column5.getSQLType().toLowerCase();
30765
- const typeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30762
+ const domainTypeSchema = is(column5, PgDomainColumn) ? column5.schema || "public" : void 0;
30763
+ const enumTypeSchema = is(column5, PgEnumColumn) ? column5.enum.schema || "public" : void 0;
30764
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
30766
30765
  const generated = column5.generated;
30767
30766
  const identity = column5.generatedIdentity;
30768
30767
  const increment = stringFromIdentityProperty(identity?.sequenceOptions?.increment) ?? "1";
@@ -31297,9 +31296,11 @@ WHERE
31297
31296
  const columnAdditionalDT = columnResponse.additional_dt;
31298
31297
  const columnDimensions = columnResponse.array_dimensions;
31299
31298
  const enumType2 = columnResponse.enum_name;
31300
- let columnType = columnResponse.data_type;
31301
- const typeSchema = columnResponse.type_schema;
31299
+ const enumSchema3 = columnResponse.enum_schema;
31300
+ const domainType = columnResponse.domain_name;
31301
+ const domainSchema3 = columnResponse.domain_schema;
31302
31302
  const defaultValueRes = columnResponse.column_default;
31303
+ let columnType = columnResponse.data_type;
31303
31304
  const isGenerated = columnResponse.is_generated === "ALWAYS";
31304
31305
  const generationExpression = columnResponse.generation_expression;
31305
31306
  const isIdentity = columnResponse.is_identity === "YES";
@@ -31381,16 +31382,18 @@ WHERE
31381
31382
  }
31382
31383
  columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char");
31383
31384
  columnTypeMapped = trimChar(columnTypeMapped, '"');
31385
+ let userDefinedType = columnTypeMapped, userDefinedTypeSchema;
31386
+ if (domainType && domainSchema3) {
31387
+ userDefinedType = domainType;
31388
+ userDefinedTypeSchema = domainSchema3;
31389
+ } else if (columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2)) {
31390
+ userDefinedType = enumType2;
31391
+ userDefinedTypeSchema = enumSchema3;
31392
+ }
31384
31393
  columnToReturn[columnName] = {
31385
31394
  name: columnName,
31386
- type: (
31387
- // First, check if it's a domain
31388
- columnAdditionalDT === "DOMAIN" && domainsToReturn[`${typeSchema}.${enumType2}`]?.name || columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
31389
- ),
31390
- typeSchema: (
31391
- // Check if it's a domain first
31392
- domainsToReturn[`${typeSchema}.${enumType2}`]?.schema || enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0
31393
- ),
31395
+ type: userDefinedType,
31396
+ typeSchema: userDefinedTypeSchema,
31394
31397
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
31395
31398
  // default: isSerial ? undefined : defaultValue,
31396
31399
  notNull: columnResponse.is_nullable === "NO",
@@ -31842,6 +31845,9 @@ WHERE
31842
31845
  c.column_default, -- Column default value
31843
31846
  c.data_type AS additional_dt, -- Data type from information_schema
31844
31847
  c.udt_name AS enum_name, -- Enum type (if applicable)
31848
+ c.udt_schema AS enum_schema, -- Enum schema (if applicable)
31849
+ c.domain_name, -- Domain type (if applicable)
31850
+ c.domain_schema, -- Domain schema (if applicable)
31845
31851
  c.is_generated, -- Is it a generated column?
31846
31852
  c.generation_expression, -- Generation expression (if generated)
31847
31853
  c.is_identity, -- Is it an identity column?
@@ -31850,8 +31856,7 @@ WHERE
31850
31856
  c.identity_increment, -- Increment for identity column
31851
31857
  c.identity_maximum, -- Maximum value for identity column
31852
31858
  c.identity_minimum, -- Minimum value for identity column
31853
- c.identity_cycle, -- Does the identity column cycle?
31854
- enum_ns.nspname AS type_schema -- Schema of the enum type
31859
+ c.identity_cycle -- Does the identity column cycle?
31855
31860
  FROM
31856
31861
  pg_attribute a
31857
31862
  JOIN
@@ -31862,10 +31867,6 @@ LEFT JOIN
31862
31867
  information_schema.columns c ON c.column_name = a.attname
31863
31868
  AND c.table_schema = ns.nspname
31864
31869
  AND c.table_name = cls.relname -- Match schema and table/view name
31865
- LEFT JOIN
31866
- pg_type enum_t ON enum_t.oid = a.atttypid -- Join to get the type info
31867
- LEFT JOIN
31868
- pg_namespace enum_ns ON enum_ns.oid = enum_t.typnamespace -- Join to get the enum schema
31869
31870
  WHERE
31870
31871
  a.attnum > 0 -- Valid column numbers only
31871
31872
  AND NOT a.attisdropped -- Skip dropped columns
package/bin.cjs CHANGED
@@ -5906,7 +5906,6 @@ var init_pgSchema = __esm({
5906
5906
  name: stringType(),
5907
5907
  type: stringType(),
5908
5908
  typeSchema: stringType().optional(),
5909
- domainTypeSchema: stringType().optional(),
5910
5909
  primaryKey: booleanType(),
5911
5910
  notNull: booleanType(),
5912
5911
  default: anyType().optional(),
@@ -5918,7 +5917,6 @@ var init_pgSchema = __esm({
5918
5917
  name: stringType(),
5919
5918
  type: stringType(),
5920
5919
  typeSchema: stringType().optional(),
5921
- domainTypeSchema: stringType().optional(),
5922
5920
  primaryKey: booleanType(),
5923
5921
  notNull: booleanType(),
5924
5922
  default: anyType().optional(),
@@ -5935,7 +5933,6 @@ var init_pgSchema = __esm({
5935
5933
  name: stringType(),
5936
5934
  type: stringType(),
5937
5935
  typeSchema: stringType().optional(),
5938
- domainTypeSchema: stringType().optional(),
5939
5936
  primaryKey: booleanType(),
5940
5937
  notNull: booleanType(),
5941
5938
  default: anyType().optional(),
@@ -18153,8 +18150,9 @@ var init_pgSerializer = __esm({
18153
18150
  const notNull = column9.notNull;
18154
18151
  const primaryKey = column9.primary;
18155
18152
  const sqlTypeLowered = column9.getSQLType().toLowerCase();
18156
- const typeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgEnumColumn) ? column9.enum.schema || "public" : void 0;
18157
- const domainTypeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgDomainColumn) ? column9.schema : void 0;
18153
+ const domainTypeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgDomainColumn) ? column9.schema || "public" : void 0;
18154
+ const enumTypeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgEnumColumn) ? column9.enum.schema || "public" : void 0;
18155
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
18158
18156
  const generated = column9.generated;
18159
18157
  const identity = column9.generatedIdentity;
18160
18158
  const increment = stringFromIdentityProperty((_a2 = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _a2.increment) ?? "1";
@@ -18166,7 +18164,6 @@ var init_pgSerializer = __esm({
18166
18164
  name,
18167
18165
  type: column9.getSQLType(),
18168
18166
  typeSchema,
18169
- domainTypeSchema,
18170
18167
  primaryKey,
18171
18168
  notNull,
18172
18169
  generated: generated ? {
@@ -18614,7 +18611,9 @@ ${withStyle.errorWarning(
18614
18611
  const notNull = column9.notNull;
18615
18612
  const primaryKey = column9.primary;
18616
18613
  const sqlTypeLowered = column9.getSQLType().toLowerCase();
18617
- const typeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgEnumColumn) ? column9.enum.schema || "public" : void 0;
18614
+ const domainTypeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgDomainColumn) ? column9.schema || "public" : void 0;
18615
+ const enumTypeSchema = (0, import_drizzle_orm4.is)(column9, import_pg_core2.PgEnumColumn) ? column9.enum.schema || "public" : void 0;
18616
+ const typeSchema = domainTypeSchema ?? enumTypeSchema;
18618
18617
  const generated = column9.generated;
18619
18618
  const identity = column9.generatedIdentity;
18620
18619
  const increment = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.increment) ?? "1";
@@ -19009,7 +19008,7 @@ WHERE
19009
19008
  const sequencesInColumns = [];
19010
19009
  const all = allTables.filter((it) => it.type === "table").map((row) => {
19011
19010
  return new Promise(async (res, rej) => {
19012
- var _a, _b, _c, _d, _e, _f, _g, _h;
19011
+ var _a, _b, _c, _d, _e, _f;
19013
19012
  const tableName = row.table_name;
19014
19013
  if (!tablesFilter(tableName))
19015
19014
  return res("");
@@ -19159,9 +19158,11 @@ WHERE
19159
19158
  const columnAdditionalDT = columnResponse.additional_dt;
19160
19159
  const columnDimensions = columnResponse.array_dimensions;
19161
19160
  const enumType2 = columnResponse.enum_name;
19162
- let columnType = columnResponse.data_type;
19163
- const typeSchema = columnResponse.type_schema;
19161
+ const enumSchema3 = columnResponse.enum_schema;
19162
+ const domainType = columnResponse.domain_name;
19163
+ const domainSchema3 = columnResponse.domain_schema;
19164
19164
  const defaultValueRes = columnResponse.column_default;
19165
+ let columnType = columnResponse.data_type;
19165
19166
  const isGenerated = columnResponse.is_generated === "ALWAYS";
19166
19167
  const generationExpression = columnResponse.generation_expression;
19167
19168
  const isIdentity = columnResponse.is_identity === "YES";
@@ -19243,16 +19244,18 @@ WHERE
19243
19244
  }
19244
19245
  columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char");
19245
19246
  columnTypeMapped = trimChar(columnTypeMapped, '"');
19247
+ let userDefinedType = columnTypeMapped, userDefinedTypeSchema;
19248
+ if (domainType && domainSchema3) {
19249
+ userDefinedType = domainType;
19250
+ userDefinedTypeSchema = domainSchema3;
19251
+ } else if (columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2)) {
19252
+ userDefinedType = enumType2;
19253
+ userDefinedTypeSchema = enumSchema3;
19254
+ }
19246
19255
  columnToReturn[columnName] = {
19247
19256
  name: columnName,
19248
- type: (
19249
- // First, check if it's a domain
19250
- columnAdditionalDT === "DOMAIN" && ((_c = domainsToReturn[`${typeSchema}.${enumType2}`]) == null ? void 0 : _c.name) || columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
19251
- ),
19252
- typeSchema: (
19253
- // Check if it's a domain first
19254
- ((_d = domainsToReturn[`${typeSchema}.${enumType2}`]) == null ? void 0 : _d.schema) || enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0
19255
- ),
19257
+ type: userDefinedType,
19258
+ typeSchema: userDefinedTypeSchema,
19256
19259
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
19257
19260
  // default: isSerial ? undefined : defaultValue,
19258
19261
  notNull: columnResponse.is_nullable === "NO",
@@ -19264,7 +19267,7 @@ WHERE
19264
19267
  minValue: stringFromDatabaseIdentityProperty(identityMinimum),
19265
19268
  maxValue: stringFromDatabaseIdentityProperty(identityMaximum),
19266
19269
  startWith: stringFromDatabaseIdentityProperty(identityStart),
19267
- cache: ((_e = sequencesToReturn[identityName]) == null ? void 0 : _e.cache) ? (_f = sequencesToReturn[identityName]) == null ? void 0 : _f.cache : ((_g = sequencesToReturn[`${tableSchema}.${identityName}`]) == null ? void 0 : _g.cache) ? (_h = sequencesToReturn[`${tableSchema}.${identityName}`]) == null ? void 0 : _h.cache : void 0,
19270
+ cache: ((_c = sequencesToReturn[identityName]) == null ? void 0 : _c.cache) ? (_d = sequencesToReturn[identityName]) == null ? void 0 : _d.cache : ((_e = sequencesToReturn[`${tableSchema}.${identityName}`]) == null ? void 0 : _e.cache) ? (_f = sequencesToReturn[`${tableSchema}.${identityName}`]) == null ? void 0 : _f.cache : void 0,
19268
19271
  cycle: identityCycle,
19269
19272
  schema: tableSchema
19270
19273
  } : void 0
@@ -19708,6 +19711,9 @@ WHERE
19708
19711
  c.column_default, -- Column default value
19709
19712
  c.data_type AS additional_dt, -- Data type from information_schema
19710
19713
  c.udt_name AS enum_name, -- Enum type (if applicable)
19714
+ c.udt_schema AS enum_schema, -- Enum schema (if applicable)
19715
+ c.domain_name, -- Domain type (if applicable)
19716
+ c.domain_schema, -- Domain schema (if applicable)
19711
19717
  c.is_generated, -- Is it a generated column?
19712
19718
  c.generation_expression, -- Generation expression (if generated)
19713
19719
  c.is_identity, -- Is it an identity column?
@@ -19716,8 +19722,7 @@ WHERE
19716
19722
  c.identity_increment, -- Increment for identity column
19717
19723
  c.identity_maximum, -- Maximum value for identity column
19718
19724
  c.identity_minimum, -- Minimum value for identity column
19719
- c.identity_cycle, -- Does the identity column cycle?
19720
- enum_ns.nspname AS type_schema -- Schema of the enum type
19725
+ c.identity_cycle -- Does the identity column cycle?
19721
19726
  FROM
19722
19727
  pg_attribute a
19723
19728
  JOIN
@@ -19728,10 +19733,6 @@ LEFT JOIN
19728
19733
  information_schema.columns c ON c.column_name = a.attname
19729
19734
  AND c.table_schema = ns.nspname
19730
19735
  AND c.table_name = cls.relname -- Match schema and table/view name
19731
- LEFT JOIN
19732
- pg_type enum_t ON enum_t.oid = a.atttypid -- Join to get the type info
19733
- LEFT JOIN
19734
- pg_namespace enum_ns ON enum_ns.oid = enum_t.typnamespace -- Join to get the enum schema
19735
19736
  WHERE
19736
19737
  a.attnum > 0 -- Valid column numbers only
19737
19738
  AND NOT a.attisdropped -- Skip dropped columns
@@ -71882,8 +71883,7 @@ var init_introspect_pg = __esm({
71882
71883
  assertUnreachable(casing2);
71883
71884
  };
71884
71885
  paramNameFor = (name, schema6) => {
71885
- const schemaSuffix = schema6 && schema6 !== "public" ? `In${schema6.capitalise()}` : "";
71886
- return `${name}${schemaSuffix}`;
71886
+ return `${name}`;
71887
71887
  };
71888
71888
  schemaToTypeScript3 = (schema6, casing2) => {
71889
71889
  Object.values(schema6.tables).forEach((table5) => {
@@ -72273,16 +72273,14 @@ import { sql } from "drizzle-orm"
72273
72273
  }
72274
72274
  return "";
72275
72275
  };
72276
- column7 = (tableName, type, name, domainTypes, enumTypes, domainTypeSchema, typeSchema, casing2, defaultValue, internals) => {
72276
+ column7 = (tableName, type, name, domainTypes, enumTypes, typeSchema, casing2, defaultValue, internals) => {
72277
72277
  var _a, _b;
72278
72278
  const isExpression = ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[name]) == null ? void 0 : _b.isDefaultAnExpression) ?? false;
72279
72279
  const lowered = type.toLowerCase().replace("[]", "");
72280
- if (enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`)) {
72281
- let out = `${withCasing2(name, casing2)}: ${withCasing2(paramNameFor(type.replace("[]", ""), typeSchema), casing2)}(${dbColumnName3({ name, casing: casing2 })})`;
72282
- return out;
72283
- }
72284
- if (domainTypes.has(`${domainTypeSchema}.${type}`)) {
72285
- return `${withCasing2(name, casing2)}: ${withCasing2(type, casing2)}(${dbColumnName3({ name, casing: casing2 })})`;
72280
+ const isDomainType = domainTypes.has(`${typeSchema}.${type}`);
72281
+ const isEnumType = enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`);
72282
+ if (isDomainType || isEnumType) {
72283
+ return `${withCasing2(name, casing2)}: ${withCasing2(paramNameFor(type.replace("[]", ""), typeSchema), casing2)}(${dbColumnName3({ name, casing: casing2 })})`;
72286
72284
  }
72287
72285
  if (lowered.startsWith("serial")) {
72288
72286
  return `${withCasing2(name, casing2)}: serial(${dbColumnName3({ name, casing: casing2 })})`;
@@ -72481,7 +72479,6 @@ import { sql } from "drizzle-orm"
72481
72479
  it.name,
72482
72480
  domainTypes,
72483
72481
  enumTypes,
72484
- it.domainTypeSchema ?? "public",
72485
72482
  it.typeSchema ?? "public",
72486
72483
  casing2,
72487
72484
  it.default,
@@ -79992,7 +79989,7 @@ init_utils5();
79992
79989
  var version2 = async () => {
79993
79990
  const { npmVersion } = await ormCoreVersions();
79994
79991
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
79995
- const envVersion = "1.0.5";
79992
+ const envVersion = "1.0.7";
79996
79993
  const kitVersion = envVersion ? `v${envVersion}` : "--";
79997
79994
  const versions = `drizzle-kit: ${kitVersion}
79998
79995
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthonyalayo/drizzle-kit",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -26,7 +26,7 @@
26
26
  "author": "Drizzle Team",
27
27
  "license": "MIT",
28
28
  "bin": {
29
- "/drizzle-kit": "./bin.cjs"
29
+ "@anthonyalayo/drizzle-kit": "./bin.cjs"
30
30
  },
31
31
  "scripts": {
32
32
  "api": "tsx ./dev/api.ts",
package/utils.js CHANGED
@@ -5201,7 +5201,6 @@ var columnV7 = objectType({
5201
5201
  name: stringType(),
5202
5202
  type: stringType(),
5203
5203
  typeSchema: stringType().optional(),
5204
- domainTypeSchema: stringType().optional(),
5205
5204
  primaryKey: booleanType(),
5206
5205
  notNull: booleanType(),
5207
5206
  default: anyType().optional(),
@@ -5213,7 +5212,6 @@ var column2 = objectType({
5213
5212
  name: stringType(),
5214
5213
  type: stringType(),
5215
5214
  typeSchema: stringType().optional(),
5216
- domainTypeSchema: stringType().optional(),
5217
5215
  primaryKey: booleanType(),
5218
5216
  notNull: booleanType(),
5219
5217
  default: anyType().optional(),
@@ -5230,7 +5228,6 @@ var columnSquashed = objectType({
5230
5228
  name: stringType(),
5231
5229
  type: stringType(),
5232
5230
  typeSchema: stringType().optional(),
5233
- domainTypeSchema: stringType().optional(),
5234
5231
  primaryKey: booleanType(),
5235
5232
  notNull: booleanType(),
5236
5233
  default: anyType().optional(),
package/utils.mjs CHANGED
@@ -5178,7 +5178,6 @@ var columnV7 = objectType({
5178
5178
  name: stringType(),
5179
5179
  type: stringType(),
5180
5180
  typeSchema: stringType().optional(),
5181
- domainTypeSchema: stringType().optional(),
5182
5181
  primaryKey: booleanType(),
5183
5182
  notNull: booleanType(),
5184
5183
  default: anyType().optional(),
@@ -5190,7 +5189,6 @@ var column2 = objectType({
5190
5189
  name: stringType(),
5191
5190
  type: stringType(),
5192
5191
  typeSchema: stringType().optional(),
5193
- domainTypeSchema: stringType().optional(),
5194
5192
  primaryKey: booleanType(),
5195
5193
  notNull: booleanType(),
5196
5194
  default: anyType().optional(),
@@ -5207,7 +5205,6 @@ var columnSquashed = objectType({
5207
5205
  name: stringType(),
5208
5206
  type: stringType(),
5209
5207
  typeSchema: stringType().optional(),
5210
- domainTypeSchema: stringType().optional(),
5211
5208
  primaryKey: booleanType(),
5212
5209
  notNull: booleanType(),
5213
5210
  default: anyType().optional(),