method

primary_keys

rails latest stable - Class: ActiveRecord::ConnectionAdapters

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v5.2.3) is shown here.

primary_keys(table_name)
public

No documentation available.

# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 478
      def primary_keys(table_name) # :nodoc:
        raise ArgumentError unless table_name.present?

        scope = quoted_scope(table_name)

        query_values(          SELECT column_name          FROM information_schema.key_column_usage          WHERE constraint_name = 'PRIMARY'            AND table_schema = #{scope[:schema]}            AND table_name = #{scope[:name]}          ORDER BY ordinal_position.strip_heredoc, "SCHEMA")
      end