From 0963e2e44f73a25889e532f7c5b601093e0b0eba Mon Sep 17 00:00:00 2001 From: wilian Date: Tue, 20 Aug 2019 20:40:13 +0000 Subject: [PATCH] bug#15267 dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/BD/FlyWay/trunk@96823 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../migration/V20190820_1444__mantis15267.sql | 7 ++++ .../migration/V20190820_1445__mantis15267.sql | 39 +++++++++++++++++++ .../migration/V20190820_1444__mantis15267.sql | 6 +++ 3 files changed, 52 insertions(+) create mode 100644 src/db/migration/V20190820_1444__mantis15267.sql create mode 100644 src/db/migration/V20190820_1445__mantis15267.sql create mode 100644 src/db/postgresql/migration/V20190820_1444__mantis15267.sql diff --git a/src/db/migration/V20190820_1444__mantis15267.sql b/src/db/migration/V20190820_1444__mantis15267.sql new file mode 100644 index 000000000..c68ce6115 --- /dev/null +++ b/src/db/migration/V20190820_1444__mantis15267.sql @@ -0,0 +1,7 @@ +declare + column_exists exception; + pragma exception_init (column_exists , -01430); +begin + execute immediate 'ALTER TABLE BPE_CTRL_DISPONIBILIDADE ADD (TIPO_VENDA VARCHAR(20))'; + exception when column_exists then null; +end; \ No newline at end of file diff --git a/src/db/migration/V20190820_1445__mantis15267.sql b/src/db/migration/V20190820_1445__mantis15267.sql new file mode 100644 index 000000000..48beeec48 --- /dev/null +++ b/src/db/migration/V20190820_1445__mantis15267.sql @@ -0,0 +1,39 @@ +declare + object_exists exception; + pragma exception_init (object_exists , -00001); +begin + execute immediate 'merge into bpe_ctrl_disponibilidade cd1 + using + ( + select b.tipoventa_id, cd.bpectrldisp_id, cd.tipo_venda + from bpe_ctrl_disponibilidade cd + join bpe bpe on bpe.bpe_id = cd.bpe_rejeitado_id + left join boleto b on b.boleto_id = bpe.boleto_id + where cd.activo = 1 + and b.tipoventa_id = 99 + and cd.tipo_venda is null + ) t on (cd1.bpectrldisp_id = t.bpectrldisp_id) + WHEN MATCHED THEN UPDATE SET cd1.tipo_venda = ''EMBARCADA'' + '; + exception when object_exists then null; +end; +/ +declare + object_exists exception; + pragma exception_init (object_exists , -00001); +begin + execute immediate 'merge into bpe_ctrl_disponibilidade cd1 + using + ( + select b.tipoventa_id, cd.bpectrldisp_id, cd.tipo_venda + from bpe_ctrl_disponibilidade cd + join bpe bpe on bpe.bpe_id = cd.bpe_rejeitado_id + left join boleto b on b.boleto_id = bpe.boleto_id + where cd.activo = 1 + and b.tipoventa_id <> 99 + and cd.tipo_venda is null + ) t on (cd1.bpectrldisp_id = t.bpectrldisp_id) + WHEN MATCHED THEN UPDATE SET cd1.tipo_venda = ''TOTALBUS'' + '; + exception when object_exists then null; +end; \ No newline at end of file diff --git a/src/db/postgresql/migration/V20190820_1444__mantis15267.sql b/src/db/postgresql/migration/V20190820_1444__mantis15267.sql new file mode 100644 index 000000000..bbc5c74f5 --- /dev/null +++ b/src/db/postgresql/migration/V20190820_1444__mantis15267.sql @@ -0,0 +1,6 @@ +DO $$ +BEGIN + ALTER TABLE BPE_CTRL_DISPONIBILIDADE ADD (TIPO_VENDA VARCHAR(20)); + EXCEPTION WHEN duplicate_column THEN NULL; +END +$$; \ No newline at end of file