Skip to content

Commit 27b6685

Browse files
Merge pull request #6046 from nhsuk/alistair/fix-pending-changes-batch-id
Add data migration to refactor `batch_id` in pending changes
2 parents 3e63737 + ddd0511 commit 27b6685

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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_migration do
4+
desc "Renames all the pending changes `batch_id`s to `batch_number`s"
5+
task rename_pending_changes_batch_id: :environment do
6+
VaccinationRecord
7+
.where("pending_changes ? 'batch_id'")
8+
.find_each do |record|
9+
record.pending_changes["batch_number"] = record.pending_changes.delete(
10+
"batch_id"
11+
)
12+
record.save!(touch: false)
13+
end
14+
end
15+
end

0 commit comments

Comments
 (0)