ALTER TABLE FCT_APROPAGENDAMENTO ADD DSCDA CLOB
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRSEQINTERLOCUTOR NUMBER
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD IDORIGEMAGEND VARCHAR2(10)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD IDSERVPREST VARCHAR2(20)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD IDSITUACAOCDA VARCHAR2(1)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRTIPOLANCAMENTOCDA NUMBER
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD DTENTRADA DATE
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD DTSAIDA DATE
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD QTHRTOTAL VARCHAR2(4)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD HRAUSENCIAALMOCO VARCHAR2(4)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD DSJUSTHRNAOFATURADA VARCHAR2(250)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRCONTATO VARCHAR2(10)
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRSEQCONTATO NUMBER
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRSEQEVOLCONT NUMBER
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD NRMOTIVOEXCEFREQ NUMBER
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD CONSTRAINT CKC_IDORIGEMAGEND CHECK (IDORIGEMAGEND IN ('CDA', 'MANUAL'))
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD CONSTRAINT CKC_IDSITUACAOCDA CHECK (IDSITUACAOCDA IN ('P', 'C', 'R'))
/

ALTER TABLE FCT_APROPAGENDAMENTO 
    ADD CONSTRAINT FKSM00449TPLANCCDA_APROPAGEND FOREIGN KEY (NRTIPOLANCAMENTOCDA)
        REFERENCES FCT_TIPOLANCAMENTOCDA (NRTIPOLANCAMENTOCDA)
/

CREATE INDEX SM00449_FK ON FCT_APROPAGENDAMENTO (NRTIPOLANCAMENTOCDA ASC)
/
   
ALTER TABLE FCT_APROPAGENDAMENTO 
    ADD CONSTRAINT FKSM00450INTERLOC_APROPAGEND FOREIGN KEY (NRSEQINTERLOCUTOR)
        REFERENCES CRM_INTERLOCUTOR (NRSEQINTERLOCUTOR)
/

CREATE INDEX SM00450_FK ON FCT_APROPAGENDAMENTO (NRSEQINTERLOCUTOR ASC)
/
        
ALTER TABLE FCT_APROPAGENDAMENTO 
    ADD CONSTRAINT FKSM00451CONT_APROPAGEND FOREIGN KEY (NRSEQCONTATO)
        REFERENCES CONTATO (NRSEQCONTATO)
/

CREATE INDEX SM00451_FK ON FCT_APROPAGENDAMENTO (NRSEQCONTATO ASC)
/

ALTER TABLE FCT_APROPAGENDAMENTO 
    ADD CONSTRAINT FKSM00452EVOLCONT_APROPAGEND FOREIGN KEY (NRSEQEVOLCONT)
        REFERENCES EVOLCONT (NRSEQEVOLCONT)
/

CREATE INDEX SM00452_FK ON FCT_APROPAGENDAMENTO (NRSEQEVOLCONT ASC)
/
        
ALTER TABLE FCT_APROPAGENDAMENTO 
    ADD CONSTRAINT FKSM00453MTVEXCEFREQ_APRAGEND FOREIGN KEY (NRMOTIVOEXCEFREQ)
        REFERENCES GPE_MOTIVOEXCEFREQ (NRMOTIVOEXCEFREQ)
/

CREATE INDEX SM00453_FK ON FCT_APROPAGENDAMENTO (NRMOTIVOEXCEFREQ ASC)
/
        
ALTER TABLE FCT_APONTAMENTOAPROPAGEN DROP CONSTRAINT FKSM00045APROPGEND
/

ALTER TABLE FCT_APROPAGENDAMENTO DROP CONSTRAINT PK_FCT_APROPAGENDAMENTO
/

DROP INDEX PK_FCT_APROPAGENDAMENTO
/

ALTER TABLE FCT_APROPAGENDAMENTO ADD CONSTRAINT PK_FCT_APROPAGENDAMENTO PRIMARY KEY (NRAPROPAGENDAMENTO)
/

ALTER TABLE FCT_APONTAMENTOAPROPAGEN 
   ADD CONSTRAINT FKSM00045APROPGEND FOREIGN KEY (NRAPROPAGENDAMENTO)
      REFERENCES FCT_APROPAGENDAMENTO (NRAPROPAGENDAMENTO) ON DELETE CASCADE
/
      
ALTER TABLE FCT_APROPAGENDAMENTO MODIFY NRRECURSOSAGENDCONT NULL
/
CREATE TABLE FCT_APROPPARTICIPANTE(
    NRTIPOLANCAMENTOCDA       NUMBER,
    NMTIPOLANCAMENTOCDA       VARCHAR2(500),
    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_FCT_TPLANCAMENCDA CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_FCT_TIPOLANCAMENTOCDA PRIMARY KEY (NRTIPOLANCAMENTOCDA)

)
/

CREATE TABLE FCT_PARTICIPANTEAPROP(
    NRPARTICIPANTEAPROP       NUMBER NOT NULL,
    NRAPROPAGENDAMENTO        NUMBER NOT NULL,
    DSNOMEPARTICIP            VARCHAR2(1000) NOT NULL,
    DSSETORPARTICIP           VARCHAR2(1000), 
    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_FCT_PARTICIPAPROP CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_FCT_PARTICIPANTEAPROP PRIMARY KEY (NRPARTICIPANTEAPROP)
)
/

ALTER TABLE FCT_PARTICIPANTEAPROP 
    ADD CONSTRAINT FKSM00454PARTICPROP_APRAGEND FOREIGN KEY (NRAPROPAGENDAMENTO)
        REFERENCES FCT_APROPAGENDAMENTO (NRAPROPAGENDAMENTO)
/

CREATE INDEX SM00454_FK ON FCT_PARTICIPANTEAPROP (NRAPROPAGENDAMENTO ASC)
/

CREATE TABLE FCT_APROPJUSTHRNFAT(
    NRAPROPJUSTHRNFAT         NUMBER NOT NULL,
    NRAPROPAGENDAMENTO        NUMBER NOT NULL,
    NRJUSTHORASNAOFATUCDA     NUMBER 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_FCT_APRJUSTHRNFAT CHECK (IDATIVO IN ('S','N')),
        CONSTRAINT PK_FCT_APROPJUSTHRNFAT PRIMARY KEY (NRAPROPJUSTHRNFAT)
)
/

ALTER TABLE FCT_APROPJUSTHRNFAT ADD QTHORASNAOFATU FLOAT(126)
/

ALTER TABLE FCT_APROPJUSTHRNFAT 
    ADD CONSTRAINT FKSM00455JUSTHRNFAT_APRAGEND FOREIGN KEY (NRAPROPAGENDAMENTO)
        REFERENCES FCT_APROPAGENDAMENTO (NRAPROPAGENDAMENTO)
/

CREATE INDEX SM00455_FK ON FCT_APROPJUSTHRNFAT (NRAPROPAGENDAMENTO ASC)
/

ALTER TABLE FCT_APROPJUSTHRNFAT 
    ADD CONSTRAINT FKSM00456APRPJUSHRNFT_JUSHRNFT FOREIGN KEY (NRJUSTHORASNAOFATUCDA)
        REFERENCES JUSTHORASNAOFATUCDA (NRJUSTHORASNAOFATUCDA)
/

CREATE INDEX SM00456_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/
        
CREATE TABLE FCT_APROPAGENDAMENTODOC (
    NRAPROPAGENDAMENTODOC      NUMBER NOT NULL,
    NRAPROPAGENDAMENTO         NUMBER NOT NULL,
    NRMODELODOCCDA      NUMBER NOT NULL,
    IDDOCUMCERTSIGN   VARCHAR2(500),
    CHAVEDOCUMCERTSIGN VARCHAR2(500),
    IDSITASSINATURA VARCHAR2(20),
    DTASSINATURA  DATE,
    DSJUSTIFRECUSAASSINAT VARCHAR2(4000),
    DTLEMBRETEASSINATURA           DATE,
    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'
	
)
/

ALTER TABLE FCT_APROPAGENDAMENTODOC ADD CONSTRAINT PK_FCT_APROPAGENDAMENTODOC PRIMARY KEY (NRAPROPAGENDAMENTODOC)
/

ALTER TABLE FCT_APROPAGENDAMENTODOC ADD CONSTRAINT CKC_IDATIVO_APRAGENDAMENTODOC CHECK (IDATIVO IN ('S', 'N'))
/

ALTER TABLE FCT_APROPAGENDAMENTODOC ADD CONSTRAINT CKC_IDSITASS_FCT_APRAGENDDOC CHECK (IDSITASSINATURA IN ('ENVIADO', 'PARCIAL','NAO_ENVIADO', 'ASSINADO', 'RECUSADO', 'MANUAL'))
/

ALTER TABLE FCT_APROPAGENDAMENTODOC 
  ADD CONSTRAINT FKSM00457APRAGEND_APRAGENDDOC FOREIGN KEY (NRAPROPAGENDAMENTO)
      REFERENCES FCT_APROPAGENDAMENTO (NRAPROPAGENDAMENTO)
/

CREATE INDEX SM00457_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/
      
ALTER TABLE FCT_APROPAGENDAMENTODOC 
  ADD CONSTRAINT FKSM00458MODELDOC_APRAGENDDOC FOREIGN KEY (NRMODELODOCCDA)
      REFERENCES MODELODOCCDA (NRMODELODOCCDA)
/

CREATE INDEX SM00458_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/

CREATE TABLE FCT_APROPAGENDAMENTODOCASSINA (
	NRAPROPAGENDAMENTODOCASSINA  NUMBER NOT NULL,    
	NRAPROPAGENDAMENTODOC      NUMBER NOT NULL,
	NRCPFSIGNATARIO       VARCHAR2(20) NOT NULL,
	NMSIGNATARIO          VARCHAR2(2000),
	DSEMAILSIGNATARIO     VARCHAR2(1000),
	IDTIPOASSINATURA      CHAR(1),
	IDSITASSINATURA       VARCHAR2(20),
	DTASSINATURA          DATE,
	DSURLASSINATURA       VARCHAR2(500),
	DSJUSTIFRECUSAASSINAT VARCHAR2(4000),
	DSJUSTIFMANUALASSINAT VARCHAR2(4000),
	DTALTSITUMANUAL       DATE,
	CDOPERALTSITUMANUAL   VARCHAR2(12),
	IDSIGNATCERTSIGN      VARCHAR2(500),
    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'
)
/

ALTER TABLE FCT_APROPAGENDAMENTODOCASSINA ADD CONSTRAINT PK_FCT_APROPAGENDAMENCASS PRIMARY KEY (NRAPROPAGENDAMENTODOCASSINA)
/

ALTER TABLE FCT_APROPAGENDAMENTODOCASSINA
  ADD CONSTRAINT FKSM00459APROPDOC_APROCDOCASS FOREIGN KEY (NRAPROPAGENDAMENTODOC)
      REFERENCES FCT_APROPAGENDAMENTODOC (NRAPROPAGENDAMENTODOC)
/

CREATE INDEX SM00459_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/

ALTER TABLE FCT_APROPAGENDAMENTODOCASSINA ADD CONSTRAINT CKC_IDTPASSINA_APROPDOCASSINA CHECK (IDTIPOASSINATURA IN ('E', 'D'))
/

ALTER TABLE FCT_APROPAGENDAMENTODOCASSINA ADD CONSTRAINT CKC_IDSITASS_APROPDOCASSINA CHECK (IDSITASSINATURA IN ('ENVIADO', 'NAO_ENVIADO', 'ASSINADO', 'RECUSADO', 'MANUAL'))
/

ALTER TABLE FCT_APROPAGENDAMENTODOCASSINA ADD CONSTRAINT CKC_IDATIVO_APROPDOCASSINA CHECK (IDATIVO IN ('S', 'N'))
/
CREATE TABLE FCT_APROPAGENDOCLOGASSINA (
	NRAPROPAGENDOCLOGASSINA NUMBER NOT NULL,     
	NRAPROPAGENDAMENTODOC          NUMBER NOT NULL, 
	NRAPROPAGENDAMENTODOCASSINA     NUMBER,
    IDDOCUMCERTSIGN         VARCHAR2(500),
	NRCPFSIGNATARIO         VARCHAR2(20),    
	DSERRO                  VARCHAR2(4000),             
    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'
)
/

ALTER TABLE FCT_APROPAGENDOCLOGASSINA ADD CONSTRAINT PK_FCT_APROPAGENDOCLOGASSINA PRIMARY KEY (NRAPROPAGENDOCLOGASSINA)
/

ALTER TABLE FCT_APROPAGENDOCLOGASSINA
  ADD CONSTRAINT FKSM00460APRPDOC_APRAGOCLOGASS FOREIGN KEY (NRAPROPAGENDAMENTODOC)
      REFERENCES FCT_APROPAGENDAMENTODOC (NRAPROPAGENDAMENTODOC)
/

CREATE INDEX SM00460_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/
	  
ALTER TABLE FCT_APROPAGENDOCLOGASSINA
  ADD CONSTRAINT FKSM00461APRDOCAS_APRAGCLOGAS FOREIGN KEY (NRAPROPAGENDAMENTODOCASSINA)
      REFERENCES FCT_APROPAGENDAMENTODOCASSINA (NRAPROPAGENDAMENTODOCASSINA)
/

CREATE INDEX SM00461_FK ON FCT_APROPJUSTHRNFAT (NRJUSTHORASNAOFATUCDA ASC)
/
	  
ALTER TABLE FCT_APROPAGENDOCLOGASSINA ADD CONSTRAINT CKC_IDATIVO_SERVPRESTDOCLOG CHECK (IDATIVO IN ('S', 'N'))
/
