New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make 'migrate' clear the schema cache afterward #24305
Make 'migrate' clear the schema cache afterward #24305
Conversation
Without clearing the caches afterward, removals done in migrations would not be reflected in a separate task in the same process. That is, given a table with a migration to remove a column, the schema cache would still reflect that a table has that in something such as the 'db:seed' task: `rake db:migrate db:seed` (A common thing to do in a script for a project ala `bin/setup`) vs `rake db:migrate && rake db:seed` (Two processes) The first would not reflect that the column was removed. The second would (cache reset).
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @tenderlove |
Thanks |
🙇 |
Forgot to add, sigh. Closes rails#24273
We just ran into this problem on 4.2.6. Is this going to be back-ported to 4.2.7 or 4.3.x? Edit: #24978 |
Changes the
migrate
task to clear ActiveRecord caches afterward.Without clearing the caches, removals done in migrations would not be reflected in a separate task in the same process. That is, given a table with a migration to remove a column, the schema cache would still reflect that a table has that in something such as the 'db:seed' task:
rake db:migrate db:seed
(A common thing to do in a script for a project ala
bin/setup
)vs
rake db:migrate && rake db:seed
(Two processes)
The first would not reflect that the column was removed. The second would (cache reset)