diff options
author | Xavier Noria <fxn@hashref.com> | 2014-02-06 15:03:20 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2014-02-06 15:03:20 +0100 |
commit | c0fb8d0b9c4d55770f7ce1a9cb62e4f2a75ca3ee (patch) | |
tree | 66bfa9ed07cc0ef7e82552eebac49a5b5d8838b5 /railties | |
parent | 7f648bc70e76b7a386a41f882ddd97105334f590 (diff) | |
parent | 8806768e9f1a2648085f7826d9a0032457182bdb (diff) | |
download | rails-c0fb8d0b9c4d55770f7ce1a9cb62e4f2a75ca3ee.tar.gz rails-c0fb8d0b9c4d55770f7ce1a9cb62e4f2a75ca3ee.tar.bz2 rails-c0fb8d0b9c4d55770f7ce1a9cb62e4f2a75ca3ee.zip |
Merge branch 'dump-schema-after-migration-flag' of git://github.com/emilsoman/rails into emilsoman-dump-schema-after-migration-flag
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'railties')
4 files changed, 60 insertions, 0 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 5ea025924b..a57d56f4aa 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,10 @@ +* Set `dump_schema_after_migration` config values in production. + + Set `config.active_record.dump_schema_after_migration` as false + in the generated `config/environments/production.rb` file. + + *Emil Soman* + * Added Thor-action for creation of migrations. Fixes #13588, #12674. diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index d2f041aa27..d9cc60d656 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -81,4 +81,9 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + <%- unless options.skip_active_record? -%> + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + <%- end -%> end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 02d8b2c91d..b814479540 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -781,5 +781,22 @@ module ApplicationTests assert_not Rails.configuration.respond_to?(:method_missing) assert Rails.configuration.respond_to?(:method_missing, true) end + + test "config.active_record.dump_schema_after_migration is false on production" do + build_app + ENV["RAILS_ENV"] = "production" + + require "#{app_path}/config/environment" + + assert_not ActiveRecord::Base.dump_schema_after_migration + end + + test "config.active_record.dump_schema_after_migration is true by default on development" do + ENV["RAILS_ENV"] = "development" + + require "#{app_path}/config/environment" + + assert ActiveRecord::Base.dump_schema_after_migration + end end end diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 33c753868c..b7fd5d02c5 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -153,6 +153,37 @@ module ApplicationTests assert_match(/up\s+\d{3,}\s+Add email to users/, output) end end + + test 'schema generation when dump_schema_after_migration is set' do + add_to_config('config.active_record.dump_schema_after_migration = false') + + Dir.chdir(app_path) do + `rails generate model book title:string; + bundle exec rake db:migrate` + + assert !File.exist?("db/schema.rb") + end + + add_to_config('config.active_record.dump_schema_after_migration = true') + + Dir.chdir(app_path) do + `rails generate model author name:string; + bundle exec rake db:migrate` + + structure_dump = File.read("db/schema.rb") + assert_match(/create_table "authors"/, structure_dump) + end + end + + test 'default schema generation after migration' do + Dir.chdir(app_path) do + `rails generate model book title:string; + bundle exec rake db:migrate` + + structure_dump = File.read("db/schema.rb") + assert_match(/create_table "books"/, structure_dump) + end + end end end end |