class ActiveRecord::ConnectionAdapters::Table

def index_exists?(column_name, **options)

See {connection.index_exists?}[rdoc-ref:SchemaStatements#index_exists?]

end
t.index(:branch_id)
unless t.index_exists?(:branch_id)

Checks to see if an index exists.
def index_exists?(column_name, **options)
  @base.index_exists?(name, column_name, **options)
end