You are here

devel_debug_log.install in Devel Debug Log 7

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

Devel debug log module install/schema hooks.

File

devel_debug_log.install
View source
<?php

/**
 * @file
 * Devel debug log module install/schema hooks.
 */

/**
 * Implements hook_install().
 */
function devel_debug_log_install() {
  if (!db_table_exists('devel_debug_log')) {
    $schema = array(
      'description' => 'Table for storing debug messages.',
      'fields' => array(
        'id' => array(
          'description' => 'The message identifier.',
          'type' => 'serial',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
        'timestamp' => array(
          'description' => 'The Unix timestamp when the message was saved.',
          'type' => 'int',
          'not null' => TRUE,
          'default' => 0,
        ),
        'title' => array(
          'description' => 'The title of the debug message.',
          'type' => 'varchar',
          'length' => '255',
          'not null' => TRUE,
          'default' => '',
        ),
        'message' => array(
          'description' => 'The debug message.',
          'type' => 'text',
          'size' => 'big',
          'not null' => TRUE,
        ),
        'serialized' => array(
          'description' => 'Indicates whether the message is serialized.',
          'type' => 'int',
          'size' => 'small',
          'not null' => TRUE,
          'default' => 0,
        ),
      ),
      'primary key' => array(
        'id',
      ),
    );
    db_create_table('devel_debug_log', $schema);
  }
}

/**
 * Implements hook_disable().
 */
function devel_debug_log_disable() {

  // Empty debug table when the module is disabled.
  db_delete('devel_debug_log')
    ->execute();
}

/**
 * Implements hook_uninstall().
 */
function devel_debug_log_uninstall() {
  if (db_table_exists('devel_debug_log')) {
    db_drop_table('devel_debug_log');
  }
}