Method: Sequel::Postgres::DatabaseMethods#indexes
- Defined in:
- lib/sequel/adapters/shared/postgres.rb
#indexes(table, opts = OPTS) ⇒ Object
Use the pg_* system tables to determine indexes on a table. Options:
- :include_partial
-
Set to true to include partial indexes
- :invalid
-
Set to true or :only to only return invalid indexes. Set to :include to also return both valid and invalid indexes. When not set or other value given, does not return invalid indexes.
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 678 def indexes(table, opts=OPTS) m = output_identifier_meth cond = {Sequel[:tab][:oid]=>regclass_oid(table, opts)} cond[:indpred] = nil unless opts[:include_partial] case opts[:invalid] when true, :only cond[:indisvalid] = false when :include # nothing else cond[:indisvalid] = true end indexes = {} _indexes_ds.where_each(cond) do |r| i = indexes[m.call(r[:name])] ||= {:columns=>[], :unique=>r[:unique], :deferrable=>r[:deferrable]} i[:columns] << m.call(r[:column]) end indexes end |