From 96f19f6cf62fb4705a75cf4a81e4e2f145a4cee2 Mon Sep 17 00:00:00 2001
From: schneems <richard.schneeman@gmail.com>
Date: Tue, 5 Jun 2012 19:15:16 -0500
Subject: raise error for pending migration

can be configured by setting config.active_record.migration. Setting to :page_load will raise an error on each page refresh if there are migrations that are pending. Setting to :page_load is defaulted in development for new applications.
---
 .../rails/app/templates/config/environments/development.rb.tt          | 3 +++
 railties/lib/rails/generators/rails/app/templates/test/test_helper.rb  | 2 ++
 2 files changed, 5 insertions(+)

(limited to 'railties')

diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index 24bcec854c..01f9396403 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -26,6 +26,9 @@
   # Log the query plan for queries taking more than this (works
   # with SQLite, MySQL, and PostgreSQL).
   config.active_record.auto_explain_threshold_in_seconds = 0.5
+
+  # Raise an error on page load if there are pending migrations
+  config.active_record.migration_error = :page_load
   <%- end -%>
 
   <%- unless options.skip_sprockets? -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb
index a8f7aeac7d..0090293200 100644
--- a/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb
+++ b/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb
@@ -4,6 +4,8 @@ require 'rails/test_help'
 
 class ActiveSupport::TestCase
 <% unless options[:skip_active_record] -%>
+  ActiveRecord::Migration.check_pending!
+
   # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
   #
   # Note: You'll currently still have to declare fixtures explicitly in integration tests
-- 
cgit v1.2.3