Skip to content

Instantly share code, notes, and snippets.

@mrkhoa99
Last active January 15, 2024 12:20
Show Gist options
  • Save mrkhoa99/a811240602857983ca220b0f1591dae9 to your computer and use it in GitHub Desktop.
Save mrkhoa99/a811240602857983ca220b0f1591dae9 to your computer and use it in GitHub Desktop.
Clean up database Magento 2 for local enviroment
//Orders, Invoices, Shipments
DELETE FROM sales_order;
DELETE FROM sales_creditmemo_comment;
DELETE FROM sales_creditmemo_item;
DELETE FROM sales_creditmemo;
DELETE FROM sales_creditmemo_grid;
DELETE FROM sales_invoice_comment;
DELETE FROM sales_invoice_item;
DELETE FROM sales_invoice;
DELETE FROM sales_invoice_grid;
DELETE FROM quote_address_item;
DELETE FROM quote_item_option;
DELETE FROM quote;
DELETE FROM quote_address;
DELETE FROM quote_item;
DELETE FROM quote_payment;
DELETE FROM quote_shipping_rate;
DELETE FROM quote_id_mask;
DELETE FROM sales_shipment_comment;
DELETE FROM sales_shipment_item;
DELETE FROM sales_shipment_track;
DELETE FROM sales_shipment;
DELETE FROM sales_shipment_grid;
DELETE FROM sales_order_address;
DELETE FROM sales_order_item;
DELETE FROM sales_order_payment;
DELETE FROM sales_order_status_history;
DELETE FROM sales_order_grid;
DELETE FROM sales_order_tax;
//RMA Enterprise v
DELETE FROM magento_rma;
DELETE FROM magento_rma_grid;
DELETE FROM magento_rma_shipping_lable;
DELETE FROM magento_rma_status_history;
//Delete Order, Invoice, Shipment, Refund aggregated
DELETE FROM sales_invoiced_aggregated;
DELETE FROM sales_invoiced_aggregated_order;
DELETE FROM sales_order_aggregated_created;
DELETE FROM sales_order_aggregated_updated;
DELETE FROM sales_refunded_aggregated;
DELETE FROM sales_refunded_aggregated_order;
DELETE FROM sales_shipping_aggregated;
DELETE FROM sales_shipping_aggregated_order;
//Reward History
DELETE FROM magento_reward_history;
//Report Event
DELETE FROM sales_bestsellers_aggregated_daily;
DELETE FROM sales_bestsellers_aggregated_monthly;
DELETE FROM sales_bestsellers_aggregated_yearly;
DELETE FROM report_viewed_product_index;
DELETE FROM report_viewed_product_aggregated_daily;
DELETE FROM report_viewed_product_aggregated_monthly;
DELETE FROM report_viewed_product_aggregated_yearly;
DELETE FROM product_alert_stock;
DELETE FROM search_query;
DELETE FROM catalogsearch_fulltext_scope1;
@mrkhoa99
Copy link
Author

@Dx3webs, yes, I changed the title. It should be for local environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment