--ABSN-3299
-- ROUTECONTROLFINALIZATION TABLE
CREATE SEQUENCE SEQ_ROUTECONTROLFINALIZATION
START WITH 1
INCREMENT BY 1;

CREATE TABLE ROUTECONTROLFINALIZATION
(
  ROUTECONTROLFINALIZATION_ID	NUMBER NOT NULL,
  ROUTECONTROL_ID			    NUMBER NOT NULL,
  STARTFINALIZATIONTIMESTAMP    DATE NOT NULL,
  ENDFINALIZATIONTIMESTAMP      DATE,
  SYSTEMUSER_ID 				NUMBER NOT NULL,
  TIMESTAMP             		DATE DEFAULT SYSDATE NOT NULL
);

ALTER TABLE ROUTECONTROLFINALIZATION
		ADD CONSTRAINT XPKROUTECONTROLFINALIZATION PRIMARY KEY (ROUTECONTROLFINALIZATION_ID);
	  
CREATE INDEX XIF1ROUTECONTROLFINALIZATION ON ROUTECONTROLFINALIZATION (ROUTECONTROL_ID);

ALTER TABLE ROUTECONTROLFINALIZATION 
		ADD CONSTRAINT FK_ROUTECTRLFIN_ROUTECTRL_ID FOREIGN KEY (ROUTECONTROL_ID) REFERENCES ROUTECONTROL (ROUTECONTROL_ID) ON DELETE CASCADE;


