You are here

uc_stock.install in Ubercart 5

File

uc_stock/uc_stock.install
View source
<?php

function uc_stock_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE {uc_product_stock} (\n        `sku` varchar(255) NOT NULL,\n        `nid` mediumint(9) NOT NULL,\n        `active` tinyint(2) NOT NULL default 0,\n        `stock` mediumint(11) NOT NULL default 0,\n        `threshold` mediumint(11) NOT NULL default 0,\n        PRIMARY KEY (`sku`),\n        KEY nid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {uc_product_stock} (\n        sku varchar(255) NOT NULL default '',\n        nid integer NOT NULL default 0,\n        active smallint NOT NULL default 0,\n        stock integer NOT NULL default 0,\n        threshold integer NOT NULL default 0,\n        PRIMARY KEY (sku)\n      );");
      db_query("CREATE INDEX {uc_product_stock}_nid ON {uc_product_stock} (nid)");
      break;
  }
  variable_del('uc_stock_threshold_notification');
  variable_del('uc_stock_threshold_notification_recipients');
  variable_del('uc_stock_threshold_notification_subject');
  variable_del('uc_stock_threshold_notification_message');
  variable_del('uc_stock_threshold_notification_format');
}
function uc_stock_uninstall() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("DROP TABLE IF EXISTS {uc_product_stock}");
      break;
    case 'pgsql':
      db_query("DROP TABLE {uc_product_stock}");
      break;
  }
}

Functions