Skip to content
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

Merged
merged 1 commit into from Mar 24, 2016

Conversation

chrisarcand
Copy link
Contributor

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)

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).
@rails-bot
Copy link

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.

@chrisarcand
Copy link
Contributor Author

r? @tenderlove

@arthurnn
Copy link
Member

Thanks

@chrisarcand chrisarcand deleted the reload-ar-cache-after-migrations branch March 24, 2016 18:15
@chrisarcand
Copy link
Contributor Author

🙇

@itsmeduncan
Copy link
Contributor

itsmeduncan commented May 11, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants