Skip to content

[O2B-1515] Preserve updated_at when migrating DESTROYED history items to DONE - #2260

Merged
graduta merged 1 commit into
mainfrom
fix/O2B-1515/preserve-updated-at-in-done-status-migration
Oct 20, 2026
Merged

graduta merged 1 commit into
mainfrom
fix/O2B-1515/preserve-updated-at-in-done-status-migration

Conversation

@graduta

@graduta graduta commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Notable changes for users:

  • Environments converted from DESTROYED to DONE keep their original history timestamps, so status history and current-status filters give the correct results

Notable changes for developers:

Changes made to the database:

  • environments_history_items.updated_at is defined as ON UPDATE CURRENT_TIMESTAMP (see v0/20240712100711-environments-milliseconds-timestamps-and-remove-toredown-at.js), so the status conversion reset the historical update time of every converted row. GetAllEnvironmentsUseCase orders the current status and the status history by this column, so converted entries could be placed after later events and change filter results. The migration now keeps the original value.
  • The migration file is modified in place. If it has already been run on an environment, its DESTROYED rows are already DONE with a reset updated_at, and this fix will not repair them (they no longer match the WHERE status = 'DESTROYED'). This is only safe if the migration has not been deployed anywhere yet; otherwise a corrective migration is needed.
  • Checked on MariaDB 10.5.9: the previous statement reset updated_at to the current time, the new one keeps it.

…s to DONE

environments_history_items.updated_at is ON UPDATE CURRENT_TIMESTAMP, so the status conversion reset the historical update time of the converted rows. As the status history and current status are ordered by this column, converted items could end up after later events. Explicitly assign updated_at = updated_at to keep the original value.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@graduta
graduta requested a review from isaachilly as a code owner October 20, 2026 11:01
@graduta graduta added bug Something isn't working backend DB labels Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.44%. Comparing base (b475464) to head (8b702dd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2260      +/-   ##
==========================================
+ Coverage   46.41%   46.44%   +0.03%     
==========================================
  Files        1053     1053              
  Lines       17353    17353              
  Branches     3161     3161              
==========================================
+ Hits         8054     8060       +6     
+ Misses       9299     9293       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graduta
graduta merged commit eca7057 into main Oct 20, 2026
41 of 43 checks passed
@graduta
graduta deleted the fix/O2B-1515/preserve-updated-at-in-done-status-migration branch October 20, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working DB

Development

Successfully merging this pull request may close these issues.

1 participant