CREATE TABLE `exp_store_config` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `preference` varchar(255) DEFAULT NULL,
  `value` text,
  PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_countries` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `code` char(2) NOT NULL DEFAULT '',
  `name` varchar(255) NOT NULL DEFAULT '',
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_discounts` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `name` varchar(255) DEFAULT NULL,
  `code` varchar(255) NOT NULL DEFAULT '',
  `start_date` int(10) unsigned DEFAULT NULL,
  `end_date` int(10) unsigned DEFAULT NULL,
  `member_group_ids` varchar(255) DEFAULT NULL,
  `entry_ids` varchar(255) DEFAULT NULL,
  `category_ids` varchar(255) DEFAULT NULL,
  `exclude_on_sale` tinyint(1) NOT NULL DEFAULT '0',
  `type` varchar(10) NOT NULL DEFAULT '',
  `purchase_qty` int(4) unsigned DEFAULT NULL,
  `purchase_total` decimal(19,4) DEFAULT NULL,
  `step_qty` int(4) unsigned DEFAULT NULL,
  `discount_qty` int(4) unsigned DEFAULT NULL,
  `match_items_on` varchar(50) DEFAULT NULL,
  `base_discount` decimal(19,4) DEFAULT NULL,
  `per_item_discount` decimal(19,4) DEFAULT NULL,
  `percent_discount` decimal(8,5) DEFAULT NULL,
  `free_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `per_user_limit` int(4) unsigned DEFAULT NULL,
  `total_use_limit` int(4) unsigned DEFAULT NULL,
  `total_use_count` int(4) unsigned NOT NULL DEFAULT '0',
  `break` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text,
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `site_id` (`site_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_emails` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL,
  `name` varchar(30) NOT NULL,
  `subject` varchar(100) NOT NULL,
  `contents` text NOT NULL,
  `bcc` varchar(255) DEFAULT NULL,
  `to` varchar(255) DEFAULT NULL,
  `mail_format` varchar(5) NOT NULL,
  `word_wrap` tinyint(1) NOT NULL DEFAULT '0',
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `site_id` (`site_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_order_adjustments` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `order_id` int(10) unsigned NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '',
  `type` varchar(32) NOT NULL DEFAULT '',
  `rate` decimal(8,5) NOT NULL DEFAULT '0.00000',
  `amount` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `taxable` tinyint(1) NOT NULL DEFAULT '0',
  `included` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_order_history` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `order_id` int(10) unsigned NOT NULL,
  `order_status_name` varchar(20) NOT NULL DEFAULT '',
  `order_status_updated` int(10) unsigned NOT NULL DEFAULT '0',
  `order_status_member_id` int(10) NOT NULL DEFAULT '0',
  `order_status_message` text,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_order_items` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `order_id` int(10) unsigned NOT NULL,
  `entry_id` int(10) unsigned DEFAULT NULL,
  `stock_id` int(10) NOT NULL DEFAULT '0',
  `sku` varchar(255) DEFAULT NULL,
  `title` varchar(100) NOT NULL,
  `url_title` varchar(255) NOT NULL DEFAULT '',
  `channel_id` int(10) NOT NULL DEFAULT '0',
  `category_ids` varchar(255) DEFAULT NULL,
  `modifiers` text,
  `price` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `regular_price` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `on_sale` tinyint(1) NOT NULL DEFAULT '0',
  `weight` double DEFAULT NULL,
  `length` double DEFAULT NULL,
  `width` double DEFAULT NULL,
  `height` double DEFAULT NULL,
  `handling` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `handling_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `free_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `tax_exempt` tinyint(1) NOT NULL DEFAULT '0',
  `item_qty` int(4) unsigned NOT NULL DEFAULT '0',
  `item_subtotal` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `item_discount` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `item_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `item_total` decimal(19,4) NOT NULL DEFAULT '0.0000',
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_orders` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL,
  `order_id` int(10) unsigned DEFAULT NULL,
  `order_hash` varchar(32) NOT NULL,
  `member_id` int(10) unsigned DEFAULT NULL,
  `order_date` int(10) unsigned NOT NULL,
  `order_completed_date` int(10) unsigned DEFAULT NULL,
  `ip_address` varchar(40) NOT NULL,
  `order_status_name` varchar(20) DEFAULT NULL,
  `order_status_updated` int(10) unsigned DEFAULT NULL,
  `order_status_member_id` int(10) DEFAULT NULL,
  `order_status_message` text,
  `order_qty` int(4) unsigned NOT NULL DEFAULT '0',
  `order_subtotal` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_subtotal_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_discount` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_discount_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_shipping` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_shipping_discount` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_shipping_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_shipping_total` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_handling` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_handling_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_handling_total` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_tax` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_total` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_paid` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `order_paid_date` int(10) unsigned DEFAULT NULL,
  `order_email` varchar(100) DEFAULT NULL,
  `discount_id` int(10) unsigned DEFAULT NULL,
  `promo_code` varchar(255) DEFAULT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `shipping_method_name` varchar(255) DEFAULT NULL,
  `shipping_method` varchar(255) DEFAULT NULL,
  `shipping_method_class` varchar(255) DEFAULT NULL,
  `shipping_method_rule` varchar(50) DEFAULT NULL,
  `shipping_override` text DEFAULT NULL,
  `tax_id` int(10) unsigned DEFAULT NULL,
  `tax_name` varchar(40) DEFAULT NULL,
  `tax_rate` decimal(8,5) NOT NULL DEFAULT '0.00000',
  `tax_override` text NOT NULL,
  `order_length` double NOT NULL DEFAULT '0',
  `order_width` double NOT NULL DEFAULT '0',
  `order_height` double NOT NULL DEFAULT '0',
  `dimension_units` varchar(5) NOT NULL DEFAULT '',
  `order_weight` double NOT NULL DEFAULT '0',
  `weight_units` varchar(5) NOT NULL DEFAULT '',
  `billing_first_name` varchar(255) DEFAULT NULL,
  `billing_last_name` varchar(255) DEFAULT NULL,
  `billing_address1` varchar(255) DEFAULT NULL,
  `billing_address2` varchar(255) DEFAULT NULL,
  `billing_city` varchar(255) DEFAULT NULL,
  `billing_state` varchar(255) DEFAULT NULL,
  `billing_country` char(2) DEFAULT NULL,
  `billing_postcode` varchar(255) DEFAULT NULL,
  `billing_phone` varchar(255) DEFAULT NULL,
  `billing_company` varchar(255) DEFAULT NULL,
  `shipping_first_name` varchar(255) DEFAULT NULL,
  `shipping_last_name` varchar(255) DEFAULT NULL,
  `shipping_address1` varchar(255) DEFAULT NULL,
  `shipping_address2` varchar(255) DEFAULT NULL,
  `shipping_city` varchar(255) DEFAULT NULL,
  `shipping_state` varchar(255) DEFAULT NULL,
  `shipping_country` char(2) DEFAULT NULL,
  `shipping_postcode` varchar(255) DEFAULT NULL,
  `shipping_phone` varchar(255) DEFAULT NULL,
  `shipping_company` varchar(255) DEFAULT NULL,
  `billing_same_as_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `shipping_same_as_billing` tinyint(1) NOT NULL DEFAULT '0',
  `order_custom1` text,
  `order_custom2` text,
  `order_custom3` text,
  `order_custom4` text,
  `order_custom5` text,
  `order_custom6` text,
  `order_custom7` text,
  `order_custom8` text,
  `order_custom9` text,
  `return_url` varchar(255) DEFAULT NULL,
  `cancel_url` varchar(255) DEFAULT NULL,
  `ip_country` char(2) DEFAULT NULL,
  `member_data_loaded` tinyint(1) NOT NULL DEFAULT '0',
  `tax_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `accept_terms` tinyint(1) NOT NULL DEFAULT '0',
  `register_member` tinyint(1) NOT NULL DEFAULT '0',
  `username` varchar(255) DEFAULT NULL,
  `screen_name` varchar(255) DEFAULT NULL,
  `password_hash` varchar(255) DEFAULT NULL,
  `password_salt` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `order_hash` (`order_hash`),
  KEY `order_id` (`order_id`),
  KEY `site_id` (`site_id`),
  KEY `member_id` (`member_id`),
  KEY `order_date` (`order_date`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_payment_methods` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `class` varchar(255) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `settings` text,
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_product_modifiers` (
  `product_mod_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `entry_id` int(10) unsigned NOT NULL,
  `mod_type` varchar(20) NOT NULL,
  `mod_name` varchar(100) NOT NULL,
  `mod_instructions` text,
  `mod_order` int(4) unsigned NOT NULL,
  PRIMARY KEY (`product_mod_id`),
  KEY `entry_id` (`entry_id`),
  KEY `mod_order` (`mod_order`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_product_options` (
  `product_opt_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_mod_id` int(10) unsigned NOT NULL,
  `opt_name` varchar(100) NOT NULL,
  `opt_price_mod` decimal(19,4) DEFAULT NULL,
  `opt_order` int(4) unsigned NOT NULL,
  PRIMARY KEY (`product_opt_id`),
  KEY `product_mod_id` (`product_mod_id`),
  KEY `opt_order` (`opt_order`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_products` (
  `entry_id` int(10) unsigned NOT NULL DEFAULT '0',
  `price` decimal(19,4) DEFAULT NULL,
  `weight` double DEFAULT NULL,
  `length` double DEFAULT NULL,
  `width` double DEFAULT NULL,
  `height` double DEFAULT NULL,
  `handling` decimal(19,4) DEFAULT NULL,
  `free_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `tax_exempt` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`entry_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_sales` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `name` varchar(255) DEFAULT NULL,
  `start_date` int(10) unsigned DEFAULT NULL,
  `end_date` int(10) unsigned DEFAULT NULL,
  `member_group_ids` varchar(255) DEFAULT NULL,
  `entry_ids` varchar(255) DEFAULT NULL,
  `category_ids` varchar(255) DEFAULT NULL,
  `per_item_discount` decimal(19,4) DEFAULT NULL,
  `percent_discount` decimal(8,5) DEFAULT NULL,
  `notes` text,
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `site_id` (`site_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_shipping_methods` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `name` varchar(255) DEFAULT NULL,
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `site_id` (`site_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_shipping_rules` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `shipping_method_id` int(10) unsigned NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `country_code` char(2) DEFAULT NULL,
  `state_code` varchar(5) DEFAULT NULL,
  `postcode` varchar(10) NOT NULL DEFAULT '',
  `min_weight` double DEFAULT NULL,
  `max_weight` double DEFAULT NULL,
  `min_order_total` decimal(19,4) DEFAULT NULL,
  `max_order_total` decimal(19,4) DEFAULT NULL,
  `min_order_qty` int(4) unsigned DEFAULT NULL,
  `max_order_qty` int(4) unsigned DEFAULT NULL,
  `base_rate` decimal(19,4) DEFAULT NULL,
  `per_item_rate` decimal(19,4) DEFAULT NULL,
  `per_weight_rate` decimal(19,4) DEFAULT NULL,
  `percent_rate` double DEFAULT NULL,
  `min_rate` decimal(19,4) DEFAULT NULL,
  `max_rate` decimal(19,4) DEFAULT NULL,
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `shipping_method_id` (`shipping_method_id`),
  KEY `country_code` (`country_code`),
  KEY `region_code` (`state_code`),
  KEY `postcode` (`postcode`),
  KEY `enabled` (`enabled`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_states` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `country_id` int(10) unsigned NOT NULL DEFAULT '0',
  `code` varchar(5) NOT NULL DEFAULT '',
  `name` varchar(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `country_id` (`country_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_statuses` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL DEFAULT '0',
  `name` varchar(255) DEFAULT NULL,
  `color` varchar(255) DEFAULT NULL,
  `email_ids` varchar(255) DEFAULT NULL,
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `site_id` (`site_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_stock` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `entry_id` int(10) unsigned NOT NULL,
  `sku` varchar(255) DEFAULT NULL,
  `stock_level` int(4) DEFAULT NULL,
  `min_order_qty` int(4) DEFAULT NULL,
  `track_stock` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `sku` (`sku`),
  KEY `entry_id` (`entry_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_stock_options` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `stock_id` int(10) unsigned NOT NULL,
  `entry_id` int(10) unsigned NOT NULL,
  `sku` varchar(255) DEFAULT NULL,
  `product_mod_id` int(10) unsigned NOT NULL,
  `product_opt_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sku` (`sku`),
  KEY `stock_id` (`stock_id`),
  KEY `product_mod_id` (`product_mod_id`),
  KEY `product_opt_id` (`product_opt_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_taxes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL,
  `name` varchar(255) NOT NULL,
  `rate` decimal(8,5) NOT NULL,
  `country_code` char(2) DEFAULT NULL,
  `state_code` varchar(5) DEFAULT NULL,
  `apply_to_shipping` tinyint(1) NOT NULL DEFAULT '0',
  `included` tinyint(1) NOT NULL DEFAULT '0',
  `enabled` tinyint(1) NOT NULL DEFAULT '0',
  `sort` int(4) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_taxes_categories` (
  `tax_id` int(10) unsigned NOT NULL DEFAULT '0',
  `category_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`tax_id`,`category_id`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `exp_store_transactions` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(5) NOT NULL,
  `order_id` int(10) unsigned NOT NULL DEFAULT '0',
  `member_id` int(10) unsigned NOT NULL DEFAULT '0',
  `parent_id` int(10) unsigned DEFAULT NULL,
  `hash` varchar(32) NOT NULL DEFAULT '',
  `date` int(10) unsigned DEFAULT NULL,
  `payment_method` varchar(255) DEFAULT NULL,
  `type` varchar(10) DEFAULT NULL,
  `amount` decimal(19,4) NOT NULL DEFAULT '0.0000',
  `status` varchar(10) DEFAULT NULL,
  `reference` varchar(255) DEFAULT NULL,
  `message` text,
  `response_data` text,
  `brand` varchar(32) DEFAULT NULL,
  `last_four` char(4) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `hash` (`hash`)
) DEFAULT CHARSET=utf8;
