Skip to content

Commit 4ec0702

Browse files
authored
Remove data migration (#3090)
This part of the migration doesn't run successfully as part of the 2.0.0 release because the model has changed too much since then. We can replace this with a Rake task that we can run post-deployment.
2 parents 4cd0b01 + 3b8d82d commit 4ec0702

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

db/migrate/20250211092238_add_year_groups_to_class_imports.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,5 @@ def change
88
array: true,
99
default: [],
1010
null: false
11-
12-
reversible do |dir|
13-
dir.up do
14-
ClassImport
15-
.includes(session: :programmes)
16-
.find_each do |class_import|
17-
year_groups = class_import.session.year_groups
18-
class_import.update!(year_groups:)
19-
end
20-
end
21-
end
2211
end
2312
end

lib/tasks/class_imports.rake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
namespace :class_imports do
4+
desc "Assign year groups to class imports without them."
5+
task assign_year_groups: :environment do
6+
ClassImport
7+
.includes(session: :programmes)
8+
.where(year_groups: [])
9+
.find_each do |class_import|
10+
year_groups = class_import.session.year_groups
11+
class_import.update_column(:year_groups, year_groups)
12+
end
13+
end
14+
end

0 commit comments

Comments
 (0)