method

primary_keys

Importance_0
v8.1.1 - Show latest stable - 0 notes - Class: SchemaStatements
primary_keys(table_name) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb, line 435
        def primary_keys(table_name) # :nodoc:
          query_values(<<~SQL, "SCHEMA")
            SELECT a.attname
            FROM pg_index i
            JOIN pg_attribute a
              ON a.attrelid = i.indrelid
              AND a.attnum = ANY(i.indkey)
            WHERE i.indrelid = #{quote(quote_table_name(table_name))}::regclass
              AND i.indisprimary
            ORDER BY array_position(i.indkey, a.attnum)
          SQL
        end
Register or log in to add new notes.