You are here

function uc_product_schema in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 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 14
Install, update and uninstall functions for the uc_product module.

Code

function uc_product_schema() {
  $schema = [];
  $schema['uc_product_features'] = [
    'description' => 'Stores information of features added to products.',
    'fields' => [
      'pfid' => [
        'description' => 'Primary key: the product feature id.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'nid' => [
        'description' => 'The {node}.nid of the product that has this feature.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'fid' => [
        'description' => 'The type of feature.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ],
      'description' => [
        'description' => 'The description of the feature.',
        'type' => 'text',
      ],
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
    ],
    'primary key' => [
      'pfid',
    ],
    'foreign keys' => [
      'uc_product' => [
        'table' => 'uc_product',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
    ],
  ];
  $schema['uc_products'] = [
    'description' => 'Product information for nodes.',
    'fields' => [
      'vid' => [
        'description' => 'The {node}.vid of the product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'nid' => [
        'description' => 'The {node}.nid of the product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'model' => [
        'description' => 'SKU or model number.',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ],
      'cost' => [
        'description' => 'The amount the store pays to sell the product.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'price' => [
        'description' => 'The amount the customer pays for the product.',
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'weight' => [
        'description' => 'Physical weight.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'weight_units' => [
        'description' => 'Unit of measure for the weight field.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'lb',
      ],
      'length' => [
        'description' => 'Physical length of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'width' => [
        'description' => 'Physical width of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'height' => [
        'description' => 'Physical height of the product or its packaging.',
        'type' => 'float',
        'not null' => TRUE,
        'default' => 0.0,
      ],
      'length_units' => [
        'description' => 'Unit of measure for the length, width, and height.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'in',
      ],
      'pkg_qty' => [
        'description' => 'The number of this product that fit in one package.',
        'type' => 'int',
        'size' => 'small',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
      'default_qty' => [
        '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,
      ],
      'shippable' => [
        'description' => 'Boolean flag signifying that the product can be shipped.',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
    ],
    'primary key' => [
      'vid',
    ],
    'foreign keys' => [
      'node' => [
        'table' => 'node',
        'columns' => [
          'nid' => 'nid',
          'vid' => 'vid',
        ],
      ],
    ],
  ];
  return $schema;
}