Skip to content

Instantly share code, notes, and snippets.

@peter
Created June 11, 2009 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter/127891 to your computer and use it in GitHub Desktop.
Save peter/127891 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment