Fixes Rubocop Migration/AddLimitToTextColumns failures
What does this MR do and why?
Solves: #388821 (closed)
It circuit-breaks array_column?(node)
method when the node is not of the type RuboCop::AST::SymbolNode
.
This rule is intend to work when adding a new array column in post-migrations.
Ex:
class AddNewArrayColumn < Gitlab::Database::Migration[2.1]
def up
add_column :my_column, :numbers, :integer, array: true, default: []
end
def down
# no-op
end
end
bin/bundle exec rubocop db/post_migrate/add_new_array_column.rb
C: Migration/SchemaAdditionMethodsNoPost: This method may not be used in post migrations. Please see documentation here: https://docs.gitlab.com/ee/development/migration_style_guide.html#choose-an-appropriate-migration-type
How to set up and validate locally
- generate a new post-migration file:
rails g post_deployment_migration TestRubocopMigration
- change the migration's body to include:
column = :partition_id define_batchable_model(:ci_build).where(column => 100)
- execute rubocop
bin/bundle exec rubocop db/post_migrate/migrationnumber_test_rubocop_migration.rb
- In
master
this should raise and error - In
388821-rubocop-migration-addlimittotextcolumns-failures
branch, this should not raise any error
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #388821 (closed)
Edited by Leonardo da Rosa