You are here

function audit_log_schema in Audit Log 8

Implements hook_schema().

File

./audit_log.install, line 11
Install, update and uninstall functions for the audit_log module.

Code

function audit_log_schema() {
  $schema['audit_log'] = [
    'description' => 'Table that contains logs of all entity events.',
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Unique event ID.',
      ],
      'entity_id' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The entity id of the entity that was created, modified or deleted',
      ],
      'entity_type' => [
        'type' => 'varchar_ascii',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The event type, usually insert, update or delete.',
      ],
      'user_id' => [
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The user id of the user who triggered the event.',
      ],
      'event' => [
        'type' => 'varchar_ascii',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The event type, usually insert, update or delete.',
      ],
      'previous_state' => [
        'type' => 'varchar_ascii',
        'length' => 64,
        'default' => '',
        'description' => 'The previous state of the entity if available',
      ],
      'current_state' => [
        'type' => 'varchar_ascii',
        'length' => 64,
        'default' => '',
        'description' => 'The current state of the entity if available',
      ],
      'message' => [
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Text of log message to be passed into the t() function.',
      ],
      'variables' => [
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
        'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
      ],
      'timestamp' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Unix timestamp of when event occurred.',
      ],
    ],
    'primary key' => [
      'id',
    ],
    'indexes' => [
      'user_id' => [
        'user_id',
      ],
      'entity_id' => [
        'entity_id',
      ],
    ],
  ];
  return $schema;
}