You are here

function redirect_schema in Redirect 7.2

Same name and namespace in other branches
  1. 7 redirect.install \redirect_schema()

Implements hook_schema().

File

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

Code

function redirect_schema() {
  $schema['redirect'] = array(
    'description' => 'Stores information on redirects.',
    'fields' => array(
      'rid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique redirect ID.',
      ),
      'hash' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'description' => 'A unique hash based on source, source_options, and language.',
      ),
      'type' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => "The redirect type; if value is 'redirect' it is a normal redirect handled by the module.",
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid of the user who created the redirect.',
      ),
      'source' => array(
        'type' => 'varchar',
        'length' => 900,
        'not null' => TRUE,
        'description' => 'The source path to redirect from.',
      ),
      'source_options' => array(
        'type' => 'blob',
        'not null' => TRUE,
        'serialize' => TRUE,
        'description' => 'A serialized array of source options.',
      ),
      'redirect' => array(
        'type' => 'varchar',
        'length' => 900,
        'not null' => TRUE,
        'description' => 'The destination path to redirect to.',
      ),
      'redirect_options' => array(
        'type' => 'blob',
        'not null' => TRUE,
        'serialize' => TRUE,
        'description' => 'A serialized array of redirect options.',
      ),
      'language' => array(
        'description' => 'The language this redirect is for; if blank, the alias will be used for unknown languages.',
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => 'und',
      ),
      'status_code' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'description' => 'The HTTP status code to use for the redirect.',
      ),
      'count' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The number of times the redirect has been used.',
      ),
      'access' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The timestamp of when the redirect was last accessed.',
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 1,
        'description' => 'Boolean indicating whether the redirect is enabled (visible to non-administrators).',
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'unique keys' => array(
      'hash' => array(
        'hash',
      ),
    ),
    'indexes' => array(
      'expires' => array(
        'type',
        'access',
      ),
      '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',
      ),
      'redirect' => array(
        'redirect',
      ),
    ),
  );
  return $schema;
}