You are here

geshinode.install in GeSHi Filter for syntax highlighting 6

Same filename and directory in other branches
  1. 5.2 geshinode.install

Installation and uninstallation functions for the GeSHi node module.

File

geshinode.install
View source
<?php

/**
 * @file
 * Installation and uninstallation functions for the GeSHi node module.
 */

/**
 * Implementation of hook_schema()
 */
function geshinode_schema() {
  $schema['geshinode'] = array(
    'description' => t('The table for geshinodes.'),
    'fields' => array(
      'nid' => array(
        'description' => t('The primary identifier for a node.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => t('The current {node_revisions}.vid version identifier.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'description' => t('The source code language of the node.'),
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  return $schema;
}

/**
 * Create tables on install
 */
function geshinode_install() {

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

/**
 * Remove tables on uninstall.
 */
function geshinode_uninstall() {

  // Drop geshinode tables.
  drupal_uninstall_schema('geshinode');
}

/**
 * Implementation of hook_update_N().
 *
 * Fix the primary key and indices on the geshinode table.
 * See http://drupal.org/node/363770 .
 */
function geshinode_update_6001() {
  $ret = array();

  // Drop unique key on 'vid'.
  db_drop_unique_key($ret, 'geshinode', 'vid');

  // Change the 'nid' field to 'int' (from 'serial').
  db_change_field($ret, 'geshinode', 'nid', 'nid', array(
    'description' => t('The primary identifier for a node.'),
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
  ));

  // Drop primary key ('nid').
  db_drop_primary_key($ret, 'geshinode');

  // Add primary key on 'vid'.
  db_add_primary_key($ret, 'geshinode', array(
    'vid',
  ));

  // Add an index on 'nid'.
  db_add_index($ret, 'geshinode', 'nid', array(
    'nid',
  ));
  return $ret;
}

Functions

Namesort descending Description
geshinode_install Create tables on install
geshinode_schema Implementation of hook_schema()
geshinode_uninstall Remove tables on uninstall.
geshinode_update_6001 Implementation of hook_update_N().