use anyhow::Result;
use colored::Colorize;
use crate::config;
pub(super) fn check_pending_migrations(resolved: &config::Resolved) -> Result<()> {
use crate::migration::{self, MigrationCheckResult};
let ctx = match migration::MigrationContext::from_resolved(resolved) {
Ok(ctx) => ctx,
Err(e) => {
log::debug!("Could not create migration context: {}", e);
return Ok(());
}
};
match migration::check_migrations(&ctx)? {
MigrationCheckResult::Current => {}
MigrationCheckResult::Pending(migrations) => {
eprintln!();
eprintln!(
"{}",
format!("⚠ Warning: {} migration(s) pending", migrations.len()).yellow()
);
eprintln!("Run {} to apply them.", "ralph migrate --apply".cyan());
}
}
Ok(())
}