You are here

modr8.install in modr8 6

Same filename and directory in other branches
  1. 5 modr8.install
  2. 7 modr8.install

File

modr8.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function modr8_schema() {
  $schema['modr8_log'] = array(
    'fields' => array(
      'modid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'author_uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'action' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'message' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'teaser' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'nid_time' => array(
        'nid',
        'modid',
      ),
      'time_action' => array(
        'timestamp',
        'action',
      ),
    ),
    'primary key' => array(
      'modid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function modr8_install() {

  // Create tables.
  drupal_install_schema('modr8');
}

/**
 * Implementation of hook_uninstall().
 */
function modr8_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('modr8');
}

/**
 * Update table definitions.
 */
function modr8_update_1000() {
  $ret = array();
  $name = 'modr8_log';
  $table = array(
    'fields' => array(
      'modid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'author_uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'action' => array(
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'message' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'teaser' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'nid_time' => array(
        'nid',
        'modid',
      ),
      'action' => array(
        'action',
      ),
    ),
    'primary key' => array(
      'modid',
    ),
  );
  db_create_table($ret, $name, $table);
  return $ret;
}

/**
 * Fix index for new block.
 */
function modr8_update_6001() {
  $ret = array();
  db_drop_index($ret, 'modr8_log', 'action');
  db_add_index($ret, 'modr8_log', 'time_action', array(
    'timestamp',
    'action',
  ));
  return $ret;
}

Functions

Namesort descending Description
modr8_install Implementation of hook_install().
modr8_schema Implementation of hook_schema().
modr8_uninstall Implementation of hook_uninstall().
modr8_update_1000 Update table definitions.
modr8_update_6001 Fix index for new block.