Merge branch 'master' into develop
This commit is contained in:
@@ -120,9 +120,15 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
||||
|
||||
|
||||
protected boolean existsColumn(String tableName, String columnName) throws SQLException, IOException {
|
||||
String schema = null;
|
||||
if (tableName.contains(".")) {
|
||||
schema = tableName.substring(0, tableName.indexOf("."));
|
||||
tableName = tableName.replace(schema + ".", "");
|
||||
}
|
||||
|
||||
String sql = Query.format("SELECT 1 FROM sys.columns\n" +
|
||||
" WHERE Name = N{}\n" +
|
||||
" AND Object_ID = Object_ID(N{})", columnName, "dbo." + tableName);
|
||||
" AND Object_ID = Object_ID(N{})", columnName, (schema != null ? schema : "dbo") + "." + tableName);
|
||||
|
||||
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
||||
|
||||
|
||||
@@ -11,8 +11,11 @@ public class Migration_20240314141529 extends BaseMigration implements Migration
|
||||
return;
|
||||
|
||||
if (existsTable("dbo.mtb_lisa_apulia_succ")) {
|
||||
executeStatement("ALTER TABLE mtb_lisa_apulia_succ ADD perc_premio numeric(5,2)",
|
||||
"ALTER TABLE mtb_lisa_apulia_succ ADD val_premio numeric(20,5)");
|
||||
if (!existsColumn("dbo.mtb_lisa_apulia_succ", "perc_premio"))
|
||||
executeStatement("ALTER TABLE mtb_lisa_apulia_succ ADD perc_premio numeric(5,2)");
|
||||
|
||||
if (!existsColumn("dbo.mtb_lisa_apulia_succ", "val_premio"))
|
||||
executeStatement("ALTER TABLE mtb_lisa_apulia_succ ADD val_premio numeric(20,5)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user