From 282f1e194ac8cbc1e72b2cee4c5c247790d601f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 25 Aug 2026 11:56:03 -0300 Subject: [PATCH] Fix production plan reservation migration --- backend/db.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/db.js b/backend/db.js index cdaddca..65ddbdf 100644 --- a/backend/db.js +++ b/backend/db.js @@ -484,6 +484,11 @@ const initDB = async () => { ); `); + await pool.query(` + ALTER TABLE cut_plan_lot_reservations + ADD COLUMN IF NOT EXISTS production_plan_id INTEGER REFERENCES production_plans(id) ON DELETE SET NULL; + `).catch(() => {}); + await pool.query(`CREATE INDEX IF NOT EXISTS idx_cut_plan_lot_reservations_lot_status ON cut_plan_lot_reservations (supply_lot_id, status);`); await pool.query(`CREATE INDEX IF NOT EXISTS idx_cut_plan_lot_reservations_reference ON cut_plan_lot_reservations (cut_plan_reference, status);`); await pool.query(`CREATE INDEX IF NOT EXISTS idx_cut_plan_lot_reservations_plan ON cut_plan_lot_reservations (production_plan_id, status);`);