You are here

function login_history_schema in Login History 8

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

Implements hook_schema().

2 calls to login_history_schema()
login_history_update_8001 in ./login_history.install
Adds the primary key field for existing tables.
login_history_update_8003 in ./login_history.install
Alters the user_agent field to allow NULL values.

File

./login_history.install, line 15
Install, update and uninstall functions for the Login History module.

Code

function login_history_schema() {
  $schema['login_history'] = [
    'description' => 'Base table to record data about login events.',
    'fields' => [
      'login_id' => [
        'description' => 'The primary identifier for a login.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uid' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'uid of user.',
      ],
      'login' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => "Timestamp for user's login.",
      ],
      'hostname' => [
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => "The user's host name.",
      ],
      'one_time' => [
        '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' => [
        'type' => 'varchar',
        'length' => 256,
        'not null' => FALSE,
        'default' => '',
        'description' => 'User agent (i.e. browser) of the device used during the login.',
      ],
    ],
    'primary key' => [
      'login_id',
    ],
    'indexes' => [
      'login_history_uid' => [
        'uid',
      ],
      'login_history_onetime' => [
        'one_time',
      ],
      'login_history_uid_host_ua' => [
        'uid',
        'hostname',
      ],
    ],
  ];
  return $schema;
}