You are here

function redirect_update_7101 in Redirect 7

Same name and namespace in other branches
  1. 7.2 redirect.install \redirect_update_7101()

Add status field.

File

./redirect.install, line 244
Install, update and uninstall functions for the redirect module.

Code

function redirect_update_7101() {
  $status_schema = array(
    'type' => 'int',
    'size' => 'small',
    'not null' => TRUE,
    'default' => 1,
    'description' => 'Boolean indicating whether the redirect is enabled (visible to non-administrators).',
  );
  if (!db_field_exists('redirect', 'status')) {
    db_add_field('redirect', 'status', $status_schema);
  }
  else {
    db_change_field('redirect', 'status', 'status', $status_schema);
  }
  if (db_index_exists('redirect', 'source_language')) {
    db_drop_index('redirect', 'source_language');
  }
  if (!db_index_exists('redirect', 'status_source_language')) {
    db_add_index('redirect', 'status_source_language', array(
      'status',
      // Limit the number of characters used by the index.
      // That allows avoiding the risk to have a PDOException
      // caused the DB index limitations of some databases.
      // see https://www.drupal.org/project/redirect/issues/2057615.
      array(
        'source',
        255,
      ),
      'language',
    ));
  }
}