parent
8bdeb3ea45
commit
0f22210bf5
@ -0,0 +1,21 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
desc "合并高校的数据,第一个参数是: 正确高校的id, 第二个参数是: 错误高校需要合并到正确高校的id"
|
||||||
|
# 命令: bundle exec rake schools:merge_school_data f_school=1 s_school=2,3
|
||||||
|
namespace :schools do
|
||||||
|
task merge_school_data: :environment do
|
||||||
|
f_school = ENV['f_school'].to_i
|
||||||
|
school = School.find_by(id: f_school)
|
||||||
|
return if school.blank?
|
||||||
|
|
||||||
|
s_school = ENV['s_school'].split(",")
|
||||||
|
merge_schools = School.where(id: s_school)
|
||||||
|
|
||||||
|
# 改变用户的学校id 和 单位
|
||||||
|
UserExtension.where(school_id: merge_schools)
|
||||||
|
.update_all(school_id: f_school, department_id: nil)
|
||||||
|
|
||||||
|
# 改变课堂的学校id
|
||||||
|
Course.where(school_id: merge_schools).update_all(school_id: f_school)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue