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> {
        create_table(
            m,
            "payment_methods",
            &[
                ("id", ColType::PkAuto),
                ("code", ColType::StringUniq),
                ("name", ColType::String),
                ("enabled", ColType::BooleanWithDefault(true)),
                ("position", ColType::IntegerWithDefault(0)),
            ],
            &[],
        )
        .await?;

        create_table(
            m,
            "shop_settings",
            &[
                ("id", ColType::PkAuto),
                ("key", ColType::StringUniq),
                ("value", ColType::TextNull),
            ],
            &[],
        )
        .await
    }

    async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
        drop_table(m, "shop_settings").await?;
        drop_table(m, "payment_methods").await
    }
}
