跳至內容 跳至搜尋
方法
C
P

實例公開方法

column(name, type, **options)

附加指定類型的一或多個欄位。

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

請參閱 TableDefinition#column

# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 319
included do
  define_column_methods :bigint, :binary, :boolean, :date, :datetime, :decimal,
    :float, :integer, :json, :string, :text, :time, :timestamp, :virtual

  alias :blob :binary
  alias :numeric :decimal
end

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

附加主索引定義至資料表定義。可反覆呼叫,但並非良策。

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