public
Last active

  • Download Gist
db.rake
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
namespace :db do
# NOTE: In Rails 3 there will be a db:setup task but it only works if ActiveRecord::Base.schema_format == :ruby
# See http://afreshcup.com/2009/05/11/seed-data-in-rails-3
# The following patch fixes db:schema:load to work with schema_format :sql:
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2789-make-rake-task-dbschemaload-compatible-with-sql-schema-format
desc 'Recreate the database, load the schema, and initialize with the seed data'
task :super_setup => [ 'db:drop', 'db:create' ] do
system("cat db/development_structure.sql db/development_data.sql | script/dbconsole")
seed_file = File.join(Rails.root, 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.