A very basic app illustrating an error on migrating a DB due to the order of operations in Rails 3.2.12.
Reproduction steps:
$ bundle exec rake db:drop && bundle exec rake db:create && bundle exec rake db:migrate rake aborted! Could not find table 'users'
I believe this was introduced here: github.com/rails/rails/commit/921a296a3390192a71abeec6d9a035cc6d1865c8#L3R54
My understanding of the issue is:
$ bundle exec rake db:migrate => loads environment => loads observers => loads UserObserver => loads User => evaluates scope :id_0, where(:id => 0) => executes engine.connection.schema_cache in ActiveRecord::PredicateBuilder => schema doesn't exist since we haven't run migrations yet => Could not find table 'users'