function opigno_statistics_install in Opigno statistics 3.x
Same name and namespace in other branches
- 8 opigno_statistics.install \opigno_statistics_install()
Implements hook_install().
File
- ./
opigno_statistics.install, line 18 - Install, update and uninstall functions for the Opigno Statistics module.
Code
function opigno_statistics_install() {
// Creates database table for tracking of the user login events.
$schema = \Drupal::database()
->schema();
$table_name = 'opigno_statistics_user_login';
if (!$schema
->tableExists($table_name)) {
$table = [
'description' => 'Track user login events',
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
],
'uid' => [
'description' => 'User ID',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'date' => [
'description' => 'Date of login',
'type' => 'varchar',
'length' => 20,
'mysql_type' => 'datetime',
'not null' => TRUE,
],
],
'primary key' => [
'id',
],
'indexes' => [
'uid' => [
'uid',
],
],
'foreign keys' => [
'users' => [
'uid' => 'uid',
],
],
];
$schema
->createTable($table_name, $table);
}
}