parent
6e322a5630
commit
7da238def9
@ -0,0 +1,16 @@
|
||||
class MigrateDeleteDepartment < ActiveRecord::Migration
|
||||
def up
|
||||
ApplyAddDepartment.where("status= 3 and created_at > '2019-07-25 00:00:00'").each do |apply|
|
||||
if apply.department.present? && !apply.department.is_auth
|
||||
user_exs = UserExtensions.where("department_id = #{apply.department_id}")
|
||||
users = User.where(id: user_exs.pluck(:user_id))
|
||||
user_exs.update_all(department_id: nil)
|
||||
users.update_all(profile_completed: false)
|
||||
apply.department.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue