ActiveRecord Migrations
suggest changeVersions
[{“Name”:“5.0”,“GroupName”:null}]
Parameters
Column type | Description |
—— | —— |:primary_key | Primary key |:string | Shorter string datatype. Allows limit option for maximum number of characters. |:text | Longer amount of text. Allows limit option for maximum number of bytes. |:integer | Integer. Allows limit option for maximum number of bytes. |:bigint | Larger integer |:float | Float |:decimal | Decimal number with variable precision. Allows precision and scale options. |:numeric | Allows precision and scale options. |:datetime | DateTime object for dates/times. |:time | Time object for times. |:date | Date object for dates. |:binary | Binary data. Allows limit option for maximum number of bytes. |:boolean | Boolean |
Remarks
- Most migration files live in
db/migrate/directory. They’re identified by a UTC timestamp at the beginning of their file name:YYYYMMDDHHMMSS_create_products.rb. - The
rails generatecommand can be shortened torails g. - If a
:typeis not passed to a field, it defaults to a string.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents