users=User.find_by_sql("select count(*) as user_count, login from users group by login having user_count>1")
users=User.where.not(id:2).find_by_sql("select count(*) as user_count, login from users group by login having user_count>1")
users.eachdo|user|
valid_users=User.where(login:user.login)
valid_users.eachdo|valid_user|
@ -10,7 +10,7 @@ class DeleteIvalidData < ActiveRecord::Migration[5.2]
end
end
mail_users=User.find_by_sql("select count(*) as user_count, mail from users where mail is not null group by mail having user_count>1")
mail_users=User.where.not(id:2).find_by_sql("select count(*) as user_count, mail from users where mail is not null group by mail having user_count>1")
mail_users.eachdo|mail_user|
valid_mail_users=User.where(mail:mail_user.mail)
valid_mail_users.eachdo|valid_mail_user|
@ -21,7 +21,7 @@ class DeleteIvalidData < ActiveRecord::Migration[5.2]
end
phone_users=User.find_by_sql("select count(*) as user_count, phone from users where phone is not null group by phone having user_count>1")
phone_users=User.where.not(id:2).find_by_sql("select count(*) as user_count, phone from users where phone is not null group by phone having user_count>1")