Method: Webhookdb::Replicator::Base#indices

Defined in:
lib/webhookdb/replicator/base.rb

#indices(table) ⇒ Array<Webhookdb::DBAdapter::Index>

Returns:



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/webhookdb/replicator/base.rb', line 484

def indices(table)
  dba_columns = [self.primary_key_column, self.remote_key_column]
  dba_columns.concat(self.storable_columns)
  dba_cols_by_name = dba_columns.index_by(&:name)

  result = []
  dba_columns.select(&:index?).each do |c|
    targets = [c]
    idx_name = self.index_name(targets)
    result << Webhookdb::DBAdapter::Index.new(name: idx_name.to_sym, table:, targets:, where: c.index_where)
  end
  self._extra_index_specs.each do |spec|
    targets = spec.columns.map { |n| dba_cols_by_name.fetch(n) }
    idx_name = self.index_name(targets)
    result << Webhookdb::DBAdapter::Index.new(name: idx_name.to_sym, table:, targets:, where: spec.where)
  end
  return result
end