-
Notifications
You must be signed in to change notification settings - Fork 168
/
triggersTypes.ts
53 lines (37 loc) · 1.16 KB
/
triggersTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { FunctionOptions } from './functionsTypes';
import type { DropOptions, Name, Value } from './generalTypes';
export interface TriggerOptions {
when?: 'BEFORE' | 'AFTER' | 'INSTEAD OF';
operation: string | string[];
constraint?: boolean;
function?: Name;
functionParams?: Value[];
level?: 'STATEMENT' | 'ROW';
condition?: string;
deferrable?: boolean;
deferred?: boolean;
}
type CreateTriggerFn1 = (
tableName: Name,
triggerName: string,
triggerOptions: TriggerOptions & DropOptions
) => string | string[];
type CreateTriggerFn2 = (
tableName: Name,
triggerName: string,
triggerOptions: TriggerOptions & FunctionOptions & DropOptions,
definition: Value
) => string | string[];
type CreateTriggerFn = CreateTriggerFn1 | CreateTriggerFn2;
export type CreateTrigger = CreateTriggerFn & { reverse: CreateTriggerFn };
export type DropTrigger = (
tableName: Name,
triggerName: string,
dropOptions?: DropOptions
) => string | string[];
type RenameTriggerFn = (
tableName: Name,
oldTriggerName: string,
newTriggerName: string
) => string | string[];
export type RenameTrigger = RenameTriggerFn & { reverse: RenameTriggerFn };