function themekey_update_6202 in ThemeKey 7.2
Same name and namespace in other branches
- 6.4 themekey.install \themekey_update_6202()
- 6.2 themekey.install \themekey_update_6202()
- 6.3 themekey.install \themekey_update_6202()
- 7.3 themekey.install \themekey_update_6202()
- 7 themekey.install \themekey_update_6202()
Implements hook_update_N().
File
- ./
themekey.install, line 385 - Database schema of
Code
function themekey_update_6202() {
$ret = array();
$field_operator = array(
'type' => 'varchar',
'length' => 2,
'not null' => TRUE,
'default' => '=',
'initial' => '=',
);
db_add_field('themekey_properties', 'operator', $field_operator);
$field_parent = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'initial' => 0,
);
db_add_field('themekey_properties', 'parent', $field_parent);
if ($result = db_query("SELECT * FROM {themekey_properties} WHERE conditions <> :conditions", array(
':conditions' => serialize(array()),
))) {
foreach ($result as $row) {
$conditions = unserialize($row->conditions);
if (is_array($conditions)) {
$parent = $row->id;
foreach ($conditions as $condition) {
$parent = db_insert('themekey_properties')
->fields(array(
'property' => $condition['property'],
'operator' => $condition['operator'],
'value' => $condition['value'],
'weight' => 0,
'theme' => $row->theme,
'enabled' => $row->enabled,
'wildcards' => serialize(array()),
'parent' => $parent,
))
->execute();
}
}
}
}
db_drop_field('themekey_properties', 'conditions');
db_drop_index('themekey_properties', 'enabled');
db_drop_index('themekey_properties', 'weight');
db_add_index('themekey_properties', 'enabled_parent_weight', array(
'enabled',
'parent',
'weight',
));
db_add_index('themekey_properties', 'parent_weight', array(
'parent',
'weight',
));
db_drop_index('themekey_paths', 'path');
db_drop_index('themekey_paths', 'fit');
db_drop_index('themekey_paths', 'weight');
db_add_index('themekey_paths', 'path_fit_weight', array(
'path',
'fit',
'weight',
));
return t('Updated ThemeKey properties.');
}