You are here

event_log_track.install in Events Log Track 8.2

Same filename and directory in other branches
  1. 8 event_log_track.install

Install, update and uninstall functions for the event_log_track module.

File

event_log_track.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the event_log_track module.
 */
use Drupal\Core\Database\Database;

/**
 * Implements hook_schema().
 */
function event_log_track_schema() {
  $schema['event_log_track'] = [
    'description' => 'Logged events by the event_log_track module.',
    'fields' => [
      'lid' => [
        'description' => 'Log id.',
        'type' => 'serial',
        'not null' => TRUE,
      ],
      'type' => [
        'description' => 'Event handler type.',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ],
      'operation' => [
        'description' => 'The operation performed.',
        'type' => 'varchar',
        'length' => '50',
        'not null' => TRUE,
      ],
      'path' => [
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        'description' => 'Current path.',
      ],
      'ref_numeric' => [
        'description' => 'A numeric value that can be used to reference an object.',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'ref_char' => [
        'description' => 'A character value that can be used to reference an object.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ],
      'description' => [
        'description' => 'Description of the event, in HTML.',
        'type' => 'text',
        'size' => 'medium',
        'not null' => TRUE,
      ],
      'uid' => [
        'description' => 'User id that triggered this event (0 = anonymous user).',
        'type' => 'int',
        'not null' => TRUE,
      ],
      'ip' => [
        'description' => 'IP address of the visitor that triggered this event.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ],
      'created' => [
        'description' => 'The event timestamp.',
        'type' => 'int',
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'lid',
    ],
    'indexes' => [
      'created' => [
        'created',
      ],
      'user' => [
        'uid',
        'ip',
      ],
      'ip' => [
        'ip',
      ],
      'join' => [
        'type',
        'operation',
        'ref_numeric',
        'ref_char',
      ],
    ],
  ];
  return $schema;
}

/**
 * Increase "ref_char" field size
 */
function event_log_track_update_8101($sandbox) {
  $field = [
    'description' => 'A character value that can be used to reference an object.',
    'type' => 'varchar',
    'length' => '255',
    'not null' => FALSE,
  ];
  $schema = Database::getConnection()
    ->schema();
  $schema
    ->changeField('event_log_track', 'ref_char', 'ref_char', $field);
  return t('"ref_char" field size increased.');
}

Functions

Namesort descending Description
event_log_track_schema Implements hook_schema().
event_log_track_update_8101 Increase "ref_char" field size