Cake Migrations 3.2
Article posted by Joel Moss on 22 Jun 2007   |  
Cake DB Migrations has now been updated to work with the very latest version of CakePHP 1.2 and the new (hopefully final) console/shells system. I have also added a few extra goodies to make life a little easier. The new features and changes are as follows:
  • You can now specify a column without the need to specify the column type. Type is set to string, which is simply a varchar(255) column.
  • Ability to add user definable foreign keys by simply specifying the 'fkey' as a column name, followed by the name(s) of the foreign key(s).
  • You can now include PHP code within the YAML migration files
Because the console system in Cake 1.2 has changed a bit, you now have to place the below script in a slightly different place. Within your main 'vendors' directory above your app and cake core directories, paste the below code into a file called 'migrate.php' and place that file in a directory called 'shells'. Now just bring up your favourite command line tool and cd into your cake applications root directory and run the following:
./cake migrate
And that is it! That will migrate to the lastest version. You can specify the version like this:
./cake migrate -v 3
As promised, I hope to create a screencast going through all aspects of migrations and how they can save your life. You can find the script in CakeForge, aswell as new versions of the Fixtures and Generator shells.

This site contains the musings of Joel Moss, and is powered by Codaset pages; a simple, yet powerful way to host your static site. Just commit and push your site to your free Git repository at Codaset, and that's it!

Tell me more about Joel »