UNPKG

1.22 kBTypeScriptView Raw
1declare module '@ioc:Adonis/Lucid/Schema' {
2 import { Knex } from 'knex';
3 import { QueryClientContract, RawQueryBindings } from '@ioc:Adonis/Lucid/Database';
4 /**
5 * Shape of callback to defer database calls
6 */
7 export type DeferCallback = (client: QueryClientContract) => void | Promise<void>;
8 /**
9 * Shape of schema class constructor
10 */
11 export interface SchemaConstructorContract {
12 disableTransactions: boolean;
13 new (db: QueryClientContract, file: string, dryRun: boolean): SchemaContract;
14 }
15 /**
16 * Shape of schema class
17 */
18 export interface SchemaContract {
19 readonly file: string;
20 dryRun: boolean;
21 debug: boolean;
22 db: QueryClientContract;
23 schema: Knex.SchemaBuilder;
24 now(precision?: number): Knex.Raw;
25 knex(): Knex.QueryBuilder;
26 raw(sql: string, bindings?: RawQueryBindings): Knex.Raw;
27 defer: (cb: DeferCallback) => void;
28 up(): Promise<void> | void;
29 down(): Promise<void> | void;
30 execUp(): Promise<string[] | boolean>;
31 execDown(): Promise<string[] | boolean>;
32 }
33 const Schema: SchemaConstructorContract;
34 export default Schema;
35}