function login_history_update_7102 in Login History 7
Add device_id and login_id columns.
File
- ./
login_history.install, line 134 - The login history install/uninstall code.
Code
function login_history_update_7102() {
if (!db_field_exists('login_history', 'device_id')) {
db_add_field('login_history', 'device_id', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'A hash of the login data to quickly identify this device.',
));
db_add_index('login_history', 'login_history_uid_device_id', array(
'uid',
'device_id',
));
db_query('UPDATE {login_history} SET device_id = SHA2(CONCAT(user_agent), 256)')
->execute();
}
if (!db_field_exists('login_history', 'login_id')) {
db_add_field('login_history', 'login_id', array(
'description' => 'The primary identifier for a login.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
), array(
'primary key' => array(
'login_id',
),
));
}
if (!db_field_exists('login_history', 'old_device_id')) {
db_add_field('login_history', 'old_device_id', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'The device id from the client cookie.',
));
}
}