0

I am helping a client clone a test server. Per the instructions they were given they have already truncated out some of the junk data created by testing, including orders and invoices, but they did not delete the RMAs. Could someone please tell me which tables I need to clear to delete the RMAs cleanly?

Here are the queries that were used to purge the test data:

DELETE FROM `sales_flat_order`;
DELETE FROM `sales_order_tax`;
DELETE FROM `downloadable_link_purchased`;
DELETE FROM `eav_entity_store` WHERE entity_type_id IN (
    SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code` IN ('order', 'invoice', 'creditmemo', 'shipment')
 );
2

I was able to figure this out on my own, figured I would post the solution in case this may help anyone.

Update: I forgot about the eav_entity_store table so that has been included. I also made some edits per Luke Rodger's comment. Thanks.

DELETE FROM `eav_attribute` 
WHERE `attribute_id` IN 
(
    SELECT `attribute_id` FROM `enterprise_rma_item_eav_attribute` 
    UNION ALL
    SELECT `attribute_id` FROM `enterprise_rma_item_form_attribute` 
);
DELETE FROM `eav_entity_store` WHERE entity_type_id IN (
    SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_type_code` = 'rma_item'
 );
DELETE FROM `enterprise_rma`;
DELETE FROM `enterprise_rma_item_eav_attribute`;
DELETE FROM `enterprise_rma_item_form_attribute`;
DELETE FROM `enterprise_rma_item_entity`;
DELETE FROM `enterprise_rma_item_entity_datetime`;
DELETE FROM `enterprise_rma_item_entity_decimal`;
DELETE FROM `enterprise_rma_item_entity_int`;
DELETE FROM `enterprise_rma_item_entity_text`;
DELETE FROM `enterprise_rma_item_entity_varchar`;
DELETE FROM `enterprise_rma_status_history`;
DELETE FROM `enterprise_rma_shipping_label`;
DELETE FROM `enterprise_rma_grid`;
  • You could also make your query a little bit cleaner by removing the WHERE 1. There is no need for it. It is equivalent of saying "Delete from table where true = true" – Luke Rodgers Apr 13 '16 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.