Skip to content
stvvt edited this page Sep 9, 2011 · 1 revision

CakePHP DB Migrations supports a number of column/field types. Most are self explanatory, but a few might need some explaining.

  • string
  • text
  • integer | int
  • blob
  • boolean | bool
  • float
  • date
  • time
  • timestamp | datetime
  • fkey | fkeys

Here is an example of how you would use these types in conjunction with other attributes:

  UP:
    add_field:
      users:
        last_name:
          type: string
          length: 10
  DOWN:
    drop_field:
      users: last_name

Or better still, use the shortened format:

  UP:
    add_field:
      users:
        last_name: 10
  DOWN:
    drop_field:
      users: last_name

Because string is the default type, we don't need to specify it. But if we want last_name to a integer with a limit of 5 (some people might!), do this:

  UP:
    add_field:
      users:
        last_name: [int, 5]
  DOWN:
    drop_field:
      users: last_name
Clone this wiki locally