From a3717c08bba2af5ba32d82f0567132c12a63d66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sat, 10 Oct 2026 19:37:13 +0500 Subject: [PATCH] Retain each schema failure report during recovery validation --- crates/coa-core/src/schema_check.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/coa-core/src/schema_check.rs b/crates/coa-core/src/schema_check.rs index 385297a..c00244d 100644 --- a/crates/coa-core/src/schema_check.rs +++ b/crates/coa-core/src/schema_check.rs @@ -42,12 +42,13 @@ pub struct Problem { pub database: String, pub table: String, pub column: String /// Keep all differences for support; never change a database to match a contract automatically. pub fn check_with_report(db: &Db, root: &Path) -> Result> { let problems = check(db, root)?; + if problems.is_empty() { return Ok(problems); } let report = serde_json::json!({ "schema": 1, "checkedAt": chrono::Utc::now().to_rfc3339(), "realm": db.realm().name(), "problems": problems, }); let path = crate::registry::metadata_dir_for(root)?.join("diagnostics") - .join(format!("schema-validation-{}.json", db.realm().name())); + .join(format!("schema-validation-{}-{}.json", db.realm().name(), uuid::Uuid::new_v4())); // A log write failure must neither hide the original mismatch nor accept an invalid schema. if let Err(error) = fsx::atomic_write_json(&path, &report) { tracing::warn!(%error, path = %path.display(), "Could not save database schema report");