
-- eseguire come utente MNP 

---------------------------------------------------------------
--SEQUENCE

CREATE SEQUENCE SEQ_LOV;
CREATE SEQUENCE seq_dbcgo_notifica_porting_out;

---------------------------------------------------------------
--TABLE

ALTER TABLE mnp_dbcgo_notifica_donor_out
ADD (codice_operatore_donating VARCHAR2(4));

---------------------------------------------------------------

ALTER TABLE mnp_dbcgo_notifica_rec_out
ADD (codice_operatore_recipient  VARCHAR2(4),
  	 codice_gruppo  VARCHAR2(12));

---------------------------------------------------------------
--------- codice dealer
---------------------------------------------------------------

ALTER TABLE mnp_sid_in
ADD (codice_dealer  VARCHAR2(10));

--------------------------------------------------------------- 

ALTER TABLE mnp_sid_scarti_in
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

ALTER TABLE mnp_msp_in_rec
ADD (codice_dealer  VARCHAR2(10));
 
---------------------------------------------------------------
 
ALTER TABLE mnp_msp_scarti_in
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

ALTER TABLE mnp_msc_in_rec
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

ALTER TABLE mnp_msc_scarti_in
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

ALTER TABLE mnp_gestione_richiesta_rec
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

ALTER TABLE mnp_dbcgo_notifica_rec_out
ADD (codice_dealer  VARCHAR2(10));

---------------------------------------------------------------

CREATE TABLE MNP_LOV
(
  LOV_ID    NUMBER NOT NULL,
  LOV_NAME  VARCHAR2(40 BYTE) NOT NULL,
  NAME      VARCHAR2(40 BYTE) NOT NULL,
  DESCR     VARCHAR2(200 BYTE) NOT NULL
)
TABLESPACE TAB_SMALL;

ALTER TABLE MNP_LOV ADD 
CONSTRAINT PK_MNP_LOV
 PRIMARY KEY (LOV_ID)
 USING INDEX 
 TABLESPACE TAB_IDX_SMALL
 ENABLE
 VALIDATE;

CREATE UNIQUE INDEX AK0_MNP_LOV ON MNP_LOV
(LOV_NAME, NAME)
TABLESPACE TAB_IDX_SMALL;

---------------------------------------------------------------

CREATE TABLE MNP_LOV_REF
(
  LOV_ID    NUMBER NOT NULL,
  LOV_ID_REF NUMBER NOT NULL
)
TABLESPACE TAB_SMALL;

ALTER TABLE MNP_LOV_REF ADD 
CONSTRAINT PK_MNP_LOV_REF
 PRIMARY KEY (LOV_ID,LOV_ID_REF)
 USING INDEX 
 TABLESPACE TAB_IDX_SMALL
 ENABLE
 VALIDATE;

ALTER TABLE MNP_LOV_REF
ADD CONSTRAINT FK0_MNP_LOV_REF
FOREIGN KEY (LOV_ID)
REFERENCES MNP_LOV (LOV_ID)
ENABLE
VALIDATE;

ALTER TABLE MNP_LOV_REF
ADD CONSTRAINT FK1_MNP_LOV_REF
FOREIGN KEY (LOV_ID_REF)
REFERENCES MNP_LOV (LOV_ID)
ENABLE
VALIDATE;

---------------------------------------------------------------

CREATE TABLE mnp_dbcgo_notifica_porting_out
    (
    id_prog                        NUMBER(18,0) NOT NULL,
    unique_id                      VARCHAR2(50),
    da_scodare                     NUMBER(1,0) DEFAULT 0  NOT NULL,
    id_richiesta                   VARCHAR2(23) NOT NULL,
    stato                          NUMBER(2,0) NOT NULL,
    data_transizione		           DATE NOT NULL,
    msisdn                         VARCHAR2(15) NOT NULL,
    data_cut_over                  DATE NOT NULL,
    dataricezionerichiesta         DATE NOT NULL,
    codice_operatore_donating      VARCHAR2(4) NOT NULL,
    codice_operatore_recipient     VARCHAR2(4) NOT NULL,
    data_invio				           DATE,
    data_creazione                 TIMESTAMP(6)      NOT NULL
 )
  TABLESPACE TAB_HUGE_2;

ALTER TABLE mnp_dbcgo_notifica_porting_out
ADD CONSTRAINT pk_dbcgo_notifica_port_out PRIMARY KEY (id_prog)
USING INDEX
TABLESPACE  TAB_IDX_HUGE_2_2;

CREATE INDEX idx_dbcgo_notifica_port_out_2 
ON mnp_dbcgo_notifica_porting_out (id_richiesta)
TABLESPACE  TAB_IDX_HUGE_2_2;

CREATE INDEX mnp_dbcgo_notifica_port_out_3 
ON mnp_dbcgo_notifica_porting_out (unique_id)
TABLESPACE  TAB_IDX_HUGE_2_2;

---------------------------------------------------------------