24 lines
664 B
JavaScript
24 lines
664 B
JavaScript
const { pool } = require('./src/db/pool');
|
|
|
|
async function deleteInventory() {
|
|
const client = await pool.connect();
|
|
try {
|
|
await client.query('BEGIN');
|
|
|
|
await client.query('DELETE FROM inventory_adjustments;');
|
|
await client.query('DELETE FROM stock_movements;');
|
|
await client.query('DELETE FROM batches;');
|
|
|
|
await client.query('COMMIT');
|
|
console.log("Successfully deleted all inventory data (batches, stock_movements, inventory_adjustments).");
|
|
} catch (err) {
|
|
await client.query('ROLLBACK');
|
|
console.error("Error deleting data:", err);
|
|
} finally {
|
|
client.release();
|
|
process.exit();
|
|
}
|
|
}
|
|
|
|
deleteInventory();
|