SET FOREIGN_KEY_CHECKS = 0;

-- Delete data in specific order (Child tables first)
DELETE FROM sales_payments;
DELETE FROM sales_returns;
DELETE FROM sales_damages;
DELETE FROM sales_order_items;
DELETE FROM sales_orders;
DELETE FROM production_logs;
DELETE FROM stock_batches;
DELETE FROM expenses;
DELETE FROM customers;
DELETE FROM suppliers;
DELETE FROM activity_logs;
DELETE FROM audit_logs;

-- Reset Auto Increment counters to start from 1
ALTER TABLE sales_payments AUTO_INCREMENT = 1;
ALTER TABLE sales_returns AUTO_INCREMENT = 1;
ALTER TABLE sales_damages AUTO_INCREMENT = 1;
ALTER TABLE sales_order_items AUTO_INCREMENT = 1;
ALTER TABLE sales_orders AUTO_INCREMENT = 1;
ALTER TABLE production_logs AUTO_INCREMENT = 1;
ALTER TABLE stock_batches AUTO_INCREMENT = 1;
ALTER TABLE expenses AUTO_INCREMENT = 1;
ALTER TABLE customers AUTO_INCREMENT = 1;
ALTER TABLE suppliers AUTO_INCREMENT = 1;
ALTER TABLE activity_logs AUTO_INCREMENT = 1;
ALTER TABLE audit_logs AUTO_INCREMENT = 1;

SET FOREIGN_KEY_CHECKS = 1;
