mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Added more whois rake tasks
This commit is contained in:
parent
14e0dbf6ab
commit
1b501dd053
1 changed files with 38 additions and 9 deletions
|
@ -16,15 +16,44 @@ namespace :whois do
|
||||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
|
|
||||||
# desc 'Delete whois database data and import from Registry master database (faster)'
|
desc 'Create whois database'
|
||||||
# task export: :environment do
|
task create: [:environment] do
|
||||||
# start = Time.zone.now.to_f
|
whois_db = "whois_#{Rails.env}"
|
||||||
# print "-----> Delete whois database data and import from Registry whois_records table..."
|
begin
|
||||||
# whois_records = WhoisRecord.pluck(:name, :body, :json)
|
puts "\n------------------------ Create #{whois_db} ---------------------------------------\n"
|
||||||
# Whois::Record.delete_all
|
ActiveRecord::Base.clear_all_connections!
|
||||||
# Whois::Record.import([:name, :body, :json], whois_records)
|
conf = ActiveRecord::Base.configurations
|
||||||
# puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
|
||||||
# end
|
ActiveRecord::Base.connection.create_database(conf[whois_db]['database'].to_sym, conf[whois_db])
|
||||||
|
rescue => e
|
||||||
|
puts "\n#{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc 'Drop whois database'
|
||||||
|
task drop: [:environment] do
|
||||||
|
# just in case we allow only drop test, comment it out only for temp
|
||||||
|
if Rails.env.test?
|
||||||
|
whois_db = "whois_#{Rails.env}"
|
||||||
|
|
||||||
|
begin
|
||||||
|
puts "\n------------------------ #{whois_db} drop ------------------------------\n"
|
||||||
|
ActiveRecord::Base.clear_all_connections!
|
||||||
|
ActiveRecord::Base.establish_connection(whois_db.to_sym)
|
||||||
|
|
||||||
|
conf = ActiveRecord::Base.configurations
|
||||||
|
if ActiveRecord::Tasks::DatabaseTasks.drop(conf[whois_db])
|
||||||
|
puts "#{conf[whois_db]['database']} dropped"
|
||||||
|
else
|
||||||
|
puts "Didn't find database #{whois_db}, no drop"
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
puts "\n#{e}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts 'Only for test'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
namespace :schema do
|
namespace :schema do
|
||||||
desc 'Load whois schema into empty whois database'
|
desc 'Load whois schema into empty whois database'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue