function customfilter_update_6103 in Custom filter 6
Same name and namespace in other branches
- 7.2 customfilter.install \customfilter_update_6103()
- 7 customfilter.install \customfilter_update_6103()
Implements hook_update_N().
File
- ./
customfilter.install, line 160 - Installation file for Custom filter.
Code
function customfilter_update_6103() {
$ret = array();
$schema = array();
$schema['customfilter_filters'] = array(
'fields' => array(
'fid' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'cache' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'description' => array(
'type' => 'text',
),
'shorttips' => array(
'type' => 'text',
),
'longtips' => array(
'type' => 'text',
),
),
'primary key' => array(
'fid',
),
);
$schema['customfilter_rules'] = array(
'fields' => array(
'rid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'fid' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'prid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'type' => 'text',
),
'enabled' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'matches' => array(
'type' => 'int',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'pattern' => array(
'type' => 'text',
),
'replacement' => array(
'type' => 'text',
),
'code' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'weight' => array(
'type' => 'int',
'size' => 'small',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'weight' => array(
'weight',
),
),
'primary key' => array(
'rid',
),
);
// Upgrade from 5.x
if (db_table_exists('customfilter_set')) {
// customfilter_set table was changed to customfilter_filters.
db_create_table($ret, 'customfilter_filters', $schema['customfilter_filters']);
$ret[] = update_sql('INSERT INTO {customfilter_filters} (fid, name, cache, description, shorttips, longtips)
SELECT sid, name, cache, description, shorttips, longtips from {customfilter_set}');
db_drop_table($ret, 'customfilter_set');
// customfilter_filter table was changed to customfilter_rules.
db_create_table($ret, 'customfilter_rules', $schema['customfilter_rules']);
$ret[] = update_sql('INSERT INTO {customfilter_rules} (rid, fid, prid, name, description, matches, pattern, replacement, code, weight)
SELECT fid, sid, parentid, name, description, matches, pattern, replacement, func, weight from {customfilter_filter}');
db_drop_table($ret, 'customfilter_filter');
}
else {
db_drop_primary_key($ret, 'customfilter_filters');
db_change_field($ret, 'customfilter_filters', 'fid', 'fid', $schema['customfilter_filters']['fid']);
db_add_primary_key($ret, 'customfilter_filters', array(
'fid',
));
db_change_field($ret, 'customfilter_rules', 'fid', 'fid', $schema['customfilter_rules']['fid']);
db_add_field($ret, 'customfilter_rules', 'enabled', $schema['customfilter_rules']['enabled']);
db_add_index($ret, 'customfilter_rules', 'weight', array(
'weight',
));
}
return $ret;
}