Class | ActiveRecord::ConnectionAdapters::TableDefinition |
In: |
lib/active_record/connection_adapters/abstract/schema_definitions.rb
|
Parent: | Object |
Represents a SQL table in an abstract way. Columns are stored as ColumnDefinition in the columns attribute.
columns | [RW] |
Instantiates a new column for the table. The type parameter must be one of the following values: :primary_key, :string, :text, :integer, :float, :datetime, :timestamp, :time, :date, :binary, :boolean.
Available options are (none of these exists by default):
This method returns self.
# Assuming def is an instance of TableDefinition def.column(:granted, :boolean) #=> granted BOOLEAN def.column(:picture, :binary, :limit => 2.megabytes) #=> picture BLOB(2097152) def.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false) #=> sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL
Appends a primary key definition to the table definition. Can be called multiple times, but this is probably not a good idea.