gluesql_core/plan/statement/
ddl.rs1use {
2 crate::ast,
3 serde::{Deserialize, Serialize},
4};
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7pub enum AlterTableOperationPlan {
8 AddColumn {
9 column_def: ast::ColumnDef,
10 },
11 DropColumn {
12 column_name: String,
13 if_exists: bool,
14 },
15 RenameColumn {
16 old_column_name: String,
17 new_column_name: String,
18 },
19 RenameTable {
20 table_name: String,
21 },
22}
23
24impl From<ast::AlterTableOperation> for AlterTableOperationPlan {
25 fn from(operation: ast::AlterTableOperation) -> Self {
26 match operation {
27 ast::AlterTableOperation::AddColumn { column_def } => Self::AddColumn { column_def },
28 ast::AlterTableOperation::DropColumn {
29 column_name,
30 if_exists,
31 } => Self::DropColumn {
32 column_name,
33 if_exists,
34 },
35 ast::AlterTableOperation::RenameColumn {
36 old_column_name,
37 new_column_name,
38 } => Self::RenameColumn {
39 old_column_name,
40 new_column_name,
41 },
42 ast::AlterTableOperation::RenameTable { table_name } => {
43 Self::RenameTable { table_name }
44 }
45 }
46 }
47}