[jifty-devel] Upgrading Jifty Apps

bart at bunting.net.au bart at bunting.net.au
Thu Jul 13 02:20:59 EDT 2006


Hi all,

I've run across a need to rename a column in one of my tables.  I had
some trouble doing so.  I almost got there but not quite :).

Below is a list of things that I did and a couple of questions:

I thought that a use base would be enough but I ended up with a use
Jifty::Upgrade qw(since); as well before things started to work at
all.

Then after struggling with the syntax of the rename command for a bit
I got something that appeared to work correctly Almost.

It was also not obvious that I needed to put the full class name in
the table => class.  But on further reflection the docs do actually
mention this in the syntax.  A simple working example may be nice to
get people off the ground.  I'm happy to wright this once I've got my
column renamed.

My upgrade.pm is:

package AHSupport::Upgrade;

use base qw(Jifty::Upgrade);
use AHSupport::Model::Shift;
use Jifty::Upgrade qw( since rename );

since '0.5' => sub {
  rename (table => 'AHSupport::Model::Shift', 
	  column => 'person', 
	  to => 'user'
	 );
}


When I finally run the upgrade I get a sql error but jifty appears to
think everything is ok.  This scares me :(.

jifty schema --setup
Jifty version 0.607070 up to date.
INFO - Generating SQL to upgrade AHSupport 0.400 database to 0.500
WARN - Warning: Use of "CORE" without parentheses is ambiguous at (eval 257) line 1.
INFO - Upgrading through 0.5
INFO - Running upgrade script
WARN - DBD::Pg::st execute failed: ERROR:  syntax error at or near "user" at character 37
WARN - Jifty::Handle=HASH(0x9af9a58) couldn't execute the query 'ALTER TABLE shifts RENAME person TO user' at /usr/local/share/perl/5.8.8/Jifty/DBI/Handle.pm line 484.
INFO - Upgraded to version 0.500

If anyone can enlighten me on what went wrong here I'll write it up
and at least put an example in the J::Upgrade pod.

Bart


More information about the jifty-devel mailing list