fraser / migration-error-3.2.12

Basic app illustrating error on migrations in Rails 3.2.12 due to interaction with observers & scopes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migration Error

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'

About

Basic app illustrating error on migrations in Rails 3.2.12 due to interaction with observers & scopes


Languages

Language:Ruby 96.1%Language:JavaScript 3.9%