<?php
// $Id: cart.install,v 1.3 2006/05/09 12:23:36 gordon Exp $

/**
 * E-Commerce cart module schema
 */
function cart_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {ec_cart} (
        cookie_id varchar(32) NOT NULL default '0',
        nid int(10) NOT NULL default '0',
        qty int(10) NOT NULL default '0',
        changed int(11) NOT NULL default '0',
        data text,
        KEY cookie_id (cookie_id)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {ec_tmp} (
        sid varchar(32) NOT NULL default '',
        tmp text NOT NULL,
        PRIMARY KEY  (sid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
       db_query("CREATE TABLE {ec_cart} (
        cookie_id varchar(32) NOT NULL default '0',
        nid integer NOT NULL default '0',
        qty integer NOT NULL default '0',
        changed integer NOT NULL default '0',
        data text
      )");
      db_query("CREATE INDEX {ec_cart}_cookie_id ON {ec_cart} (cookie_id)");
      db_query("CREATE TABLE {ec_tmp} (
        sid varchar(32) NOT NULL default '',
        tmp text NOT NULL,
        PRIMARY KEY  (sid)
      )");
      break;
  }
}

