You are here

uc_product_minmax.install in Ubercart Product Minimum & Maximum 6

Same filename and directory in other branches
  1. 7 uc_product_minmax.install

File

uc_product_minmax.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function uc_product_minmax_schema() {
  $schema['uc_product_minmax'] = array(
    'fields' => array(
      'pfid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'product_min' => array(
        'type' => 'int',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'pmin_multiple' => array(
        'type' => 'int',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'product_max' => array(
        'type' => 'int',
        'size' => 'medium',
        'not null' => TRUE,
      ),
      'display_min' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'display_multiple' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'display_max' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'display_weight' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}
function uc_product_minmax_install() {

  // Create tables.
  drupal_install_schema('uc_product_minmax');
}
function uc_product_minmax_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('uc_product_minmax');
  update_sql("DELETE FROM {uc_product_features} WHERE fid = 'minmax'");
}
function uc_product_minmax_update_6001() {
  $ret = array();
  db_add_field($ret, 'uc_product_minmax', 'display_min', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  db_add_field($ret, 'uc_product_minmax', 'display_max', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  db_add_field($ret, 'uc_product_minmax', 'weight', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  return $ret;
}
function uc_product_minmax_update_6002() {
  $ret = array();
  db_add_field($ret, 'uc_product_minmax', 'display_weight', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  return $ret;
}
function uc_product_minmax_update_6003() {
  $ret = array();
  db_add_field($ret, 'uc_product_minmax', 'display_multiple', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
  ));
  db_change_field($ret, 'uc_product_minmax', 'pmin_multiple', 'pmin_multiple', array(
    'type' => 'int',
    'size' => 'medium',
    'not null' => TRUE,
  ));
  db_query("UPDATE {uc_product_minmax} SET pmin_multiple = product_min WHERE pmin_multiple = 1");
  db_query("UPDATE {uc_product_minmax} SET display_multiple = 1 WHERE display_min = 1");
  return $ret;
}