Instantiates a newcolumn
for the table. The type parameter is normally one of the
migrations native
types, which is one of the following: :primary_key,:string,:text,:integer,:float,:decimal,:datetime,:time,:date,:binary,:boolean.

You may use a type not in this list as long as it is supported by your
database (for example, “polygon” in MySQL), but this will not be
database agnostic and should usually be avoided.

Available options are (none of these exists by default):

:limit - Requests a maximum column
length. This is number of characters for :string and
:textcolumns
and number of bytes for :binary and :integercolumns.

:default - The column’s default value. Use nil for NULL.

:null - Allows or disallows NULL values in the column.
This option could have been named :null_allowed.

Note: The precision is the total number of significant digits and the scale
is the number of digits that can be stored following the decimal point. For
example, the number 123.45 has a precision of 5 and a scale of 2. A decimal
with a precision of 5 and a scale of 2 can range from -999.99 to 999.99.

Please be aware of different RDBMS implementations behavior with
:decimal columns:

The SQL standard says the default scale should be 0, :scale <=
:precision, and makes no comments about the requirements of
:precision.

Short-hand examples

Instead of calling column
directly, you can also work with the short-hand definitions for the default
types. They use the type as the method name instead of as a parameter and
allow for multiple columns
to be defined in a single statement.

There’s a short-hand method for each of the type values declared at the
top. And then there’s TableDefinition#timestamps that’ll add
created_at and updated_at as datetimes.

TableDefinition#references will add an appropriately-named _id column, plus
a corresponding _type column
if the :polymorphic option is supplied. If :polymorphic
is a hash of options, these will be used when creating the _typecolumn.
The :index
option will also create an index, similar to calling add_index. So
what can be written like this: