instance method primary_key

Ruby on Rails 8.0.4

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

primary_key(name, type = :primary_key, **options)

Appends a primary key definition to the table definition. Can be called multiple times, but this is probably not a good idea.

Parameters

name req
type opt = :primary_key
options keyrest
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 308
      def primary_key(name, type = :primary_key, **options)
        column(name, type, **options.merge(primary_key: true))
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 308 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::ColumnMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close