You are here

function uc_product_install in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_product/uc_product.install \uc_product_install()

Ubercart uc_product.module schema

File

uc_product/uc_product.install, line 11
Database installation, uninstallation, and updates for the product module.

Code

function uc_product_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {uc_product_classes} (\n        `pcid` varchar(32) NOT NULL,\n        `name` varchar(255) NOT NULL,\n        `description` text,\n        PRIMARY KEY  (`pcid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_product_features} (\n        `pfid` mediumint(9) NOT NULL default 0,\n        `nid` mediumint(9) NOT NULL default 0,\n        `fid` varchar(32) NOT NULL,\n        `description` text,\n        PRIMARY KEY (`pfid`),\n        KEY nid (nid)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_products} (\n        `vid` mediumint(9) NOT NULL default 0,\n        `nid` mediumint(9) NOT NULL default 0,\n        `model` varchar(255) NOT NULL default '',\n        `list_price` decimal(10,2) NOT NULL default 0.00,\n        `cost` decimal(10,2) NOT NULL default 0.00,\n        `sell_price` decimal(10,2) NOT NULL default 0.00,\n        `weight` float NOT NULL default 0,\n        `weight_units` varchar(255) NOT NULL default 'lb',\n        `length` float unsigned NOT NULL default 0,\n        `width` float unsigned NOT NULL default 0,\n        `height` float unsigned NOT NULL default 0,\n        `length_units` varchar(255) NOT NULL default 'in',\n        `pkg_qty` smallint unsigned NOT NULL default 1,\n        `default_qty` smallint(5) unsigned NOT NULL default 1,\n        `unique_hash` varchar(32) NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        `shippable` tinyint(2) NOT NULL default 1,\n        PRIMARY KEY  (`vid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      break;
    case "pgsql":
      db_query("CREATE TABLE {uc_product_classes} (\n        pcid varchar(32) NOT NULL default '',\n        name varchar(255) NOT NULL default '',\n        description text,\n        PRIMARY KEY  (pcid)\n      );");
      db_query("CREATE TABLE {uc_product_features} (\n        pfid serial NOT NULL,\n        nid integer NOT NULL default 0,\n        fid varchar(32) NOT NULL,\n        description text,\n        PRIMARY KEY (pfid)\n      );");
      db_query("CREATE INDEX {uc_product_features}_nid ON {uc_product_features} (nid)");
      db_query("CREATE TABLE {uc_products} (\n        vid integer NOT NULL default 0,\n        nid integer NOT NULL default 0,\n        model varchar(255) NOT NULL default '',\n        list_price decimal(10,2) NOT NULL default 0.00,\n        cost decimal(10,2) NOT NULL default 0.00,\n        sell_price decimal(10,2) NOT NULL default 0.00,\n        weight float NOT NULL default 0,\n        weight_units varchar(255) NOT NULL default 'lb',\n        length float NOT NULL default 0,\n        width float NOT NULL default 0,\n        height float NOT NULL default 0,\n        length_units varchar(255) NOT NULL default 'in',\n        pkg_qty smallint_unsigned NOT NULL default 1,\n        default_qty smallint_unsigned NOT NULL default 1,\n        unique_hash varchar(32) NOT NULL default '',\n        ordering smallint NOT NULL default 0,\n        shippable smallint NOT NULL default 1,\n        PRIMARY KEY (vid)\n      );");
      break;
  }
}