You are here

function login_history_schema in Login History 7

Same name and namespace in other branches
  1. 8 login_history.install \login_history_schema()
  2. 6 login_history.install \login_history_schema()

Implements hook_schema().

File

./login_history.install, line 56
The login history install/uninstall code.

Code

function login_history_schema() {
  $schema['login_history'] = array(
    'description' => 'Base table to record data about login events.',
    'fields' => array(
      'login_id' => array(
        'description' => 'The primary identifier for a login.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'uid of user.',
      ),
      'login' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for user's login.",
      ),
      'device_id' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'A hash of the login data to quickly identify this device.',
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => "The user's host name.",
      ),
      'one_time' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Indicates whether the login was from a one-time login link (e.g. password reset).',
      ),
      'user_agent' => array(
        'type' => 'varchar',
        'length' => 256,
        'not null' => TRUE,
        'default' => '',
        'description' => 'User agent (i.e. browser) of the device used during the login.',
      ),
      'old_device_id' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Any device id from the client cookie.',
      ),
    ),
    'indexes' => array(
      'login_history_uid' => array(
        'uid',
      ),
      'login_history_onetime' => array(
        'one_time',
      ),
      'login_history_uid_host' => array(
        'uid',
        'hostname',
      ),
      'login_history_uid_device_id' => array(
        'uid',
        'device_id',
      ),
    ),
    'primary key' => array(
      'login_id',
    ),
  );
  return $schema;
}