Hi, I found this code in a great tip on railsweenie, but as someone new
to rails I don’t know how to integrate this into my project. Can you
please help?
namespace :db do
desc “Loads a schema.rb file into the database and then loads the
initial database fixtures.”
task :bootstrap => [‘db:schema:load’, ‘db:bootstrap:load’]
namespace :bootstrap do
desc "Load initial database fixtures (in db/bootstrap/.yml) into
the current environment’s database. Load specific fixtures using
FIXTURES=x,y"
task :load => :environment do
require ‘active_record/fixtures’
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
(ENV[‘FIXTURES’] ? ENV[‘FIXTURES’].split(/,/) :
Dir.glob(File.join(RAILS_ROOT, ‘db’, ‘bootstrap’, '.{yml,csv}'))).each
do |fixture_file|
Fixtures.create_fixtures(‘db/bootstrap’,
File.basename(fixture_file, ‘.*’))
end
end
end
end
I think I over estimated the work load this script could handle, or
maybe I should use something like FasterCSV?
The file Im ‘bootstrapping’ is a world location database, about 158MB
and over 3 million lines. I think Im going to have to go back to an SQL
insert file, it would have been nice to have this all done through rake
though, Ill just have to use it for smaller data sets.
3009059 db/bootstrap/locations.csv
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.