diff options
Diffstat (limited to 'rubocop/migration_helpers.rb')
-rw-r--r-- | rubocop/migration_helpers.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index 355450bbf57..c26ba88f269 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -1,14 +1,13 @@ module RuboCop # Module containing helper methods for writing migration cops. module MigrationHelpers - WHITELISTED_TABLES = %i[ + # Tables with permanently small number of records + SMALL_TABLES = %i[ application_settings plan_limits ].freeze - # Blacklisted tables due to: - # - number of columns (> 50 on GitLab.com as of 03/2020) - # - number of records + # Tables with large number of columns (> 50 on GitLab.com as of 03/2020) WIDE_TABLES = %i[ users projects @@ -21,6 +20,10 @@ module RuboCop TABLE_METHODS = %i(create_table create_table_if_not_exists change_table).freeze + def high_traffic_tables + @high_traffic_tables ||= rubocop_migrations_config.dig('Migration/UpdateLargeTable', 'DeniedTables') + end + # Returns true if the given node originated from the db/migrate directory. def in_migration?(node) in_deployment_migration?(node) || in_post_deployment_migration?(node) @@ -53,5 +56,13 @@ module RuboCop def dirname(node) File.dirname(node.location.expression.source_buffer.name) end + + def rubocop_migrations_config + @rubocop_migrations_config ||= YAML.load_file(File.join(rubocop_path, 'rubocop-migrations.yml')) + end + + def rubocop_path + File.expand_path(__dir__) + end end end |