//! `/schema/migrations` response orchestration.
//!
//! This module isolates migration-specific response handling so catalog
//! response helpers for other endpoints remain focused on shared flows.
use actix_web::HttpResponse;
use serde_json::json;
use sqlx::{Pool, Postgres};
use super::catalog_migration_error_mapper::schema_migrations_fetch_error;
use super::catalog_migration_loader::load_schema_migration_rows;
/// Builds a `/schema/migrations` response for the resolved schema client pool.
pub(super) async fn schema_migrations_response(pool: &Pool<Postgres>) -> HttpResponse {
match load_schema_migration_rows(pool).await {
Ok(migrations) => HttpResponse::Ok().json(json!({ "migrations": migrations })),
Err(err) => schema_migrations_fetch_error(err),
}
}