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
use {
super::{DataType, Expr, ObjectName},
serde::{Deserialize, Serialize},
};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AlterTableOperation {
AddColumn { column_def: ColumnDef },
DropColumn {
column_name: String,
if_exists: bool,
},
RenameColumn {
old_column_name: String,
new_column_name: String,
},
RenameTable { table_name: ObjectName },
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ColumnDef {
pub name: String,
pub data_type: DataType,
pub options: Vec<ColumnOptionDef>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ColumnOptionDef {
pub name: Option<String>,
pub option: ColumnOption,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ColumnOption {
Null,
NotNull,
Default(Expr),
Unique { is_primary: bool },
}