You are here

commerce_wishlist.install in Commerce Wishlist 7.2

File

commerce_wishlist.install
View source
<?php

/**
 * Implements hook_schema().
 */
function commerce_wishlist_schema() {
  $schema = array();
  $schema['commerce_wishlist'] = array(
    'description' => 'The base table for commerce wishlist',
    'fields' => array(
      'wishlist_id' => array(
        'description' => 'The primary identifier for a wishlist.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'User identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'wishlist_id',
    ),
    'indexes' => array(
      'wishlist_uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'owner' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['commerce_wishlist_item'] = array(
    'description' => 'Table for products in a Commerce wishlist',
    'fields' => array(
      'item_id' => array(
        'description' => 'The primary identifier for a wishlist item.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'wishlist_id' => array(
        'description' => 'The wishlist ID this item belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => 'Node identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'product_id' => array(
        'description' => 'Identifier for a product.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'quantity' => array(
        'type' => 'numeric',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => 0,
        'precision' => 10,
        'scale' => 2,
      ),
      'added' => array(
        'type' => 'int',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Timestamp for when the product was added to the wishlist.',
      ),
    ),
    'primary key' => array(
      'item_id',
    ),
    'foreign keys' => array(
      'commerce_wishlist' => array(
        'table' => 'commerce_wishlist',
        'columns' => array(
          'wishlist_id' => 'wishlist_id',
        ),
      ),
      'wishlist_product_display' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'wishlist_product' => array(
        'table' => 'commerce_product',
        'columns' => array(
          'product_id' => 'product_id',
        ),
      ),
    ),
    'indexes' => array(
      'item_added' => array(
        'added',
      ),
      'item_wishlist_id' => array(
        'wishlist_id',
      ),
      'item_product_id' => array(
        'product_id',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function commerce_wishlist_uninstall() {

  // Remove module variables.
  variable_del('commerce_wishlist_element');
  variable_del('commerce_wishlist_product_types');
  variable_del('commerce_wishlist_weight');
}

Functions