Index: imagecache.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.install,v retrieving revision 1.22 diff -u -p -r1.22 imagecache.install --- imagecache.install 22 Dec 2008 00:01:19 -0000 1.22 +++ imagecache.install 5 Jan 2009 21:18:48 -0000 @@ -198,6 +198,7 @@ function imagecache_update_4() { case 'mysql': case 'mysqli': $ret[] = update_sql("ALTER TABLE {imagecache_action} ADD COLUMN action varchar(255) not null default '' after weight"); + break; case 'pgsql': $ret[] = update_sql("ALTER TABLE {imagecache_action} ADD COLUMN action varchar(255) NOT NULL DEFAULT ''"); break; @@ -244,3 +245,32 @@ function imagecache_update_5() { return array(); } + +/** + * Upgrade from Drupal 5 => Drupal 6. + * Use serial data type for primary keys. Add module field and presetid index. + */ +function imagecache_update_6000() { + $ret = array(); + $schema = imagecache_schema(); + + // Update primary keys to serial type for Drupal 6 + $tables = array( + 'imagecache_preset' => 'presetid', + 'imagecache_action' => 'actionid', + ); + foreach ($tables as $table => $field) { + db_drop_primary_key($ret, $table); + db_change_field($ret, $table, $field, $field, $schema[$table]['fields'][$field], array('primary key' => array($field))); + $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{{$table}}_{$field}'"); + } + + // Add 'module' column to action table and set module to imagecache + db_add_field($ret, 'imagecache_action', 'module', $schema['imagecache_action']['fields']['module']); + $ret[] = update_sql("UPDATE {imagecache_action} set module = 'imagecache'"); + + // Add 'presetid' index to action table + db_add_index($ret, 'imagecache_action', 'presetid', array('presetid')); + + return $ret; +}