You are here

feedback.install in Feedback 6.2

Same filename and directory in other branches
  1. 5.2 feedback.install
  2. 5 feedback.install
  3. 7.2 feedback.install

File

feedback.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function feedback_schema() {
  $schema['feedback'] = array(
    'description' => t('Stores all feedback messages.'),
    'fields' => array(
      'fid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => t('The primary identifier for a feedback message.'),
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The user id of the author of a feedback message.'),
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The status of a feedback message.'),
      ),
      'message' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
        'description' => t('The actual feedback message.'),
      ),
      'location' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('The internal Drupal path of the page the feedback message was submitted on.'),
      ),
      'location_masked' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('The masked Drupal path of the page the feedback message was submitted on.'),
      ),
      'url' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => t('The absolute URL of the page the feedback message was submitted on.'),
      ),
      'useragent' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => t('The user agent of the feedback message author.'),
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The UNIX timestamp when the feedback message was created.'),
      ),
    ),
    'primary key' => array(
      'fid',
    ),
    'indexes' => array(
      'location' => array(
        array(
          'location',
          32,
        ),
      ),
      'location_masked' => array(
        array(
          'location_masked',
          32,
        ),
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function feedback_install() {
  drupal_install_schema('feedback');
}

/**
 * Implementation of hook_uninstall().
 */
function feedback_uninstall() {
  drupal_uninstall_schema('feedback');
  db_query("DELETE FROM {variable} WHERE name LIKE 'feedback_%%'");
}

/**
 * Change fid into type serial field.
 */
function feedback_update_6100() {
  $ret = array();
  db_drop_primary_key($ret, 'feedback');
  db_change_field($ret, 'feedback', 'fid', 'fid', array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ), array(
    'primary key' => array(
      'fid',
    ),
  ));
  return $ret;
}

/**
 * Add column for absolute URL.
 */
function feedback_update_6101() {
  $ret = array();
  db_add_field($ret, 'feedback', 'url', array(
    'type' => 'text',
    'not null' => TRUE,
  ));
  $ret[] = update_sql("UPDATE {feedback} SET url = location");
  return $ret;
}

Functions

Namesort descending Description
feedback_install Implementation of hook_install().
feedback_schema Implementation of hook_schema().
feedback_uninstall Implementation of hook_uninstall().
feedback_update_6100 Change fid into type serial field.
feedback_update_6101 Add column for absolute URL.