const { sequelize, Order, OrderItem } = require('../models');

const clearOrders = async () => {
    try {
        await sequelize.authenticate();
        console.log('Database connected.');

        // Clear existing Orders and OrderItems
        await OrderItem.destroy({ where: {}, truncate: false });
        await Order.destroy({ where: {}, truncate: false });

        console.log('All dummy orders and transaction items have been cleared.');
        console.log('Database is ready for real transactions.');
        process.exit(0);
    } catch (error) {
        console.error('Failed to clear orders:', error);
        process.exit(1);
    }
};

clearOrders();
