//! SeaORM migration: add `stream` column to `room_ai` table

use sea_orm_migration::prelude::*;

pub struct Migration;

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

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .get_connection()
            .execute_raw(sea_orm::Statement::from_string(
                sea_orm::DbBackend::Postgres,
                "ALTER TABLE room_ai ADD COLUMN IF NOT EXISTS stream BOOLEAN NOT NULL DEFAULT true;",
            ))
            .await?;
        Ok(())
    }

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