Class: RuboCop::Cop::Migration::ChangeColumnNull
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Migration::ChangeColumnNull
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/migration/change_column_null.rb
Overview
Avoid simply setting ‘NOT NULL` constraint on an existing column in PostgreSQL.
It blocks reads and writes while every row is checked. In PostgreSQL 12+, you can safely set ‘NOT NULL` constraint if corresponding check constraint exists.
Constant Summary collapse
- MSG =
'Avoid simply setting `NOT NULL` constraint on an existing column in PostgreSQL.'- RESTRICT_ON_SEND =
%i[ change_column_null change_null ].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.
48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/migration/change_column_null.rb', line 48 def on_send(node) return if called_with_validate_constraint?(node) add_offense(node) do |corrector| autocorrect(corrector, node) end end |