I am trying to clear all test orders from Magento 2.2.x using this SQL query in my PHPMyAdmin but I'm getting an error.
Here's the query I am running:
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE `sales_order`;
TRUNCATE `sendfriend_log`;
TRUNCATE `wishlist`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
The error I am getting is:
SQL query:
TRUNCATE `sales_order`
MySQL said: Documentation#1701 - Cannot truncate a table referenced in a foreign key constraint (`store`.`downloadable_link_purchased`, CONSTRAINT `DOWNLOADABLE_LINK_PURCHASED_ORDER_ID_SALES_ORDER_ENTITY_ID` FOREIGN KEY (`order_id`) REFERENCES `store`.`sales_order` (`entity_id`))