Class: RuboCop::Cop::Migration::RenameColumn
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Migration::RenameColumn
- Defined in:
- lib/rubocop/cop/migration/rename_column.rb
Overview
Avoid renaming columns that are in use.
It will cause errors in your application. A safer approach is to:
-
Create a new column
-
Write to both columns
-
Backfill data from the old column to the new column
-
Move reads from the old column to the new column
-
Stop writing to the old column
-
Drop the old column
Constant Summary collapse
- MSG =
'Avoid renaming columns that are in use.'- RESTRICT_ON_SEND =
i[ rename_column ].freeze
Instance Method Summary collapse
- #on_send(node) ⇒ void (also: #on_csend)
Instance Method Details
#on_send(node) ⇒ void Also known as: on_csend
This method returns an undefined value.
54 55 56 57 58 |
# File 'lib/rubocop/cop/migration/rename_column.rb', line 54 def on_send(node) return unless bad?(node) add_offense(node) end |