From 5553e48fa8c143812fa54b8ff0c8fd7185276a5a Mon Sep 17 00:00:00 2001 From: Kamil Date: Wed, 23 Oct 2024 22:52:08 +0200 Subject: [PATCH] #2755 Signaling the data source that has a problem: - refactoring V2_8_0_1__AddTypeRef3ColumnToEvents; --- .../mysql/V2_8_0_1__AddTypeRef3ColumnToEvents.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/org/scada_lts/dao/migration/mysql/V2_8_0_1__AddTypeRef3ColumnToEvents.java b/src/org/scada_lts/dao/migration/mysql/V2_8_0_1__AddTypeRef3ColumnToEvents.java index 5935bc901..61b8977f9 100644 --- a/src/org/scada_lts/dao/migration/mysql/V2_8_0_1__AddTypeRef3ColumnToEvents.java +++ b/src/org/scada_lts/dao/migration/mysql/V2_8_0_1__AddTypeRef3ColumnToEvents.java @@ -25,14 +25,11 @@ public void migrate(Context context) throws Exception { } private void migrate(JdbcTemplate jdbcTmp) { - String sql = "ALTER TABLE events ADD COLUMN typeRef3 int not null"; - try { - jdbcTmp.update(sql); - } catch (Exception ex) { - if(ex.getMessage() != null && !ex.getMessage().contains("Duplicate")) - throw ex; - LOG.warn(ex.getMessage(), ex); - } + + boolean existsTypeRef3Column = jdbcTmp.queryForObject("SELECT (SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`= DATABASE() AND `TABLE_NAME`='events' AND `COLUMN_NAME`='typeRef3') IS NOT NULL;", boolean.class); + + if(!existsTypeRef3Column) + jdbcTmp.update( "ALTER TABLE events ADD COLUMN typeRef3 int not null"); } }