rake-db 2.11.4 → 2.12.0

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import * as orchid_core from 'orchid-core';
2
- import { ColumnTypesBase, EmptyObject, RawSQLBase, MaybeArray } from 'orchid-core';
3
- import { ColumnsShape, Db as Db$1, ColumnType, EnumColumn, raw, Adapter, DefaultColumnTypes, DbResult, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions } from 'pqb';
1
+ import * as pqb from 'pqb';
2
+ import { ColumnsShape, Db as Db$1, ColumnType, EnumColumn, raw, Adapter, DbResult, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, DefaultColumnTypes, AdapterOptions, QueryLogOptions } from 'pqb';
3
+ import { EmptyObject, RawSQLBase, ColumnSchemaConfig, MaybeArray, ColumnTypeBase } from 'orchid-core';
4
4
 
5
5
  type CreateTableResult<Table extends string, Shape extends ColumnsShape> = {
6
6
  table: Db$1<Table, Shape>;
@@ -20,18 +20,18 @@ type ChangeOptions = {
20
20
  };
21
21
  type TableChangeMethods = typeof tableChangeMethods;
22
22
  declare const tableChangeMethods: {
23
- name(this: ColumnTypesBase, name: string): any;
23
+ name(this: RakeDbColumnTypes, name: string): any;
24
24
  add: typeof add;
25
25
  drop: typeof add;
26
- change(this: ColumnTypesBase, from: ColumnType | Change, to: ColumnType | Change, options?: ChangeOptions): Change;
26
+ change(from: ColumnType | Change, to: ColumnType | Change, options?: ChangeOptions): Change;
27
27
  default(value: unknown | RawSQLBase): Change;
28
28
  nullable(): Change;
29
29
  nonNullable(): Change;
30
30
  comment(comment: string | null): Change;
31
31
  rename(name: string): RakeDbAst.ChangeTableItem.Rename;
32
- enum(name: string): EnumColumn<string, [string, ...string[]]>;
32
+ enum(name: string): EnumColumn<pqb.DefaultSchemaConfig, undefined, string, [string, ...string[]]>;
33
33
  };
34
- type TableChanger<CT extends ColumnTypesBase> = MigrationColumnTypes<CT> & TableChangeMethods;
34
+ type TableChanger<CT> = MigrationColumnTypes<CT> & TableChangeMethods;
35
35
  type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | EmptyObject>;
36
36
 
37
37
  type DropMode = 'CASCADE' | 'RESTRICT';
@@ -44,14 +44,14 @@ type TableOptions = {
44
44
  snakeCase?: boolean;
45
45
  language?: string;
46
46
  };
47
- type TextColumnCreator = () => TextColumn;
48
- type MigrationColumnTypes<CT extends ColumnTypesBase> = Omit<CT, 'text' | 'string' | 'enum'> & {
47
+ type TextColumnCreator = (min?: number, max?: number) => TextColumn<ColumnSchemaConfig>;
48
+ type MigrationColumnTypes<CT> = Omit<CT, 'text' | 'string' | 'enum'> & {
49
49
  text: TextColumnCreator;
50
50
  string: TextColumnCreator;
51
51
  citext: TextColumnCreator;
52
- enum: (name: string) => EnumColumn;
52
+ enum: (name: string) => EnumColumn<ColumnSchemaConfig, unknown>;
53
53
  };
54
- type ColumnsShapeCallback<CT extends ColumnTypesBase, Shape extends ColumnsShape = ColumnsShape> = (t: MigrationColumnTypes<CT> & {
54
+ type ColumnsShapeCallback<CT, Shape extends ColumnsShape = ColumnsShape> = (t: MigrationColumnTypes<CT> & {
55
55
  raw: typeof raw;
56
56
  }) => Shape;
57
57
  type ChangeTableOptions = {
@@ -59,7 +59,7 @@ type ChangeTableOptions = {
59
59
  language?: string;
60
60
  comment?: string | [string, string] | null;
61
61
  };
62
- type ChangeTableCallback<CT extends ColumnTypesBase> = (t: TableChanger<CT>) => TableChangeData;
62
+ type ChangeTableCallback<CT> = (t: TableChanger<CT>) => TableChangeData;
63
63
  type ColumnComment = {
64
64
  column: string;
65
65
  comment: string | null;
@@ -68,20 +68,9 @@ type SilentQueries = {
68
68
  silentQuery: Adapter['query'];
69
69
  silentArrays: Adapter['arrays'];
70
70
  };
71
- type DbMigration<CT extends ColumnTypesBase = DefaultColumnTypes> = DbResult<CT> & Migration<CT> & {
71
+ type DbMigration<CT extends RakeDbColumnTypes> = DbResult<CT> & Migration<CT> & {
72
72
  adapter: SilentQueries;
73
73
  };
74
- type ConstraintArg = {
75
- name?: string;
76
- references?: [
77
- columns: [string, ...string[]],
78
- table: string,
79
- foreignColumn: [string, ...string[]],
80
- options: Omit<ForeignKeyOptions, 'name' | 'dropMode'>
81
- ];
82
- check?: RawSQLBase;
83
- dropMode?: DropMode;
84
- };
85
74
  /**
86
75
  * Creates a new `db` instance that is an instance of `pqb` with mixed in migration methods from the `Migration` class.
87
76
  * It overrides `query` and `array` db adapter methods to intercept SQL for the logging.
@@ -91,12 +80,12 @@ type ConstraintArg = {
91
80
  * @param config - config of `rakeDb`
92
81
  * @param asts - array of migration ASTs to collect changes into
93
82
  */
94
- declare const createMigrationInterface: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(tx: TransactionAdapter, up: boolean, config: RakeDbConfig<CT>, asts: RakeDbAst[]) => DbMigration<CT>;
95
- declare class Migration<CT extends ColumnTypesBase> {
83
+ declare const createMigrationInterface: <SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColumnTypes>(tx: TransactionAdapter, up: boolean, config: RakeDbConfig<SchemaConfig, CT>, asts: RakeDbAst[]) => DbMigration<CT>;
84
+ declare class Migration<CT extends RakeDbColumnTypes> {
96
85
  adapter: TransactionAdapter;
97
86
  log?: QueryLogObject;
98
87
  up: boolean;
99
- options: RakeDbConfig;
88
+ options: RakeDbConfig<ColumnSchemaConfig>;
100
89
  migratedAsts: RakeDbAst[];
101
90
  columnTypes: CT;
102
91
  /**
@@ -890,7 +879,7 @@ declare namespace RakeDbAst {
890
879
  action: 'create' | 'drop';
891
880
  schema?: string;
892
881
  name: string;
893
- baseType: ColumnType;
882
+ baseType: ColumnTypeBase;
894
883
  notNull?: boolean;
895
884
  collation?: string;
896
885
  default?: RawSQLBase;
@@ -947,8 +936,28 @@ declare namespace RakeDbAst {
947
936
  };
948
937
  }
949
938
 
950
- type Db = DbResult<DefaultColumnTypes>;
951
- type BaseTable<CT extends ColumnTypesBase> = {
939
+ type RakeDbColumnTypes = {
940
+ index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): EmptyObject;
941
+ foreignKey(columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?: ForeignKeyOptions): EmptyObject;
942
+ primaryKey(columns: string[], options?: {
943
+ name?: string;
944
+ }): EmptyObject;
945
+ check(check: RawSQLBase): EmptyObject;
946
+ constraint(arg: ConstraintArg): EmptyObject;
947
+ };
948
+ type ConstraintArg = {
949
+ name?: string;
950
+ references?: [
951
+ columns: [string, ...string[]],
952
+ table: string,
953
+ foreignColumn: [string, ...string[]],
954
+ options: Omit<ForeignKeyOptions, 'name' | 'dropMode'>
955
+ ];
956
+ check?: RawSQLBase;
957
+ dropMode?: DropMode;
958
+ };
959
+ type Db = DbResult<RakeDbColumnTypes>;
960
+ type BaseTable<CT> = {
952
961
  exportAs: string;
953
962
  getFilePath(): string;
954
963
  nowSQL?: string;
@@ -958,12 +967,13 @@ type BaseTable<CT extends ColumnTypesBase> = {
958
967
  language?: string;
959
968
  };
960
969
  };
961
- type InputRakeDbConfig<CT extends ColumnTypesBase> = Partial<Omit<RakeDbConfig<CT>, 'columnTypes'>> & ({
962
- columnTypes?: CT | ((t: DefaultColumnTypes) => CT);
970
+ type InputRakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT> = Partial<Omit<RakeDbConfig<SchemaConfig, CT>, 'columnTypes'>> & ({
971
+ columnTypes?: CT | ((t: DefaultColumnTypes<ColumnSchemaConfig>) => CT);
963
972
  } | {
964
973
  baseTable?: BaseTable<CT>;
965
974
  });
966
- type RakeDbConfig<CT extends ColumnTypesBase = DefaultColumnTypes> = {
975
+ type RakeDbConfig<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<ColumnSchemaConfig>> = {
976
+ schemaConfig: SchemaConfig;
967
977
  columnTypes: CT;
968
978
  basePath: string;
969
979
  dbScript: string;
@@ -973,7 +983,7 @@ type RakeDbConfig<CT extends ColumnTypesBase = DefaultColumnTypes> = {
973
983
  migrationsTable: string;
974
984
  snakeCase: boolean;
975
985
  language?: string;
976
- commands: Record<string, (options: AdapterOptions[], config: RakeDbConfig<CT>, args: string[]) => void | Promise<void>>;
986
+ commands: Record<string, (options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>, args: string[]) => void | Promise<void>>;
977
987
  noPrimaryKey?: NoPrimaryKeyOption;
978
988
  baseTable?: BaseTable<CT>;
979
989
  appCodeUpdater?: AppCodeUpdater;
@@ -1014,18 +1024,18 @@ type MigrationItem = {
1014
1024
  load(): Promise<unknown>;
1015
1025
  };
1016
1026
 
1017
- declare const createDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<CT>) => Promise<void>;
1018
- declare const dropDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<CT>) => Promise<void>;
1019
- declare const resetDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<CT>) => Promise<void>;
1027
+ declare const createDb: <SchemaConfig extends ColumnSchemaConfig, CT>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
1028
+ declare const dropDb: <SchemaConfig extends ColumnSchemaConfig, CT>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
1029
+ declare const resetDb: <SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColumnTypes>(arg: MaybeArray<AdapterOptions>, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
1020
1030
 
1021
- declare const writeMigrationFile: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(config: RakeDbConfig<CT>, version: string, name: string, content: (importPath: string, name: string) => string) => Promise<void>;
1022
- declare const generate: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(config: RakeDbConfig<CT>, [name]: string[]) => Promise<void>;
1031
+ declare const writeMigrationFile: <SchemaConfig extends ColumnSchemaConfig, CT>(config: RakeDbConfig<SchemaConfig, CT>, version: string, name: string, content: (importPath: string, name: string) => string) => Promise<void>;
1032
+ declare const generate: <SchemaConfig extends ColumnSchemaConfig, CT>(config: RakeDbConfig<SchemaConfig, CT>, [name]: string[]) => Promise<void>;
1023
1033
  declare const makeFileTimeStamp: () => string;
1024
1034
 
1025
- type ChangeCallback<CT extends ColumnTypesBase = ColumnTypesBase> = (db: DbMigration<CT>, up: boolean) => Promise<void>;
1035
+ type ChangeCallback<CT extends RakeDbColumnTypes> = (db: DbMigration<CT>, up: boolean) => Promise<void>;
1026
1036
 
1027
1037
  declare const RAKE_DB_LOCK_KEY = "8582141715823621641";
1028
- type MigrateFn = <CT extends ColumnTypesBase>(options: MaybeArray<AdapterOptions>, config: RakeDbConfig<CT>, args?: string[]) => Promise<void>;
1038
+ type MigrateFn = <SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColumnTypes>(options: MaybeArray<AdapterOptions>, config: RakeDbConfig<SchemaConfig, CT>, args?: string[]) => Promise<void>;
1029
1039
  /**
1030
1040
  * Will run all pending yet migrations, sequentially in order,
1031
1041
  * will apply `change` functions top-to-bottom.
@@ -1048,13 +1058,13 @@ declare const rollback: MigrateFn;
1048
1058
  * Takes the same options as {@link migrate}.
1049
1059
  */
1050
1060
  declare const redo: MigrateFn;
1051
- declare const migrateOrRollback: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(trx: TransactionAdapter, config: RakeDbConfig<CT>, files: MigrationItem[], count: number, asts: RakeDbAst[], up: boolean) => Promise<void>;
1052
- declare const changeCache: Record<string, ChangeCallback[] | undefined>;
1061
+ declare const migrateOrRollback: (trx: TransactionAdapter, config: RakeDbConfig<ColumnSchemaConfig, RakeDbColumnTypes>, files: MigrationItem[], count: number, asts: RakeDbAst[], up: boolean) => Promise<void>;
1062
+ declare const changeCache: Record<string, ChangeCallback<RakeDbColumnTypes>[] | undefined>;
1053
1063
 
1054
1064
  /**
1055
1065
  * Type of {@link rakeDb} function
1056
1066
  */
1057
- type RakeDbFn = (<C extends ColumnTypesBase = DefaultColumnTypes>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<C>, args?: string[]) => RakeDbChangeFn<C> & {
1067
+ type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColumnTypes>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<SchemaConfig, CT>, args?: string[]) => RakeDbChangeFn<CT> & {
1058
1068
  promise: Promise<void>;
1059
1069
  }) & {
1060
1070
  /**
@@ -1070,16 +1080,16 @@ type RakeDbFn = (<C extends ColumnTypesBase = DefaultColumnTypes>(options: Maybe
1070
1080
  /**
1071
1081
  * Type of {@link rakeDb.lazy} function
1072
1082
  */
1073
- type RakeDbLazyFn = <C extends ColumnTypesBase = DefaultColumnTypes>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<C>) => {
1074
- change: RakeDbChangeFn<C>;
1075
- run(args: string[], config?: Partial<RakeDbConfig<C>>): Promise<void>;
1083
+ type RakeDbLazyFn = <SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColumnTypes>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<SchemaConfig, CT>) => {
1084
+ change: RakeDbChangeFn<CT>;
1085
+ run(args: string[], config?: Partial<RakeDbConfig<SchemaConfig, CT>>): Promise<void>;
1076
1086
  };
1077
1087
  /**
1078
1088
  * Function to use in migrations to wrap database changes
1079
1089
  * Saves the given callback to an internal queue,
1080
1090
  * and also returns the callback in case you want to export it from migration.
1081
1091
  */
1082
- type RakeDbChangeFn<C extends ColumnTypesBase> = (fn: ChangeCallback<C>) => ChangeCallback<C>;
1092
+ type RakeDbChangeFn<CT extends RakeDbColumnTypes> = (fn: ChangeCallback<CT>) => ChangeCallback<CT>;
1083
1093
  /**
1084
1094
  * Function to configure and run `rakeDb`.
1085
1095
  *
@@ -1089,8 +1099,8 @@ type RakeDbChangeFn<C extends ColumnTypesBase> = (fn: ChangeCallback<C>) => Chan
1089
1099
  */
1090
1100
  declare const rakeDb: RakeDbFn;
1091
1101
 
1092
- declare const saveMigratedVersion: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(db: SilentQueries, version: string, config: RakeDbConfig<CT>) => Promise<void>;
1093
- declare const removeMigratedVersion: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(db: SilentQueries, version: string, config: RakeDbConfig<CT>) => Promise<void>;
1094
- declare const getMigratedVersionsMap: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>(db: TransactionAdapter, config: RakeDbConfig<CT>) => Promise<Record<string, boolean>>;
1102
+ declare const saveMigratedVersion: <SchemaConfig extends ColumnSchemaConfig, CT>(db: SilentQueries, version: string, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
1103
+ declare const removeMigratedVersion: <SchemaConfig extends ColumnSchemaConfig, CT>(db: SilentQueries, version: string, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
1104
+ declare const getMigratedVersionsMap: <SchemaConfig extends ColumnSchemaConfig, CT>(db: TransactionAdapter, config: RakeDbConfig<SchemaConfig, CT>) => Promise<Record<string, boolean>>;
1095
1105
 
1096
1106
  export { AppCodeUpdater, AppCodeUpdaterParams, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, DbMigration, DropMode, Migration, MigrationColumnTypes, RAKE_DB_LOCK_KEY, RakeDbAst, RakeDbConfig, SilentQueries, TableOptions, changeCache, createDb, createMigrationInterface, dropDb, generate, getMigratedVersionsMap, makeFileTimeStamp, migrate, migrateOrRollback, rakeDb, redo, removeMigratedVersion, resetDb, rollback, saveMigratedVersion, writeMigrationFile };
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ var __objRest$2 = (source, exclude) => {
39
39
  return target;
40
40
  };
41
41
  const migrationConfigDefaults = {
42
+ schemaConfig: pqb.defaultSchemaConfig,
42
43
  migrationsPath: path.join("src", "db", "migrations"),
43
44
  migrationsTable: "schemaMigrations",
44
45
  snakeCase: false,
@@ -100,13 +101,16 @@ const processRakeDbConfig = (config) => {
100
101
  }
101
102
  if ("baseTable" in config) {
102
103
  const proto = (_b = config.baseTable) == null ? void 0 : _b.prototype;
103
- result.columnTypes = proto.types || pqb.columnTypes;
104
+ result.columnTypes = proto.types || pqb.makeColumnTypes(pqb.defaultSchemaConfig);
104
105
  if (proto.snakeCase)
105
106
  result.snakeCase = true;
106
107
  if (proto.language)
107
108
  result.language = proto.language;
108
109
  } else {
109
- result.columnTypes = "columnTypes" in config && (typeof config.columnTypes === "function" ? config.columnTypes(pqb.columnTypes) : config.columnTypes) || pqb.columnTypes;
110
+ const ct = "columnTypes" in config && config.columnTypes;
111
+ result.columnTypes = (typeof ct === "function" ? ct(
112
+ pqb.makeColumnTypes(pqb.defaultSchemaConfig)
113
+ ) : ct) || pqb.makeColumnTypes;
110
114
  }
111
115
  return result;
112
116
  };
@@ -616,7 +620,12 @@ const primaryKeyToSql = (primaryKey) => {
616
620
 
617
621
  const tableMethods = {
618
622
  enum(name) {
619
- return new pqb.EnumColumn(name, []);
623
+ return new pqb.EnumColumn(
624
+ pqb.defaultSchemaConfig,
625
+ name,
626
+ [],
627
+ void 0
628
+ );
620
629
  }
621
630
  };
622
631
 
@@ -686,14 +695,10 @@ const createTable$1 = async (migration, up, tableName, options, fn) => {
686
695
  let table;
687
696
  return {
688
697
  get table() {
689
- return table != null ? table : table = migration(
690
- tableName,
691
- shape,
692
- {
693
- noPrimaryKey: options.noPrimaryKey ? "ignore" : void 0,
694
- snakeCase: options.snakeCase
695
- }
696
- );
698
+ return table != null ? table : table = migration(tableName, shape, {
699
+ noPrimaryKey: options.noPrimaryKey ? "ignore" : void 0,
700
+ snakeCase: options.snakeCase
701
+ });
697
702
  }
698
703
  };
699
704
  };
@@ -956,7 +961,8 @@ const columnTypeToColumnChange = (item) => {
956
961
  const nameKey = Symbol("name");
957
962
  const tableChangeMethods = __spreadProps$2(__spreadValues$4({}, tableMethods), {
958
963
  name(name) {
959
- const types = Object.create(pqb.columnTypes.name.call(this, name));
964
+ orchidCore.setCurrentColumnName(name);
965
+ const types = Object.create(this);
960
966
  types[nameKey] = name;
961
967
  return types;
962
968
  },
@@ -1001,7 +1007,9 @@ const changeTable = async (migration, up, tableName, options, fn) => {
1001
1007
  orchidCore.setDefaultLanguage(language);
1002
1008
  pqb.resetTableData();
1003
1009
  resetChangeTableData();
1004
- const tableChanger = Object.create(migration.columnTypes);
1010
+ const tableChanger = Object.create(
1011
+ migration.columnTypes
1012
+ );
1005
1013
  Object.assign(tableChanger, tableChangeMethods);
1006
1014
  tableChanger[orchidCore.snakeCaseKey] = snakeCase;
1007
1015
  const changeData = (fn == null ? void 0 : fn(tableChanger)) || {};
@@ -2271,7 +2279,7 @@ function makeMigrateFn(defaultCount, up, fn) {
2271
2279
  const migrate = makeMigrateFn(
2272
2280
  Infinity,
2273
2281
  true,
2274
- (trx, configs, files, count, asts) => migrateOrRollback(trx, configs, files, count, asts, true)
2282
+ (trx, config, files, count, asts) => migrateOrRollback(trx, config, files, count, asts, true)
2275
2283
  );
2276
2284
  const rollback = makeMigrateFn(
2277
2285
  1,
@@ -3159,28 +3167,38 @@ const getColumn = (ctx, data, domains, _a) => {
3159
3167
  ]);
3160
3168
  var _a2, _b2;
3161
3169
  let column;
3162
- const klass = pqb.columnsByType[getColumnType(type, isSerial)];
3163
- if (klass) {
3164
- column = pqb.instantiateColumn(klass, params);
3170
+ const columnType = getColumnType(type, isSerial);
3171
+ const typeFn = ctx.columnsByType[columnType];
3172
+ if (typeFn) {
3173
+ column = pqb.instantiateColumn(typeFn, params);
3165
3174
  } else {
3166
3175
  const domainColumn = domains[`${typeSchema}.${type}`];
3167
3176
  if (domainColumn) {
3168
- column = new pqb.DomainColumn(type).as(domainColumn);
3177
+ column = new pqb.DomainColumn(ctx.columnSchemaConfig, type).as(domainColumn);
3169
3178
  } else {
3170
3179
  const enumType = data.enums.find(
3171
3180
  (item) => item.name === type && item.schemaName === typeSchema
3172
3181
  );
3173
3182
  if (enumType) {
3174
- column = new pqb.EnumColumn(type, enumType.values);
3183
+ column = new pqb.EnumColumn(
3184
+ ctx.columnSchemaConfig,
3185
+ type,
3186
+ enumType.values,
3187
+ ctx.columnSchemaConfig.type
3188
+ );
3175
3189
  } else {
3176
- column = new pqb.CustomTypeColumn(type);
3190
+ column = new pqb.CustomTypeColumn(ctx.columnSchemaConfig, type);
3177
3191
  ((_b2 = (_a2 = ctx.unsupportedTypes)[type]) != null ? _b2 : _a2[type] = []).push(
3178
3192
  `${schemaName}${tableName ? `.${tableName}` : ""}.${name}`
3179
3193
  );
3180
3194
  }
3181
3195
  }
3182
3196
  }
3183
- return isArray ? new pqb.ArrayColumn(column) : column;
3197
+ return isArray ? new pqb.ArrayColumn(
3198
+ ctx.columnSchemaConfig,
3199
+ column,
3200
+ ctx.columnSchemaConfig.type
3201
+ ) : column;
3184
3202
  };
3185
3203
  const getColumnType = (type, isSerial) => {
3186
3204
  if (!isSerial)
@@ -3682,9 +3700,11 @@ const pullDbStructure = async (options, config) => {
3682
3700
  const currentSchema = adapter.schema || "public";
3683
3701
  const db = new DbStructure(adapter);
3684
3702
  const ctx = {
3685
- unsupportedTypes: {},
3686
3703
  snakeCase: config.snakeCase,
3687
- currentSchema
3704
+ unsupportedTypes: {},
3705
+ currentSchema,
3706
+ columnSchemaConfig: config.schemaConfig,
3707
+ columnsByType: pqb.makeColumnsByType(config.schemaConfig)
3688
3708
  };
3689
3709
  const ast = await structureToAst(ctx, db);
3690
3710
  await adapter.close();
@@ -3801,7 +3821,11 @@ var __spreadValues = (a, b) => {
3801
3821
  };
3802
3822
  const rakeDb = (options, partialConfig = {}, args = process.argv.slice(2)) => {
3803
3823
  const config = processRakeDbConfig(partialConfig);
3804
- const promise = runCommand(options, config, args).catch((err) => {
3824
+ const promise = runCommand(
3825
+ options,
3826
+ config,
3827
+ args
3828
+ ).catch((err) => {
3805
3829
  var _a;
3806
3830
  if (err instanceof RakeDbError) {
3807
3831
  (_a = config.logger) == null ? void 0 : _a.error(err.message);