-
Notifications
You must be signed in to change notification settings - Fork 290
/
Copy pathalter-column-node.ts
45 lines (40 loc) · 1.14 KB
/
alter-column-node.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
import { OperationNode } from './operation-node.js'
import { freeze } from '../util/object-utils.js'
import { ColumnNode } from './column-node.js'
import { DataTypeNode } from './data-type-node.js'
import { ValueNode } from './value-node.js'
import { RawNode } from './raw-node.js'
export type AlterColumnNodeProps = Omit<AlterColumnNode, 'kind' | 'column'>
export interface AlterColumnNode extends OperationNode {
readonly kind: 'AlterColumnNode'
readonly column: ColumnNode
readonly dataType?: DataTypeNode
readonly dataTypeExpression?: RawNode
readonly setDefault?: ValueNode | RawNode
readonly dropDefault?: true
readonly setNotNull?: true
readonly dropNotNull?: true
}
/**
* @internal
*/
export const AlterColumnNode = freeze({
is(node: OperationNode): node is AlterColumnNode {
return node.kind === 'AlterColumnNode'
},
create(column: string): AlterColumnNode {
return freeze({
kind: 'AlterColumnNode',
column: ColumnNode.create(column),
})
},
cloneWith(
node: AlterColumnNode,
props: AlterColumnNodeProps
): AlterColumnNode {
return freeze({
...node,
...props,
})
},
})