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,
            "site_settings",
            &[
                ("id", ColType::PkAuto),
                ("site_name", ColType::StringNull),
                ("site_short_name", ColType::StringNull),
                ("site_url", ColType::StringNull),
                ("site_title", ColType::StringNull),
                ("site_description", ColType::StringNull),
                ("hero_title", ColType::StringNull),
                ("hero_subtitle", ColType::StringNull),
                ("owner_name", ColType::StringNull),
                ("owner_title", ColType::StringNull),
                ("owner_bio", ColType::TextNull),
                ("owner_avatar_url", ColType::StringNull),
                ("social_github", ColType::StringNull),
                ("social_twitter", ColType::StringNull),
                ("social_email", ColType::StringNull),
                ("location", ColType::StringNull),
                ("tech_stack", ColType::JsonBinaryNull),
            ],
            &[],
        )
        .await
    }

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