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> {
        // The store is EUR-only. Currency is no longer stored per product/order;
        // the euro symbol is rendered everywhere in the UI.
        remove_column(m, "products", "currency").await?;
        remove_column(m, "orders", "currency").await
    }

    async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
        add_column(m, "products", "currency", ColType::StringWithDefault("EUR".to_string())).await?;
        add_column(m, "orders", "currency", ColType::StringWithDefault("EUR".to_string())).await
    }
}
