-
Notifications
You must be signed in to change notification settings - Fork 279
/
alter-table-node.ts
50 lines (45 loc) · 1.58 KB
/
alter-table-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
46
47
48
49
50
import { OperationNode } from './operation-node.js'
import { freeze } from '../util/object-utils.js'
import { AddColumnNode } from './add-column-node.js'
import { DropColumnNode } from './drop-column-node.js'
import { TableNode } from './table-node.js'
import { IdentifierNode } from './identifier-node.js'
import { RenameColumnNode } from './rename-column-node.js'
import { AlterColumnNode } from './alter-column-node.js'
import { AddConstraintNode } from './add-constraint-node.js'
import { DropConstraintNode } from './drop-constraint-node.js'
import { ModifyColumnNode } from './modify-column-node.js'
export type AlterTableNodeProps = Omit<AlterTableNode, 'kind' | 'table'>
export interface AlterTableNode extends OperationNode {
readonly kind: 'AlterTableNode'
readonly table: TableNode
readonly renameTo?: TableNode
readonly setSchema?: IdentifierNode
readonly renameColumn?: RenameColumnNode
readonly addColumn?: AddColumnNode
readonly dropColumn?: DropColumnNode
readonly alterColumn?: AlterColumnNode
readonly modifyColumn?: ModifyColumnNode
readonly addConstraint?: AddConstraintNode
readonly dropConstraint?: DropConstraintNode
}
/**
* @internal
*/
export const AlterTableNode = freeze({
is(node: OperationNode): node is AlterTableNode {
return node.kind === 'AlterTableNode'
},
create(table: string): AlterTableNode {
return freeze({
kind: 'AlterTableNode',
table: TableNode.create(table),
})
},
cloneWith(node: AlterTableNode, props: AlterTableNodeProps): AlterTableNode {
return freeze({
...node,
...props,
})
},
})