Fix database tasks in test namespace. #4030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 15fb430 introduced some issues.
Previously to that commit, when I executed
rake db:test:clone_structure
the structure was dumped (to structure.sql) and then loaded again no matter whether
the
config.active_record.schema_format
was set to :sql or :ruby. That was OKbecause I'm explicitly saying that I want the structure to be cloned.
Now, when I call the same task, although the structure is dumped, the loaded schema
depends on the value of the
config.active_record.schema_format
. So If I have it setto :ruby and then I call
rake db:test:clone_structure
the loaded file is schema.rb andnot the structure.sql how it is supposed to be according to the name of the task and
its description.
The same thing happens when I call
rake db:test:clone
. When called,a new schema.rb is created but the file used to load the schema depends on
config.active_record.schema_format
. If I have it set to :sql, a new schema.rbis created but the structure.sql file is used to create the database. So it is
not consistent.
This pull request solves the problem. When
db:test:clone_structure
is invoked, thestructure is dumped and then loaded into the test database. When
db:test:clone
isinvoked the schema is dumped and then loaded into the test database. None of these
tasks depends now on the value of
config.active_record.schema_format