robson-core 0.1.0

Rust async agent orchestrator for automated development workflows
Documentation
use sea_orm_migration::prelude::*;

/// Defensive migration for databases created with the old sqlx system.
/// Adds columns that may be missing if the tasks table already existed
/// before the sea_orm migration ran. Uses raw SQL and ignores errors
/// when the column already exists (SQLite does not support ADD COLUMN IF NOT EXISTS).
#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        let db = manager.get_connection();

        // repo_url — added by old 006_task_repo_url.sql; may be absent on older DBs
        let _ = db
            .execute_unprepared("ALTER TABLE tasks ADD COLUMN repo_url TEXT NOT NULL DEFAULT ''")
            .await;

        // description — added by old 005_task_description.sql
        let _ = db
            .execute_unprepared("ALTER TABLE tasks ADD COLUMN description TEXT")
            .await;

        // token on repos — added by old 004_repo_token.sql
        let _ = db
            .execute_unprepared("ALTER TABLE repos ADD COLUMN token TEXT NOT NULL DEFAULT ''")
            .await;

        Ok(())
    }

    async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
        // SQLite does not support DROP COLUMN on older versions; no-op is safe here.
        Ok(())
    }
}