You are here

function uc_product_schema in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_product/uc_product.install \uc_product_schema()
  2. 7.3 uc_product/uc_product.install \uc_product_schema()

Implements hook_schema().

File

uc_product/uc_product.install, line 11
Install, update and uninstall functions for the uc_product module.

Code

function uc_product_schema() {
  $schema = array();
  $schema['uc_product_classes'] = array(
    'description' => 'The list of product node types.',
    'fields' => array(
      'pcid' => array(
        'description' => 'The node type identifier.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The human-readable name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'The description of the node type.',
        'type' => 'text',
      ),
    ),
    'primary key' => array(
      'pcid',
    ),
  );
  $schema['uc_product_features'] = array(
    'description' => 'Stores information of features added to products.',
    'fields' => array(
      'pfid' => array(
        'description' => 'Primary key: the product feature id.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'The {node}.nid of the product that has this feature.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fid' => array(
        'description' => 'The type of feature.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'The description of the feature.',
        'type' => 'text',
      ),
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
    'primary key' => array(
      'pfid',
    ),
  );
  $schema['uc_products'] = array(
    'description' => 'Product information for nodes.',
    'fields' => array(
      'vid' => array(
        'description' => 'The {node}.vid of the product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'description' => 'The {node}.nid of the product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'model' => array(
        'description' => 'SKU or model number.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'list_price' => array(
        'description' => 'Suggested retail price.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'cost' => array(
        'description' => 'The amount the store pays to sell the product.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'sell_price' => array(
        'description' => 'The amount the customer pays for the product.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'weight' => array(
        'description' => 'Physical weight.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'weight_units' => array(
        'description' => 'Unit of measure for the weight field.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'lb',
      ),
      'length' => array(
        'description' => 'Physical length of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'width' => array(
        'description' => 'Physical width of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'height' => array(
        'description' => 'Physical height of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'length_units' => array(
        'description' => 'Unit of measure for the length, width, and height.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'in',
      ),
      'pkg_qty' => array(
        'description' => 'The number of this product that fit in one package.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'default_qty' => array(
        'description' => 'The default value for the quantity field in the "Add to Cart" form.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      'unique_hash' => array(
        'description' => 'A multi-site unique identifier for a product.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => md5(''),
      ),
      'ordering' => array(
        'description' => 'The sort criteria for products.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'shippable' => array(
        'description' => 'Boolean flag signifying that the product can be shipped.',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
    ),
    'indexes' => array(
      'nid' => array(
        'nid',
      ),
    ),
    'primary key' => array(
      'vid',
    ),
  );
  return $schema;
}