From 5ca11fefce6d83f5db399aa4412f1f1a0d42b2e6 Mon Sep 17 00:00:00 2001 From: Seamus Abshere Date: Mon, 23 Jul 2012 17:33:00 -0500 Subject: [PATCH 1/2] Make sure :environment task is executed before db:schema:load or db:structure:load Otherwise, if schema_format = :sql, you will see: $ rake db:setup --trace ** Invoke db:setup (first_time) ** Invoke db:schema:load_if_ruby (first_time) ** Invoke db:create (first_time) ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:create db_example_development already exists db_example_test already exists ** Execute db:schema:load_if_ruby #<-------- :environment hasn't been executed yet ** Invoke db:schema:load (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:schema:load ~/db_example/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it then try again. --- activerecord/lib/active_record/railties/databases.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 78ecb1cdc5..31e04fdc93 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -242,7 +242,7 @@ db_namespace = namespace :db do end end - task :load_if_ruby => 'db:create' do + task :load_if_ruby => [:environment, 'db:create'] do db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby end @@ -327,7 +327,7 @@ db_namespace = namespace :db do end end - task :load_if_sql => 'db:create' do + task :load_if_sql => [:environment, 'db:create'] do db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql end end From e7e86566ccc7bfb3fa0046961ef38f5431d55e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 5 Aug 2012 20:33:26 -0300 Subject: [PATCH 2/2] Update changelog --- activerecord/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 08aa3aae34..50407a2488 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,10 @@ ## Rails 4.0.0 (unreleased) ## +* Make sure `:environment` task is executed before `db:schema:load` or `db:structure:load` + Fixes #4772. + + *Seamus Abshere* + * Removed `:finder_sql` and `:counter_sql` collection association options. Please use scopes instead.