You are here

context_node.install in Context Node 7

Same filename and directory in other branches
  1. 6 context_node.install

File

context_node.install
View source
<?php

/**
 * Implement hook_schema().
 */
function context_node_schema() {
  $schema = array();
  $schema['context_node'] = array(
    'description' => 'Custom layout context node table.',
    'fields' => array(
      'nid' => array(
        'description' => 'Node nid number',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'Node vid number',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'context' => array(
        'description' => 'Node template',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
      ),
    ),
    'unique keys' => array(
      'vid' => array(
        'vid',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
  );
  return $schema;
}

/**
 * Implement hook_install()
 */
function context_node_install() {
}

/**
 * Implement hook_uninstall()
 */
function context_node_uninstall() {

  // Delete all existing variables
  $types = array_keys(node_type_get_types());
  foreach ($types as $type) {
    variable_del("context_node_" . $type);
    variable_del("context_node_default_" . $type);
  }
}

/**
 * Update the database to prevent duplicated 'vid'
 * - adding vid as a unique key and a primary key -
 */
function context_node_update_7100() {
  $ret = array();
  db_add_unique_key('context_node', 'vid', array(
    'vid',
  ));
  db_add_primary_key('context_node', array(
    'vid',
  ));
  return $ret;
}

Functions

Namesort descending Description
context_node_install Implement hook_install()
context_node_schema Implement hook_schema().
context_node_uninstall Implement hook_uninstall()
context_node_update_7100 Update the database to prevent duplicated 'vid'