Skip to content

Commit 80926cc

Browse files
authored
Merge pull request #4646 from nhsuk/fix-vaccination-records-location
Add `data_migrations:fix_vaccination_records_location`
2 parents 2984d05 + 06fde4a commit 80926cc

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)