From cb164dfdf7fb60dbfd6b1dde66ed0df3c3c44e02 Mon Sep 17 00:00:00 2001 From: alberto Date: Fri, 23 Sep 2016 20:03:06 +0000 Subject: [PATCH] git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/BD/FlyWay/trunk@60663 d1611594-4594-4d17-8e1d-87c2c4800839 --- .classpath | 13 ++++++++ .project | 30 +++++++++++++++++++ .settings/org.eclipse.jdt.core.prefs | 11 +++++++ .settings/org.eclipse.wst.common.component | 6 ++++ ....eclipse.wst.common.project.facet.core.xml | 8 +++++ src/META-INF/MANIFEST.MF | 3 ++ .../rjconsultores/ventaboletos/FlyWay.java | 29 ++++++++++++++++++ .../V20160726_1445__casetapeajeexcepcion.sql | 29 ++++++++++++++++++ .../V20160727_1529__exibecorridabloqueada.sql | 1 + .../migration/V20160727_1536__mantis7411.sql | 4 +++ .../V20160728_1738__inativarruta.sql | 1 + ...V20160729_1502__excepcionpeajevigencia.sql | 5 ++++ .../migration/V20160801_1033__mantis7781.sql | 21 +++++++++++++ .../migration/V20160801_1449__txemarque.sql | 7 +++++ .../V20160801_1732__dropTarifaConstraint.sql | 15 ++++++++++ ...0802_1636__dropTarifaOficialConstraint.sql | 14 +++++++++ .../V20160804_1559__nullvalesruta.sql | 2 ++ ...818_1000__increase_importe_peaje_scale.sql | 1 + .../V20160822_2033__reunpaulista.sql | 7 +++++ .../migration/V20160825_1712__mantis7849.sql | 2 ++ .../migration/V20160830_1614__mantis7879.sql | 13 ++++++++ .../V20160901_1030__classeindicepeaj.sql | 11 +++++++ .../V20160913_1649__classeindicepeaje.sql | 4 +++ .../migration/V20160921_0945__mantis7982.sql | 1 + 24 files changed, 238 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 src/META-INF/MANIFEST.MF create mode 100644 src/com/rjconsultores/ventaboletos/FlyWay.java create mode 100644 src/db/migration/V20160726_1445__casetapeajeexcepcion.sql create mode 100644 src/db/migration/V20160727_1529__exibecorridabloqueada.sql create mode 100644 src/db/migration/V20160727_1536__mantis7411.sql create mode 100644 src/db/migration/V20160728_1738__inativarruta.sql create mode 100644 src/db/migration/V20160729_1502__excepcionpeajevigencia.sql create mode 100644 src/db/migration/V20160801_1033__mantis7781.sql create mode 100644 src/db/migration/V20160801_1449__txemarque.sql create mode 100644 src/db/migration/V20160801_1732__dropTarifaConstraint.sql create mode 100644 src/db/migration/V20160802_1636__dropTarifaOficialConstraint.sql create mode 100644 src/db/migration/V20160804_1559__nullvalesruta.sql create mode 100644 src/db/migration/V20160818_1000__increase_importe_peaje_scale.sql create mode 100644 src/db/migration/V20160822_2033__reunpaulista.sql create mode 100644 src/db/migration/V20160825_1712__mantis7849.sql create mode 100644 src/db/migration/V20160830_1614__mantis7879.sql create mode 100644 src/db/migration/V20160901_1030__classeindicepeaj.sql create mode 100644 src/db/migration/V20160913_1649__classeindicepeaje.sql create mode 100644 src/db/migration/V20160921_0945__mantis7982.sql diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..5ffd997a0 --- /dev/null +++ b/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..839642918 --- /dev/null +++ b/.project @@ -0,0 +1,30 @@ + + + Flyway + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..54e493c07 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..d2ee621a4 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,6 @@ + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..8e77f872f --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF new file mode 100644 index 000000000..5e9495128 --- /dev/null +++ b/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/src/com/rjconsultores/ventaboletos/FlyWay.java b/src/com/rjconsultores/ventaboletos/FlyWay.java new file mode 100644 index 000000000..8bbb04985 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/FlyWay.java @@ -0,0 +1,29 @@ +package com.rjconsultores.ventaboletos; + +import org.apache.log4j.Logger; +import org.flywaydb.core.Flyway; +import javax.sql.DataSource; + +public class FlyWay { + private static Logger log = Logger.getLogger(FlyWay.class); + + public static void start(final DataSource dataSource) { + log.info("Executando Flyway..."); + + try{ + final Flyway flyway = new Flyway(); + + flyway.setDataSource(dataSource); + flyway.setValidateOnMigrate(false); + flyway.setIgnoreFutureMigrations(true); + flyway.setOutOfOrder(true); + flyway.setBaselineOnMigrate(true); + + flyway.migrate(); + }catch(Throwable t){ + log.error("Erro ao executar o flyway",t); + } + + log.info("Flyway executado."); + } +} diff --git a/src/db/migration/V20160726_1445__casetapeajeexcepcion.sql b/src/db/migration/V20160726_1445__casetapeajeexcepcion.sql new file mode 100644 index 000000000..89eb7a32e --- /dev/null +++ b/src/db/migration/V20160726_1445__casetapeajeexcepcion.sql @@ -0,0 +1,29 @@ + +CREATE TABLE + CASETA_PEAJE_EXCEPCION + ( + CASETAPEAJEEXCEPCION_ID NUMBER(7) NOT NULL, + CASETAPEAJE_ID NUMBER(7) NOT NULL, + FECHAVENTAINI DATE, + FECHAVENTAFIN DATE, + FECHORINICIO DATE, + FECHORFINAL DATE, + INDLUNES NUMBER(1), + INDMARTES NUMBER(1), + INDMIERCOLES NUMBER(1), + INDJUEVES NUMBER(1), + INDVIERNES NUMBER(1), + INDSABADO NUMBER(1), + INDDOMINGO NUMBER(1), + ACTIVO NUMBER(1), + FECMODIF DATE, + USUARIO_ID NUMBER(7), + PRECIO NUMBER(7,2), + CONSTRAINT CASETA_PEAJE_EXCEPCION_PK PRIMARY KEY (CASETAPEAJEEXCEPCION_ID), + CONSTRAINT CASETAPEXCEPCION_CASETA_FK FOREIGN KEY (CASETAPEAJE_ID) REFERENCES + CASETA_PEAJE (CASETAPEAJE_ID), + CONSTRAINT NNC_CASETAPEAJEEXCEPCION_ID CHECK ("CASETAPEAJEEXCEPCION_ID" IS NOT NULL), + CONSTRAINT NNC_CASETAPEAJE_ID CHECK ("CASETAPEAJE_ID" IS NOT NULL) + ); + +CREATE SEQUENCE "CASETA_PEAJE_EXCEPCION_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE ; \ No newline at end of file diff --git a/src/db/migration/V20160727_1529__exibecorridabloqueada.sql b/src/db/migration/V20160727_1529__exibecorridabloqueada.sql new file mode 100644 index 000000000..fe80a6ea5 --- /dev/null +++ b/src/db/migration/V20160727_1529__exibecorridabloqueada.sql @@ -0,0 +1 @@ +ALTER TABLE CONF_RESTRICAO_CANALVENTA ADD (INDEXIBECORRIDABLOQ NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE); \ No newline at end of file diff --git a/src/db/migration/V20160727_1536__mantis7411.sql b/src/db/migration/V20160727_1536__mantis7411.sql new file mode 100644 index 000000000..6c2bdd96a --- /dev/null +++ b/src/db/migration/V20160727_1536__mantis7411.sql @@ -0,0 +1,4 @@ +insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID) +values +(FUNCION_SISTEMA_SEQ.NEXTVAL,'2','VDA > MANUTENÇÃO DE SERVIÇOS >> MODIFICAÇÕES DE SERVIÇO >>> INICIADO/FECHADO', +'COM.RJCONSULTORES.VENTABOLETOS.GUI.VENTA.MENU.ITENS.MODIFICASERVICOINICIADOFECHADO','1',SYSDATE,'1'); \ No newline at end of file diff --git a/src/db/migration/V20160728_1738__inativarruta.sql b/src/db/migration/V20160728_1738__inativarruta.sql new file mode 100644 index 000000000..bcfd41c28 --- /dev/null +++ b/src/db/migration/V20160728_1738__inativarruta.sql @@ -0,0 +1 @@ +ALTER TABLE RUTA ADD INDRUTACENLADA NUMERIC(1) default 0; \ No newline at end of file diff --git a/src/db/migration/V20160729_1502__excepcionpeajevigencia.sql b/src/db/migration/V20160729_1502__excepcionpeajevigencia.sql new file mode 100644 index 000000000..290516755 --- /dev/null +++ b/src/db/migration/V20160729_1502__excepcionpeajevigencia.sql @@ -0,0 +1,5 @@ +ALTER TABLE + EXCEPCION_PEAJE_VIGENCIA ADD (CASETAPEAJE_ID NUMBER(7)); +ALTER TABLE + EXCEPCION_PEAJE_VIGENCIA ADD CONSTRAINT EXCPEAJEVIGENCIA_CASETA_FK FOREIGN KEY + (CASETAPEAJE_ID) REFERENCES CASETA_PEAJE (CASETAPEAJE_ID) \ No newline at end of file diff --git a/src/db/migration/V20160801_1033__mantis7781.sql b/src/db/migration/V20160801_1033__mantis7781.sql new file mode 100644 index 000000000..545752ea9 --- /dev/null +++ b/src/db/migration/V20160801_1033__mantis7781.sql @@ -0,0 +1,21 @@ +declare + column_exists exception; + ja_existe exception; + pragma exception_init (column_exists , -01430); + pragma exception_init (ja_existe , -00001); +begin + execute immediate 'ALTER TABLE EMPRESA ADD INDGENNUMFOLIOVTAINTIMPOST NUMBER(1,0) DEFAULT 0 NOT NULL'; + INSERT INTO FUNCION_SISTEMA VALUES + ( + FUNCION_SISTEMA_SEQ.NEXTVAL, + 1, + 'ADM > CATALOGOS >> EMPRESA >> GERA NUMERO BILHETE VENDA INTERNET E IMP. POSTERIOR', + 'COM.RJCONSULTORES.ADMINISTRACION.GUI.CATALOGO.MENU.EMPRESA.GENERAFOLIOSISTEMAVTAINTIMPPOSTERIOR', + 1 , + sysdate, + 1 + ); + exception + when column_exists then null; + when ja_existe then null; +end; \ No newline at end of file diff --git a/src/db/migration/V20160801_1449__txemarque.sql b/src/db/migration/V20160801_1449__txemarque.sql new file mode 100644 index 000000000..f11e90705 --- /dev/null +++ b/src/db/migration/V20160801_1449__txemarque.sql @@ -0,0 +1,7 @@ +declare + column_exists exception; + pragma exception_init (column_exists , -01430); +begin + execute immediate 'ALTER TABLE TAXA_EMBARQUE_PARADA ADD (EMPRESA_ID NUMBER(7) DEFAULT -1 NOT NULL)'; + exception when column_exists then null; +end; \ No newline at end of file diff --git a/src/db/migration/V20160801_1732__dropTarifaConstraint.sql b/src/db/migration/V20160801_1732__dropTarifaConstraint.sql new file mode 100644 index 000000000..a6350b011 --- /dev/null +++ b/src/db/migration/V20160801_1732__dropTarifaConstraint.sql @@ -0,0 +1,15 @@ +--drop constraint se existe +DECLARE +itemExists NUMBER; +BEGIN + itemExists := 0; + +SELECT COUNT(CONSTRAINT_NAME) INTO itemExists +FROM ALL_CONSTRAINTS +WHERE UPPER(CONSTRAINT_NAME) = UPPER('TARIFA_UNICA'); + +IF itemExists > 0 THEN +EXECUTE IMMEDIATE 'ALTER TABLE TARIFA DROP CONSTRAINT TARIFA_UNICA'; +END IF; + +END; \ No newline at end of file diff --git a/src/db/migration/V20160802_1636__dropTarifaOficialConstraint.sql b/src/db/migration/V20160802_1636__dropTarifaOficialConstraint.sql new file mode 100644 index 000000000..6657085e0 --- /dev/null +++ b/src/db/migration/V20160802_1636__dropTarifaOficialConstraint.sql @@ -0,0 +1,14 @@ +--drop constraint se existe +DECLARE +itemExists NUMBER; +BEGIN + itemExists := 0; + +SELECT COUNT(CONSTRAINT_NAME) INTO itemExists +FROM ALL_CONSTRAINTS +WHERE UPPER(CONSTRAINT_NAME) = UPPER('UNIQUE_TARIFA_OFICIAL'); + +IF itemExists > 0 THEN +EXECUTE IMMEDIATE 'ALTER TABLE TARIFA_OFICIAL DROP CONSTRAINT UNIQUE_TARIFA_OFICIAL'; +END IF; +END; \ No newline at end of file diff --git a/src/db/migration/V20160804_1559__nullvalesruta.sql b/src/db/migration/V20160804_1559__nullvalesruta.sql new file mode 100644 index 000000000..2287cab4d --- /dev/null +++ b/src/db/migration/V20160804_1559__nullvalesruta.sql @@ -0,0 +1,2 @@ +update ruta set INDRUTACENLADA=0 where INDRUTACENLADA is null; +alter table ruta modify (INDRUTACENLADA not null); \ No newline at end of file diff --git a/src/db/migration/V20160818_1000__increase_importe_peaje_scale.sql b/src/db/migration/V20160818_1000__increase_importe_peaje_scale.sql new file mode 100644 index 000000000..d83b8c5e7 --- /dev/null +++ b/src/db/migration/V20160818_1000__increase_importe_peaje_scale.sql @@ -0,0 +1 @@ +alter table peaje modify (importepeaje number(15, 10)); \ No newline at end of file diff --git a/src/db/migration/V20160822_2033__reunpaulista.sql b/src/db/migration/V20160822_2033__reunpaulista.sql new file mode 100644 index 000000000..0ae82b1b1 --- /dev/null +++ b/src/db/migration/V20160822_2033__reunpaulista.sql @@ -0,0 +1,7 @@ +declare + column_exists exception; + pragma exception_init (column_exists , -01430); +begin + execute immediate 'ALTER TABLE TARIFA_KM MODIFY (KMATE NUMBER(7, 2))'; + exception when column_exists then null; +end; \ No newline at end of file diff --git a/src/db/migration/V20160825_1712__mantis7849.sql b/src/db/migration/V20160825_1712__mantis7849.sql new file mode 100644 index 000000000..9b77d1f2e --- /dev/null +++ b/src/db/migration/V20160825_1712__mantis7849.sql @@ -0,0 +1,2 @@ +ALTER TABLE DIAGRAMA_AUTOBUS ADD (INDTIPO NUMBER(1)); +UPDATE DIAGRAMA_AUTOBUS SET INDTIPO = INDBARCO + 1; \ No newline at end of file diff --git a/src/db/migration/V20160830_1614__mantis7879.sql b/src/db/migration/V20160830_1614__mantis7879.sql new file mode 100644 index 000000000..37c767e7a --- /dev/null +++ b/src/db/migration/V20160830_1614__mantis7879.sql @@ -0,0 +1,13 @@ +declare + dup_val_on_index exception; + pragma exception_init (dup_val_on_index , -00001); +begin + execute immediate 'insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID) + values (FUNCION_SISTEMA_SEQ.NEXTVAL,1,''ADM > INTEGRACION'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.INTEGRACION'',1,SYSDATE, -1)'; + execute immediate 'insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID) + values (FUNCION_SISTEMA_SEQ.NEXTVAL,1,''ADM > ANALITICO'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.ANALITICO'',1,SYSDATE, -1)'; + execute immediate 'insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID) + values (FUNCION_SISTEMA_SEQ.NEXTVAL,1,''ADM > ANALITICO > BGM'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.ANALITICO.BGM'',1,SYSDATE,-1)'; + + exception when dup_val_on_index then null; +end; \ No newline at end of file diff --git a/src/db/migration/V20160901_1030__classeindicepeaj.sql b/src/db/migration/V20160901_1030__classeindicepeaj.sql new file mode 100644 index 000000000..270a4880a --- /dev/null +++ b/src/db/migration/V20160901_1030__classeindicepeaj.sql @@ -0,0 +1,11 @@ +CREATE TABLE CLASSE_INDICE_PEAJE ( + CLASSE_INDICE_PEAJE_ID INTEGER PRIMARY KEY, + ACTIVO NUMERIC(1), + CLASSE_SERVICIO_ID INTEGER, + ORGAOCONCEDENTE_ID INTEGER, + INDICE_PEAJE INTEGER, + FOREIGN KEY (CLASSE_SERVICIO_ID) REFERENCES CLASE_SERVICIO (CLASESERVICIO_ID), + FOREIGN KEY (ORGAOCONCEDENTE_ID) REFERENCES ORGAO_CONCEDENTE (ORGAOCONCEDENTE_ID) +); + +CREATE SEQUENCE "CLASSE_INDICE_PEAJE_SEQ" MINVALUE 1 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE ; \ No newline at end of file diff --git a/src/db/migration/V20160913_1649__classeindicepeaje.sql b/src/db/migration/V20160913_1649__classeindicepeaje.sql new file mode 100644 index 000000000..1a269bb55 --- /dev/null +++ b/src/db/migration/V20160913_1649__classeindicepeaje.sql @@ -0,0 +1,4 @@ +DELETE FROM CLASSE_INDICE_PEAJE; + +ALTER TABLE CLASSE_INDICE_PEAJE +MODIFY (INDICE_PEAJE NUMERIC(7,2)); diff --git a/src/db/migration/V20160921_0945__mantis7982.sql b/src/db/migration/V20160921_0945__mantis7982.sql new file mode 100644 index 000000000..e332b4ef6 --- /dev/null +++ b/src/db/migration/V20160921_0945__mantis7982.sql @@ -0,0 +1 @@ +alter table PUNTO_VENTA ADD (FECFECHAMENTO DATE, FECABERTURA DATE); \ No newline at end of file