diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index f3cb2a971e..ee611f6a2a 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -291,15 +291,11 @@ db_namespace = namespace :db do end desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)' - task :setup => :environment do - db_namespace["create"].invoke - db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby - db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql - db_namespace["seed"].invoke - end + task :setup => :seed desc 'Load the seed data from db/seeds.rb' - task :seed => 'db:abort_if_pending_migrations' do + task :seed => ['db:schema:load_if_ruby', 'db:structure:load_if_sql'] do + db_namespace['abort_if_pending_migrations'].invoke Rails.application.load_seed end @@ -362,6 +358,10 @@ db_namespace = namespace :db do abort %{#{file} doesn't exist yet. Run `rake db:migrate` to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded} end end + + task :load_if_ruby => 'db:create' do + db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby + end end namespace :structure do @@ -437,6 +437,10 @@ db_namespace = namespace :db do raise "Task not supported by '#{abcs[env]['adapter']}'" end end + + task :load_if_sql => 'db:create' do + db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql + end end namespace :test do |