-- ABS-156650 Downloading to RA - Add PDAStartDownloadTimestamp and PDAEndDownloadTimestamp

--ROUTECONTROLRADOWNLOAD TABLE
CREATE SEQUENCE SEQ_ROUTECONTROLRADOWNLOAD
START WITH 1
INCREMENT BY 1;

CREATE TABLE ROUTECONTROLRADOWNLOAD
(
  ROUTECONTROLRADOWNLOAD_ID NUMBER NOT NULL,
  ROUTECONTROL_ID NUMBER NOT NULL,
  STARTDOWNLOADTIMESTAMP DATE NOT NULL,
  ENDDOWNLOADTIMESTAMP DATE,
  SYSTEMUSER_ID NUMBER NOT NULL,
  TIMESTAMP DATE DEFAULT SYSDATE NOT NULL
);

ALTER TABLE ROUTECONTROLRADOWNLOAD ADD CONSTRAINT XPKROUTECONTROLRADOWNLOAD PRIMARY KEY (ROUTECONTROLRADOWNLOAD_ID);

ALTER TABLE ROUTECONTROLRADOWNLOAD
  ADD CONSTRAINT ROUTECONTROLRADOWNLOAD_RC FOREIGN KEY (ROUTECONTROL_ID)
  REFERENCES ROUTECONTROL (ROUTECONTROL_ID) ON DELETE CASCADE;

CREATE INDEX XIE1ROUTECONTROLRADOWNLOAD ON ROUTECONTROLRADOWNLOAD (ROUTECONTROL_ID);
