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

Add change_column_null from BulkChangeTable #1280

Closed
fkmy opened this issue May 17, 2024 · 0 comments
Closed

Add change_column_null from BulkChangeTable #1280

fkmy opened this issue May 17, 2024 · 0 comments

Comments

@fkmy
Copy link

fkmy commented May 17, 2024

Is your feature request related to a problem? Please describe.

There is a cop BulkChangeTable that checks for combinable alter queries when changing multiple columns.

Sorry if I am mistaken, but I believe that in the past there was no corresponding change_table method for the change_column_null method, and that is how it was removed. #48

But then the change_null method in change_table is added, which corresponds to the change_column_null method.
rails/rails@972d18e

Describe the solution you'd like

I want to check for combinable alter queries and warn if NULL constraint changes are made to multiple columns.

# bad
def change
  change_column_null :users, :name, false
  change_column_null :users, :nickname, false
end

# good
def change
  change_table :users, bulk: true do |t|
    t.change_null :name, false
    t.change_null :nickname, false
  end
end

Describe alternatives you've considered

Since there is a method change_null in change_table corresponding to the change_column_null method, how about adding a change check for null constraints to BulkChangeTable?

Additional context

Nothing specifically.

ccutrer added a commit to ccutrer/rubocop-rails that referenced this issue May 22, 2024
change_column_null is only combinable with PostgreSQL, and is only
available as change_null within a change_table block since Rails 6.1,
so target to only those cases.
ccutrer added a commit to ccutrer/rubocop-rails that referenced this issue May 22, 2024
change_column_null is only combinable with PostgreSQL, and is only
available as change_null within a change_table block since Rails 6.1,
so target to only those cases.
@koic koic closed this as completed in e71b373 Jun 5, 2024
koic added a commit that referenced this issue Jun 5, 2024
…change-table

[Fix #1280] Handle change_column_null for BulkChangeTable
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

No branches or pull requests

1 participant