CREATE TABLE FCM_ORDEMSERVHISTORICO (
    NRORDEMSERVHISTORICO   NUMBER        NOT NULL,
    NRSOLICITACAOSERV      NUMBER,
    NRORDEMSERV            NUMBER,
    DSORDEMSERVHISTORICO   VARCHAR2(500),
    DTHISTORDEMSERV        DATE          NOT NULL,
    NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    DTINCLUSAO        DATE            DEFAULT SYSDATE,
    DTULTATU          DATE            DEFAULT SYSDATE,
    NRORGINCLUSAO     NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERINCLUSAO    VARCHAR2(12)    DEFAULT '1' 					NULL,
    NRORGULTATU       NUMBER          DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')		NULL,
    CDOPERULTATU      VARCHAR2(12)    DEFAULT '1',
		CONSTRAINT CKC_IDATIVO_FCM_ORDMSRVHSTRIC CHECK (IDATIVO IN ('S','N'))
)
/

ALTER TABLE FCM_ORDEMSERVHISTORICO ADD CONSTRAINT PK_FCM_ORDEMSERVHISTORICO PRIMARY KEY (NRORDEMSERVHISTORICO)
/
ALTER TABLE FCM_ORDEMSERVHISTORICO ADD CONSTRAINT FKFCM00221ORDSRVHIST_SOLISERV FOREIGN KEY (NRSOLICITACAOSERV) REFERENCES FCM_SOLICITACAOSERV (NRSOLICITACAOSERV)
/
CREATE INDEX FCM00221_FK ON FCM_ORDEMSERVHISTORICO (NRSOLICITACAOSERV ASC)
/

ALTER TABLE FCM_ORDEMSERVHISTORICO ADD CONSTRAINT FKFCM00215ORDSRVHIST_ORDSERV
  FOREIGN KEY (NRORDEMSERV) REFERENCES FCM_ORDEMSERV (NRORDEMSERV)
/
CREATE INDEX FCM00222_FK ON FCM_ORDEMSERVHISTORICO (NRORDEMSERV ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV ADD NRGERENCIAMENTOCHK NUMBER
/

ALTER TABLE FCM_SOLICITACAOSERV ADD CONSTRAINT FKFCM00223SOLISERV_GERENCHK FOREIGN KEY (NRGERENCIAMENTOCHK) 
	REFERENCES FCM_GERENCIAMENTOCHK (NRGERENCIAMENTOCHK) ON DELETE CASCADE
/
CREATE INDEX FCM00223_FK ON FCM_SOLICITACAOSERV (NRGERENCIAMENTOCHK ASC)
/

ALTER TABLE FCM_SOLICITACAOSERV ADD NRCHECKLISTAGEND NUMBER
/

ALTER TABLE FCM_SOLICITACAOSERV ADD CONSTRAINT FKFCM00224SOLISERV_CHKAGEND FOREIGN KEY (NRCHECKLISTAGEND) 
	REFERENCES FCM_CHECKLISTAGEND (NRCHECKLISTAGEND) ON DELETE CASCADE
/
CREATE INDEX FCM00224_FK ON FCM_SOLICITACAOSERV (NRCHECKLISTAGEND ASC)
/


ALTER TABLE FCM_PARAMGERAL ADD IDAUTORIZAINICIATAREFAOUTRO CHAR(1) DEFAULT 'N' NOT NULL
	CONSTRAINT CKC_IDTRZNICTRFTR_FCM_PRAMGRL CHECK (IDAUTORIZAINICIATAREFAOUTRO IN ('S', 'N'))
/


ALTER TABLE FCM_CHKAGENDHISTORICO ADD CONSTRAINT CKC_IDTIPOHISTRIC_CHKAGNDHIST CHECK (IDTIPOHISTORICO IN ('1', '2', '3', '4', '5', '6', '7', '8', '9'))
/
ALTER TABLE FCM_CHKAGENDHISTORICO ADD JUSTIFICATIVAKANBAN  VARCHAR2(4000)
/
