function image_update_6100 in Image 6
Same name and namespace in other branches
- 7 image.install \image_update_6100()
Add primary key and index on 'fid' to {image} table.
File
- ./
image.install, line 304
Code
function image_update_6100() {
$ret = array();
db_change_field($ret, 'image', 'nid', 'nid', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
db_change_field($ret, 'image', 'fid', 'fid', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
));
// We remove and re-add primary keys and indexes because the column types
// are changed. Sometimes however these don't exist in the first place.
// @see http://drupal.org/node/562810
// Try to suppress errors during removal.
@db_drop_primary_key($ret, 'image');
db_add_primary_key($ret, 'image', array(
'nid',
'image_size',
));
@db_drop_index($ret, 'image', 'image_fid');
db_add_index($ret, 'image', 'fid', array(
'fid',
));
// Notify the user that they may get harmless fail messages here.
$ret[] = array(
'success' => TRUE,
'query' => t('You can safely ignore the error message "Failed: ALTER TABLE {image} DROP PRIMARY KEY" or "DROP INDEX image_fid".'),
);
return $ret;
}