-
Notifications
You must be signed in to change notification settings - Fork 125
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
Migrate with cleared schema cache #401
Migrate with cleared schema cache #401
Conversation
365cbd6
to
456ee9e
Compare
yay it failed even though it didn't locally... looking... |
2e7af20
to
0a7e9ec
Compare
Ok, finally, fixed. The complexities with resetting column information in migration tests are still needed around each example because the migration stub gets reused in tests. I verified this works in migration specs and also with a test database that was raising the |
@Fryguy please review |
0a7e9ec
to
7fd57b0
Compare
Wrap each migration with a clearing of the schema cache to ensure the schema/column information is not cached. Since migrations very often change schema, these caches are likely to get busted. Migration authors don't realize they may need to reset the column information whenever they change the schema so it's often overlooked. It often doesn't cause a problem, until it does: 20180424141617_azure_backslash_to_forward_slash.rb - loads stub: class OrchestrationStack < ActiveRecord::Base - orchestration_stacks table column information is cached by table name 20181010134649_add_evm_owner_to_orchestration_stacks.rb - adds evm_owner, miq_group, tenant references (_id columns) 20181016140921_migrate_orch_stacks_to_have_ownership_concept.rb - loads stub: class OrchestrationStack < ActiveRecord::Base - uses cached table column information - Blows up trying to store bigint into what rails thinks is an integer column: stack.update_attributes(:evm_owner_id => user.id, :tenant_id => user.current_tenant.id, :miq_group_id => user.current_group.id) '34000000000001 is out of range for ActiveModel::Type::Integer with limit 4 bytes' This commit eliminates the need to reset column information for any of these migrations as we clear the schema cache for all tables before each migration. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1732808
7fd57b0
to
cdfce63
Compare
Checked commit jrafanie@cdfce63 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Note, I've retested the problematic database down and up using the "reset cache only before migrate" since I previously tested "before and after migrate". |
Migrate with cleared schema cache (cherry picked from commit 44bbd51) https://bugzilla.redhat.com/show_bug.cgi?id=1732808
Ivanchuk backport details:
|
Alternative to #398
Wrap each migration with a clearing of the schema cache to ensure the
schema/column information is not cached. Since migrations very often
change schema, these caches are likely to get busted.
Migration authors don't realize they may need to reset the column
information whenever they change the schema so it's often overlooked.
It often doesn't cause a problem, until it does:
This commit eliminates the need to reset column information for any of
these migrations as we clear the schema cache for all tables before each
migration.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1732808