robson-gateway-webhook 0.1.0

Rust async agent orchestrator for automated development workflows
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use anyhow::Result;
use sea_orm::{Database, DatabaseConnection};

pub async fn connect(db_path: &str) -> Result<DatabaseConnection> {
    let url = if db_path == ":memory:" || db_path == "sqlite::memory:" {
        "sqlite::memory:".to_string()
    } else {
        format!("sqlite://{}?mode=rwc", db_path)
    };
    Ok(Database::connect(&url).await?)
}

pub async fn connect_and_migrate(db_path: &str) -> Result<DatabaseConnection> {
    let db = connect(db_path).await?;
    use crate::migration::MigratorTrait;
    crate::migration::Migrator::up(&db, None).await?;
    Ok(db)
}