index option added for change_table migrations#23593
Conversation
|
(@rails-bot has picked a reviewer for you, use r? to override) |
|
@rafaelfranca you were the one with objection on this feature, are you still against of this? If not, I'll resolve the conflicts and then we can merge. I remember too many times I tried to add columns to tables with indices by forgetting that rails does not support this feature and it's really annoying. WDYT? |
|
If there's still pushback, you could refactor this PR to raise an error if someone tries to add an index inline within a Either way, there's something that needs to be added because its really unclear that this is currently unsupported. |
|
I'm fine with it in column. Can you rebase? |
In case if we want to add a column into the existing table
with index on it, we have to add column and index in two
seperate lines.
With this feature we don't need to write an extra line to
add index for column. We can just use `index` option.
Old behaviour in action:
```
change_table(:languages) do |t|
t.string :country_code
t.index: :country_code
end
```
New behaviour in action:
```
change_table(:languages) do |t|
t.string :country_code, index: true
end
```
Exactly same behaviour is already exist for `create_table` migrations.
7ba022b to
5e4c22d
Compare
|
@rafaelfranca done. |
index option added for change_table migrations
index option added for change_table migrations rails/rails#23593
In case if we want to add a column into the existing table
with index on it, we have to add column and index in two
seperate lines.
With this feature we don't need to write an extra line to
add index for column. We can just use
indexoption.Old behaviour in action:
New behaviour in action:
Exactly same behaviour is already exist for
create_tablemigrations.There was a pull request created by me which was about adding
indexoption foradd_columnhelper. I understand the concern behind closing it and it make sense but this addition is different from it. So I'm not pushing same idea again.