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,
            "comments",
            &[
                ("id", ColType::PkAuto),
                ("post_id", ColType::UuidNull),
                ("author", ColType::StringNull),
                ("email", ColType::StringNull),
                ("avatar", ColType::StringNull),
                ("content", ColType::TextNull),
                ("reply_to", ColType::UuidNull),
                ("approved", ColType::BooleanNull),
            ],
            &[],
        )
        .await
    }

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