You are here

vars.install in Variable API 6

Same filename and directory in other branches
  1. 6.2 vars.install
  2. 7.2 vars.install
  3. 7 vars.install

Install, update and uninstall functions for the Variable API module.

File

vars.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Variable API module.
 */

/**
 * Implements hook_schema().
 */
function vars_schema() {
  $schema = array();
  $schema['variable_default'] = array(
    'description' => 'The default values for the variables as set by the modules.',
    'fields' => array(
      'vdid' => array(
        'description' => 'The primary key.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'module' => array(
        'description' => 'The module owning the variable.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The name of the variable.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'description' => 'The value of the variable.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'flags' => array(
        'description' => 'Flags associated with the variable.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
    ),
    'indexes' => array(
      'module' => array(
        array(
          'module',
          32,
        ),
      ),
      'name' => array(
        array(
          'name',
          32,
        ),
      ),
      'flags' => array(
        'flags',
      ),
    ),
    'unique key' => array(
      'module_name' => array(
        'module',
        'name',
      ),
    ),
    'primary key' => array(
      'vdid',
    ),
  );
  $schema['cache_vars'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_vars']['description'] = 'Cache table for the Variable API module.';
  return $schema;
}

/**
 * Implements hook_install().
 */
function vars_install() {
  drupal_install_schema('vars');
  db_query("UPDATE {system} SET weight = -99 WHERE name = 'vars' AND type = 'module'");
}

/**
 * Implements hook_update_N().
 */
function vars_update_6102() {
  $ret = array();
  cache_clear_all('*', 'cache_vars', TRUE);
  $ret[] = array(
    'success' => TRUE,
    'query' => 'Flushed the module cache',
  );
  return $ret;
}

/**
 * Implements hook_update_N().
 */
function vars_update_6103() {
  $ret = array();
  $ret[] = update_sql("UPDATE {system} SET weight = -99 WHERE name = 'vars' AND type = 'module'");
  return $ret;
}

/**
 * Implements hook_uninstall().
 */
function vars_uninstall() {
  drupal_uninstall_schema('vars');
}

Functions

Namesort descending Description
vars_install Implements hook_install().
vars_schema Implements hook_schema().
vars_uninstall Implements hook_uninstall().
vars_update_6102 Implements hook_update_N().
vars_update_6103 Implements hook_update_N().