A Weblog written, styled and hacked by Joel Moss
OK boys and girls; I just posted the first and hopefully only release candidate of Migrations v4.0. Get it while it’s hot.
This release includes a few bug fixes. In fact, it fixes most known bugs, and allowed me to close a lot of the bug tickets. There are only three or four left, which I hope to eradicate by the time the stable release comes around.
Here’s the changes since the beta…
UUID Switch
Migrations have supported Cake’s UUID columns as of v3.7, but in that release you could only use them if you had enabled the appropriate variable within the script itself. This obviously meant that you couldn’t enable UUID’s on a per migration basis. No more I tell you, no more!
If you want your ID column to use UUID’s, just use this in your migration:
And now when you run that migration,the id column will be created with the correct type and length for using UUID’s.
No ID Syntax Change
Following on from the above, and to make things just a little easier; using the following will create a table with no ID column:
This replaces the no_id syntax.
MySQL Specific Commands
And because we all use MySQL right? You can now use some extra commands when creating tables:
Pretty much self-explanatory right?
So as I said, I hope this will be the only release candidate, so please submit your bug reports, so I can push out a perfect stable release.
Enjoy!
My name is Joel Moss, a web developer and all round nice guy, living in Manchester, England. I am currently working full time for ShermansTravel.com, but I fill whatever spare time I have with lots of good and wholesome "stuff"! Like developing my own ideas; such as Tooum, contributing to the excellent CakePHP framework, and doing more work for ShermansTravel.
So this is my blog - my soap box! Here I attempt to share my likes, my dislikes, and my opinions. As well as providing some occasional respite from the daily crap we all endure. Enjoy ;)
Hey, if you want to reach me, i'm available via email:joel[at]developwithstyle[dot]com, and AIM:joelkmoss.
Derick
May 26th, 2008 at 12:55 pm
Eek, I am not sure if this is considered an “Issue” and there are no “Enhancement” tickets category. Anyways, how about having collation support for columns as well? I guess it will be better to have UUID in CHAR(36) in latin1_bin collation. Great work as always.
Andrew Assarattanakul
May 27th, 2008 at 2:17 pm
Thanks for the new update. Looking forward in testing it with my migration files with some minor changes to them to work with the newer format.
Joel
May 27th, 2008 at 9:10 pm
Glad ya like it guys.
@Derick: Please feel free to open an issue. There is an option to select the issue type to enhancement.
Chanon
June 16th, 2008 at 10:22 am
Hi!, I was wondering, how do you add a boolean column to a table that is not_null?
I’ve tried many ways but can’t get it to work.
Chanon
June 16th, 2008 at 10:24 am
This is what I tried, but the resulting column is NULL instead of NOT NULL
UP:
add_field:
games:
my_flag:
type: boolean
length: 1
not_null:
DOWN:
drop_field:
games: [my_flag]
itsnotvalid
June 21st, 2008 at 5:35 pm
Just started using it. I am actually wonder why PEAR and MDB2 is needed, as Cake already have a bunch of drivers under cake.cake.libs.model.datasources. It seems that using less dependencies would be far better than using some external dependencies, given that the core already have the needed features.
Also filed a bug in Google Code. Have a nice day!
Watts
July 25th, 2008 at 5:30 pm
While this may just be me, I was consistently getting an error with Migrations 4.0rc1 when I tried to run “migrate generate from db” to build the full_schema.yml file: “PHP Fatal error: Class ‘ConnectionManager’ not found in /usr/local/lib/cake-1.2/vendors/shells/migrate.php on line 465″.
This was solved by adding “connection_manager” to the App::import line at the start of the migrate.php file.
lfm
August 11th, 2008 at 4:25 pm
Hi,
I’ve a problem with installation.
I use MAMP and Pear is already installed with it, but not MDB2.
I tried to install necessery package but all time when I try to run ‘cake migrate’ I see:
” Error: PEAR NOT FOUND
Unable to include PEAR.php and MDB2.php”
How should I install MDB2 to MAMP?
wdm
September 11th, 2008 at 3:08 pm
The “PEAR NOT FOUND” error seems to occur even if you do have pear installed, but not MDB2
pear install MDB2at the command line will install MDB2, and the error should go away,You might need to first set your php path in ~/.bash_profile. This makes sure pear will be talking to the MAMP php version, mine looks like:
# Set PATH for php (override default /bin/php)
export PATH=/Applications/MAMP/bin/php5/bin:$PATH
But… now I have a new error. After typing ‘cake migrate help’ I get:
Warning: MDB2::include_once(MDB2/Driver/postgres.php): failed to open stream: No such file or directory in /Applications/MAMP/bin/php5/lib/php/MDB2.php on line 332
Warning: MDB2::include_once(): Failed opening 'MDB2/Driver/postgres.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/bin/php5/lib/php/MDB2.php on line 332
Error: MDB2 ERROR
unable to find package 'MDB2_Driver_postgres' file 'MDB2/Driver/postgres.php'
Tony Bianco
November 20th, 2008 at 1:07 am
Is there any place where we can see the full examples of using migrations within a yml file?
Joel
November 21st, 2008 at 1:50 am
@tony: Yeah, take a look at the github wiki: http://github.com/joelmoss/cakephp-db-migrations/wikis
Funky Weasel
December 16th, 2008 at 11:07 am
@wdm: Sorry I’m a few months late - you need to install the MDB2 database driver seperately, even though the pear install on MDB2 claims that it’s already set them up. e.g.
pear install MDB2_Driver_mysql
Hope this helps anyone else stuck with similar problems. Cake Migrate is a pain to set up, but well worth it if you want to keep revision tracking of db structure.
Ben Rasmusen
February 19th, 2009 at 10:07 pm
I’m also having trouble with the install. I’m getting the following error when trying to run the migration console:
** Unable to include PEAR.php and MDB2.php **
I have PEAR installed as well as the MDB2 package:
Package Version State
MDB2 2.4.1 stable
PEAR 1.7.1 stable
I noticed the note above regarding the PATH. I believe my PATH should be solid. I have a native install of PHP/MySQL/Apache running on OSX 10.5.6. My PATH:
“$PATH:/usr/local/bin:/usr/local/subversion/bin:/opt/local/bin:/opt/local/sbin:/Users//Sites/cake/console:/opt/local/lib/php”
Is this an issue with my local setup? Any help on resolving this would be greatly appreciated. Thanks!
Martin
March 13th, 2009 at 9:23 pm
I had the same problem with Postgres, I’ve solved the issue creating a file called postgres.php right in the same directory that is pgsql.php and adding this code.
Martin
March 13th, 2009 at 9:24 pm
include(”pgsql.php”);
class MDB2_Driver_postgres extends MDB2_Driver_pgsql
{
}