迁移报错

dev_forum
daiao 6 years ago
parent db84d635b5
commit e83ba51d93

@ -8,7 +8,7 @@ module Searchable::Dependents::User
private
def check_searchable_dependents
if firstname_previously_changed? || lastname_previously_changed? || user_extension.school_id_previously_changed?
if firstname_previously_changed? || lastname_previously_changed? || user_extension&.school_id_previously_changed?
# reindex shixun
created_shixuns.each(&:reindex)

@ -2,8 +2,8 @@ class ModifyLoginForUsers < ActiveRecord::Migration[5.2]
def change
users = User.where("created_on > '2019-07-26 19:00:00'")
users.find_each do |use|
use.update_attributes(login: use.login.strip, phone: use.phone.try(:strip))
use.user_extension.update_column(:student_id, use.user_extension.student_id.try(:strip))
use.update_attributes(login: use.login&.strip, phone: use.phone&.strip)
use.user_extension.update_column(:student_id, use.user_extension&.student_id&.strip)
end
end
end

Loading…
Cancel
Save