Source:
<code>public String getMySQLScript() { String sql = ""; final String fk_workflow_assign = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_assign FOREIGN KEY (assigned_to) REFERENCES cms_role (id);"; final String fk_workflow_task_asset = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_task_asset FOREIGN KEY (webasset) REFERENCES identifier (id);"; final String fk_workflow_step = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_step FOREIGN KEY (status) REFERENCES workflow_step (id);"; Connection conn = null; final List<String> tables = new ArrayList<String>( Arrays.asList("workflow_task")); try { conn = DbConnectionFactory.getDataSource().getConnection(); conn.setAutoCommit(true); final List<ForeignKey> listForeignKeys = this.getForeingKeys(conn, tables, false); final List<String> listForeignKeysNames = new ArrayList<String>(); for(ForeignKey foreignKey : listForeignKeys){ listForeignKeysNames.add(foreignKey.fkName()); <START> } <END> if(!listForeignKeysNames.contains("FK_workflow_assign")){ sql = sql + fk_workflow_assign; } if(!listForeignKeysNames.contains("FK_workflow_task_asset")){ sql = sql + fk_workflow_task_asset; } if(!listForeignKeysNames.contains("FK_workflow_step")){ sql = sql + fk_workflow_step; } } catch (Exception e) { Logger.error(this, String.format("Error running the upgrade task 4215", e.getMessage()), e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException ex) { Logger.error(this, String.format("Error closing the connection", ex.getMessage()), ex); } } return sql; }</code><technical_language>for consideration, lines 57-60 replaced with: final List<String> listForeignKeysNames = listForeignKeys.stream().map(LittleObject::getName).collect(Collectors.toList());</technical_language>

Target:
public String getMySQLScript() { String sql = ""; final String FKWORKFLOWASSIGN = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_assign FOREIGN KEY (assigned_to) REFERENCES cms_role (id);"; final String FKWORKFLOWTASKASSET = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_task_asset FOREIGN KEY (webasset) REFERENCES identifier (id);"; final String FKWORKFLOWSTEP = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_step FOREIGN KEY (status) REFERENCES workflow_step (id);"; Connection conn = null; final List<String> tables = new ArrayList<>( Arrays.asList("workflow_task")); try { conn = DbConnectionFactory.getDataSource().getConnection(); conn.setAutoCommit(true); final List<ForeignKey> listForeignKeys = this.getForeingKeys(conn, tables, false); final List<String> listForeignKeysNames = listForeignKeys.stream().map(ForeignKey::fkName).collect( CollectionsUtils.toImmutableList()); if(!listForeignKeysNames.contains("FK_workflow_assign")){ sql += FKWORKFLOWASSIGN; } if(!listForeignKeysNames.contains("FK_workflow_task_asset")){ sql += FKWORKFLOWTASKASSET; } if(!listForeignKeysNames.contains("FK_workflow_step")){ sql += FKWORKFLOWSTEP; } } catch (Exception e) { Logger.error(this,"Error Running Upgrade Task 4215 " + e.getMessage(),e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException ex) { Logger.error(this,"Error Closing the Connection " + ex.getMessage(),ex); } } return sql; }