-
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
Pare back default index
option for the migration generator
#23179
Pare back default index
option for the migration generator
#23179
Conversation
I believe, this will need a CHANGELOG. |
Yeah, I will add it also looking at failures from railties. |
454ffe9
to
71b4c05
Compare
references
will add index by default now, user can index: false
to opt outindex
option for the migration generator
71b4c05
to
bc82a72
Compare
end | ||
end | ||
end | ||
|
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 removed these tests. Should I add them for checking index_is_not_added_for_references_association
?
bc82a72
to
c3fb781
Compare
Changelog added and build is green now. |
r? @matthewd IIRC you were involved in the versioned migration changes. That's landed, correct? I'm not familiar enough with what's happening there to know if this only affects new migrations or if it affects old as well. If we haven't finished versioned migrations, and this is changing the behavior of existing migrations, I feel quite strongly that this should wait until 5.1 |
c3fb781
to
7a028be
Compare
@sgrif Yup, we have to update https://github.com/rails/rails/blob/master/activerecord/lib/active_record/migration/compatibility.rb to not create index by default unless specified for legacy migrations. I will work on it. |
@prathamesh-sonpatki matthewd@f87c457 may be helpful... I had the Actual Change, but hadn't gone back and chased it through the tests |
Thanks, I will check it. |
cb871a9
to
9f85bb5
Compare
- Using `references` or `belongs_to` in migrations will always add index for the referenced column by default, without adding `index:true` option to generated migration file. - Users can opt out of this by passing `index: false`. - Legacy migrations won't be affected by this change. They will continue to run as they were before. - Fixes rails#18146
9f85bb5
to
909818b
Compare
@matthewd Please review, took care of legacy migrations with your commit and added a test case for it. |
…index-option-to-references Pare back default `index` option for the migration generator
❤️ |
- Followup of rails#23179
…i skip] - Followup of rails#23179.
The default value of `index` is true from Rails 5.0. cf. rails/rails#23179
The default value of `index` is true from Rails 5.0. cf. rails/rails#23179
The default value of `index` is true since Rails 5.0. cf. rails/rails#23179
As of rails/rails#23179, using `belongs_to` or `references` automatically adds an index. public-activity#64 previously manually added the indexes, but they are no longer needed.
references
orbelongs_to
in migrations will always add indexfor the referenced column by default, without adding
index:true
optionto generated migration file.
index: false
.r? @sgrif cc @rafaelfranca