* Move emails from users table to email_addresses table. * Validate that addresses are formatted correctly and are unique across users. Existing invalid emails are grandfathered in. * Add is_verified flag (the address has been confirmed by the user). * Add is_deliverable flag (an undeliverable address is an address that bounces). * Normalize addresses to prevent registering multiple accounts with the same email address (using tricks like Gmail's plus addressing).
10 lines
355 B
Ruby
Executable File
10 lines
355 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
require_relative "../../config/environment"
|
|
|
|
User.where.not(email: nil).find_each.with_index do |user, n|
|
|
email = EmailAddress.new(user: user, address: user.email, is_verified: true)
|
|
email.save(validate: false)
|
|
puts "n=#{n} id=#{user.id} name=#{user.name} email=#{user.email} normalized_address=#{email.normalized_address}"
|
|
end
|