From c0df2b017f72371bbefc2027168682b2da16b609 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 22 Jun 2019 14:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=81=E7=A7=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20190621105144_sync_ivalid_users.rb | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/db/migrate/20190621105144_sync_ivalid_users.rb b/db/migrate/20190621105144_sync_ivalid_users.rb index 3520ca84d..f2875977f 100644 --- a/db/migrate/20190621105144_sync_ivalid_users.rb +++ b/db/migrate/20190621105144_sync_ivalid_users.rb @@ -1,34 +1,34 @@ class SyncIvalidUsers < ActiveRecord::Migration[5.2] - def change - 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.each do |user| - valid_users = User.where(login: user.login) - valid_users.each do |valid_user| - unless valid_user.lastname.present? - valid_user.delete - end - end - end - - 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.each do |mail_user| - valid_mail_users = User.where(mail: mail_user.mail) - valid_mail_users.each do |valid_mail_user| - unless valid_mail_user.lastname.present? - valid_mail_user.delete - end - end - end - - - 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") - phone_users.each do |phone_user| - valid_phone_users = User.where(phone: phone_user.phone) - valid_phone_users.each do |valid_phone_user| - unless valid_phone_user.lastname.present? - valid_phone_user.delete - end - end - end - end + # def change + # 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.each do |user| + # valid_users = User.where(login: user.login) + # valid_users.each do |valid_user| + # unless valid_user.lastname.present? + # valid_user.delete + # end + # end + # end + # + # 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.each do |mail_user| + # valid_mail_users = User.where(mail: mail_user.mail) + # valid_mail_users.each do |valid_mail_user| + # unless valid_mail_user.lastname.present? + # valid_mail_user.delete + # end + # end + # end + # + # + # 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") + # phone_users.each do |phone_user| + # valid_phone_users = User.where(phone: phone_user.phone) + # valid_phone_users.each do |valid_phone_user| + # unless valid_phone_user.lastname.present? + # valid_phone_user.delete + # end + # end + # end + # end end