rails/rails — pull request #6665 by schneems (2012-06-07 18:19:28+00:00)
Title: Notify A User they Have Pending Migrations 

## Problem

After a member of a team adds commits new code and a migration, other developers might not notice the migration and will get `NoMethodError`, `UnknownAttributeError`, or other exceptions raised.

I've seen this behavior confuse beginner rails developers and seasoned devs. Usually they are capable of figuring out they need to run migrations, but the error is misleading, frustrating, and potentially time consuming.

## Solution

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.

Setting `config.active_record.migration` to `:app_start` will raise an error when the app is initialized if there are pending migrations. Setting to `:app_start` is defaulted in test mode.

This check is turned off in production.

The check can be disabled by setting `config.active_record.skip_migration_errors = true`. This is useful when the error would conflict with fixing the problem such as having an error on `:app_start` and trying to run `rake db:migrate` which starts the app. A convenience rake task is also included to be run before `:environment` is loaded on crucial tasks.

## Notes

This PR picks up where #4165 left off.

Screenshot of `:page_load` error: http://cl.ly/0Q0t3z1s3R2Z142p2o1B

Screenshot of `:app_start` error: http://cl.ly/1k0c1i2O0v122T3P2Y1n

Railties Tests are green: https://gist.github.com/2885779

AR Tests are green: https://gist.github.com/2885796

cc/ @jonleighton