Move data migrations from rake tasks to gem

See #1298
This commit is contained in:
Alex Sherman 2020-02-25 14:19:24 +05:00
parent ed27152bb1
commit 4ddbb08e80
19 changed files with 111 additions and 271 deletions

View file

View file

@ -1,16 +0,0 @@
namespace :data_migrations do
task convert_domain_delete_date: :environment do
processed_domain_count = 0
Domain.transaction do
Domain.find_each do |domain|
next unless domain.delete_date
domain.update_columns(delete_date: domain.delete_date + 1.day)
processed_domain_count += 1
end
end
puts "Domains processed: #{processed_domain_count}"
end
end

View file

@ -1,15 +0,0 @@
namespace :data_migrations do
task delete_orphaned_registrant_verifications: :environment do
orphaned_registrant_verifications = RegistrantVerification.where.not(domain_id: Domain.ids)
orphaned_registrant_verification_count = orphaned_registrant_verifications.count
processed_registrant_verification_count = 0
orphaned_registrant_verifications.each do |registrant_verification|
registrant_verification.destroy!
processed_registrant_verification_count += 1
end
puts "Processed: #{processed_registrant_verification_count} out of" \
" #{orphaned_registrant_verification_count}"
end
end

View file

@ -1,16 +0,0 @@
namespace :data_migrations do
task regenerate_registrar_reference_numbers: [:environment] do
processed_registrar_count = 0
Registrar.transaction do
Registrar.all.each do |registrar|
next unless registrar.reference_no.start_with?('RF')
registrar.update_columns(reference_no: Billing::ReferenceNo.generate)
processed_registrar_count += 1
end
end
puts "Registrars processed: #{processed_registrar_count}"
end
end