--------------------------------------------------------------------------
-- 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 
---DROP CONSTRAINT CONCTACONTABLE_PLAASIE_FK;
ALTER TABLE PLAASIENTO
   ADD CONSTRAINT CONCTACONTABLE_PLAASIE_FK FOREIGN KEY (CIA, CTA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLAMOVDED_FK;
ALTER TABLE PLAMOVDED
   ADD CONSTRAINT CONCTACONTABLE_PLAMOVDED_FK FOREIGN KEY (CIA, CTA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLAMOVDEDALT_FK;
ALTER TABLE PLAMOVDED
   ADD CONSTRAINT CONCTACONTABLE_PLAMOVDEDALT_FK FOREIGN KEY (CIA, CTAALTERNA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLAMOVDEV_FK;
ALTER TABLE PLAMOVDEV
   ADD CONSTRAINT CONCTACONTABLE_PLAMOVDEV_FK FOREIGN KEY (CIA, CTA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLACTAPLA_FK;
ALTER TABLE PLACTAPLANILLA
   ADD CONSTRAINT CONCTACONTABLE_PLACTAPLA_FK FOREIGN KEY (CIA, CTA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLAPARMO_PLA_FK;
ALTER TABLE PLAPARMONEDA
   ADD CONSTRAINT CONCTACONTABLE_PLAPARMO_PLA_FK FOREIGN KEY (CIA, CTAPLANILLA)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

---DROP CONSTRAINT CONCTACONTABLE_PLAPARMO_FON_FK;
ALTER TABLE PLAPARMONEDA
   ADD CONSTRAINT CONCTACONTABLE_PLAPARMO_FON_FK FOREIGN KEY (CIA, CTAFONDO)
      REFERENCES CON_CUENTA (COD_CIA, COD_CTA)
/

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

---DROP CONSTRAINT RHACCIONEMP_PLASALARIO_FK;
ALTER TABLE PLASALARIO
   ADD CONSTRAINT RHACCIONEMP_PLASALARIO_FK FOREIGN KEY (CIA, ACCION, NUMERO)
      REFERENCES RHACCIONEMP (CIA, ACCION, NUMERO)
/

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

ALTER TABLE PLAIDIOMAEMP DROP CONSTRAINT PLAEMPLEADO_IDIOMA_FK;
ALTER TABLE PLAIDIOMAEMP
   ADD CONSTRAINT PLAEMPLEADO_IDIOMAEMP_FK FOREIGN KEY (CIA, EMPLEADO)
      REFERENCES PLAEMPLEADO (CIA, EMPLEADO);
----
----
---DROP CONSTRAINT PLAPERINC_NUMPAGO_CK;
ALTER TABLE PLAPERINC
ADD CONSTRAINT PLAPERINC_NUMPAGO_CK CHECK (NUMPAGO >= 0);

---DROP CONSTRAINT PLAPERINC_DIAS_CK;
ALTER TABLE PLAPERINC
ADD CONSTRAINT PLAPERINC_DIAS_CK CHECK (DIAS >= 0);

---DROP CONSTRAINT PLAPERINC_ESTADO_CK;
ALTER TABLE PLAPERINC
ADD CONSTRAINT PLAPERINC_ESTADO_CK CHECK (ESTADO IN ('P','A','N'));

---DROP CONSTRAINT PLAPERVAC_NUMPAGO_CK;
ALTER TABLE PLAPERVAC
ADD CONSTRAINT PLAPERVAC_NUMPAGO_CK CHECK (NUMPAGO >= 0);

---DROP CONSTRAINT PLAPERVAC_DIAS_CK;
ALTER TABLE PLAPERVAC
ADD CONSTRAINT PLAPERVAC_DIAS_CK CHECK (DIAS >= 0);

---DROP CONSTRAINT PLAPERVAC_ESTADO_CK;
ALTER TABLE PLAPERVAC
ADD CONSTRAINT PLAPERVAC_ESTADO_CK CHECK (ESTADO IN ('P','A','N'));

---DROP CONSTRAINT PLAPUESTO_MESESPROME_CK;
ALTER TABLE PLAPUESTO
ADD CONSTRAINT PLAPUESTO_MESESPROME_CK CHECK (MESESPROMEXTRAS IS NULL OR (MESESPROMEXTRAS >= 1 ));

---DROP CONSTRAINT PLARESUMENSALTMP_SALARIOACT_CK;
ALTER TABLE PLARESUMENSALTMP
ADD CONSTRAINT PLARESUMENSALTMP_SALARIOACT_CK CHECK (SALARIOACTUAL >= 0);

ALTER TABLE PLATARIFALABOR DROP PRIMARY KEY CASCADE;
ALTER TABLE PLATARIFALABOR
ADD CONSTRAINT PLATARIFALABOR_PK PRIMARY KEY (CIA, LABOR, FECHA);

---DROP CONSTRAINT PLAEMPLEADO_PENSIONADO_CK;
ALTER TABLE PLAEMPLEADO
ADD CONSTRAINT PLAEMPLEADO_PENSIONADO_CK CHECK (PENSIONADO IN ('S','N'));

---DROP CONSTRAINT PLALABORESTRAB_TARIFA_CK;
ALTER TABLE PLALABORESTRAB
ADD CONSTRAINT PLALABORESTRAB_TARIFA_CK CHECK (TARIFA >= 0);

---DROP CONSTRAINT PLALIQUIDACION_MONAHOASO_CK;
ALTER TABLE PLALIQUIDACION
ADD CONSTRAINT PLALIQUIDACION_MONAHOASO_CK CHECK (MONAHOASO >= 0);

---DROP CONSTRAINT PLALIQUIDACION_MONAHOVAC_CK;
ALTER TABLE PLALIQUIDACION
ADD CONSTRAINT PLALIQUIDACION_MONAHOVAC_CK CHECK (MONAHOVAC >= 0);

---DROP CONSTRAINT PLALIQUIDACION_MONAPOVAC_CK;
ALTER TABLE PLALIQUIDACION
ADD CONSTRAINT PLALIQUIDACION_MONAPOVAC_CK CHECK (MONAPOVAC >= 0);

---DROP CONSTRAINT PLADETDEVEN_CLASE_CK;
ALTER TABLE PLADETDEVEN
ADD CONSTRAINT PLADETDEVEN_CLASE_CK CHECK (CLASE IN ('H','L','M'));

---DROP CONSTRAINT PLAMOVPRO_CLASEEMP_CK;
ALTER TABLE PLAMOVPRO
ADD CONSTRAINT PLAMOVPRO_CLASEEMP_CK CHECK (CLASEEMP IN ('P','N','A'));

---DROP CONSTRAINT PLAPARAMETRO_PORCBONOVA_CK;
ALTER TABLE PLAPARAMETRO
ADD CONSTRAINT PLAPARAMETRO_PORCBONOVA_CK CHECK (PORCBONOVAC >= 0);

ALTER TABLE PLAMOVPRO
MODIFY(CLASEEMP  NOT NULL);

ALTER TABLE PLAPARAMETRO
MODIFY(PROMVAC  NOT NULL);

ALTER TABLE PLALABORESTRAB
MODIFY(TARIFA  DEFAULT NULL);

ALTER TABLE PLACCOSTOEMP
MODIFY(PORCENTAJE NUMBER(5,2));

ALTER TABLE PLAPUESTO
DROP CONSTRAINT PLAPUESTO_MESESPROMEXTRAS_CK;
ALTER TABLE PLAPUESTO
 ADD CONSTRAINT PLAPUESTO_MESESPROMEXTRAS_CK
 CHECK (MESESPROMEXTRAS > 1);

ALTER TABLE PLAHORARIO
 DROP CONSTRAINT PLAHORARIO_DFDOBLES_CK;
ALTER TABLE PLAHORARIO
 ADD CONSTRAINT PLAHORARIO_DFDOBLES_CK CHECK (DFDOBLES IN ('S','N'));

ALTER TABLE PLAPLANILLA
 DROP CONSTRAINT PLAPLANILLA_CALCULO_CK;
ALTER TABLE PLAPLANILLA
 ADD CONSTRAINT PLAPLANILLA_CALCULO_CK CHECK (CALCULO IN ('H','M','L','D'));

ALTER TABLE PLATARIFALABOR DROP CONSTRAINT PLATARIFA_PK;
ALTER TABLE PLATARIFALABOR ADD CONSTRAINT PLATARIFALABOR_PK PRIMARY KEY (CIA, LABOR, FECHA);