You are here

tb_megamenu.install in The Better Mega Menu 7

Same filename and directory in other branches
  1. 8 tb_megamenu.install
  2. 2.x tb_megamenu.install

File

tb_megamenu.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function tb_megamenu_schema() {
  $schema = array();
  $schema['tb_megamenus'] = array(
    'fields' => array(
      'menu_name' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'block_config' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => FALSE,
      ),
      'menu_config' => array(
        'type' => 'text',
        'size' => 'medium',
        'not null' => FALSE,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => '12',
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'menu_name',
      'language',
    ),
  );
  return $schema;
}

/**
 * Add language field.
 */
function tb_megamenu_update_7101(&$sandbox) {

  // remove existing primary key
  db_query("ALTER TABLE {tb_megamenus} DROP primary key");
  $field = array(
    'type' => 'varchar',
    'length' => 12,
    'not null' => TRUE,
    'default' => '',
  );
  $keys_new = array(
    'primary key' => array(
      'menu_name',
      'language',
    ),
  );
  db_add_field('tb_megamenus', 'language', $field, $keys_new);

  // set all existing menus to current language
  db_query("UPDATE {tb_megamenus} SET language = :language", array(
    ':language' => $GLOBALS['language']->language,
  ));
  return t('Added language field and set all existing menus to current language');
}

/**
 * Deprecated update - rolled into 7101 to prevent possible data loss.
 */
function tb_megamenu_update_7102(&$sandbox) {
}

/**
 * Increase size of config columns to accommodate larger menus.
 */
function tb_megamenu_update_7103(&$sandbox) {

  // Increase column sizes so large menus can be saved properly.
  db_change_field('tb_megamenus', 'block_config', 'block_config', array(
    'type' => 'text',
    'size' => 'medium',
    'not null' => FALSE,
  ));
  db_change_field('tb_megamenus', 'menu_config', 'menu_config', array(
    'type' => 'text',
    'size' => 'medium',
    'not null' => FALSE,
  ));
}

Functions

Namesort descending Description
tb_megamenu_schema Implementation of hook_schema().
tb_megamenu_update_7101 Add language field.
tb_megamenu_update_7102 Deprecated update - rolled into 7101 to prevent possible data loss.
tb_megamenu_update_7103 Increase size of config columns to accommodate larger menus.