Skip to content

Commit

Permalink
Add Rake task to migrate timeline events
Browse files Browse the repository at this point in the history
Since we're going to stop using the old_state and new_state fields and
instead rely on the existing old_value and new_value fields.
  • Loading branch information
thomasleese committed Sep 28, 2023
1 parent 592dc3e commit 04da91b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/tasks/timeline_events.rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
namespace :timeline_events do
desc "Migrate state_changed events"
task migrate_state_changed: :environment do
TimelineEvent.where(event_type: "state_changed").update_all(
event_type: "status_changed",
)
desc "Migrate old_state/new_state"
task migrate_old_new_state: :environment do
TimelineEvent
.where(event_type: %w[status_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

0 comments on commit 04da91b

Please sign in to comment.