From 635df4331ffcdb719cf569e08f2be07e4073975c Mon Sep 17 00:00:00 2001 From: "valdir.cordeiro" Date: Wed, 14 Jun 2023 14:40:28 -0300 Subject: [PATCH] =?UTF-8?q?bug#al-2761=20GLPI=2064102=20-=20{Projeto}=20-?= =?UTF-8?q?=20Espec=20Pricing=20Conex=C3=A3o=20-=20Aguia=20Branca=20dev:?= =?UTF-8?q?=20qua:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correção do script para evitar problemas em bancos de réplica. --- pom.xml | 2 +- src/db/migration/V20230605_1453__AL2761.sql | 132 ++++++++++++++++-- .../migration/V20230605_1453__AL2761.sql | 32 ++++- 3 files changed, 152 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index ff27813b4..8592eac50 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores Flyway - 1.4.1 + 1.4.2 diff --git a/src/db/migration/V20230605_1453__AL2761.sql b/src/db/migration/V20230605_1453__AL2761.sql index 8d19358e0..e925ddc21 100644 --- a/src/db/migration/V20230605_1453__AL2761.sql +++ b/src/db/migration/V20230605_1453__AL2761.sql @@ -1,12 +1,120 @@ -declare - object_exists exception; - except_00957 exception; - - pragma exception_init (object_exists , -01430); - pragma exception_init (except_00957 , -00957); -begin - execute immediate 'ALTER TABLE PRICING_OCUPA_ANTECIPA MODIFY IMPORTE NUMBER(10,2)'; - exception - when object_exists then null; - when except_00957 then null; -end; \ No newline at end of file +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01440 , -01440); +begin + execute immediate 'ALTER TABLE PRICING_OCUPA_ANTECIPA ADD (IMPORTE_AUX NUMBER(10,2))'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; +end; +/ +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01440 , -01440); +begin + execute immediate 'UPDATE PRICING_OCUPA_ANTECIPA SET IMPORTE_AUX = IMPORTE'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; +end; +/ +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + except_00904 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01442 , -01440); + pragma exception_init (except_00904 , -00904); +begin + execute immediate 'ALTER TABLE PRICING_OCUPA_ANTECIPA DROP COLUMN IMPORTE'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; + when except_00904 then null; +end; +/ +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01440 , -01440); +begin + execute immediate 'ALTER TABLE PRICING_OCUPA_ANTECIPA ADD (IMPORTE NUMBER(10,2))'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; +end; +/ +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01440 , -01440); +begin + execute immediate 'UPDATE PRICING_OCUPA_ANTECIPA SET IMPORTE = IMPORTE_AUX'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; +end; +/ +declare + object_exists exception; + except_01451 exception; + except_01442 exception; + except_01440 exception; + except_00904 exception; + + pragma exception_init (object_exists , -01430); + pragma exception_init (except_01451 , -01451); + pragma exception_init (except_01442 , -01442); + pragma exception_init (except_01442 , -01440); + pragma exception_init (except_00904 , -00904); +begin + execute immediate 'ALTER TABLE PRICING_OCUPA_ANTECIPA DROP COLUMN IMPORTE_AUX'; + exception + when object_exists then null; + when except_01451 then null; + when except_01442 then null; + when except_01440 then null; + when except_00904 then null; +end; +/ \ No newline at end of file diff --git a/src/db/postgresql/migration/V20230605_1453__AL2761.sql b/src/db/postgresql/migration/V20230605_1453__AL2761.sql index 6b6273dee..d257bcfe8 100644 --- a/src/db/postgresql/migration/V20230605_1453__AL2761.sql +++ b/src/db/postgresql/migration/V20230605_1453__AL2761.sql @@ -1,5 +1,35 @@ DO $$ BEGIN - ALTER TABLE PRICING_OCUPA_ANTECIPA MODIFY IMPORTE NUMBER(10,2); + ALTER TABLE PRICING_OCUPA_ANTECIPA ADD (IMPORTE_AUX NUMBER(10,2)); +END +$$; +/ +DO $$ +BEGIN + UPDATE PRICING_OCUPA_ANTECIPA SET IMPORTE_AUX = IMPORTE; +END +$$; +/ +DO $$ +BEGIN + ALTER TABLE PRICING_OCUPA_ANTECIPA DROP COLUMN IMPORTE; +END +$$; +/ +DO $$ +BEGIN + ALTER TABLE PRICING_OCUPA_ANTECIPA ADD (IMPORTE NUMBER(10,2)); +END +$$; +/ +DO $$ +BEGIN + UPDATE PRICING_OCUPA_ANTECIPA SET IMPORTE = IMPORTE_AUX; +END +$$; +/ +DO $$ +BEGIN + ALTER TABLE PRICING_OCUPA_ANTECIPA DROP COLUMN IMPORTE_AUX; END $$;