use anyhow::Context; use config::scoped::{MigrateConfig, ScopedConfig}; use models::migrate::sync_schema; use sea_orm::Database; use tracing::info; const DEFAULT_LOG_FILTER: &str = "info,migrate=debug"; #[tokio::main] async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt() .with_env_filter( tracing_subscriber::EnvFilter::try_from_default_env() .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new(DEFAULT_LOG_FILTER)), ) .init(); let cfg = MigrateConfig::load().context("loading configuration")?; let opts = cfg .database .primary_connect_options() .map_err(|e| anyhow::anyhow!(e))?; let db = Database::connect(opts) .await .context("connecting to postgres")?; info!("running schema migration"); sync_schema(&db).await.context("running schema sync")?; info!("schema migration completed"); Ok(()) }