rake-db 2.23.37 → 2.23.38

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,5 +1,5 @@
1
1
  import * as orchid_core from 'orchid-core';
2
- import { MaybeArray, RawSQLBase, ColumnDataCheckBase, RecordString, EmptyObject, ColumnSchemaConfig, QueryLogObject, QueryLogOptions, MaybePromise, RecordOptionalString, ColumnTypeBase, ForeignKeyTable, SingleSql } from 'orchid-core';
2
+ import { MaybeArray, RawSQLBase, ColumnDataCheckBase, RecordString, ColumnTypeBase, EmptyObject, ColumnSchemaConfig, QueryLogObject, QueryLogOptions, MaybePromise, RecordOptionalString, ForeignKeyTable, SingleSql } from 'orchid-core';
3
3
  import * as pqb from 'pqb';
4
4
  import { TableData, ColumnsShape, NoPrimaryKeyOption, ColumnType, EnumColumn, raw, Adapter, DbResult, TransactionAdapter, TableDataFn, TableDataItem, DbDomainArg, Db as Db$1, QueryArraysResult, AdapterOptions, DefaultColumnTypes, DefaultSchemaConfig, SearchWeight, ColumnsByType } from 'pqb';
5
5
 
@@ -198,23 +198,33 @@ declare namespace RakeDbAst {
198
198
 
199
199
  declare function add(item: ColumnType, options?: {
200
200
  dropMode?: DropMode;
201
- }): EmptyObject;
202
- declare function add(emptyObject: EmptyObject): EmptyObject;
201
+ }): SpecialChange;
202
+ declare function add(emptyObject: EmptyObject): SpecialChange;
203
203
  declare function add(items: Record<string, ColumnType>, options?: {
204
204
  dropMode?: DropMode;
205
205
  }): Record<string, RakeDbAst.ChangeTableItem.Column>;
206
- type Change = RakeDbAst.ChangeTableItem.Change & ChangeOptions;
206
+ interface Change extends RakeDbAst.ChangeTableItem.Change, ChangeOptions {
207
+ }
207
208
  type ChangeOptions = RakeDbAst.ChangeTableItem.ChangeUsing;
209
+ interface SpecialChange {
210
+ type: SpecialChange;
211
+ }
212
+ interface OneWayChange {
213
+ type: 'change';
214
+ name?: string;
215
+ to: RakeDbAst.ColumnChange;
216
+ using?: RakeDbAst.ChangeTableItem.ChangeUsing;
217
+ }
208
218
  type TableChangeMethods = typeof tableChangeMethods;
209
219
  declare const tableChangeMethods: {
210
220
  name(name: string): any;
211
221
  add: typeof add;
212
222
  drop: typeof add;
213
- change(from: ColumnType | Change, to: ColumnType | Change, using?: ChangeOptions): Change;
214
- default(value: unknown | RawSQLBase): Change;
215
- nullable(): Change;
216
- nonNullable(): Change;
217
- comment(comment: string | null): Change;
223
+ change(from: ColumnType | OneWayChange, to: ColumnType | OneWayChange, using?: ChangeOptions): Change;
224
+ default(value: unknown | RawSQLBase): OneWayChange;
225
+ nullable(): OneWayChange;
226
+ nonNullable(): OneWayChange;
227
+ comment(comment: string | null): OneWayChange;
218
228
  /**
219
229
  * Rename a column:
220
230
  *
@@ -254,7 +264,7 @@ declare const tableChangeMethods: {
254
264
  enum(name: string): EnumColumn<pqb.DefaultSchemaConfig, undefined, string, [string, ...string[]]>;
255
265
  };
256
266
  type TableChanger<CT> = MigrationColumnTypes<CT> & TableChangeMethods;
257
- type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | EmptyObject>;
267
+ type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | SpecialChange | ColumnTypeBase>;
258
268
 
259
269
  type DropMode = 'CASCADE' | 'RESTRICT';
260
270
  type TableOptions = {
package/dist/index.js CHANGED
@@ -759,12 +759,10 @@ const addOrDrop = (type, item, options) => {
759
759
  if (item instanceof pqb.UnknownColumn) {
760
760
  const empty = columnTypeToColumnChange({
761
761
  type: "change",
762
- from: {},
763
762
  to: {}
764
763
  });
765
764
  const add2 = columnTypeToColumnChange({
766
765
  type: "change",
767
- from: {},
768
766
  to: {
769
767
  checks: item.data.checks
770
768
  }
@@ -840,24 +838,22 @@ const tableChangeMethods = {
840
838
  };
841
839
  },
842
840
  default(value) {
843
- return { type: "change", from: { default: null }, to: { default: value } };
841
+ return { type: "change", to: { default: value } };
844
842
  },
845
843
  nullable() {
846
844
  return {
847
845
  type: "change",
848
- from: { nullable: false },
849
846
  to: { nullable: true }
850
847
  };
851
848
  },
852
849
  nonNullable() {
853
850
  return {
854
851
  type: "change",
855
- from: { nullable: true },
856
852
  to: { nullable: false }
857
853
  };
858
854
  },
859
855
  comment(comment) {
860
- return { type: "change", from: { comment: null }, to: { comment } };
856
+ return { type: "change", to: { comment } };
861
857
  },
862
858
  /**
863
859
  * Rename a column: