CREATE TABLE ERROR_CLASSIFICATION (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'A' NOT NULL, 
  DESCRIPTION VARCHAR2(500) NOT NULL,
  CONSTRAINT PK_ERROR_CLASSIFICATION PRIMARY KEY(ID)
)
/
CREATE SEQUENCE SEQ_ERROR_CLASSIFICATION START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE REPLANNING_REASON (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'A' NOT NULL, 
  DESCRIPTION VARCHAR2(500) NOT NULL,
  CONSTRAINT PK_REPLANNING_REASON PRIMARY KEY(ID)
)
/
CREATE SEQUENCE SEQ_REPLANNING_REASON START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE TASK_REPLANNING_REASON (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'A' NOT NULL, 
  REPLANNING_REASON_ID NUMBER(10) NOT NULL, 
  TASK_ID NUMBER(10) NOT NULL, 
  ORIGIN_PROJECT NUMBER(10) DEFAULT NULL NULL, 
  DESTINY_PROJECT NUMBER(10) DEFAULT NULL NULL,
  CONSTRAINT PK_TASK_REPLANNING_REASON PRIMARY KEY(ID)
)
/
ALTER TABLE TASK_REPLANNING_REASON ADD CONSTRAINT TASK_REP_REASON_REP_REASON_FK FOREIGN KEY (REPLANNING_REASON_ID) REFERENCES REPLANNING_REASON (ID)
/
ALTER TABLE TASK_REPLANNING_REASON ADD CONSTRAINT TASK_REPLANNING_REASON_TASK_FK FOREIGN KEY (TASK_ID) REFERENCES TASK (ID)
/
ALTER TABLE TASK_REPLANNING_REASON ADD CONSTRAINT TASK_REP_REASON_ORI_PROJECT_FK FOREIGN KEY (ORIGIN_PROJECT) REFERENCES PROJECT (ID)
/
ALTER TABLE TASK_REPLANNING_REASON ADD CONSTRAINT TASK_REP_REASON_DES_PROJECT_FK FOREIGN KEY (DESTINY_PROJECT) REFERENCES PROJECT (ID)
/
CREATE SEQUENCE SEQ_TASK_REPLANNING_REASON START WITH 1 MINVALUE 1 INCREMENT BY 1
/
CREATE TABLE TASK_TYPE_PROJECT_TYPE (
  ORGANIZATION_ID NUMBER(10) NOT NULL, 
  ID NUMBER(10) NOT NULL, 
  CREATED_BY NUMBER(10) DEFAULT NULL NULL, 
  CREATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  UPDATED_BY NUMBER(10) DEFAULT NULL NULL, 
  UPDATED_AT DATE DEFAULT SYSDATE NOT NULL, 
  STATUS VARCHAR2(1) DEFAULT 'A' NOT NULL, 
  TASK_TYPE_ID NUMBER(10) NOT NULL, 
  PROJECT_TYPE_ID NUMBER(10) NOT NULL,
  CONSTRAINT PK_TASK_TYPE_PROJECT_TYPE PRIMARY KEY(ID)
)
/
ALTER TABLE TASK_TYPE_PROJECT_TYPE ADD CONSTRAINT TASK_TP_PROJECT_TP_TASK_TP_FK FOREIGN KEY (TASK_TYPE_ID) REFERENCES TASK_TYPE (ID)
/
ALTER TABLE TASK_TYPE_PROJECT_TYPE ADD CONSTRAINT TASK_TP_PROJ_TP_PROJ_TP_FK FOREIGN KEY (PROJECT_TYPE_ID) REFERENCES PROJECT_TYPE (ID)
/
CREATE SEQUENCE SEQ_TASK_TYPE_PROJECT_TYPE START WITH 1 MINVALUE 1 INCREMENT BY 1
/
ALTER TABLE TASK ADD (
  USED_IN_FRAMING VARCHAR2(1) DEFAULT 'Y' NOT NULL, 
  ERROR_CLASSIFICATION_ID NUMBER(10) DEFAULT NULL NULL
)
/
ALTER TABLE TASK ADD CONSTRAINT TASK_ERROR_CLASSIFICATION_FK FOREIGN KEY (ERROR_CLASSIFICATION_ID) REFERENCES ERROR_CLASSIFICATION (ID)