You are here

function customfilter_update_6103 in Custom filter 7

Same name and namespace in other branches
  1. 6 customfilter.install \customfilter_update_6103()
  2. 7.2 customfilter.install \customfilter_update_6103()

Implements hook_update_N().

File

./customfilter.install, line 161
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',
    ),
  );
  db_drop_primary_key('customfilter_filters');
  db_change_field('customfilter_filters', 'fid', 'fid', $schema['customfilter_filters']['fid']);
  db_add_primary_key('customfilter_filters', array(
    'fid',
  ));
  db_change_field('customfilter_rules', 'fid', 'fid', $schema['customfilter_rules']['fid']);
  db_add_field('customfilter_rules', 'enabled', $schema['customfilter_rules']['enabled']);
  db_add_index('customfilter_rules', 'weight', array(
    'weight',
  ));

  // hook_update_N() no longer returns a $ret array. Instead, return
  // nothing or a translated string indicating the update ran successfully.
  // See http://drupal.org/node/224333#update_sql.
  return t('TODO Add a descriptive string here to show in the UI.');
}