--------------------------------------------------------------------------
-- Play this script in PRUEBAS@VISANY to make it look like DESA@VISMAR
--                                                                      --
-- Please review the script before using it to make sure it won't       --
-- cause any unacceptable data loss.                                    --
--                                                                      --
-- PRUEBAS@VISANY Schema Extracted by User PRUEBAS 
-- DESA@VISMAR Schema Extracted by User DESA 
-- Difference : Column Order (No action taken) 

--
-- PLADETPASIVO  (Table) 
--
CREATE TABLE PLADETPASIVO
(
  CIA             CHAR(3 BYTE)                  NOT NULL,
  FECHASALIDA     DATE                          NOT NULL,
  EMPLEADO        VARCHAR2(15 BYTE)             NOT NULL,
  FECHAINGRESO    DATE                          NOT NULL,
  MESESLABORADOS  NUMBER(7,2)                   NOT NULL,
  SALARIO         NUMBER(14,2)                  NOT NULL,
  SALPROMDIA      NUMBER(14,2)                  NOT NULL,
  SALPROMVAC      NUMBER(14,2)                  NOT NULL,
  PERSEIS         NUMBER(4)                     NOT NULL,
  PERAGUINALDO    NUMBER(4)                     NOT NULL,
  PERSALIDA       NUMBER(4)                     NOT NULL,
  MONCESANTIA     NUMBER(14,2)                  NOT NULL,
  MONPREAVISO     NUMBER(14,2)                  NOT NULL,
  MONAGUINALDO    NUMBER(14,2)                  NOT NULL,
  MONVACACION     NUMBER(14,2)                  NOT NULL,
  MONAHOVAC       NUMBER(14,2)                  NOT NULL,
  MONAPOVAC       NUMBER(14,2)                  NOT NULL,
  MONAPOASO       NUMBER(14,2)                  NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADETPASIVO
 ADD CONSTRAINT PLADETPASIVO_PK
 PRIMARY KEY
 (CIA, FECHASALIDA, EMPLEADO);

ALTER TABLE PLAPARAMETRO
 ADD (DIASPAGOVAC  NUMBER(3)                        DEFAULT 1                     NOT NULL);

ALTER TABLE PLAPUESTO
MODIFY(MESESPROMEXTRAS  NULL);

ALTER TABLE PLARESUMENSALTMP
MODIFY(SALARIOACTUAL  DEFAULT 0);

ALTER TABLE PLATEF
MODIFY(CUENTA  NULL);

ALTER TABLE PLADETTURNO
 ADD (DIA  CHAR(1 BYTE)                             DEFAULT 0                     NOT NULL);

ALTER TABLE PLALIQUIDACION
MODIFY(MONAHOVAC  DEFAULT 0);

ALTER TABLE PLALIQUIDACION
MODIFY(MONAPOVAC  DEFAULT 0);

ALTER TABLE PLALIQUIDACION
MODIFY(MONAHOASO  DEFAULT 0);

--
-- PLAMOVPROEMP  (Table) 
--
CREATE TABLE PLAMOVPROEMP
(
  CIA        CHAR(3 BYTE)                       NOT NULL,
  EMPLEADO   VARCHAR2(15 BYTE)                  NOT NULL,
  TIPOMOV    CHAR(3 BYTE)                       NOT NULL,
  TIPOVALOR  CHAR(1 BYTE)                       NOT NULL,
  VALOR      NUMBER(14,4)                       NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAMOVPROEMP
 ADD CONSTRAINT PLAMOVPROEMP_TIPOVALOR_CK
 CHECK (tipoValor in ('M','P'));

ALTER TABLE PLAMOVPROEMP
 ADD CONSTRAINT PLAMOVPROEMP_VALOR_CK
 CHECK (valor >= 0);

ALTER TABLE PLAMOVPROEMP
 ADD CONSTRAINT PLAMOVPROEMP_PK
 PRIMARY KEY
 (CIA, EMPLEADO, TIPOMOV);

ALTER TABLE PLAPRESTAMO
MODIFY(REFERENCIA  DEFAULT '0');

OK
ALTER TABLE PLAABOPRE
 DROP CONSTRAINT PLAABOPRE_INDPLANILL_CK;
ALTER TABLE PLAABOPRE
 ADD CONSTRAINT PLAABOPRE_INDPLANILL_CK
 CHECK (indplanilla in ('A','C','L','E','O','M'));

ALTER TABLE PLAPERINC
 DROP PRIMARY KEY CASCADE;
ALTER TABLE PLAPERINC
 ADD CONSTRAINT PLAPERINC_PK
 PRIMARY KEY
 (CIA, PLANILLA, PERIODO, INDPLANILLA, NUMPAGO, EMPLEADO, FECHAINICIAL);

ALTER TABLE PLAPERVAC
 DROP PRIMARY KEY CASCADE;
ALTER TABLE PLAPERVAC
 ADD CONSTRAINT PLAPERVAC_PK
 PRIMARY KEY
 (CIA, PLANILLA, PERIODO, INDPLANILLA, NUMPAGO, EMPLEADO, FECHAINICIAL);

ALTER TABLE PLADETTURNO
 DROP PRIMARY KEY CASCADE;
ALTER TABLE PLADETTURNO
 ADD CONSTRAINT PLADETTURNO_PK
 PRIMARY KEY
 (CIA, TURNO, DIA, ORDINAL);

ALTER TABLE PLAHORASTRAB
 ADD CONSTRAINT PLAHORASTRAB_SALARIOHOR_CK
 CHECK (salarioHora >= 0);

ALTER TABLE PLALABORESTRAB
 DROP CONSTRAINT PLALABORESTRAB_CANTIDAD_CK;
ALTER TABLE PLALABORESTRAB
 ADD CONSTRAINT PLALABORESTRAB_CANTIDAD_CK
 CHECK (cantidad > 0);

ALTER TABLE PLAMARCA
 ADD CONSTRAINT PLAMARCA_SALARIOHOR_CK
 CHECK (salarioHora >= 0);

ALTER TABLE PLACCOSTOEMP
 DROP CONSTRAINT PLACCOSTOEMP_PORCENTAJE_CK;
ALTER TABLE PLACCOSTOEMP
 ADD CONSTRAINT PLACCOSTOEMP_PORCENTAJE_CK
 CHECK (porcentaje > 0);

ALTER TABLE PLAMOVPROEMP
 ADD CONSTRAINT PLAEMPLEADO_MOVPROEMP_FK 
 FOREIGN KEY (CIA, EMPLEADO) 
 REFERENCES PLAEMPLEADO (CIA,EMPLEADO);

ALTER TABLE PLATEF
 ADD CONSTRAINT BANMAE_PLATEF_FK 
 FOREIGN KEY (CIA, CUENTAEMPRESA) 
 REFERENCES BANMAE (COD_CIA,CUENTA);

ALTER TABLE PLATARIFALABOR
 ADD CONSTRAINT PLALABOR_TARIFALAB_FK 
 FOREIGN KEY (CIA, LABOR) 
 REFERENCES PLALABOR (CIA, LABOR);

ALTER TABLE PLAIDIOMAEMP
 ADD CONSTRAINT PLAEMPLEADO_IDIOMAEMP_FK 
 FOREIGN KEY (CIA, EMPLEADO) 
 REFERENCES PLAEMPLEADO (CIA,EMPLEADO);

ALTER TABLE PLAIDIOMAEMP
 ADD CONSTRAINT RHIDIOMA_IDIOMAEMP_FK 
 FOREIGN KEY (IDIOMA) 
 REFERENCES RHIDIOMA (IDIOMA);

ALTER TABLE PLACCOSTOEMP
 ADD CONSTRAINT PLAEMPLEADO_CCOSTOEMP_FK 
 FOREIGN KEY (CIA, EMPLEADO) 
 REFERENCES PLAEMPLEADO (CIA,EMPLEADO);

CAMBIOS MEXICO

ALTER TABLE PLAPARAMETRO
 ADD (DIASAGUINALDO  NUMBER(3) DEFAULT 15       NOT NULL);

ALTER TABLE PLAPARAMETRO
 ADD (PORCSUBSIDIO  NUMBER(5,2)  DEFAULT 100    NOT NULL);

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMSS  CHAR(3 BYTE));

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMPSAL  CHAR(3 BYTE));

ALTER TABLE PLAPARAMETRO
 ADD (MOVIMPNOMINA  CHAR(3 BYTE));

CREATE TABLE PLADEVIMPNOMINA
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL
);

ALTER TABLE PLADEVIMPNOMINA
 ADD CONSTRAINT PLADEVIMPNOMINA_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

--
-- PLADEVIMPSAL  (Table) 
--
CREATE TABLE PLADEVIMPSAL
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL,
  FORMULA  VARCHAR2(80 BYTE)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADEVIMPSAL
 ADD CONSTRAINT PLADEVIMPSAL_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

--
-- PLADEVPTU  (Table) 
--
CREATE TABLE PLADEVPTU
(
  CIA      CHAR(3 BYTE)                         NOT NULL,
  TIPOMOV  CHAR(3 BYTE)                         NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLADEVPTU
 ADD CONSTRAINT PLADEVPTU_PK
 PRIMARY KEY
 (CIA, TIPOMOV);

-- Difference : Column Order (No action taken) 
ALTER TABLE PLAEMPLEADO
 ADD (CURP  VARCHAR2(20 BYTE));
--
CREATE TABLE PLAIMPSAL
(
  CIA            CHAR(3 BYTE)                   NOT NULL,
  PLANILLA       CHAR(2 BYTE)                   NOT NULL,
  LIMITEINF      NUMBER(14,2)                   NOT NULL,
  CUOTAFIJA      NUMBER(14,2)                   NOT NULL,
  PORCEXCEDENTE  NUMBER(5,2)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSAL
 ADD CONSTRAINT PLAIMPSAL_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

--
-- PLAIMPSALCREDITO  (Table) 
--
CREATE TABLE PLAIMPSALCREDITO
(
  CIA        CHAR(3 BYTE)                       NOT NULL,
  PLANILLA   CHAR(2 BYTE)                       NOT NULL,
  LIMITEINF  NUMBER(14,2)                       NOT NULL,
  CREDITO    NUMBER(14,2)                       NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSALCREDITO
 ADD CONSTRAINT PLAIMPSALCREDITO_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

--
-- PLAIMPSALSUBSIDIO  (Table) 
--
CREATE TABLE PLAIMPSALSUBSIDIO
(
  CIA            CHAR(3 BYTE)                   NOT NULL,
  PLANILLA       CHAR(2 BYTE)                   NOT NULL,
  LIMITEINF      NUMBER(14,2)                   NOT NULL,
  CUOTAFIJA      NUMBER(14,2)                   NOT NULL,
  PORCEXCEDENTE  NUMBER(5,2)                    NOT NULL
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

ALTER TABLE PLAIMPSALSUBSIDIO
 ADD CONSTRAINT PLAIMPSALSUBSIDIO_PK
 PRIMARY KEY
 (CIA, PLANILLA, LIMITEINF);

ALTER TABLE PLADEVIMPNOMINA
 ADD CONSTRAINT PLAMOVDEV_DEVIMPNOMINA_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

ALTER TABLE PLADEVIMPSAL
 ADD CONSTRAINT PLAMOVDEV_DEVIMPSAL_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

ALTER TABLE PLADEVPTU
 ADD CONSTRAINT PLAMOVDEV_DEVPTU_FK 
 FOREIGN KEY (CIA, TIPOMOV) 
 REFERENCES PLAMOVDEV (CIA,TIPOMOV);

ALTER TABLE PLAIMPSAL
 ADD CONSTRAINT PLAPLANILLA_IMPSAL_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);

ALTER TABLE PLAIMPSALCREDITO
 ADD CONSTRAINT PLAPLANILLA_IMPSALCREDITO_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);

ALTER TABLE PLAIMPSALSUBSIDIO
 ADD CONSTRAINT PLAPLANILLA_IMPSALSUBSIDIO_FK 
 FOREIGN KEY (CIA, PLANILLA) 
 REFERENCES PLAPLANILLA (CIA,PLANILLA);