rake-db 2.4.25 → 2.4.30

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,4 @@
1
- import { ColumnType, EnumColumn, UnknownColumn, ColumnTypes, ColumnsShape, DbResult, DefaultColumnTypes, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions, Adapter } from 'pqb';
2
- import * as orchid_core from 'orchid-core';
1
+ import { ColumnType, EnumColumn, ColumnTypes, ColumnsShape, DbResult, DefaultColumnTypes, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions, Adapter } from 'pqb';
3
2
  import { EmptyObject, RawExpression, ColumnTypesBase, raw, MaybeArray } from 'orchid-core';
4
3
 
5
4
  declare function add(this: ColumnTypesBase, item: ColumnType, options?: {
@@ -25,7 +24,6 @@ declare const tableChangeMethods: {
25
24
  comment(comment: string | null): Change;
26
25
  rename(name: string): RakeDbAst.ChangeTableItem.Rename;
27
26
  enum(this: ColumnTypesBase, name: string): EnumColumn<string, [string, ...string[]]>;
28
- check(this: ColumnTypesBase, value: RawExpression<orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>): UnknownColumn;
29
27
  };
30
28
  declare type TableChanger = MigrationColumnTypes & TableChangeMethods;
31
29
  declare type TableChangeData = Record<string, RakeDbAst.ChangeTableItem.Column | RakeDbAst.ChangeTableItem.Rename | Change | EmptyObject>;
@@ -57,6 +55,17 @@ declare type ColumnComment = {
57
55
  comment: string | null;
58
56
  };
59
57
  declare type Migration = DbResult<DefaultColumnTypes> & MigrationBase;
58
+ declare type ConstraintArg = {
59
+ name?: string;
60
+ references?: [
61
+ columns: [string, ...string[]],
62
+ table: string,
63
+ foreignColumn: [string, ...string[]],
64
+ options: Omit<ForeignKeyOptions, 'name' | 'dropMode'>
65
+ ];
66
+ check?: RawExpression;
67
+ dropMode?: DropMode;
68
+ };
60
69
  declare const createMigrationInterface: (tx: TransactionAdapter, up: boolean, options: RakeDbConfig) => Migration;
61
70
  declare class MigrationBase {
62
71
  adapter: TransactionAdapter;
@@ -83,6 +92,10 @@ declare class MigrationBase {
83
92
  dropPrimaryKey(tableName: string, columns: string[], options?: {
84
93
  name?: string;
85
94
  }): Promise<void>;
95
+ addCheck(tableName: string, check: RawExpression): Promise<void>;
96
+ dropCheck(tableName: string, check: RawExpression): Promise<void>;
97
+ addConstraint(tableName: string, constraint: ConstraintArg): Promise<void>;
98
+ dropConstraint(tableName: string, constraint: ConstraintArg): Promise<void>;
86
99
  renameColumn(tableName: string, from: string, to: string): Promise<void>;
87
100
  createSchema(schemaName: string): Promise<void>;
88
101
  dropSchema(schemaName: string): Promise<void>;
@@ -97,7 +110,7 @@ declare class MigrationBase {
97
110
  constraintExists(constraintName: string): Promise<boolean>;
98
111
  }
99
112
 
100
- declare type RakeDbAst = RakeDbAst.Table | RakeDbAst.ChangeTable | RakeDbAst.RenameTable | RakeDbAst.Schema | RakeDbAst.Extension | RakeDbAst.Enum | RakeDbAst.Domain | RakeDbAst.ForeignKey;
113
+ declare type RakeDbAst = RakeDbAst.Table | RakeDbAst.ChangeTable | RakeDbAst.RenameTable | RakeDbAst.Schema | RakeDbAst.Extension | RakeDbAst.Enum | RakeDbAst.Domain | RakeDbAst.Constraint;
101
114
  declare namespace RakeDbAst {
102
115
  type Table = {
103
116
  type: 'table';
@@ -200,12 +213,12 @@ declare namespace RakeDbAst {
200
213
  createIfNotExists?: boolean;
201
214
  dropIfExists?: boolean;
202
215
  };
203
- type ForeignKey = {
204
- type: 'foreignKey';
216
+ type Constraint = {
217
+ type: 'constraint';
205
218
  action: 'create';
206
219
  tableSchema?: string;
207
220
  tableName: string;
208
- } & TableData.ForeignKey;
221
+ } & TableData.Constraint;
209
222
  }
210
223
 
211
224
  declare type Db = DbResult<DefaultColumnTypes>;