gitdataai/lib/migrate/src/main.rs

27 lines
562 B
Rust

use anyhow::Result;
use clap::Parser;
use sqlx::postgres::PgPoolOptions;
#[derive(Parser)]
#[command(name = "migrate", about = "Database migration tool")]
struct Cli {
#[arg(short, long, env = "DATABASE_URL")]
database_url: String,
}
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter("migrate=info")
.init();
let cli = Cli::parse();
let pool = PgPoolOptions::new()
.max_connections(1)
.connect(&cli.database_url)
.await?;
migrate::run_up(&pool).await
}