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);`);