--ABS-112018/ABS-114473
-------- OUTOFCIRCHISTEXTRAINFO --------

CREATE TABLE OUTOFCIRCHISTEXTRAINFO 
(
  OUTOFCIRCULATIONHISTORY_ID NUMBER NOT NULL,
  RVCHANGEREASONCODE_ID      NUMBER NOT NULL,
  SYSTEMUSER_ID              NUMBER NOT NULL,
  TIMESTAMP                  DATE NOT NULL
);

COMMENT ON COLUMN OUTOFCIRCHISTEXTRAINFO.RVCHANGEREASONCODE_ID
  IS 'Reason entered when manually changing the residual value for a unique garment. 
Only used when module JSGCUSTOM is in the license or when system setting MGCRESVALUECHANGEREASON = 1
';

ALTER TABLE OUTOFCIRCHISTEXTRAINFO
  ADD CONSTRAINT PK_OUTOFCIRCHISTEXTRAINFO PRIMARY KEY (OUTOFCIRCULATIONHISTORY_ID);
  
CREATE INDEX XIF1OUTOFCIRCHISTEXTRAINFO ON OUTOFCIRCHISTEXTRAINFO (RVCHANGEREASONCODE_ID ASC);

ALTER TABLE OUTOFCIRCHISTEXTRAINFO
  ADD CONSTRAINT FK_OUTOFCHISTEXTINF_OUTOFCHIST FOREIGN KEY (OUTOFCIRCULATIONHISTORY_ID)
  REFERENCES OUTOFCIRCULATIONHISTORY (OUTOFCIRCULATIONHISTORY_ID) ON DELETE CASCADE;
ALTER TABLE OUTOFCIRCHISTEXTRAINFO
  ADD CONSTRAINT FK_OUTOFCHISTEXTINF_REASONCODE FOREIGN KEY (RVCHANGEREASONCODE_ID)
  REFERENCES REASONCODE (REASONCODE_ID) ON DELETE CASCADE;