Migration runner

From fritzprix/libr-agent · View interactive version

Migration runner is an AI agent skill from the GitHub repository fritzprix/libr-agent. Run and verify SeaORM database migrations against in-memory SQLite. Use when applying migrations, verifying schema changes, or testing migration correctness.

How to use this skill

Skill file

Migration Runner

Run and verify SeaORM database migrations for LibrAgent.

Setup

use sqlx::sqlite::SqlitePoolOptions;
use sea_orm::SqlxSqliteConnector;
use tauri_mcp_agent_lib::migration::Migrator;
use sea_orm_migration::MigratorTrait;

async fn setup_db() -> sea_orm::DatabaseConnection {
    let pool = SqlitePoolOptions::new()
        .connect("sqlite::memory:")
        .await
        .unwrap();
    let db = SqlxSqliteConnector::from_sqlx_sqlite_pool(pool);
    Migrator::up(&db, None).await.unwrap();
    db
}

Verification Patterns

Schema Validation

let db = setup_db().await;
// Verify tables exist
let result = db.query_all(
    "SELECT name FROM sqlite_master WHERE type='table'"
).await.unwrap();
assert!(result.iter().any(|r| r["name"].to_string().contains("expected_table")));

Migration Up/Down

let db = setup_db().await;
Migrator::up(&db, None).await.unwrap();
// Verify schema after up
Migrator::down(&db, None).await.unwrap();
// Verify schema after down

Foreign Key Validation

let db = setup_db().await;
// Attempt invalid foreign key insertion
// Verify foreign key constraint is enforced

Key Files

CI Integration

Tests must be in src-tauri/tests/ as integration tests. Run with:

cargo test --tests
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.