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", "residence_address", ColType::StringNull).await?;
        add_column(m, "orders", "residence_city", ColType::StringNull).await?;
        add_column(m, "orders", "residence_zip", ColType::StringNull).await?;
        add_column(m, "orders", "residence_country", ColType::StringNull).await
    }

    async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
        remove_column(m, "orders", "residence_country").await?;
        remove_column(m, "orders", "residence_zip").await?;
        remove_column(m, "orders", "residence_city").await?;
        remove_column(m, "orders", "residence_address").await
    }
}
