toasty_sql/stmt/
drop_column.rs1use super::{Name, Statement};
2
3use toasty_core::schema::db::{Column, TableId};
4
5#[derive(Debug, Clone)]
7pub struct DropColumn {
8 pub table: TableId,
10
11 pub name: Name,
13
14 pub if_exists: bool,
16}
17
18impl Statement {
19 pub fn drop_column(column: &Column) -> Self {
23 DropColumn {
24 table: column.id.table,
25 name: Name::from(&column.name[..]),
26 if_exists: false,
27 }
28 .into()
29 }
30
31 pub fn drop_column_if_exists(column: &Column) -> Self {
35 DropColumn {
36 table: column.id.table,
37 name: Name::from(&column.name[..]),
38 if_exists: true,
39 }
40 .into()
41 }
42}
43
44impl From<DropColumn> for Statement {
45 fn from(value: DropColumn) -> Self {
46 Self::DropColumn(value)
47 }
48}