Thursday November 20, 2008
Installation of CakePHP Migrations
This is a quick how to use CakePHP Migrations. First download the three packages Migrations Pear Core and MDB2. Put the migrations vendor plugin into the cake/vendor directory. Place the two Pear packages into your php include directory, and/or modify your php.ini to reflect the location of installation.
How To Use
In the cake/console directory there is a ./cake or cake.bat file (depending on operating system)
Generating a Migration
to generate a migration file for a User model simply write
cake.bat migrate g user
This will create a file in app/config/migrations/ named timestampuser e.g. 1226324252user.yml
# migration YAML file
UP:
create_table:
table_name:
name:
description: text
count: integer
is_active: boolean
DOWN:
droptable: tablename
Please Note: Make sure you remove the text "table_name" and replace it with the table name you generated the file for, e.g. "user"
Also ensure all fields have a type.
Processing Migrations
To get the database up to the latest migration file
cake.bat migrate all
Back
