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

Removes duplicate indexes from activities migration template #379

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamkiczula
Copy link

I noticed in my app that I had duplicate indexes. As of rails/rails#23179, using belongs_to or references automatically adds an index. #64 previously manually added the indexes, but they are no longer needed.

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.
@ur5us ur5us self-assigned this Jun 14, 2023
@bhtabor
Copy link

bhtabor commented Feb 1, 2024

Thank you @adamkiczula! I think this should be merged to avoid unnecessary redundant indexes.

@ur5us
Copy link
Collaborator

ur5us commented Feb 8, 2024

Thanks @adamkiczula. Will take a look in the next few days.

@ur5us ur5us added the bug label Feb 8, 2024
@adamkiczula
Copy link
Author

Thanks, I learned recently that with this change Rails actually defaults to type, id for the index, which I believe is less optimal in some cases (but more optimal if you're querying just by type). Just pointing out that the two aren't equivalent, an alternative would be to disable Rails' default index in the template. Or maybe just pick one, but add a comment informing the user explaining and they can modify based on their use case?

@bhtabor
Copy link

bhtabor commented Mar 8, 2024

Rails actually defaults to type, id for the index, which I believe is less optimal in some cases (but more optimal if you're querying just by type).

Good point. I think querying just by type is much more common than just by id though. Rails default is probably enough here.

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

Successfully merging this pull request may close these issues.

None yet

3 participants