mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Add data migration to fill EmailAddressVerifications
This commit is contained in:
parent
9758c82221
commit
ee7d69c1ce
4 changed files with 29 additions and 160 deletions
19
db/data/20200608084321_fill_email_verifications.rb
Normal file
19
db/data/20200608084321_fill_email_verifications.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class FillEmailVerifications < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
registrar_billing_emails = Registrar.pluck(:billing_email).uniq.reject(&:blank?)
|
||||
registrar_emails = Registrar.pluck(:email).uniq.reject(&:blank?)
|
||||
contact_emails = Contact.pluck(:email).uniq.reject(&:blank?)
|
||||
|
||||
emails = (contact_emails || registrar_emails || registrar_billing_emails).uniq
|
||||
|
||||
result = emails.map do |email|
|
||||
{ email: email, domain: Mail::Address.new(email).domain || 'not_found' }
|
||||
end
|
||||
|
||||
EmailAddressVerification.import result, batch_size: 500
|
||||
end
|
||||
|
||||
def down
|
||||
EmailAddressVerification.delete_all
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue