ActiveRecord Migrations
suggest changeVersions
[{“Name”:“5.0”,“GroupName”:null}]
Parameters
| Column type | Description |
|---|---|
:primary_key |
Primary key. |
:string |
Shorter string. Allows a limit option for the maximum number of characters. |
:text |
Longer text. Allows a limit option for the maximum number of bytes. |
:integer |
Integer. Allows a limit option for the number of bytes used to store the value. |
:bigint |
Larger integer. |
:float |
Float. |
:decimal |
Decimal number with variable precision. Allows precision and scale options. |
:numeric |
Alias of :decimal. Allows precision and scale options. |
:datetime |
Date and time. |
:time |
Time of day. |
:date |
Date. |
:binary |
Binary data. Allows a limit option for the maximum number of bytes. |
:boolean |
Boolean. |
Remarks
- Most migration files live in the
db/migrate/directory. Each file name starts with a UTC timestamp:YYYYMMDDHHMMSS_create_products.rb. - The
rails generatecommand can be shortened torails g. - If a generator column omits a type, it defaults to
:string.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents