mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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 ```
This commit is contained in:
parent
ba882934bb
commit
707be603cf
1 changed files with 1 additions and 1 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue