use sea_query::{Alias, Table};
use vespertide_core::ColumnType;
use crate::sql::helpers::build_drop_enum_type_sql;
use crate::sql::types::BuiltQuery;
pub(super) fn build_direct_delete_column(
table: &str,
column: &str,
column_type: Option<&ColumnType>,
) -> Vec<BuiltQuery> {
let mut stmts = Vec::new();
let stmt = Table::alter()
.table(Alias::new(table))
.drop_column(Alias::new(column))
.to_owned();
stmts.push(BuiltQuery::AlterTable(Box::new(stmt)));
if let Some(col_type) = column_type
&& let Some(drop_type_sql) = build_drop_enum_type_sql(table, col_type)
{
stmts.push(BuiltQuery::Raw(drop_type_sql));
}
stmts
}