Class: Gitlab::Database::ObsoleteIgnoredColumns

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/database/obsolete_ignored_columns.rb

Overview

Checks which ‘ignored_columns` definitions can be safely removed by scanning the current schema for all `ApplicationRecord` descendants.

Instance Method Summary collapse

Constructor Details

#initialize(base = ApplicationRecord) ⇒ ObsoleteIgnoredColumns

Returns a new instance of ObsoleteIgnoredColumns.



8
9
10
# File 'lib/gitlab/database/obsolete_ignored_columns.rb', line 8

def initialize(base = ApplicationRecord)
  @base = base
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/database/obsolete_ignored_columns.rb', line 12

def execute
  @base.descendants.filter_map do |klass|
    next if klass.abstract_class?

    safe_to_remove = ignored_columns_safe_to_remove_for(klass)
    next if safe_to_remove.empty?

    [klass.name, safe_to_remove]
  end.compact.sort_by(&:first)
end