use sea_orm_migration::prelude::*; #[derive(DeriveMigrationName)] pub struct Migration; #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { let sql = include_str!("sql/m20260509_000004_add_message_versioning.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 INDEX IF EXISTS idx_ai_msg_version_latest; DROP INDEX IF EXISTS idx_ai_msg_version_group; ALTER TABLE ai_message DROP COLUMN IF EXISTS is_latest; ALTER TABLE ai_message DROP COLUMN IF EXISTS version_number; ALTER TABLE ai_message DROP COLUMN IF EXISTS version_group_id;" .to_string(), )) .await?; Ok(()) } }