From 601b41575e085950235769056e8ddc810cac8768 Mon Sep 17 00:00:00 2001 From: "gleison.cruz" Date: Fri, 15 Dec 2023 10:17:03 -0300 Subject: [PATCH 1/2] fixes bug#AL-3308 Acertando o script deste card que estava apontando a foreign key para a tabela errada --- pom.xml | 2 +- src/db/migration/V20231312_1654__AL-3308.sql | 17 +++++++++++++++++ src/db/migration/V20232611_1245__AL3308.sql | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/db/migration/V20231312_1654__AL-3308.sql diff --git a/pom.xml b/pom.xml index 1591ef2ba..ea26e83e6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores Flyway - 1.23.0 + 1.23.1 diff --git a/src/db/migration/V20231312_1654__AL-3308.sql b/src/db/migration/V20231312_1654__AL-3308.sql new file mode 100644 index 000000000..c38fa3ce9 --- /dev/null +++ b/src/db/migration/V20231312_1654__AL-3308.sql @@ -0,0 +1,17 @@ +DECLARE + itemExists NUMBER; + column_exists exception; + pragma exception_init (column_exists , -01430); +BEGIN + itemExists := 0; + SELECT COUNT(CONSTRAINT_NAME) INTO itemExists + FROM ALL_CONSTRAINTS + WHERE UPPER(CONSTRAINT_NAME) = UPPER('TIPO_EVENTO_EXTRA_FORMAPAGO_FK'); + + 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)'; + exception when column_exists then null; +END; \ No newline at end of file diff --git a/src/db/migration/V20232611_1245__AL3308.sql b/src/db/migration/V20232611_1245__AL3308.sql index b9807cbfa..c838c099d 100644 --- a/src/db/migration/V20232611_1245__AL3308.sql +++ b/src/db/migration/V20232611_1245__AL3308.sql @@ -12,7 +12,7 @@ begin USUARIO_ID NUMBER(7), PRIMARY KEY (TIPOEVENTOEXTRAFORMAPAGO_ID), CONSTRAINT TIPO_EVENTO_EXTRA_FMPTEE_FK FOREIGN KEY (TIPOEVENTOEXTRA_ID) REFERENCES TIPO_EVENTO_EXTRA (TIPOEVENTOEXTRA_ID), - CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK FOREIGN KEY (FORMAPAGO_ID) REFERENCES PUNTO_VENTA (PUNTOVENTA_ID) + CONSTRAINT TIPO_EVENTO_EXTRA_FORMAPAGO_FK FOREIGN KEY (FORMAPAGO_ID) REFERENCES FORMA_PAGO (FORMAPAGO_ID) )'; exception when object_exists then null; From a32bd45fba11f91918632256026ee5de162b0b6c Mon Sep 17 00:00:00 2001 From: "gleison.cruz" Date: Fri, 15 Dec 2023 10:50:43 -0300 Subject: [PATCH 2/2] fixes bug#AL-3308 --- pom.xml | 2 +- src/db/migration/V20231312_1654__AL-3308.sql | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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