method
column
v1.1.6 -
Show latest stable
-
0 notes -
Class: ActiveRecord::ConnectionAdapters::TableDefinition
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (27)
- 2.0.3 (27)
- 2.1.0 (0)
- 2.2.1 (6)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-3)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (3)
- 4.1.8 (0)
- 4.2.1 (-4)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (-38)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
column(name, type, options = {})
public
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):
- :limit: Requests a maximum column length (:string, :text, :binary or :integer columns only)
- :default: The column’s default value. You cannot explicitely set the default value to NULL. Simply leave off this option if you want a NULL default value.
- :null: Allows or disallows NULL values in the column. This option could have been named :null_allowed.
This method returns self.
Examples
# 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