CREATE TABLE IF NOT EXISTS `configuration` (
  `config_id` int(11) NOT NULL auto_increment,
  `config_name` text collate utf8_unicode_ci NOT NULL,
  `config_pname` text collate utf8_unicode_ci NOT NULL,
  `config_description` text collate utf8_unicode_ci NOT NULL,
  `config_value` text collate utf8_unicode_ci NOT NULL,
  `config_type` char(1) collate utf8_unicode_ci NOT NULL default 's',
  PRIMARY KEY  (`config_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `coupons` (
  `coupon_id` int(10) unsigned NOT NULL auto_increment,
  `coupon_name` varchar(10) collate utf8_unicode_ci NOT NULL,
  `coupon_pname` text collate utf8_unicode_ci NOT NULL,
  `coupon_type` tinyint(1) NOT NULL default '0' COMMENT '0 = $, 1 = %',
  `coupon_appliesto` tinyint(1) NOT NULL default '0' COMMENT '0 = cart, else = itemid',
  `coupon_value` float unsigned NOT NULL COMMENT 'positive value -- percent or value OFF of initial price',
  `coupon_quantity` int(11) NOT NULL COMMENT 'negative 1 signifies a limitless quantity',
  `coupon_expire` timestamp NOT NULL default CURRENT_TIMESTAMP COMMENT 'can be set to any given time of day on any given day',
  PRIMARY KEY  (`coupon_id`),
  KEY `coupon_name` (`coupon_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `categories` (
  `cat_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  `cat_name` TEXT NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `products_categories` (
  `cat_id` INT UNSIGNED NOT NULL ,
  `product_id` INT UNSIGNED NOT NULL,
  PRIMARY KEY  (`cat_id`,`product_id`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `pending_purchases` (
  `unique_token` varchar(32) collate utf8_unicode_ci NOT NULL,
  `user_id` int(11) NOT NULL,
  `user_cart` text collate utf8_unicode_ci NOT NULL,
  `date` timestamp NOT NULL default CURRENT_TIMESTAMP,
  UNIQUE KEY `unique_token` (`unique_token`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `products` (
  `product_id` int(11) unsigned NOT NULL auto_increment,
  `product_name` text collate utf8_unicode_ci NOT NULL,
  `product_description` text collate utf8_unicode_ci NOT NULL,
  `product_fullinfo` text collate utf8_unicode_ci NOT NULL,
  `product_image` text collate utf8_unicode_ci NOT NULL,
  `product_price` decimal(7,2) unsigned NOT NULL,
  `product_instock` int(10) NOT NULL,
  `product_link` text collate utf8_unicode_ci NOT NULL,
  `product_public` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`product_id`),
  FULLTEXT KEY `product_text` (`product_name`,`product_description`,`product_fullinfo`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `purchases` (
  `purchase_id` int(10) unsigned NOT NULL auto_increment,
  `user_id` int(10) unsigned NOT NULL,
  `product_id` int(10) unsigned NOT NULL,
  `product_name` text collate utf8_unicode_ci NOT NULL,
  `product_link` text collate utf8_unicode_ci NOT NULL,
  `purchase_quantity` int(10) unsigned NOT NULL,
  `purchase_paid` tinyint(1) NOT NULL default '0',
  `purchase_date` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`purchase_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



CREATE TABLE IF NOT EXISTS `users` (
  `user_id` int(10) unsigned NOT NULL auto_increment,
  `user_name` text collate utf8_unicode_ci NOT NULL,
  `user_paypal` varchar(100) collate utf8_unicode_ci NOT NULL,
  `user_ips` text collate utf8_unicode_ci NOT NULL,
  `user_balance` float NOT NULL,
  `user_password` varchar(40) collate utf8_unicode_ci NOT NULL,
  `user_salt` varchar(8) collate utf8_unicode_ci NOT NULL,
  `user_otheremail` varchar(100) collate utf8_unicode_ci NOT NULL,
  `user_realname` text collate utf8_unicode_ci NOT NULL,
  `user_streetaddress` text collate utf8_unicode_ci NOT NULL,
  `user_streetaddress2` text collate utf8_unicode_ci NOT NULL,
  `user_city` text collate utf8_unicode_ci NOT NULL,
  `user_state` text collate utf8_unicode_ci NOT NULL,
  `user_postalcode` text collate utf8_unicode_ci NOT NULL,
  `user_country` char(3) collate utf8_unicode_ci NOT NULL,
  `user_currentcart` text collate utf8_unicode_ci NOT NULL,
  `user_permissions` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
