123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::ConnectionAdapters::ColumnMethods

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

Class Method Summary

::ActiveSupport::Concern - Extended

class_methods

Define class methods from given block.

included

Evaluate given block in context of base class, so that you can write class macros here.

prepended

Evaluate given block in context of base class, so that you can write class macros here.

Instance Method Summary

DSL Calls

included

[ GitHub ]


256
257
258
259
260
261
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 256

included do
  define_column_methods :bigint, :binary, :boolean, :date, :datetime, :decimal,
    :float, :integer, :json, :string, :text, :time, :timestamp, :virtual

  alias :numeric :decimal
end

Instance Method Details

#column(name, type, **options)

Appends a column or columns of a specified type.

t.string(:goat)
t.string(:goat, :sheep)

See TableDefinition#column

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 256

RDoc directive :method: column

#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.

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 241

def primary_key(name, type = :primary_key, **options)
  column(name, type, **options.merge(primary_key: true))
end