Skip to content

Commit 9816bc5

Browse files
committed
Add data_migrations:fix_vaccination_records_location
This fixes an issue where some vaccination records are currently invalid as they have both a `location_id` and a `location_name`. Jira-Issue: MAV-2016
1 parent 9c38574 commit 9816bc5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/tasks/data_migrations.rake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
namespace :data_migrations do
4+
desc "Fix vaccination record locations where both location_id and location_name is set"
5+
task fix_vaccination_record_locations: :environment do
6+
vaccination_records =
7+
VaccinationRecord
8+
.where.not(location_id: nil)
9+
.where.not(location_name: nil)
10+
11+
puts "#{vaccination_records.count} vaccination records need fixing"
12+
13+
vaccination_records.update_all(location_id: nil)
14+
end
15+
end

0 commit comments

Comments
 (0)