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,
            "posts",
            &[
                ("id", ColType::PkAuto),
                ("title", ColType::StringNull),
                ("slug", ColType::String),
                ("description", ColType::StringNull),
                ("content", ColType::TextNull),
                ("category", ColType::StringNull),
                ("tags", ColType::JsonBinaryNull),
                ("post_type", ColType::StringNull),
                ("image", ColType::StringNull),
                ("pinned", ColType::BooleanNull),
            ],
            &[],
        )
        .await
    }

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