You are here

function uc_stock_schema in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_stock/uc_stock.install \uc_stock_schema()
  2. 7.3 uc_stock/uc_stock.install \uc_stock_schema()

Implements hook_schema().

File

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

Code

function uc_stock_schema() {
  $schema = [];
  $schema['uc_product_stock'] = [
    'description' => 'Stock levels for Ubercart products.',
    'fields' => [
      'sku' => [
        'description' => 'SKU (Stock Keeping Unit) of a product.',
        'type' => 'varchar',
        'length' => '191',
        'not null' => TRUE,
        'default' => '',
      ],
      'nid' => [
        'description' => 'Node ID of a product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'active' => [
        'description' => 'Boolean flag indicating whether stock is being tracked for this product. 1 => Yes. 0 => No.',
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'stock' => [
        'description' => 'Quantity in stock.',
        'type' => 'int',
        'size' => 'medium',
        'not null' => TRUE,
        'default' => 0,
      ],
      'threshold' => [
        'description' => 'Minimum quantity threshold level.',
        'type' => 'int',
        'size' => 'medium',
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'indexes' => [
      'nid' => [
        'nid',
      ],
    ],
    'primary key' => [
      'sku',
    ],
    'foreign keys' => [
      'uc_products' => [
        'table' => 'uc_products',
        'columns' => [
          'nid' => 'nid',
        ],
      ],
    ],
  ];
  return $schema;
}