×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: bejoy balan
Added: Sep 18, 2017 1:26 PM
Views: 9
Tags: db magento order
https://www.designhaven.co.uk/2014/08/cleanly-delete-orders-sales-customer-data-magento/
  1. TRUNCATE `sales_flat_creditmemo`;
  2. TRUNCATE `sales_flat_creditmemo_comment`;
  3. TRUNCATE `sales_flat_creditmemo_grid`;
  4. TRUNCATE `sales_flat_creditmemo_item`;
  5. TRUNCATE `sales_flat_invoice`;
  6. TRUNCATE `sales_flat_invoice_comment`;
  7. TRUNCATE `sales_flat_invoice_grid`;
  8. TRUNCATE `sales_flat_invoice_item`;
  9. TRUNCATE `sales_flat_order`;
  10. TRUNCATE `sales_flat_order_address`;
  11. TRUNCATE `sales_flat_order_grid`;
  12. TRUNCATE `sales_flat_order_item`;
  13. TRUNCATE `sales_flat_order_payment`;
  14. TRUNCATE `sales_flat_order_status_history`;
  15. TRUNCATE `sales_flat_quote`;
  16. TRUNCATE `sales_flat_quote_address`;
  17. TRUNCATE `sales_flat_quote_address_item`;
  18. TRUNCATE `sales_flat_quote_item`;
  19. TRUNCATE `sales_flat_quote_item_option`;
  20. TRUNCATE `sales_flat_quote_payment`;
  21. TRUNCATE `sales_flat_quote_shipping_rate`;
  22. TRUNCATE `sales_flat_shipment`;
  23. TRUNCATE `sales_flat_shipment_comment`;
  24. TRUNCATE `sales_flat_shipment_grid`;
  25. TRUNCATE `sales_flat_shipment_item`;
  26. TRUNCATE `sales_flat_shipment_track`;
  27. TRUNCATE `sales_invoiced_aggregated`;            # ??
  28. TRUNCATE `sales_invoiced_aggregated_order`;        # ??
  29. TRUNCATE `log_quote`;
  30.  
  31. ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
  32. ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
  33. ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
  34. ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
  35. ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
  36. ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
  37. ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
  38. ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
  39. ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
  40. ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
  41. ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
  42. ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
  43. ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
  44. ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
  45. ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
  46. ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
  47. ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
  48. ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
  49. ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
  50. ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
  51. ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
  52. ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
  53. ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
  54. ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
  55. ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
  56. ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
  57. ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
  58. ALTER TABLE `log_quote` AUTO_INCREMENT=1;
  59.  
  60. #########################################
  61. # DOWNLOADABLE PURCHASED
  62. #########################################
  63. TRUNCATE `downloadable_link_purchased`;
  64. TRUNCATE `downloadable_link_purchased_item`;
  65.  
  66. ALTER TABLE `downloadable_link_purchased` AUTO_INCREMENT=1;
  67. ALTER TABLE `downloadable_link_purchased_item` AUTO_INCREMENT=1;
  68.  
  69. #########################################
  70. # RESET ID COUNTERS
  71. #########################################
  72. TRUNCATE `eav_entity_store`;
  73. ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;
  74.  
  75.  
  76. ##############################
  77. # CUSTOMER RELATED TABLES
  78. ##############################
  79. TRUNCATE `customer_address_entity`;
  80. TRUNCATE `customer_address_entity_datetime`;
  81. TRUNCATE `customer_address_entity_decimal`;
  82. TRUNCATE `customer_address_entity_int`;
  83. TRUNCATE `customer_address_entity_text`;
  84. TRUNCATE `customer_address_entity_varchar`;
  85. TRUNCATE `customer_entity`;
  86. TRUNCATE `customer_entity_datetime`;
  87. TRUNCATE `customer_entity_decimal`;
  88. TRUNCATE `customer_entity_int`;
  89. TRUNCATE `customer_entity_text`;
  90. TRUNCATE `customer_entity_varchar`;
  91. TRUNCATE `tag`;
  92. TRUNCATE `tag_relation`;
  93. TRUNCATE `tag_summary`;
  94. TRUNCATE `tag_properties`;            ## CHECK ME
  95. TRUNCATE `wishlist`;
  96. TRUNCATE `log_customer`;
  97.  
  98. ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
  99. ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
  100. ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
  101. ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
  102. ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
  103. ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
  104. ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
  105. ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
  106. ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
  107. ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
  108. ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
  109. ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
  110. ALTER TABLE `tag` AUTO_INCREMENT=1;
  111. ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
  112. ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
  113. ALTER TABLE `tag_properties` AUTO_INCREMENT=1;
  114. ALTER TABLE `wishlist` AUTO_INCREMENT=1;
  115. ALTER TABLE `log_customer` AUTO_INCREMENT=1;
  116.  
  117.  
  118. ##############################
  119. # ADDITIONAL LOGS
  120. ##############################
  121. TRUNCATE `log_url`;
  122. TRUNCATE `log_url_info`;
  123. TRUNCATE `log_visitor`;
  124. TRUNCATE `log_visitor_info`;
  125. TRUNCATE `report_event`;
  126. TRUNCATE `report_viewed_product_index`;
  127. TRUNCATE `sendfriend_log`;
  128. ### ??? TRUNCATE `log_summary`
  129.  
  130. ALTER TABLE `log_url` AUTO_INCREMENT=1;
  131. ALTER TABLE `log_url_info` AUTO_INCREMENT=1;
  132. ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
  133. ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
  134. ALTER TABLE `report_event` AUTO_INCREMENT=1;
  135. ALTER TABLE `report_viewed_product_index` AUTO_INCREMENT=1;
  136. ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
  137. ### ??? ALTER TABLE `log_summary` AUTO_INCREMENT=1;
  138.  
  139. SET FOREIGN_KEY_CHECKS=1;
  140.