diff --git a/pom.xml b/pom.xml index ea26e83e6..5b080e39b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores Flyway - 1.23.1 + 1.23.2 diff --git a/src/db/migration/V20231312_1654__AL-3308.sql b/src/db/migration/V20231312_1654__AL-3308.sql index c38fa3ce9..e811ef183 100644 --- a/src/db/migration/V20231312_1654__AL-3308.sql +++ b/src/db/migration/V20231312_1654__AL-3308.sql @@ -1,4 +1,5 @@ DECLARE + tabelaExists NUMBER; itemExists NUMBER; column_exists exception; pragma exception_init (column_exists , -01430); @@ -11,7 +12,12 @@ BEGIN IF itemExists > 0 THEN EXECUTE IMMEDIATE 'ALTER TABLE TIPO_EVENTO_EXTRA_FORMAPAGO DROP CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK'; END IF; - - EXECUTE IMMEDIATE 'ALTER TABLE TIPO_EVENTO_EXTRA_FORMAPAGO ADD CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK FOREIGN KEY (FORMAPAGO_ID) REFERENCES FORMA_PAGO (FORMAPAGO_ID)'; + + SELECT COUNT(TABLE_NAME) INTO tabelaExists + FROM ALL_TABLES + WHERE UPPER(TABLE_NAME) = UPPER('TIPO_EVENTO_EXTRA_FORMAPAGO'); + IF itemExists > 0 THEN + EXECUTE IMMEDIATE 'ALTER TABLE TIPO_EVENTO_EXTRA_FORMAPAGO ADD CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK FOREIGN KEY (FORMAPAGO_ID) REFERENCES FORMA_PAGO (FORMAPAGO_ID)'; + END IF; exception when column_exists then null; END; \ No newline at end of file