//! SeaORM migration: create project_board tables

use sea_orm_migration::prelude::*;

pub struct Migration;

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

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        let sql = include_str!("sql/m20260407_000002_create_project_board.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,
                "DROP TABLE IF EXISTS project_board_card; DROP TABLE IF EXISTS project_board_column; DROP TABLE IF EXISTS project_board;",
            ))
            .await?;
        Ok(())
    }
}
