instance method fetch_indexes

Ruby on Rails edge

Since edge Private — implementation detail, not part of the public API

Signature

fetch_indexes(tables)

No documentation comment.

Parameters

tables req
Source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb, line 947
          def fetch_indexes(tables)
            fetch_by_schema(tables) do |schema, group|
              # t.relname comes last so #build_indexes can keep reading columns by position.
              rows = query_rows(<<~SQL)
                SELECT distinct i.relname, d.indisunique, d.indkey, pg_get_indexdef(d.indexrelid),
                                pg_catalog.obj_description(i.oid, 'pg_class') AS comment, d.indisvalid,
                                ARRAY(
                                  SELECT pg_get_indexdef(d.indexrelid, k + 1, true)
                                  FROM generate_subscripts(d.indkey, 1) AS k
                                  ORDER BY k
                                ) AS columns, t.relname
                FROM pg_class t
                INNER JOIN pg_index d ON t.oid = d.indrelid
                INNER JOIN pg_class i ON d.indexrelid = i.oid
                LEFT JOIN pg_namespace n ON n.oid = t.relnamespace
                WHERE i.relkind IN ('i', 'I')
                  AND d.indisprimary = 'f'
                  AND n.nspname = #{schema} AND t.relname IN (#{quoted_table_names(group)})
                ORDER BY i.relname
              SQL
              by_name = rows.group_by(&:last)

              group.index_with { |table| build_indexes(table, rows_for(by_name, table)) }
            end
          end

Defined in activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb line 947 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close