Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
reset_column_information not called after each migration #6939
I have made a demo app (https://github.com/lulalala/migration-bug) to demonstrate the issue. The readme shows the step to prepare the database, and reproduce the error.
Basically I have a migration B which adds a new column, and a migration C to fill that column. It works okay if those B & C are to run in one go. However I have a migration A which basically does some lookup, and when running A, B and C together, migration C won't update column at all.
If I explicitly call
I am using Rails 3.2.6 and Ruby 1.9.3
I believe this is the expected behavior.
Using models in your migration is considered iffy, and as such I'd expect that you're expected to jump through a hoop or two in order to do so.
The Rails Guide has a section about using models in your migration:
The example they use has a single migration with both the structural change and the data change in the same migration, and they clearly expect the developer to call
If I'm reading this correctly, then column information is read in when the connection to the database is established.
All the pending migrations are run using the same connection pool, and therefore column information would not be expected to be refreshed until the next time you connect (e.g. the next time you run
I believe that when multiple migrations are run, it should behave the same if I run them separately or run them together.
And the API said
I take the meaning of immediate as being "within the same migration". And in my case I am using the model before the migration, and in different migration files. Which is completely different to what the API specify users to use reset_column_information.
Technically, we could run