diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2009-05-11 19:08:13 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2009-05-11 19:08:13 +0200 |
commit | 4932f7b38f72104819022abca0c952ba6f9888cb (patch) | |
tree | b8f5d82f7a00d910e6e88648cfe3cda345cd0295 /railties/lib/tasks | |
parent | 2e7409f035236c719c5b1567c4bb3e65a5e543bc (diff) | |
download | rails-4932f7b38f72104819022abca0c952ba6f9888cb.tar.gz rails-4932f7b38f72104819022abca0c952ba6f9888cb.tar.bz2 rails-4932f7b38f72104819022abca0c952ba6f9888cb.zip |
Added db/seeds.rb as a default file for storing seed data for the database. Can be loaded with rake db:seed (or created alongside the db with db:setup). (This is also known as the "Stop Putting Gawd Damn Seed Data In Your Migrations" feature) [DHH]
Diffstat (limited to 'railties/lib/tasks')
-rw-r--r-- | railties/lib/tasks/databases.rake | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 9588fabb2d..cdab5d8bb0 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -156,8 +156,8 @@ namespace :db do Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end - desc 'Drops and recreates the database from db/schema.rb for the current environment.' - task :reset => ['db:drop', 'db:create', 'db:schema:load'] + desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' + task :reset => [ 'db:drop', 'db:setup' ] desc "Retrieves the charset for the current environment's database" task :charset => :environment do @@ -206,6 +206,15 @@ namespace :db do end end + desc 'Create the database, load the schema, and initialize with the seed data' + task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] + + desc 'Load the seed data from db/seeds.rb' + task :seed => :environment do + seed_file = File.join(Rails.root, 'db', 'seeds.rb') + load(seed_file) if File.exist?(seed_file) + end + namespace :fixtures do desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." task :load => :environment do |