aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/railties
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-06-30 16:32:59 +0200
committerYves Senn <yves.senn@gmail.com>2015-06-30 16:36:03 +0200
commit2183caa24a678395c4367b1dedee583069fb1797 (patch)
tree4ed6d74c15c7dfb740c44374cc6c4ce99bca9044 /activerecord/lib/active_record/railties
parenta8f250a22c6278946e9ee519d99e2ce0e8ab4652 (diff)
downloadrails-2183caa24a678395c4367b1dedee583069fb1797.tar.gz
rails-2183caa24a678395c4367b1dedee583069fb1797.tar.bz2
rails-2183caa24a678395c4367b1dedee583069fb1797.zip
`dump_schema_after_migration` applies migration tasks other than db:migrate
Closes #20743. The task `db:_dump` now only dumps the schema if `ActiveRecord::Base.dump_schema_after_migration` is true. This has effects: - `db:migrate:up` - `db:migrate:down` - `db:forward` - `db:rollback`
Diffstat (limited to 'activerecord/lib/active_record/railties')
-rw-r--r--activerecord/lib/active_record/railties/databases.rake21
1 files changed, 12 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 66fb3ae44b..85734aea90 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -42,19 +42,22 @@ db_namespace = namespace :db do
desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
task :migrate => [:environment, :load_config] do
ActiveRecord::Tasks::DatabaseTasks.migrate
- db_namespace['_dump'].invoke if ActiveRecord::Base.dump_schema_after_migration
+ db_namespace['_dump'].invoke
end
+ # IMPORTANT: This task won't dump the schema if ActiveRecord::Base.dump_schema_after_migration is set to false
task :_dump do
- case ActiveRecord::Base.schema_format
- when :ruby then db_namespace["schema:dump"].invoke
- when :sql then db_namespace["structure:dump"].invoke
- else
- raise "unknown schema format #{ActiveRecord::Base.schema_format}"
+ if ActiveRecord::Base.dump_schema_after_migration
+ case ActiveRecord::Base.schema_format
+ when :ruby then db_namespace["schema:dump"].invoke
+ when :sql then db_namespace["structure:dump"].invoke
+ else
+ raise "unknown schema format #{ActiveRecord::Base.schema_format}"
+ end
+ # Allow this task to be called as many times as required. An example is the
+ # migrate:redo task, which calls other two internally that depend on this one.
+ db_namespace['_dump'].reenable
end
- # Allow this task to be called as many times as required. An example is the
- # migrate:redo task, which calls other two internally that depend on this one.
- db_namespace['_dump'].reenable
end
namespace :migrate do