-- ABS-13619
CREATE TABLE CUSTOMERREASONCODE
(
  CUSTOMER_ID   NUMBER NOT NULL,
  REASONCODE_ID NUMBER NOT NULL,
  SYSTEMUSER_ID NUMBER NOT NULL,
  TIMESTAMP     DATE NOT NULL
);

ALTER TABLE CUSTOMERREASONCODE
  ADD CONSTRAINT XPKCUSTOMERREASONCODE PRIMARY KEY (CUSTOMER_ID, REASONCODE_ID);

CREATE INDEX XIF1CUSTOMERREASONCODE ON CUSTOMERREASONCODE (CUSTOMER_ID ASC);

CREATE INDEX XIF2CUSTOMERREASONCODE ON CUSTOMERREASONCODE (REASONCODE_ID ASC);

ALTER TABLE CUSTOMERREASONCODE
  ADD CONSTRAINT CUSTOMERREASONCODE_CUSTOMER_ID FOREIGN KEY (CUSTOMER_ID)
  REFERENCES CUSTOMER (CUSTOMER_ID) ON DELETE CASCADE;

ALTER TABLE CUSTOMERREASONCODE
  ADD CONSTRAINT CUSTOMERREASONCODE_RC_ID FOREIGN KEY (REASONCODE_ID)
  REFERENCES REASONCODE (REASONCODE_ID) ON DELETE CASCADE;

