{
  "validated_at": "2026-05-05",
  "tenant": "tenancy_demo",
  "commands": {
    "initial_dry_run": {
      "inventory_kardex_missing_fk": 710,
      "inventory_kardex_would_be_updated": 11,
      "prescription_prescriptions_missing_fk": 0,
      "prescription_prescriptions_would_be_updated": 0
    },
    "real_backfill": {
      "inventory_kardex_missing_fk_before_update": 710,
      "inventory_kardex_updated": 11,
      "prescription_prescriptions_missing_fk": 0,
      "prescription_prescriptions_updated": 0
    },
    "post_backfill_dry_run": {
      "inventory_kardex_missing_fk": 699,
      "inventory_kardex_would_be_updated": 0,
      "prescription_prescriptions_missing_fk": 0,
      "prescription_prescriptions_would_be_updated": 0
    }
  },
  "cross_check_after_backfill": [
    {
      "type": "App\\Models\\Tenant\\Document",
      "joined_rows": 208,
      "with_json_presentation": 38,
      "with_json_presentation_and_null_fk": 0,
      "null_fk_without_json_presentation": 168
    },
    {
      "type": "App\\Models\\Tenant\\SaleNote",
      "joined_rows": 37,
      "with_json_presentation": 8,
      "with_json_presentation_and_null_fk": 0,
      "null_fk_without_json_presentation": 29
    },
    {
      "type": "App\\Models\\Tenant\\Purchase",
      "joined_rows": 78,
      "with_json_presentation": 1,
      "with_json_presentation_and_null_fk": 0,
      "null_fk_without_json_presentation": 77
    },
    {
      "type": "App\\Models\\Tenant\\PurchaseSettlement",
      "joined_rows": 0,
      "with_json_presentation": 0,
      "with_json_presentation_and_null_fk": 0,
      "null_fk_without_json_presentation": 0
    }
  ],
  "summary_after_backfill": {
    "inventory_kardex_null_fk_total": 699,
    "prescription_prescriptions_null_fk_total": 0,
    "recoverable_rows_remaining_from_json": 0
  },
  "health_check": {
    "exit_code": 1,
    "items_without_any_presentation": 10,
    "document_related_kardex_missing_fk": 270,
    "note": "Remaining null FK rows are not recoverable from presentation JSON; health-check also reports historical QA items without presentations."
  },
  "conclusion": "Backfill completed successfully for all rows recoverable from historical JSON."
}
