diff --git a/lib/tasks/timeline_events.rake b/lib/tasks/timeline_events.rake index 13bceac257..58a57497c2 100644 --- a/lib/tasks/timeline_events.rake +++ b/lib/tasks/timeline_events.rake @@ -5,4 +5,18 @@ namespace :timeline_events do event_type: "status_changed", ) end + + desc "Migrate old_state/new_state" + task migrate_old_new_state: :environment do + TimelineEvent + .where(event_type: %w[state_changed assessment_section_recorded]) + .each do |timeline_event| + timeline_event.update!( + old_value: timeline_event.old_state, + new_value: timeline_event.new_state, + old_state: "", + new_state: "", + ) + end + end end