You are here

function uc_attribute_install in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_attribute/uc_attribute.install \uc_attribute_install()

File

uc_attribute/uc_attribute.install, line 3

Code

function uc_attribute_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("CREATE TABLE {uc_attributes} (\n        `aid` mediumint(9) NOT NULL auto_increment,\n        `name` varchar(255) NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        `required` tinyint(2) NOT NULL default 0,\n        `display` tinyint(2) NOT NULL default 1,\n        `description` varchar(255) NOT NULL,\n        PRIMARY KEY (`aid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_attribute_options} (\n        `aid` mediumint(9) NOT NULL,\n        `oid` mediumint(9) NOT NULL auto_increment,\n        `name` varchar(255) NOT NULL,\n        `cost` decimal(10,2) NOT NULL,\n        `price` decimal(10,2) NOT NULL,\n        `weight` float NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        PRIMARY KEY (`oid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_class_attributes} (\n        `pcid` varchar(32) NOT NULL,\n        `aid` mediumint(9) NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        `default_option` mediumint(9) NOT NULL default '0',\n        `required` tinyint(2) NOT NULL default 0,\n        `display` tinyint(2) NOT NULL default 1,\n        PRIMARY KEY (`pcid`, `aid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_class_attribute_options} (\n        `pcid` varchar(32) NOT NULL,\n        `oid` mediumint(9) NOT NULL,\n        `cost` decimal(10,2) NOT NULL,\n        `price` decimal(10,2) NOT NULL,\n        `weight` float NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        PRIMARY KEY (`pcid`,`oid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_product_attributes} (\n        `nid` mediumint(9) NOT NULL,\n        `aid` mediumint(9) NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        `default_option` mediumint(9) NOT NULL default '0',\n        `required` tinyint(2) NOT NULL default 0,\n        `display` tinyint(2) NOT NULL default 1,\n        PRIMARY KEY (`nid`, `aid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_product_options} (\n        `nid` mediumint(9) NOT NULL,\n        `oid` mediumint(9) NOT NULL,\n        `cost` decimal(10,2) NOT NULL,\n        `price` decimal(10,2) NOT NULL,\n        `weight` float NOT NULL,\n        `ordering` tinyint(2) NOT NULL default 0,\n        PRIMARY KEY  (`nid`,`oid`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      db_query("CREATE TABLE {uc_product_adjustments} (\n        `nid` mediumint(9) NOT NULL,\n        `combination` varchar(255) NOT NULL,\n        `model` varchar(255) NOT NULL,\n        PRIMARY KEY  (`nid`, `combination`)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {uc_attributes} (\n        aid serial NOT NULL,\n        name varchar(255) NOT NULL default '',\n        ordering smallint NOT NULL default 0,\n        required smallint NOT NULL default 0,\n        display smallint NOT NULL default 1,\n        description varchar(255) NOT NULL default '',\n        PRIMARY KEY (aid)\n      );");
      db_query("CREATE TABLE {uc_attribute_options} (\n        aid integer NOT NULL default 0,\n        oid serial NOT NULL,\n        name varchar(255) NOT NULL default '',\n        cost decimal(10,2) NOT NULL default 0.00,\n        price decimal(10,2) NOT NULL default 0.00,\n        weight float NOT NULL default 0.0,\n        ordering smallint NOT NULL default 0,\n        PRIMARY KEY (oid)\n      ) WITHOUT OIDS;");
      db_query("CREATE TABLE {uc_class_attributes} (\n        pcid varchar(32) NOT NULL default '',\n        aid integer NOT NULL default 0,\n        ordering smallint NOT NULL default 0,\n        default_option integer NOT NULL default '0',\n        required smallint NOT NULL default 0,\n        display smallint NOT NULL default 1,\n        PRIMARY KEY (pcid, aid)\n      );");
      db_query("CREATE TABLE {uc_class_attribute_options} (\n        pcid varchar(32) NOT NULL default '',\n        oid integer NOT NULL default 0,\n        cost decimal(10,2) NOT NULL default 0.00,\n        price decimal(10,2) NOT NULL default 0.00,\n        weight float NOT NULL default 0.0,\n        ordering smallint NOT NULL default 0,\n        PRIMARY KEY (pcid,oid)\n      ) WITHOUT OIDS;");
      db_query("CREATE TABLE {uc_product_attributes} (\n        nid integer NOT NULL default 0,\n        aid integer NOT NULL default 0,\n        ordering smallint NOT NULL default 0,\n        default_option integer NOT NULL default 0,\n        required smallint NOT NULL default 0,\n        display smallint NOT NULL default 1,\n        PRIMARY KEY (nid, aid)\n      );");
      db_query("CREATE TABLE {uc_product_options} (\n        nid integer NOT NULL default 0,\n        oid integer NOT NULL default 0,\n        cost decimal(10,2) NOT NULL default 0.00,\n        price decimal(10,2) NOT NULL default 0.00,\n        weight float NOT NULL default 0,\n        ordering smallint NOT NULL default 0,\n        PRIMARY KEY  (nid,oid)\n      ) WITHOUT OIDS;");
      db_query("CREATE TABLE {uc_product_adjustments} (\n        nid integer NOT NULL default 0,\n        combination varchar(255) NOT NULL default '',\n        model varchar(255) NOT NULL default '',\n        PRIMARY KEY (nid, combination)\n      );");
      break;
  }
}