You are here

commerce_option.install in Commerce Product Option 7

Same filename and directory in other branches
  1. 7.2 commerce_option.install

File

commerce_option.install
View source
<?php

/**
 * Implements hook_schema().
 */
function commerce_option_schema() {
  $schema = array();
  $schema['commerce_option'] = array(
    'description' => 'The base table for option lines.',
    'fields' => array(
      'option_id' => array(
        'description' => 'The primary identifier for the option.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'set_id' => array(
        'description' => 'The {commerce_option_set}.set_id of this.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'product_id' => array(
        'description' => 'The {commerce_product}.product_id which is linked with this option.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'field_name' => array(
        'description' => 'The {commerce_product} field_name which is linked with this option.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'field_delta' => array(
        'description' => 'The {commerce_product} field delta which is linked with this option.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'line_item_id' => array(
        'description' => 'The {commerce_line_item}.line_item_id that is linked with this option.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the option was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the product was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
    ),
    'primary key' => array(
      'option_id',
    ),
    'indexes' => array(
      'set_id' => array(
        'set_id',
      ),
    ),
    'foreign keys' => array(
      'line_item' => array(
        'table' => 'commerce_line_item',
        'columns' => array(
          'line_item_id' => 'line_item_id',
        ),
      ),
    ),
  );
  $schema['commerce_option_set'] = array(
    'description' => 'Stores information about {commerce_option} sets.',
    'fields' => array(
      'set_id' => array(
        'description' => 'The machine-readable name of this set.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The human-readable name of this set.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'A brief description of this set.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this option set.',
      ),
    ),
    'primary key' => array(
      'set_id',
    ),
  );
  return $schema;
}

/**
 * Add new field, which are used to track the line item with the exact option
 * value on the view page.
 *
 */
function commerce_option_update_7100() {
  db_add_field('commerce_option', 'product_id', array(
    'description' => 'The {commerce_product}.product_id which is linked with this option.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field('commerce_option', 'field_name', array(
    'description' => 'The {commerce_product} field_name which is linked with this option.',
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field('commerce_option', 'field_delta', array(
    'description' => 'The {commerce_product} field delta which is linked with this option.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field('commerce_option_set', 'data', array(
    'type' => 'text',
    'not null' => FALSE,
    'size' => 'big',
    'serialize' => TRUE,
    'description' => 'A serialized array of additional data related to this option set.',
  ));
  return t('Add new fields to the product option entity.');
}

Functions

Namesort descending Description
commerce_option_schema Implements hook_schema().
commerce_option_update_7100 Add new field, which are used to track the line item with the exact option value on the view page.