Class: RuboCop::Cop::Spbtv::Postgres::ChangeColumn
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Spbtv::Postgres::ChangeColumn
- Defined in:
- lib/rubocop/cop/spbtv/postgres/change_column.rb
Overview
Do not change column.
It is not strictly unsafe for all changes. Changing the length of a varchar, for example, does not lock a table. But if column type change requires a rewrite or not depends on the datatype, in this case this operation requires updating each row of the table. As workaround, you can add a new column with needed type, change the code to write to both columns, and backfill the new column.
Constant Summary collapse
- MSG =
'Do not change column.'.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/rubocop/cop/spbtv/postgres/change_column.rb', line 24 def on_send(node) _, _, * = *node if node.command?(:change_column) add_offense(node, :selector, MSG) end end |