diff --git a/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20250212175115.java b/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20250212175115.java new file mode 100644 index 0000000000..9224a6a31c --- /dev/null +++ b/ems-core/src/main/java/it/integry/ems/migration/model/Migration_20250212175115.java @@ -0,0 +1,59 @@ +package it.integry.ems.migration.model; + +import it.integry.ems.migration._base.BaseMigration; +import it.integry.ems.migration._base.IntegryCustomer; +import it.integry.ems.migration._base.MigrationModelInterface; +import it.integry.ems_model.utility.dto.IndexTableDTO; + +import java.util.Arrays; + +public class Migration_20250212175115 extends BaseMigration implements MigrationModelInterface { + + @Override + public void up() throws Exception { + if (isHistoryDB()) + return; + + executeStatement("CREATE TABLE [dbo].[mrl_depo_sgrp](\n" + + "\tid bigint identity not null,\n" + + "\t[cod_mdep] [varchar](5) NULL,\n" + + "\t[cod_mgrp] [varchar](5) NOT NULL,\n" + + "\t[cod_msgr] [varchar](5) NOT NULL,\n" + + "\t[priorita] [int] NULL\n" + + ") ON [PRIMARY]", + "alter table mrl_depo_sgrp add constraint pk_mrl_depo_sgrp primary key ( id );"); + + IndexTableDTO indexTableDTO = new IndexTableDTO() + .setIndexName("uk_mrl_depo_sgrp") + .setTableName("mrl_depo_sgrp") + .setColumnsIndex(Arrays.asList( + new IndexTableDTO.ColumnIndex("cod_mgrp"), + new IndexTableDTO.ColumnIndex("cod_msgr"))) + .setUnique(true) + .setOverride(true); + createIndex(indexTableDTO); + + if (isCustomer(IntegryCustomer.Gramm)) { + executeStatement("insert into mrl_depo_sgrp\n" + + "select CONVERT(VARCHAR(5), CASE\tMTB_SGRP.COD_MSGR \n" + + "\t\tWHEN '01' THEN '01'\n" + + "\t\tWHEN '02' THEN '34'\n" + + "\t\tWHEN '07' THEN '34'\n" + + "\t\tWHEN '04' THEN '33' END) AS cod_mdep,\n" + + "\t\tcod_mgrp,\n" + + "\t\tcod_msgr,\n" + + "\t\tCONVERT(int, CASE\tMTB_SGRP.COD_MSGR \n" + + "\t\tWHEN '01' THEN 1\n" + + "\t\tWHEN '02' THEN 2\n" + + "\t\tWHEN '07' THEN 2\n" + + "\t\tWHEN '04' THEN 3 END) AS priorita\t\t\n" + + "from mtb_sgrp\n" + + "where cod_mgrp in ('PFP','PFC')\n" + + "AND COD_MSGR IN ('01','02','04','07') "); + } + } + + @Override + public void down() throws Exception { + } +} \ No newline at end of file