Add Rake tasks to setup the database

parent 460a86ad
Pipeline #4234 skipped
namespace :db do
desc "Load seed data from the cities CSV"
task seed_cities: :environment do
print "Seeding cities..."
# insert importing states
print "OK\n"
end
desc "Load seed data from the states CSV"
task seed_states: [ :environment, :seed_regions ] do
print "Seeding states..."
# insert importing states
print "OK\n"
end
desc "Load seed data from the regions CSV"
task seed_regions: :environment do
print "Seeding regions..."
# insert importing regions
print "OK\n"
end
desc "Load seed data from the locations CSV"
task seed_locations: :environment do
print "Seeding locations..."
# insert importing locations
print "OK\n"
end
desc "Load seed data from the administration levels CSV"
task seed_administrative_levels: :environment do
print "Seeding administrative levels..."
# insert importing administrative levels
print "OK\n"
end
desc "Import school classes from an input CSV"
task import_school_classes: [ :environment, :seed_cities, :seed_states,
:seed_locations, :seed_administrative_levels ] do
print "Importing school classes..."
# insert importing school classes
print "OK\n"
end
# enhance db:setup task to import school classes automatically after it is finished
Rake::Task["db:setup"].enhance do
Rake::Task["db:import_school_classes"].invoke
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment