You are here

nodeapi_example.install in Examples for Developers 6

Same filename and directory in other branches
  1. 7 nodeapi_example/nodeapi_example.install

Nodeapi example module's install and uninstall code.

File

nodeapi_example/nodeapi_example.install
View source
<?php

/**
 * @file
 * Nodeapi example module's install and uninstall code.
 */

/**
 * Implementation of hook_install().
 */
function nodeapi_example_install() {
  drupal_install_schema('nodeapi_example');
}

/**
 * Implementation of hook_uninstall().
 */
function nodeapi_example_uninstall() {
  drupal_uninstall_schema('nodeapi_example');
}

/**
 * Implementation of hook_schema().
 */
function nodeapi_example_schema() {
  $schema['nodeapi_example'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique ID.'),
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('node id for the rating'),
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('version id for rating'),
      ),
      'rating' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('rating for this node'),
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}
function nodeapi_example_update_1() {
  return _system_update_utf8(array(
    'nodeapi_example',
  ));
}

Functions