toasty_sql/stmt/
alter_table.rs1use super::{Name, Statement};
2
3use toasty_core::schema::db::Table;
4
5#[derive(Debug, Clone)]
7pub struct AlterTable {
8 pub name: Name,
10
11 pub action: AlterTableAction,
13}
14
15#[derive(Debug, Clone)]
17pub enum AlterTableAction {
18 RenameTo(Name),
20}
21
22impl Statement {
23 pub fn alter_table_rename_to(table: &Table, new_name: &str) -> Self {
25 AlterTable {
26 name: Name::from(&table.name[..]),
27 action: AlterTableAction::RenameTo(Name::from(new_name)),
28 }
29 .into()
30 }
31}
32
33impl From<AlterTable> for Statement {
34 fn from(value: AlterTable) -> Self {
35 Self::AlterTable(value)
36 }
37}