Skip to content

Commit e404264

Browse files
committed
Add migration to backfill the district_name field for US schools where empty
1 parent b2ab5f7 commit e404264

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+
class BackfillDistrictNameForUsSchools < ActiveRecord::Migration[7.2]
2+
def up
3+
School
4+
.where(country_code: "US")
5+
.where("district_name IS NULL OR BTRIM(district_name) = ''")
6+
.update_all(district_name: "District Unknown")
7+
end
8+
9+
def down
10+
School
11+
.where(country_code: "US")
12+
.where(district_name: "District Unknown")
13+
.update_all(district_name: nil)
14+
end
15+
end

0 commit comments

Comments
 (0)