diff options
author | schneems <richard.schneeman@gmail.com> | 2013-12-25 17:25:38 -0500 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2013-12-25 18:03:55 -0500 |
commit | 707be603cfae39e82b63bbcf1fc64a2392edb693 (patch) | |
tree | 4631f02476645748f5ba1033dd9255f1739c567e /railties | |
parent | ba882934bb66e240aef5e240272f3875ff86b8e7 (diff) | |
download | rails-707be603cfae39e82b63bbcf1fc64a2392edb693.tar.gz rails-707be603cfae39e82b63bbcf1fc64a2392edb693.tar.bz2 rails-707be603cfae39e82b63bbcf1fc64a2392edb693.zip |
ensure environment is run before db:structure:load
Right now `db:drop` depends on `load_config` since so when `db:drop` gets executed `load_config` gets run. `db:structure:load` depends on `[:environment, :load_config]`. So before it runs, it executes `environment` but because `load_config` has already executed it is skipped. Note `db:load_config` is "invoke"-d twice, but only "execute"-d once:
```
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:drop
** Invoke db:structure:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config
** Execute db:structure:load
```
The fix for this is making sure that the environment is run before any `load_config`:
```
** Invoke environment (first_time)
** Execute environment
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:drop
** Invoke db:structure:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:structure:load
```
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index 3577aa2e6b..f8c7f98b03 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -129,7 +129,7 @@ module ApplicationTests bundle exec rake db:migrate db:structure:dump` structure_dump = File.read("db/structure.sql") assert_match(/CREATE TABLE \"books\"/, structure_dump) - `bundle exec rake db:drop db:structure:load` + `bundle exec rake environment db:drop db:structure:load` assert_match(/#{expected[:database]}/, ActiveRecord::Base.connection_config[:database]) require "#{app_path}/app/models/book" |