Модуль Delete Orders Pro

Наш ответ Керзону (очистка всех заказов и корзин, для thirty bees, структура таблиц может отличаться от PS) :
Код:
USE [your-database-name-here];

-- --------------------------------------------

DROP TABLE IF EXISTS [your-database-prefix].dc_cart;
CREATE TABLE [your-database-prefix].dc_cart (
  id_cart int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  id_shop_group int(11) UNSIGNED NOT NULL DEFAULT 1,
  id_shop int(11) UNSIGNED NOT NULL DEFAULT 1,
  id_carrier int(11) UNSIGNED NOT NULL,
  delivery_option text NOT NULL,
  id_lang int(11) UNSIGNED NOT NULL,
  id_address_delivery int(11) UNSIGNED NOT NULL,
  id_address_invoice int(11) UNSIGNED NOT NULL,
  id_currency int(11) UNSIGNED NOT NULL,
  id_customer int(11) UNSIGNED NOT NULL,
  id_guest int(11) UNSIGNED NOT NULL,
  secure_key varchar(32) NOT NULL DEFAULT '-1',
  recyclable tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
  gift tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  gift_message text DEFAULT NULL,
  mobile_theme tinyint(1) NOT NULL DEFAULT 0,
  allow_seperated_package tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  date_add datetime NOT NULL,
  date_upd datetime NOT NULL,
  PRIMARY KEY (id_cart)
)
ENGINE = INNODB,
AUTO_INCREMENT = 11,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX cart_customer (id_customer);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_address_delivery (id_address_delivery);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_address_invoice (id_address_invoice);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_carrier (id_carrier);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_currency (id_currency);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_guest (id_guest);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_lang (id_lang);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_shop (id_shop, date_add);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_shop_2 (id_shop, date_upd);

ALTER TABLE [your-database-prefix].dc_cart
ADD INDEX id_shop_group (id_shop_group);
-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_cart_product;
CREATE TABLE [your-database-prefix].dc_cart_product (
  id_cart int(11) UNSIGNED NOT NULL,
  id_product int(11) UNSIGNED NOT NULL,
  id_address_delivery int(11) UNSIGNED NOT NULL DEFAULT 0,
  id_shop int(11) UNSIGNED NOT NULL DEFAULT 1,
  id_product_attribute int(11) UNSIGNED NOT NULL DEFAULT 0,
  quantity int(11) UNSIGNED NOT NULL DEFAULT 0,
  date_add datetime NOT NULL,
  PRIMARY KEY (id_cart, id_product, id_product_attribute, id_address_delivery)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_cart_product
ADD INDEX id_cart_order (id_cart, date_add, id_product, id_product_attribute);

ALTER TABLE [your-database-prefix].dc_cart_product
ADD INDEX id_product_attribute (id_product_attribute);
-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_orders;
CREATE TABLE [your-database-prefix].dc_orders (
  id_order int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  reference varchar(32) DEFAULT NULL,
  id_shop_group int(11) UNSIGNED NOT NULL DEFAULT 1,
  id_shop int(11) UNSIGNED NOT NULL DEFAULT 1,
  id_carrier int(11) UNSIGNED NOT NULL,
  id_lang int(11) UNSIGNED NOT NULL,
  id_customer int(11) UNSIGNED NOT NULL,
  id_cart int(11) UNSIGNED NOT NULL,
  id_currency int(11) UNSIGNED NOT NULL,
  id_address_delivery int(11) UNSIGNED NOT NULL,
  id_address_invoice int(11) UNSIGNED NOT NULL,
  current_state int(11) UNSIGNED NOT NULL,
  secure_key varchar(32) NOT NULL DEFAULT '-1',
  payment varchar(255) NOT NULL,
  conversion_rate decimal(13, 6) NOT NULL DEFAULT 1.000000,
  module varchar(64) DEFAULT NULL,
  recyclable tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  gift tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  gift_message text DEFAULT NULL,
  mobile_theme tinyint(1) NOT NULL DEFAULT 0,
  shipping_number varchar(64) DEFAULT NULL,
  total_discounts decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_discounts_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_discounts_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid_real decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_products decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_products_wt decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  carrier_tax_rate decimal(10, 3) NOT NULL DEFAULT 0.000,
  total_wrapping decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_wrapping_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_wrapping_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  round_mode tinyint(1) NOT NULL DEFAULT 2,
  round_type tinyint(1) NOT NULL DEFAULT 1,
  invoice_number int(11) UNSIGNED NOT NULL DEFAULT 0,
  delivery_number int(11) UNSIGNED NOT NULL DEFAULT 0,
  invoice_date datetime NOT NULL,
  delivery_date datetime NOT NULL,
  valid int(1) UNSIGNED NOT NULL DEFAULT 0,
  date_add datetime NOT NULL,
  date_upd datetime NOT NULL,
  PRIMARY KEY (id_order)
)
ENGINE = INNODB,
AUTO_INCREMENT = 7,
AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX current_state (current_state);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX date_add (date_add);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_address_delivery (id_address_delivery);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_address_invoice (id_address_invoice);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_carrier (id_carrier);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_cart (id_cart);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_currency (id_currency);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_customer (id_customer);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_lang (id_lang);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_shop (id_shop);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX id_shop_group (id_shop_group);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX invoice_number (invoice_number);

ALTER TABLE [your-database-prefix].dc_orders
ADD INDEX reference (reference);
-- --------------------------------------------

DROP TABLE IF EXISTS [your-database-prefix].dc_order_carrier;
CREATE TABLE [your-database-prefix].dc_order_carrier (
  id_order_carrier int(11) NOT NULL AUTO_INCREMENT,
  id_order int(11) UNSIGNED NOT NULL,
  id_carrier int(11) UNSIGNED NOT NULL,
  id_order_invoice int(11) UNSIGNED DEFAULT NULL,
  weight decimal(20, 6) DEFAULT NULL,
  shipping_cost_tax_excl decimal(20, 6) DEFAULT NULL,
  shipping_cost_tax_incl decimal(20, 6) DEFAULT NULL,
  tracking_number varchar(64) DEFAULT NULL,
  date_add datetime NOT NULL,
  PRIMARY KEY (id_order_carrier)
)
ENGINE = INNODB,
AUTO_INCREMENT = 7,
AVG_ROW_LENGTH = 2730,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_carrier
ADD INDEX id_carrier (id_carrier);

ALTER TABLE [your-database-prefix].dc_order_carrier
ADD INDEX id_order (id_order);

ALTER TABLE [your-database-prefix].dc_order_carrier
ADD INDEX id_order_invoice (id_order_invoice);

-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_order_detail;
CREATE TABLE [your-database-prefix].dc_order_detail (
  id_order_detail int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  id_order int(11) UNSIGNED NOT NULL,
  id_order_invoice int(11) DEFAULT NULL,
  id_warehouse int(11) UNSIGNED DEFAULT 0,
  id_shop int(11) UNSIGNED NOT NULL,
  product_id int(11) UNSIGNED NOT NULL,
  product_attribute_id int(11) UNSIGNED DEFAULT NULL,
  product_name varchar(255) NOT NULL,
  product_quantity int(11) UNSIGNED NOT NULL DEFAULT 0,
  product_quantity_in_stock int(10) NOT NULL DEFAULT 0,
  product_quantity_refunded int(11) UNSIGNED NOT NULL DEFAULT 0,
  product_quantity_return int(11) UNSIGNED NOT NULL DEFAULT 0,
  product_quantity_reinjected int(11) UNSIGNED NOT NULL DEFAULT 0,
  product_price decimal(20, 6) NOT NULL DEFAULT 0.000000,
  reduction_percent decimal(10, 2) NOT NULL DEFAULT 0.00,
  reduction_amount decimal(20, 6) NOT NULL DEFAULT 0.000000,
  reduction_amount_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  reduction_amount_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  group_reduction decimal(10, 2) NOT NULL DEFAULT 0.00,
  product_quantity_discount decimal(20, 6) NOT NULL DEFAULT 0.000000,
  product_ean13 varchar(13) DEFAULT NULL,
  product_upc varchar(12) DEFAULT NULL,
  product_reference varchar(32) DEFAULT NULL,
  product_supplier_reference varchar(32) DEFAULT NULL,
  product_weight decimal(20, 6) NOT NULL,
  id_tax_rules_group int(11) UNSIGNED DEFAULT 0,
  tax_computation_method tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
  tax_name varchar(16) NOT NULL,
  tax_rate decimal(10, 3) NOT NULL DEFAULT 0.000,
  ecotax decimal(21, 6) NOT NULL DEFAULT 0.000000,
  ecotax_tax_rate decimal(5, 3) NOT NULL DEFAULT 0.000,
  discount_quantity_applied tinyint(1) NOT NULL DEFAULT 0,
  download_hash varchar(255) DEFAULT NULL,
  download_nb int(11) UNSIGNED DEFAULT 0,
  download_deadline datetime DEFAULT NULL,
  total_price_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_price_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  unit_price_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  unit_price_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_price_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_price_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  purchase_supplier_price decimal(20, 6) NOT NULL DEFAULT 0.000000,
  original_product_price decimal(20, 6) NOT NULL DEFAULT 0.000000,
  original_wholesale_price decimal(20, 6) NOT NULL DEFAULT 0.000000,
  PRIMARY KEY (id_order_detail)
)
ENGINE = INNODB,
AUTO_INCREMENT = 8,
AVG_ROW_LENGTH = 2340,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_detail
ADD INDEX id_order_id_order_detail (id_order, id_order_detail);

ALTER TABLE [your-database-prefix].dc_order_detail
ADD INDEX id_tax_rules_group (id_tax_rules_group);

ALTER TABLE [your-database-prefix].dc_order_detail
ADD INDEX order_detail_order (id_order);

ALTER TABLE [your-database-prefix].dc_order_detail
ADD INDEX product_attribute_id (product_attribute_id);

ALTER TABLE [your-database-prefix].dc_order_detail
ADD INDEX product_id (product_id);

-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_order_history;
CREATE TABLE [your-database-prefix].dc_order_history (
  id_order_history int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  id_employee int(11) UNSIGNED NOT NULL,
  id_order int(11) UNSIGNED NOT NULL,
  id_order_state int(11) UNSIGNED NOT NULL,
  date_add datetime NOT NULL,
  PRIMARY KEY (id_order_history)
)
ENGINE = INNODB,
AUTO_INCREMENT = 10,
AVG_ROW_LENGTH = 1820,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_history
ADD INDEX id_employee (id_employee);

ALTER TABLE [your-database-prefix].dc_order_history
ADD INDEX id_order_state (id_order_state);

ALTER TABLE [your-database-prefix].dc_order_history
ADD INDEX order_history_order (id_order);

-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_order_invoice;
CREATE TABLE [your-database-prefix].dc_order_invoice (
  id_order_invoice int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  id_order int(11) NOT NULL,
  number int(11) NOT NULL,
  delivery_number int(11) NOT NULL,
  delivery_date datetime DEFAULT NULL,
  total_discount_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_discount_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_paid_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_products decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_products_wt decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_shipping_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  shipping_tax_computation_method int(11) UNSIGNED NOT NULL,
  total_wrapping_tax_excl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  total_wrapping_tax_incl decimal(20, 6) NOT NULL DEFAULT 0.000000,
  shop_address text DEFAULT NULL,
  invoice_address text DEFAULT NULL,
  delivery_address text DEFAULT NULL,
  note text DEFAULT NULL,
  date_add datetime NOT NULL,
  PRIMARY KEY (id_order_invoice)
)
ENGINE = INNODB,
AUTO_INCREMENT = 4,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_invoice
ADD INDEX id_order (id_order);

-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_order_invoice_payment;
CREATE TABLE [your-database-prefix].dc_order_invoice_payment (
  id_order_invoice int(11) UNSIGNED NOT NULL,
  id_order_payment int(11) UNSIGNED NOT NULL,
  id_order int(11) UNSIGNED NOT NULL,
  PRIMARY KEY (id_order_invoice, id_order_payment)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_invoice_payment
ADD INDEX id_order (id_order);

ALTER TABLE [your-database-prefix].dc_order_invoice_payment
ADD INDEX order_payment (id_order_payment);

-- --------------------------------------------
DROP TABLE IF EXISTS [your-database-prefix].dc_order_payment;
CREATE TABLE [your-database-prefix].dc_order_payment (
  id_order_payment int(11) NOT NULL AUTO_INCREMENT,
  order_reference varchar(9) DEFAULT NULL,
  id_currency int(10) UNSIGNED NOT NULL,
  amount decimal(10, 2) NOT NULL,
  payment_method varchar(255) NOT NULL,
  conversion_rate decimal(13, 6) NOT NULL DEFAULT 1.000000,
  transaction_id varchar(254) DEFAULT NULL,
  card_number varchar(254) DEFAULT NULL,
  card_brand varchar(254) DEFAULT NULL,
  card_expiration char(7) DEFAULT NULL,
  card_holder varchar(254) DEFAULT NULL,
  date_add datetime NOT NULL,
  PRIMARY KEY (id_order_payment)
)
ENGINE = INNODB,
AUTO_INCREMENT = 4,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_unicode_ci;

ALTER TABLE [your-database-prefix].dc_order_payment
ADD INDEX order_reference (order_reference);

Вообще, такой скрипт генерится за пару минут в phpmyadmin или в heidisql или в dbforge for mysql
 
Назад
Сверху