Skip to content

Commit a5c8e38

Browse files
committed
Backfill school_id column
In the previous two commits we added a `school_id` column on `patient_locations`. This commit adds a data migration to make sure it is populated for existing rows. Jira-Issue: MAV-7114 Jira-Issue: MAV-7113
1 parent 871784b commit a5c8e38

2 files changed

Lines changed: 16 additions & 1 deletion

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+
class BackfillPatientLocationSchool < ActiveRecord::Migration[8.1]
4+
def up
5+
execute <<-SQL
6+
UPDATE patient_locations
7+
SET school_id = location_id
8+
WHERE school_id IS NULL
9+
SQL
10+
end
11+
12+
def down
13+
# Nothing to do to revert this.
14+
end
15+
end

db/data_schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DataMigrate::Data.define(version: 2026_04_22_155320)
1+
DataMigrate::Data.define(version: 2026_04_27_125506)

0 commit comments

Comments
 (0)