You are here

block_inject.install in Block Inject 7

Schema function for the Block Inject table *

File

block_inject.install
View source
<?php

/**
 * @file
 * Schema function for the Block Inject table *
 */

/*
 * Implements hook_schema().
 */
function block_inject_schema() {
  $schema = array();
  $schema['block_inject'] = array(
    'description' => 'The regions that are injected into nodes.',
    'fields' => array(
      'id' => array(
        'description' => 'The id',
        'type' => 'serial',
        'length' => 5,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'region' => array(
        'description' => 'The region that is injected',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'node_type' => array(
        'description' => 'The node type the region is injected in',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'node_name' => array(
        'description' => 'The name of the node type the region is injected in',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'bi_condition' => array(
        'description' => 'The condition if any',
        'type' => 'text',
        'default' => NULL,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['block_inject_exceptions'] = array(
    'description' => 'The exceptions table.',
    'fields' => array(
      'id' => array(
        'description' => 'The id',
        'type' => 'serial',
        'length' => 5,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'bi_id' => array(
        'description' => 'The block_inject region ID',
        'type' => 'int',
        'length' => 2,
      ),
      'nid' => array(
        'description' => 'The block_inject region ID',
        'type' => 'int',
        'length' => 5,
      ),
      'except_injection' => array(
        'description' => 'The status of the exception',
        'type' => 'int',
        'length' => 1,
      ),
      'offset' => array(
        'description' => 'Offset for the injecton',
        'type' => 'int',
        'length' => 1,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
  );
  return $schema;
}

/**
 * Updates the block_inject table to increase the node_type and node_name fields
 * to allow for more node types per region.
 */
function block_inject_update_7100() {
  db_change_field('block_inject', 'node_type', 'node_type', array(
    'type' => 'text',
  ), $keys_new = array());
  db_change_field('block_inject', 'node_name', 'node_name', array(
    'type' => 'text',
  ), $keys_new = array());
}

/**
 * Creates the block_inject_exceptions table
 */
function block_inject_update_7101() {
  $table = array(
    'description' => 'The exceptions table.',
    'fields' => array(
      'id' => array(
        'description' => 'The id',
        'type' => 'serial',
        'length' => 5,
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'bi_id' => array(
        'description' => 'The block_inject region ID',
        'type' => 'int',
        'length' => 2,
      ),
      'nid' => array(
        'description' => 'The block_inject region ID',
        'type' => 'int',
        'length' => 5,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  db_create_table('block_inject_exceptions', $table);
}

/**
 * Updates the block_inject_exceptions table to add 2 new columns: status of the injection expception and the offset
 */
function block_inject_update_7102() {
  $exception_status_field = array(
    'description' => 'The status of the exception',
    'type' => 'int',
    'length' => 1,
  );
  $offset_field = array(
    'description' => 'Offset for the injecton',
    'type' => 'int',
    'length' => 1,
  );
  db_add_field('block_inject_exceptions', 'except_injection', $exception_status_field, $keys_new = array());
  db_add_field('block_inject_exceptions', 'offset', $offset_field, $keys_new = array());
}

/**
 * Updates the block_inject table to add the condition column
 */
function block_inject_update_7103() {
  $condition = array(
    'description' => 'The condition if any',
    'type' => 'text',
    'default' => NULL,
    'serialize' => TRUE,
  );
  db_add_field('block_inject', 'bi_condition', $condition, $keys_new = array());
}

/**
 * Add index on nid to block_inject_exceptions.
 */
function block_inject_update_7104() {
  $schema = block_inject_schema();
  db_add_index('block_inject_exceptions', 'nid', $schema['block_inject_exceptions']['indexes']['nid']);
}

Functions

Namesort descending Description
block_inject_schema
block_inject_update_7100 Updates the block_inject table to increase the node_type and node_name fields to allow for more node types per region.
block_inject_update_7101 Creates the block_inject_exceptions table
block_inject_update_7102 Updates the block_inject_exceptions table to add 2 new columns: status of the injection expception and the offset
block_inject_update_7103 Updates the block_inject table to add the condition column
block_inject_update_7104 Add index on nid to block_inject_exceptions.