summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 21:09:17 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 21:09:17 +0000
commitc77fda905a8619b756163c10a75171dc9cfe7084 (patch)
treeffa93b37bfe4b99ba0b8584c7a0bd1a4cd19772a /rubocop
parente0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (diff)
downloadgitlab-ce-c77fda905a8619b756163c10a75171dc9cfe7084.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/migration/add_column_with_default.rb44
1 files changed, 38 insertions, 6 deletions
diff --git a/rubocop/cop/migration/add_column_with_default.rb b/rubocop/cop/migration/add_column_with_default.rb
index d9f8fe62a86..68e53b17f19 100644
--- a/rubocop/cop/migration/add_column_with_default.rb
+++ b/rubocop/cop/migration/add_column_with_default.rb
@@ -10,7 +10,37 @@ module RuboCop
class AddColumnWithDefault < RuboCop::Cop::Cop
include MigrationHelpers
- WHITELISTED_TABLES = [:application_settings].freeze
+ # Tables >= 10 GB on GitLab.com as of 02/2020
+ BLACKLISTED_TABLES = %i[
+ audit_events
+ ci_build_trace_sections
+ ci_builds
+ ci_builds_metadata
+ ci_job_artifacts
+ ci_pipeline_variables
+ ci_pipelines
+ ci_stages
+ deployments
+ events
+ issues
+ merge_request_diff_commits
+ merge_request_diff_files
+ merge_request_diffs
+ merge_request_metrics
+ merge_requests
+ note_diff_files
+ notes
+ project_authorizations
+ projects
+ push_event_payloads
+ resource_label_events
+ sent_notifications
+ system_note_metadata
+ taggings
+ todos
+ users
+ web_hook_logs
+ ].freeze
MSG = '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, ' \
'see https://gitlab.com/gitlab-org/gitlab/issues/38060'.freeze
@@ -23,21 +53,23 @@ module RuboCop
return unless in_migration?(node)
add_column_with_default?(node) do |table, options|
- break if table_whitelisted?(table) || nulls_allowed?(options)
-
- add_offense(node, location: :selector)
+ add_offense(node, location: :selector) if offensive?(table, options)
end
end
private
+ def offensive?(table, options)
+ table_blacklisted?(table) && !nulls_allowed?(options)
+ end
+
def nulls_allowed?(options)
options.find { |opt| opt.key.value == :allow_null && opt.value.true_type? }
end
- def table_whitelisted?(symbol)
+ def table_blacklisted?(symbol)
symbol && symbol.type == :sym &&
- WHITELISTED_TABLES.include?(symbol.children[0])
+ BLACKLISTED_TABLES.include?(symbol.children[0])
end
end
end