inovve

How to completely reset Magento installation MYSQL tables

Jan 18th, 2013
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 11.88 KB | None | 0 0
  1. #-- Magento 1.7.0.0 SQL Table Resets
  2. #-- On initial install Magento has 335 tables
  3.  
  4. #SET FOREIGN_KEY_CHECKS=0;
  5. #SET FOREIGN_KEY_CHECKS=1;
  6.  
  7.  
  8. SET FOREIGN_KEY_CHECKS=0;
  9.  
  10. #---------------------------------
  11. #-- RESET SECTION --- PRODUCTS ---
  12. #---------------------------------
  13.  
  14. #-- Stock Tables --
  15. TRUNCATE TABLE `cataloginventory_stock`;
  16. INSERT INTO `cataloginventory_stock` (`stock_id`, `stock_name`) VALUES
  17. (1, 'Default');
  18. TRUNCATE TABLE `cataloginventory_stock_item`;
  19. TRUNCATE TABLE `cataloginventory_stock_status`;
  20. TRUNCATE TABLE `cataloginventory_stock_status_idx`;
  21. TRUNCATE TABLE `cataloginventory_stock_status_tmp`;
  22.  
  23. #-- Product Tables --
  24. TRUNCATE TABLE `catalog_product_bundle_option`;
  25. TRUNCATE TABLE `catalog_product_bundle_option_value`;
  26. TRUNCATE TABLE `catalog_product_bundle_price_index`;
  27. TRUNCATE TABLE `catalog_product_bundle_selection`;
  28. TRUNCATE TABLE `catalog_product_bundle_selection_price`;
  29. TRUNCATE TABLE `catalog_product_bundle_stock_index`;
  30. TRUNCATE TABLE `catalog_product_enabled_index`;
  31. TRUNCATE TABLE `catalog_product_entity`;
  32. TRUNCATE TABLE `catalog_product_entity_datetime`;
  33. TRUNCATE TABLE `catalog_product_entity_decimal`;
  34. TRUNCATE TABLE `catalog_product_entity_gallery`;
  35. TRUNCATE TABLE `catalog_product_entity_group_price`;
  36. TRUNCATE TABLE `catalog_product_entity_int`;
  37. TRUNCATE TABLE `catalog_product_entity_media_gallery`;
  38. TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
  39. TRUNCATE TABLE `catalog_product_entity_text`;
  40. TRUNCATE TABLE `catalog_product_entity_tier_price`;
  41. TRUNCATE TABLE `catalog_product_entity_varchar`;
  42. TRUNCATE TABLE `catalog_product_link`;
  43. TRUNCATE TABLE `catalog_product_link_attribute`;
  44. INSERT INTO `catalog_product_link_attribute` (`product_link_attribute_id`, `link_type_id`, `product_link_attribute_code`, `data_type`) VALUES
  45. (1, 1, 'position', 'int'),
  46. (2, 3, 'position', 'int'),
  47. (3, 3, 'qty', 'decimal'),
  48. (4, 4, 'position', 'int'),
  49. (5, 5, 'position', 'int');
  50. TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
  51. TRUNCATE TABLE `catalog_product_link_attribute_int`;
  52. TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
  53. TRUNCATE TABLE `catalog_product_link_type`;
  54. INSERT INTO `catalog_product_link_type` (`link_type_id`, `code`) VALUES
  55. (1, 'relation'),
  56. (3, 'super'),
  57. (4, 'up_sell'),
  58. (5, 'cross_sell');
  59. TRUNCATE TABLE `catalog_product_option`;
  60. TRUNCATE TABLE `catalog_product_option_price`;
  61. TRUNCATE TABLE `catalog_product_option_title`;
  62. TRUNCATE TABLE `catalog_product_option_type_price`;
  63. TRUNCATE TABLE `catalog_product_option_type_title`;
  64. TRUNCATE TABLE `catalog_product_option_type_value`;
  65. TRUNCATE TABLE `catalog_product_relation`;
  66. TRUNCATE TABLE `catalog_product_super_attribute`;
  67. TRUNCATE TABLE `catalog_product_super_attribute_label`;
  68. TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
  69. TRUNCATE TABLE `catalog_product_super_link`;
  70. TRUNCATE TABLE `catalog_product_website`;
  71.  
  72. #-- Compare Items Table
  73. TRUNCATE TABLE `catalog_compare_item`;
  74.  
  75. #-- Product Related Indexes
  76. TRUNCATE TABLE `catalog_product_index_eav`;
  77. TRUNCATE TABLE `catalog_product_index_eav_decimal`;
  78. TRUNCATE TABLE `catalog_product_index_eav_decimal_idx`;
  79. TRUNCATE TABLE `catalog_product_index_eav_decimal_tmp`;
  80. TRUNCATE TABLE `catalog_product_index_eav_idx`;
  81. TRUNCATE TABLE `catalog_product_index_eav_tmp`;
  82. TRUNCATE TABLE `catalog_product_index_group_price`;
  83. TRUNCATE TABLE `catalog_product_index_price`;
  84. TRUNCATE TABLE `catalog_product_index_price_bundle_idx`;
  85. TRUNCATE TABLE `catalog_product_index_price_bundle_opt_idx`;
  86. TRUNCATE TABLE `catalog_product_index_price_bundle_opt_tmp`;
  87. TRUNCATE TABLE `catalog_product_index_price_bundle_sel_idx`;
  88. TRUNCATE TABLE `catalog_product_index_price_bundle_sel_tmp`;
  89. TRUNCATE TABLE `catalog_product_index_price_bundle_tmp`;
  90. TRUNCATE TABLE `catalog_product_index_price_cfg_opt_agr_idx`;
  91. TRUNCATE TABLE `catalog_product_index_price_cfg_opt_agr_tmp`;
  92. TRUNCATE TABLE `catalog_product_index_price_cfg_opt_idx`;
  93. TRUNCATE TABLE `catalog_product_index_price_cfg_opt_tmp`;
  94. TRUNCATE TABLE `catalog_product_index_price_downlod_idx`;
  95. TRUNCATE TABLE `catalog_product_index_price_downlod_tmp`;
  96. TRUNCATE TABLE `catalog_product_index_price_final_idx`;
  97. TRUNCATE TABLE `catalog_product_index_price_final_tmp`;
  98. TRUNCATE TABLE `catalog_product_index_price_idx`;
  99. TRUNCATE TABLE `catalog_product_index_price_opt_agr_idx`;
  100. TRUNCATE TABLE `catalog_product_index_price_opt_agr_tmp`;
  101. TRUNCATE TABLE `catalog_product_index_price_opt_idx`;
  102. TRUNCATE TABLE `catalog_product_index_price_opt_tmp`;
  103. TRUNCATE TABLE `catalog_product_index_price_tmp`;
  104. TRUNCATE TABLE `catalog_product_index_tier_price`;
  105. TRUNCATE TABLE `catalog_product_index_website`;
  106.  
  107. #-- Product Flat Tables
  108. #TRUNCATE TABLE `catalog_product_flat_1`;
  109.  
  110.  
  111. #-----------------------------------
  112. #-- RESET SECTION --- CATEGORIES ---
  113. #-----------------------------------
  114.  
  115. TRUNCATE TABLE `catalog_category_entity`;
  116. INSERT INTO `catalog_category_entity` (`entity_id`, `entity_type_id`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`) VALUES
  117. (1, 3, 0, 0, '2012-05-24 00:28:25', '2012-05-24 00:28:25', '1', 0, 0, 1),
  118. (2, 3, 3, 1, '2012-05-24 00:28:26', '2012-05-24 00:28:26', '1/2', 1, 1, 0);
  119. TRUNCATE TABLE `catalog_category_entity_datetime`;
  120. TRUNCATE TABLE `catalog_category_entity_decimal`;
  121. TRUNCATE TABLE `catalog_category_entity_int`;
  122. INSERT INTO `catalog_category_entity_int` (`value_id`, `entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
  123. (1, 3, 61, 0, 1, 1),
  124. (2, 3, 61, 1, 1, 1),
  125. (3, 3, 36, 0, 2, 1),
  126. (4, 3, 61, 0, 2, 1),
  127. (5, 3, 36, 1, 2, 1),
  128. (6, 3, 61, 1, 2, 1);
  129. TRUNCATE TABLE `catalog_category_entity_text`;
  130. INSERT INTO `catalog_category_entity_text` (`value_id`, `entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
  131. (1, 3, 59, 0, 1, NULL),
  132. (2, 3, 59, 1, 1, NULL),
  133. (3, 3, 59, 0, 2, NULL),
  134. (4, 3, 59, 1, 2, NULL);
  135. TRUNCATE TABLE `catalog_category_entity_varchar`;
  136. INSERT INTO `catalog_category_entity_varchar` (`value_id`, `entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
  137. (1, 3, 35, 0, 1, 'Root Catalog'),
  138. (2, 3, 35, 1, 1, 'Root Catalog'),
  139. (3, 3, 37, 1, 1, 'root-catalog'),
  140. (4, 3, 35, 0, 2, 'Default Category'),
  141. (5, 3, 35, 1, 2, 'Default Category'),
  142. (6, 3, 43, 1, 2, 'PRODUCTS'),
  143. (7, 3, 37, 1, 2, 'default-category');
  144. TRUNCATE TABLE `catalog_category_product`;
  145. TRUNCATE TABLE `catalog_category_product_index`;
  146. TRUNCATE TABLE `catalog_category_product_index_enbl_idx`;
  147. TRUNCATE TABLE `catalog_category_product_index_enbl_tmp`;
  148. TRUNCATE TABLE `catalog_category_product_index_idx`;
  149. TRUNCATE TABLE `catalog_category_product_index_tmp`;
  150.  
  151.  
  152. #-------------------------------------
  153. #-- RESET SECTION --- ACCOUNT INFO ---
  154. #-------------------------------------
  155.  
  156. #-- Clean out Notification Inbox
  157. TRUNCATE TABLE `adminnotification_inbox`;
  158.  
  159. #-- Sales data
  160. TRUNCATE TABLE `sales_flat_creditmemo`;
  161. TRUNCATE TABLE `sales_flat_creditmemo_comment`;
  162. TRUNCATE TABLE `sales_flat_creditmemo_grid`;
  163. TRUNCATE TABLE `sales_flat_creditmemo_item`;
  164. TRUNCATE TABLE `sales_flat_invoice`;
  165. TRUNCATE TABLE `sales_flat_invoice_comment`;
  166. TRUNCATE TABLE `sales_flat_invoice_grid`;
  167. TRUNCATE TABLE `sales_flat_invoice_item`;
  168. TRUNCATE TABLE `sales_flat_order`;
  169. TRUNCATE TABLE `sales_flat_order_address`;
  170. TRUNCATE TABLE `sales_flat_order_grid`;
  171. TRUNCATE TABLE `sales_flat_order_item`;
  172. TRUNCATE TABLE `sales_flat_order_payment`;
  173. TRUNCATE TABLE `sales_flat_order_status_history`;
  174. TRUNCATE TABLE `sales_flat_quote`;
  175. TRUNCATE TABLE `sales_flat_quote_address`;
  176. TRUNCATE TABLE `sales_flat_quote_address_item`;
  177. TRUNCATE TABLE `sales_flat_quote_item`;
  178. TRUNCATE TABLE `sales_flat_quote_item_option`;
  179. TRUNCATE TABLE `sales_flat_quote_payment`;
  180. TRUNCATE TABLE `sales_flat_quote_shipping_rate`;
  181. TRUNCATE TABLE `sales_flat_shipment`;
  182. TRUNCATE TABLE `sales_flat_shipment_comment`;
  183. TRUNCATE TABLE `sales_flat_shipment_grid`;
  184. TRUNCATE TABLE `sales_flat_shipment_item`;
  185. TRUNCATE TABLE `sales_flat_shipment_track`;
  186. TRUNCATE TABLE `sales_invoiced_aggregated`;
  187. TRUNCATE TABLE `sales_invoiced_aggregated_order`;
  188. TRUNCATE TABLE `sales_order_aggregated_created`;
  189. TRUNCATE TABLE `sales_order_aggregated_updated`;
  190. TRUNCATE TABLE `sales_order_tax`;
  191. TRUNCATE TABLE `sales_order_tax_item`;
  192. TRUNCATE TABLE `tax_order_aggregated_created`;
  193. TRUNCATE TABLE `tax_order_aggregated_updated`;
  194. TRUNCATE TABLE `paypal_payment_transaction`;
  195. TRUNCATE TABLE `paypal_settlement_report`;
  196. TRUNCATE TABLE `paypal_settlement_report_row`;
  197.  
  198. #-- Customer accounts
  199.  
  200. TRUNCATE TABLE `customer_address_entity`;
  201. TRUNCATE TABLE `customer_address_entity_datetime`;
  202. TRUNCATE TABLE `customer_address_entity_decimal`;
  203. TRUNCATE TABLE `customer_address_entity_int`;
  204. TRUNCATE TABLE `customer_address_entity_text`;
  205. TRUNCATE TABLE `customer_address_entity_varchar`;
  206. TRUNCATE TABLE `customer_entity`;
  207. TRUNCATE TABLE `customer_entity_datetime`;
  208. TRUNCATE TABLE `customer_entity_decimal`;
  209. TRUNCATE TABLE `customer_entity_int`;
  210. TRUNCATE TABLE `customer_entity_text`;
  211. TRUNCATE TABLE `customer_entity_varchar`;
  212.  
  213. #-- Customer related logs
  214.  
  215. TRUNCATE TABLE `log_customer`;
  216. TRUNCATE TABLE `log_quote`;
  217. TRUNCATE TABLE `log_summary`;
  218. TRUNCATE TABLE `log_url`;
  219. TRUNCATE TABLE `log_url_info`;
  220. TRUNCATE TABLE `log_visitor`;
  221. TRUNCATE TABLE `log_visitor_info`;
  222. TRUNCATE TABLE `log_visitor_online`;
  223. TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
  224. TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
  225. TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;
  226. TRUNCATE TABLE `sendfriend_log`;
  227. TRUNCATE TABLE `tag`;
  228. TRUNCATE TABLE `tag_properties`;
  229. TRUNCATE TABLE `tag_relation`;
  230. TRUNCATE TABLE `tag_summary`;
  231. TRUNCATE TABLE `wishlist`;
  232. TRUNCATE TABLE `wishlist_item`;
  233. TRUNCATE TABLE `wishlist_item_option`;
  234. DELETE FROM `catalogsearch_query`;
  235.  
  236. #-- Newsletter related
  237.  
  238. TRUNCATE TABLE `newsletter_problem`;
  239. TRUNCATE TABLE `newsletter_queue`;
  240. TRUNCATE TABLE `newsletter_queue_link`;
  241. TRUNCATE TABLE `newsletter_queue_store_link`;
  242. TRUNCATE TABLE `newsletter_subscriber`;
  243. TRUNCATE TABLE `newsletter_template`;
  244.  
  245.  
  246. #----------------------------------------
  247. #-- RESET SECTION --- CATALOGUE RULES ---
  248. #----------------------------------------
  249.  
  250. TRUNCATE TABLE `catalogrule`;
  251. TRUNCATE TABLE `catalogrule_affected_product`;
  252. TRUNCATE TABLE `catalogrule_customer_group`;
  253. TRUNCATE TABLE `catalogrule_group_website`;
  254. TRUNCATE TABLE `catalogrule_product`;
  255. TRUNCATE TABLE `catalogrule_product_price`;
  256. TRUNCATE TABLE `catalogrule_website`;
  257.  
  258.  
  259. #------------------------------------
  260. #-- RESET SECTION --- SALES RULES ---
  261. #------------------------------------
  262.  
  263. TRUNCATE TABLE `salesrule`;
  264. TRUNCATE TABLE `salesrule_coupon`;
  265. TRUNCATE TABLE `salesrule_coupon_usage`;
  266. TRUNCATE TABLE `salesrule_customer`;
  267. TRUNCATE TABLE `salesrule_customer_group`;
  268. TRUNCATE TABLE `salesrule_label`;
  269. TRUNCATE TABLE `salesrule_product_attribute`;
  270. TRUNCATE TABLE `salesrule_website`;
  271.  
  272.  
  273. #------------------------------
  274. #-- RESET SECTION --- POLLS ---
  275. #------------------------------
  276.  
  277. TRUNCATE TABLE `poll`;
  278. TRUNCATE TABLE `poll_answer`;
  279. TRUNCATE TABLE `poll_store`;
  280. TRUNCATE TABLE `poll_vote`;
  281.  
  282.  
  283. #-----------------------------------------
  284. #-- RESET SECTION --- CLEAN INDEX LOGS ---
  285. #-----------------------------------------
  286.  
  287. TRUNCATE TABLE `index_event`;
  288. TRUNCATE TABLE `index_process`;
  289. TRUNCATE TABLE `index_process_event`;
  290. TRUNCATE TABLE `report_event`;
  291. TRUNCATE TABLE `report_viewed_product_index`;
  292.  
  293. #-------------------------------------
  294. #-- RESET SECTION --- URL REWRITES ---
  295. #-------------------------------------
  296.  
  297. TRUNCATE TABLE `core_url_rewrite`;
  298.  
  299. #-----------------------------------
  300. #-- RESET SECTION --- ATTRIBUTES ---
  301. #-----------------------------------
  302.  
  303. #DELETE FROM `eav_attribute` WHERE `attribute_id` > 133; # This will DELETE ALL attributes added since DEFAULT installation
  304.  
  305. #DELETE FROM `eav_attribute` WHERE `attribute_id` > 133 AND `entity_type_id` = 4; # This will DELETE ALL product ONLY attributes added since DEFAULT installation
  306.  
  307. SET FOREIGN_KEY_CHECKS=1;
Advertisement
Add Comment
Please, Sign In to add comment