diff --git a/changelog/change_disable_rails_unused_ignored_columns.md b/changelog/change_disable_rails_unused_ignored_columns.md new file mode 100644 index 0000000000..cf95414e2e --- /dev/null +++ b/changelog/change_disable_rails_unused_ignored_columns.md @@ -0,0 +1 @@ +* [#1249](https://github.com/rubocop/rubocop-rails/issues/1249): Disable `Rails/UnusedIgnoredColumns` by default. ([@earlopain][]) diff --git a/config/default.yml b/config/default.yml index 37291c46bf..024577de79 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1163,8 +1163,9 @@ Rails/UnknownEnv: Rails/UnusedIgnoredColumns: Description: 'Remove a column that does not exist from `ignored_columns`.' - Enabled: pending + Enabled: false VersionAdded: '2.11' + VersionChanged: <> Include: - app/models/**/*.rb diff --git a/lib/rubocop/cop/rails/unused_ignored_columns.rb b/lib/rubocop/cop/rails/unused_ignored_columns.rb index c099b97a4d..a7551e87da 100644 --- a/lib/rubocop/cop/rails/unused_ignored_columns.rb +++ b/lib/rubocop/cop/rails/unused_ignored_columns.rb @@ -7,6 +7,12 @@ module Rails # `ignored_columns` is necessary to drop a column from RDBMS, but you don't need it after the migration # to drop the column. You avoid forgetting to remove `ignored_columns` by this cop. # + # IMPORTANT: This cop can't be used to effectively check for unused columns because the development + # and production schema can be out of sync until the migration has been run on production. As such, + # this cop can cause `ignored_columns` to be removed even though the production schema still contains + # the column, which can lead to downtime when the migration is actually executed. Only enable this cop + # if you know your migrations will be run before any of your Rails applications boot with the modified code. + # # @example # # bad # class User < ApplicationRecord