summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--imagecache.install60
1 files changed, 60 insertions, 0 deletions
diff --git a/imagecache.install b/imagecache.install
index b1433f3..46bdbea 100644
--- a/imagecache.install
+++ b/imagecache.install
@@ -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;
+}