? d5.sql
? imagecache.install_3.patch
Index: imagecache.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.install,v
retrieving revision 1.23
diff -u -p -r1.23 imagecache.install
--- imagecache.install	5 Jan 2009 22:28:07 -0000	1.23
+++ imagecache.install	6 Jan 2009 01:15:00 -0000
@@ -245,3 +245,63 @@ 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();
+
+  // Our additions to the schema.
+  $schema['imagecache_preset'] = array(
+    'fields' => array(
+      'presetid' => array(
+        'description' => t('The primary identifier for an imagecache_preset.'),
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+    ),
+    'primary key' => array('presetid'),
+  );
+  $schema['imagecache_action'] = array(
+    'fields' => array(
+      'actionid' => array(
+        'description' => t('The primary identifier for an imagecache_action.'),
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'module' => array(
+        'description' => t('The module that defined the action.'),
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'initial' => 'imagecache',
+      ),
+    ),
+    'primary key' => array('actionid'),
+  );
+
+  // Update primary keys to serial type for Drupal 6
+  foreach ($schema as $table => $info) {
+    db_drop_primary_key($ret, $table);
+    $field = $info['primary key'][0];
+    if (db_table_exists($table)) {
+      $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{{$table}}_{$field}'");
+    }
+    db_change_field($ret, $table, $field, $field, $info['fields'][$field], array('primary key' => array($field)));
+  }
+
+  // Add 'module' column to action table.
+  if (!db_column_exists('imagecache_action', 'module')) {
+    db_add_field($ret, 'imagecache_action', 'module', $schema['imagecache_action']['fields']['module']);
+  }
+
+  // Add 'presetid' index to action table
+  db_add_index($ret, 'imagecache_action', 'presetid', array('presetid'));
+
+  return $ret;
+}
