You are here

uc_dropdown_attributes.install in Dropdown Attributes 7

Same filename and directory in other branches
  1. 8 uc_dropdown_attributes.install
  2. 6 uc_dropdown_attributes.install

Install, update, and uninstall functions for the uc_dropdown_attributes module.

File

uc_dropdown_attributes.install
View source
<?php

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

/**
 * Implements hook_schema().
 */
function uc_dropdown_attributes_schema() {
  $schema['uc_dropdown_attributes'] = array(
    'description' => 'Stores attributes that are displayed depending on the value of another attribute.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Node id of product',
      ),
      'aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of child',
      ),
      'parent_aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of parent',
      ),
      'parent_values' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'normal',
        'description' => 'Values of the parent attribute that trigger the dependent attribute',
      ),
      'required' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether the dependent attribute is optional (0) or required (1)',
      ),
    ),
    'primary key' => array(
      'nid',
      'aid',
    ),
  );
  $schema['uc_dropdown_classes'] = array(
    'description' => 'Stores attributes that are displayed depending on the value of another attribute.',
    'fields' => array(
      'pcid' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'Product class id',
      ),
      'aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of child',
      ),
      'parent_aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of parent',
      ),
      'parent_values' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'normal',
        'description' => 'Values of the parent attribute that trigger the dependent attribute',
      ),
      'required' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether the dependent attribute is optional (0) or required (1)',
      ),
    ),
    'primary key' => array(
      'pcid',
      'aid',
    ),
  );
  return $schema;
}

/**
 * Adds the html field to {uc_dropdown_attributes}.
 */
function uc_dropdown_attributes_update_7000() {
  $spec = array(
    'type' => 'text',
    'not null' => TRUE,
    'initial' => '',
    'size' => 'normal',
    'description' => 'HTML code for attribute.',
  );
  db_add_field('uc_dropdown_attributes', 'html', $spec);
}

/**
 * Adds the {uc_dropdown_classes} table.
 */
function uc_dropdown_attributes_update_7001() {
  $schema['uc_dropdown_classes'] = array(
    'description' => 'Stores attributes that are displayed depending on the value of another attribute.',
    'fields' => array(
      'pcid' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'description' => 'Product class id',
      ),
      'aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of child',
      ),
      'parent_aid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Attribute id of parent',
      ),
      'parent_values' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'normal',
        'description' => 'Values of the parent attribute that trigger the dependent attribute',
      ),
      'required' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Whether the dependent attribute is optional (0) or required (1)',
      ),
      'html' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'normal',
        'description' => 'HTML code for attribute.',
      ),
    ),
    'primary key' => array(
      'pcid',
      'aid',
    ),
  );
  db_create_table('uc_dropdown_classes', $schema['uc_dropdown_classes']);
}

/**
 * Drops the html field.
 */
function uc_dropdown_attributes_update_7002() {
  db_drop_field('uc_dropdown_attributes', 'html');
  db_drop_field('uc_dropdown_classes', 'html');
}

Functions

Namesort descending Description
uc_dropdown_attributes_schema Implements hook_schema().
uc_dropdown_attributes_update_7000 Adds the html field to {uc_dropdown_attributes}.
uc_dropdown_attributes_update_7001 Adds the {uc_dropdown_classes} table.
uc_dropdown_attributes_update_7002 Drops the html field.