Merge remote-tracking branch 'origin/develop' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -177,16 +177,8 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
return val != null && val == 1;
|
||||
}
|
||||
|
||||
protected boolean existColumn(String tableName, String columnName) throws SQLException, IOException {
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||
"FROM sys.syscolumns\n" +
|
||||
"WHERE name = %s\n" +
|
||||
" AND OBJECT_NAME(id) = %s", columnName, tableName));
|
||||
}
|
||||
|
||||
protected void renameColumn(String tableName, String oldColumnname, String newColumnName) throws SQLException, IOException {
|
||||
if (existColumn(tableName, oldColumnname)) {
|
||||
if (existsColumn(tableName, oldColumnname)) {
|
||||
String sql =
|
||||
"exec sp_rename 'dbo." + tableName + "." + oldColumnname + "', " + newColumnName + ", 'COLUMN'";
|
||||
executeStatement(sql);
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Migration_20241202145553 extends BaseMigration implements Migration
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
if (!existColumn("mtb_lisa_costo_data", "part_iva" ))
|
||||
if (!existsColumn("mtb_lisa_costo_data", "part_iva" ))
|
||||
executeStatement("ALTER TABLE mtb_lisa_costo_data ADD part_iva varchar(20)");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class Migration_20250224114817 extends BaseMigration implements Migration
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (existsTable("apuliac_agg_prz_csv") && !existColumn("apuliac_agg_prz_csv", "altro")){
|
||||
if (existsTable("apuliac_agg_prz_csv") && !existsColumn("apuliac_agg_prz_csv", "altro")){
|
||||
executeStatement("alter table apuliac_agg_prz_csv add altro varchar(max)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Migration_20250225124406 extends BaseMigration implements Migration
|
||||
if (isCustomerDb(IntegryCustomerDB.Siciliani_DMS))
|
||||
return;
|
||||
|
||||
if (!existColumn("mtb_aart", "flag_stampa_docu_vend"))
|
||||
if (!existsColumn("mtb_aart", "flag_stampa_docu_vend"))
|
||||
executeStatement(
|
||||
"alter table mtb_aart add flag_stampa_docu_vend bit not null default 1");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
public class Migration_20250303123610 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
Boolean exist = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
"SELECT Cast( COUNT(*) as bit)\n" +
|
||||
"FROM \n" +
|
||||
" INFORMATION_SCHEMA.KEY_COLUMN_USAGE c\n" +
|
||||
"JOIN \n" +
|
||||
" INFORMATION_SCHEMA.TABLE_CONSTRAINTS t \n" +
|
||||
" ON c.CONSTRAINT_NAME = t.CONSTRAINT_NAME\n" +
|
||||
"WHERE \n" +
|
||||
" t.TABLE_NAME = 'mtb_movi'\n" +
|
||||
" AND t.CONSTRAINT_TYPE = 'PRIMARY KEY'\n" +
|
||||
"\tand c.COLUMN_NAME = 'cod_anag'");
|
||||
|
||||
if ( exist ){
|
||||
Boolean newSp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
"SELECT cast(IIF(value='S',1,0) as bit) FROM stb_gest_setup where gest_name = 'DATI_AZIENDA' AND section = 'PROGRESSIVI_MAG' and key_section = 'NUOVA_PROCEDURA'"
|
||||
);
|
||||
Boolean existMov = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
||||
"SELECT cast(count(*) as bit) from mtb_movi"
|
||||
);
|
||||
|
||||
if ( newSp || !existMov ) {
|
||||
executeStatement(
|
||||
"EXEC DropPrimaryKey 'mtb_movi'" +
|
||||
"ALTER TABLE mtb_movi ADD PRIMARY KEY (num_mov, cod_mdep, id_riga);\n"
|
||||
);
|
||||
if ( !existMov )
|
||||
updateSetupValue("DATI_AZIENDA", "PROGRESSIVI_MAG", "NUOVA_PROCEDURA", "S");
|
||||
} else {
|
||||
|
||||
// throw new Exception(String.format("Sull'azienda %s è ancora attiva la vecchia stored procedure di aggioramento progressivi di magazzino", advancedDataSource.getDataSource().getDbName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user