UNPKG

1.19 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 raw(sql: string, bindings?: RawQueryBindings): Knex.Raw;
26 defer: (cb: DeferCallback) => void;
27 up(): Promise<void> | void;
28 down(): Promise<void> | void;
29 execUp(): Promise<string[] | boolean>;
30 execDown(): Promise<string[] | boolean>;
31 }
32 const Schema: SchemaConstructorContract;
33 export default Schema;
34}