//! SeaORM migration: add resolved and in_reply_to columns to pull_request_review_comment

use sea_orm_migration::prelude::*;

pub struct Migration;

impl MigrationName for Migration {
    fn name(&self) -> &str {
        "m20250628_000082_add_pr_review_comment_resolve"
    }
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        let sql = include_str!("sql/m20250628_000082_add_pr_review_comment_resolve.sql");
        super::execute_sql(manager, sql).await
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .get_connection()
            .execute_raw(sea_orm::Statement::from_string(
                sea_orm::DbBackend::Postgres,
                "ALTER TABLE pull_request_review_comment \
                     DROP COLUMN IF EXISTS resolved, \
                     DROP COLUMN IF EXISTS in_reply_to;",
            ))
            .await?;
        Ok(())
    }
}
