diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-06-30 16:32:59 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-06-30 16:36:03 +0200 |
commit | 2183caa24a678395c4367b1dedee583069fb1797 (patch) | |
tree | 4ed6d74c15c7dfb740c44374cc6c4ce99bca9044 /railties | |
parent | a8f250a22c6278946e9ee519d99e2ce0e8ab4652 (diff) | |
download | rails-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 'railties')
-rw-r--r-- | railties/test/application/rake/migrations_test.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 70e8908a46..2d8bd7c571 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -158,20 +158,22 @@ module ApplicationTests add_to_config('config.active_record.dump_schema_after_migration = false') Dir.chdir(app_path) do - `bin/rails generate model book title:string; - bin/rake db:migrate` + `bin/rails generate model book title:string` + output = `bin/rails generate model author name:string` + version = output =~ %r{[^/]+db/migrate/(\d+)_create_authors\.rb} && $1 - assert !File.exist?("db/schema.rb") + `bin/rake db:migrate db:rollback db:forward db:migrate:up db:migrate:down VERSION=#{version}` + assert !File.exist?("db/schema.rb"), "should not dump schema when configured not to" end add_to_config('config.active_record.dump_schema_after_migration = true') Dir.chdir(app_path) do - `bin/rails generate model author name:string; - bin/rake db:migrate` + `bin/rails generate model reviews book_id:integer` + `bin/rake db:migrate` structure_dump = File.read("db/schema.rb") - assert_match(/create_table "authors"/, structure_dump) + assert_match(/create_table "reviews"/, structure_dump) end end |