use super::{Name, Statement};
use toasty_core::schema::db::Table;
#[derive(Debug, Clone)]
pub struct AlterTable {
pub name: Name,
pub action: AlterTableAction,
}
#[derive(Debug, Clone)]
pub enum AlterTableAction {
RenameTo(Name),
}
impl Statement {
pub fn alter_table_rename_to(table: &Table, new_name: &str) -> Self {
AlterTable {
name: Name::from(&table.name[..]),
action: AlterTableAction::RenameTo(Name::from(new_name)),
}
.into()
}
}
impl From<AlterTable> for Statement {
fn from(value: AlterTable) -> Self {
Self::AlterTable(value)
}
}