Skip to content

Hot fix/documents being soft deleted - #641

Open
tsubik wants to merge 2 commits into
developfrom
hot-fix/documents-being-soft-deleted
Open

Hot fix/documents being soft deleted#641
tsubik wants to merge 2 commits into
developfrom
hot-fix/documents-being-soft-deleted

Conversation

@tsubik

@tsubik tsubik commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This is already on production, backfilling to develop branch.

Fix documents being soft-deleted instead of reset

RequiredOperatorDocumentFmu#applies_to_forest_type? compared forest_types
(Strings, since ForestType::TYPES is a HashWithIndifferentAccess) against
forest_type.to_sym, so it was always false for forest-type-scoped required
documents. That made condition 5 in OperatorDocument#destroy always fire, so
documents were soft-deleted instead of reset to doc_not_provided.

Shipped 2026-07-30. Affected exactly 2 documents (19045, 19349), both already
restored by hand — verified point-in-time against all 401 destroy events since
the release; the other 399 were legitimate.

Changes

  • Fix the comparison, plus the same bug in check:docs_forest_type_mismatch
  • Specs for applies_to_forest_type? and for destroying an FMU document
    (the existing #destroy spec used a country document, which has no fmu_id
    and so never reached that condition — the gap that let this through)
  • rake fix:erroneous_document_deletion to clean up what the deletion left
    behind: born-deleted history rows, PaperTrail destroy events, the score row
    it created, and document updated_at. Dry run by default (FOR_REAL=true
    to apply, SKIP_STATISTICS=true to leave statistics for a later backfill).

@tsubik
tsubik requested a review from santostiago August 25, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant