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

disable BulkChangeTable cop #55

Merged

Conversation

Cohen-Carlisle
Copy link
Contributor

@Cohen-Carlisle Cohen-Carlisle commented Jul 29, 2024

While this cop can offer faster migrations for very large databases, it also leads to more complex, more error-prone, and less understandable migrations for smaller (most) projects. For example, change_table with bulk: true does not properly reverse migrations that add columns and indices on those columns. The columns are dropped first and it then attempts to drop the indices, which were automatically dropped when the columns were dropped, resulting in an error. Furthermore, this situation is harder to debug with bulk: true as the standard rails migration logging just logs change_table(:bulk=>true), not the individual columns and indices being added/dropped. Finally, it only alerts on a subset of alter table statements, allowing some to be outside a change_table but forcing others to be inside the change_table block.

While this cop can offer faster migrations for very large databases, it
also leads to more complex, more error-prone, and less understandable
migrations for smaller (most) projects. For example, `change_table` with
`bulk: true` does not properly reverse migrations that add columns and
indices on those columns. The columns are dropped first and it then
attempts to drop the indices, which were automatically dropped when the
columns were dropped, resulting in an error. Furthermore, this situation
is harder to debug with `bulk: true` as the standard rails migration
logging just logs `change_table(:bulk=>true)`, not the individual columns
and indices being added/dropped. Finally, it only alerts on a subset of
alter table statements, allowing some to be outside a `change_table` but
forcing others to be inside the `change_table` block.
@searls
Copy link
Contributor

searls commented Jul 29, 2024

That does indeed seem bad!

@searls searls merged commit 3570b7a into standardrb:main Jul 29, 2024
4 checks passed
@Cohen-Carlisle
Copy link
Contributor Author

Wow, that was quick! I spotted a typo in my commit message and amended it (hence the force push). I just barely got it in 😉 Thanks for the fast response and merge!

@Cohen-Carlisle Cohen-Carlisle deleted the disable-bulk-change-table-cop branch July 29, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants