-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix 6.1 change_table setting datetime precision [7-0-stable] #49011
Conversation
Hmm, let me fix the test failures |
Okay, I believe I've found the issue. |
Previously, most version of the Migration class would call `super` in compatible_table_definition to ensure that they append all of the later Migration verion's TableDefinition modules. However, the latest Migration class did not do this and prepended its own TableDefinition because there was no super method for it to call. This led to an issue where Action Text migrations started failing on Rails main, after migration option validation was added in e6da3eb. The new functionality was not supposed to affect V6_0 Migrations, but it was because both V6_1 and V7_0 were not calling super. This commit fixes the issue by correctly calling super in both classes. It also adds a compatible_table_definition method to Current that returns the value passed in so that all of the versioned Migrations can always return super.
68a9c36
to
e571ec3
Compare
This is similar to a [previous commit][1] which ensures that versioned migrations always call `super` in `compatible_table_definition`. In this case, these methods are being pulled up to `Current` so that all subclasses will use a `TableDefinition` class and future developers do not have to remember to add all of these methods to new versioned classes when a new one is created. [1]: 16f8bd7
e571ec3
to
54b3ef4
Compare
|
||
class BaseCompatibilityTest < ActiveRecord::TestCase | ||
attr_reader :connection | ||
self.use_transactional_tests = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL tests failed without transactional_tests
disabled on 7-0-stable
but they passed on main
. From what I can tell, this is due to SchemaMigration
no longer inheriting from ActiveRecord::Base
: 436277d
Should we disable transactional_tests
on main
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to.
While working on rails#48969, I found that some of the Compatibility test cases were not working correctly. The tests removed in this commit were never running the `change_table` migration and so were not actually testing that `change_table` works correctly. The issue is that the two migrations created in these tests both have `nil` versions, and so the Migrator only runs the first one. This commit refactors the tests so that its easier to test the behavior of each Migration class version (and I think the rest of the tests should be updated to use this strategy as well). Additionally, since the tests are fixed it exposed that `t.change` in a `change_table` is not behaving as expected so that is fixed as well. (manually backported to 7-0-stable because it did not apply cleanly)
54b3ef4
to
6155ad6
Compare
This ended up requiring more backports to get fully working:
#46241 - add
compatible_table_definition
toCurrent
#47648 - ensure empty options aren't logged
#49012 - move
*_table
methods up toCurrent
to prevent subclasses not implementing themMotivation / Background
While working on #48969, I found that some of the Compatibility test cases were not working correctly. The tests removed in this commit were never running the
change_table
migration and so were not actually testing thatchange_table
works correctly. The issue is that the two migrations created in these tests both havenil
versions, and so the Migrator only runs the first one.Detail
This commit refactors the tests so that its easier to test the behavior of each Migration class version (and I think the rest of the tests should be updated to use this strategy as well). Additionally, since the tests are fixed it exposed that
t.change
in achange_table
is not behaving as expected so that is fixed as well.Additional information
Ref #48974
(manually backported to 7-0-stable because it did not apply cleanly)
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]