Guest User

Untitled

a guest
Jan 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class DowncaseEmail < ActiveRecord::Migration
  2. def up
  3. User.all.each do |user|
  4. user.update_attributes :email => user.email.downcase
  5. end
  6. end
  7. end
  8.  
  9. class DowncaseEmail < ActiveRecord::Migration
  10. def up
  11. if %w[MySQL PostgreSQL].include? ActiveRecord::Base.connection.adapter_name
  12. execute "UPDATE users SET email = LOWER(email)"
  13. else
  14. User.all.each do |user|
  15. user.update_attributes email: user.email.downcase
  16. end
  17. end
  18. end
  19. end
  20.  
  21. execute("UPDATE users SET email = LOWER(email)")
  22.  
  23. User.update_all('email = lower(email)')
Add Comment
Please, Sign In to add comment