55 lines
2.5 KiB
Ruby
55 lines
2.5 KiB
Ruby
namespace :db do
|
|
desc "Import a maxmind geo (139) database; run like this: rake db:import_maxmind_geo file=<path_to_GeoIPCity.csv>"
|
|
task import_maxmind_geo: :environment do
|
|
MaxMindGeo.import_from_max_mind ENV['file']
|
|
end
|
|
|
|
desc "Import a maxmind isp (142) database; run like this: rake db:import_maxmind_isp file=<path_to_GeoIPISP-142.csv>"
|
|
task import_maxmind_isp: :environment do
|
|
MaxMindIsp.import_from_max_mind ENV['file']
|
|
end
|
|
|
|
desc "Import a maxmind blocks (134) database; run like this: rake db:import_geoip_blocks file=<path_to_GeoIPCity-134-Blocks.csv>"
|
|
task import_geoip_blocks: :environment do
|
|
GeoIpBlocks.import_from_max_mind ENV['file']
|
|
end
|
|
|
|
desc "Import a maxmind locations (134) database; run like this: rake db:import_geoip_locations file=<path_to_GeoIPCity-134-Location.csv>"
|
|
task import_geoip_locations: :environment do
|
|
GeoIpLocations.import_from_max_mind ENV['file']
|
|
end
|
|
|
|
desc "Import a maxmind isp (124) database; run like this: rake db:import_jam_isp file=<path_to_GeoIPISP.csv>"
|
|
task import_jam_isp: :environment do
|
|
JamIsp.import_from_max_mind ENV['file']
|
|
end
|
|
|
|
desc "Import a iso3166 country database (countrycodes and names); run like this: rake db:import_countries file=/path/to/iso3166.csv"
|
|
task import_countries: :environment do
|
|
Country.import_from_iso3166 ENV['file']
|
|
end
|
|
|
|
desc "Import a region database (regioncode, regionname); run like this: rake db:import_regions countrycode=XX file=/path/to/xx_region.csv"
|
|
task import_regions: :environment do
|
|
Region.import_from_xx_region(ENV['countrycode'], ENV['file'])
|
|
end
|
|
|
|
desc "Help"
|
|
task help: :environment do
|
|
puts "bundle exec rake db:import_maxmind_isp file=/path/to/GeoIPISP-142.csv # geo-142"
|
|
puts "bundle exec rake db:import_maxmind_geo file=/path/to/GeoIPCity.csv # geo-139"
|
|
puts "bundle exec rake db:import_geoip_blocks file=/path/to/GeoIPCity-134-Blocks.csv # geo-134"
|
|
puts "bundle exec rake db:import_geoip_locations file=/path/to/GeoIPCity-134-Location.csv # geo-134"
|
|
puts "bundle exec rake db:import_jam_isp file=/path/to/GeoIPISP.csv # geo-124"
|
|
puts "bundle exec rake db:import_countries file=/path/to/iso3166.csv # db/geodata"
|
|
puts "bundle exec rake db:import_regions countrycode=XX file=/path/to/xx_region.csv # db/geodata, both of them"
|
|
end
|
|
|
|
desc "Create a fake set of maxmind data"
|
|
task phony_maxmind: :environment do
|
|
MaxMindManager.active_record_transaction do |manager|
|
|
manager.create_phony_database()
|
|
end
|
|
end
|
|
end
|