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> {
        // Populated only after an admin manually sends the order to a carrier.
        add_column(m, "orders", "tracking_number", ColType::StringNull).await?;
        add_column(m, "orders", "shipment_id", ColType::StringNull).await?;
        add_column(m, "orders", "label_url", ColType::StringNull).await?;
        Ok(())
    }

    async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
        remove_column(m, "orders", "tracking_number").await?;
        remove_column(m, "orders", "shipment_id").await?;
        remove_column(m, "orders", "label_url").await?;
        Ok(())
    }
}
