-- Migration 096: Add im_haus to internal request positions and FK back from external order positions
--
-- im_haus (ausruestung_anfrage_positionen): auto-set when external bestellposition is received
-- anfrage_position_id (bestellpositionen): explicit link so receipt can sync back

ALTER TABLE ausruestung_anfrage_positionen
  ADD COLUMN IF NOT EXISTS im_haus BOOLEAN DEFAULT false;

ALTER TABLE bestellpositionen
  ADD COLUMN IF NOT EXISTS anfrage_position_id INT
    REFERENCES ausruestung_anfrage_positionen(id) ON DELETE SET NULL;
