-- ABS-56081/ ABS-58357

--- STOCKTRANSACTION table---
ALTER TABLE STOCKTRANSACTION ADD (RETURNEDCUSTOMER_LINK_ID NUMBER NULL);

COMMENT ON COLUMN STOCKTRANSACTION.RETURNEDCUSTOMER_LINK_ID
  IS 'This is only filled when any non-unique items are returned to stock from a certain customer';

CREATE INDEX XIF9STOCKTRANSACTION ON STOCKTRANSACTION (RETURNEDCUSTOMER_LINK_ID ASC);

ALTER TABLE STOCKTRANSACTION
  ADD CONSTRAINT STOCKTRANSACTION_RETURNEDCUST FOREIGN KEY (RETURNEDCUSTOMER_LINK_ID)
  REFERENCES CUSTOMER_LINK (CUSTOMER_LINK_ID) ON DELETE SET NULL;