use loco_rs::schema::*;
use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
        add_column(m, "orders", "payment_method", ColType::StringNull).await?;
        add_column(m, "orders", "carrier_code", ColType::StringNull).await?;
        add_column(m, "orders", "carrier_name", ColType::StringNull).await?;
        add_column(m, "orders", "shipping_cents", ColType::BigIntegerWithDefault(0)).await?;
        add_column(m, "orders", "pickup_point_id", ColType::StringNull).await?;
        add_column(m, "orders", "pickup_point_name", ColType::StringNull).await?;
        Ok(())
    }

    async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
        remove_column(m, "orders", "payment_method").await?;
        remove_column(m, "orders", "carrier_code").await?;
        remove_column(m, "orders", "carrier_name").await?;
        remove_column(m, "orders", "shipping_cents").await?;
        remove_column(m, "orders", "pickup_point_id").await?;
        remove_column(m, "orders", "pickup_point_name").await?;
        Ok(())
    }
}
