@@ -0,0 +1,1615 @@
+package db.migration;%0A%0Aimport lombok.extern.slf4j.Slf4j;%0Aimport org.flywaydb.core.api.migration.spring.SpringJdbcMigration;%0Aimport org.springframework.jdbc.core.JdbcTemplate;%0A%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * populates is_malicious column for existing data resources by setting to 'N'%0A * is_malicious column is NULL at this stage after v1_14%0A * Created by teye%0A */%0A@Slf4j%0Apublic class V1_15__update_is_malicious_entry_for_existing_data_resources implements SpringJdbcMigration %7B%0A%0A    @Override%0A    public void migrate(final JdbcTemplate jdbcTemplate) throws Exception %7B%0A        migrate(jdbcTemplate, %22data_resources%22, %22is_malicious%22);%0A    %7D%0A%0A    private void migrate(final JdbcTemplate jdbcTemplate, final String table, final String column) %7B%0A        final String s1 = String.format(%22SELECT id, %25s FROM prod.%25s%22, column, table);%0A        final List%3CMap%3CString, Object%3E%3E list = jdbcTemplate.queryForList(s1);%0A        list.forEach(map -%3E %7B%0A            final Object content = map.get(String.format(%22is_malicious%22, column));%0A            final Object id = map.get(%22id%22);%0A%0A            // only update columns that are null%0A            // not needed but just in case%0A            log.info(%22Content: %7B%7D%22, content);%0A            if(content == null %7C%7C content.equals(%22%22)) %7B%0A                boolean isMalicious = false;%0A                final String s2 = String.format(%22UPDATE prod.%25s SET %25s = ? WHERE id = ?%22, table, column);%0A                jdbcTemplate.update(s2, isMalicious, id);%0A                log.info(%22Updated %7B%7D entry: id=%7B%7D, %7B%7D=%7B%7D%22, table, id, column, isMalicious);%0A            %7D%0A        %7D);%0A    %7D%0A%7D%0A

add migration script to populate is_malicious column