-- Fix missing columns referenced by application code.
-- Resolves SQLSTATE[42S22] "Unknown column" errors found across api/ files.
-- IMPORTANT: Already applied on Aug 3 2026. Do NOT re-run unless the columns
-- were dropped; ALTER TABLE ADD COLUMN is not idempotent in MySQL.

ALTER TABLE material_issues
  ADD COLUMN created_by INT NULL AFTER issued_to;

ALTER TABLE warehouse_tasks
  ADD COLUMN completed_by INT NULL AFTER assigned_to;

ALTER TABLE stock_transfers
  ADD COLUMN transfer_date DATE NULL AFTER lr_date;

ALTER TABLE purchase_return_items
  ADD COLUMN line_no INT NULL AFTER return_id;

ALTER TABLE contractor_rfqs
  ADD COLUMN currency_code VARCHAR(3) NULL AFTER delivery_location,
  ADD COLUMN closing_date DATE NULL AFTER response_deadline;

ALTER TABLE pallets
  ADD COLUMN max_cartons INT NULL AFTER packing_order_id,
  ADD COLUMN notes TEXT NULL AFTER status;
