From: Simon Brandhof Date: Sat, 18 Jun 2016 11:58:28 +0000 (+0200) Subject: Fix migration from 4.5 X-Git-Tag: 6.0-RC1~280 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9be0c674d3a5c1100c319ed619049a0c3d02358b;p=sonarqube.git Fix migration from 4.5 PROJECT_MEASURES.PROJECT_ID is not populated in 4.5 so it can't be used to group updates during migration --- diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfMeasures.java index 4a3c23827b2..7c624bfb3f6 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfMeasures.java +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateComponentUuidOfMeasures.java @@ -35,18 +35,18 @@ public class PopulateComponentUuidOfMeasures extends BaseDataChange { @Override public void execute(Context context) throws SQLException { MassUpdate massUpdate = context.prepareMassUpdate(); - massUpdate.select("select distinct pm.project_id, s.component_uuid from project_measures pm inner join snapshots s on s.id=pm.snapshot_id where pm.component_uuid is null"); - massUpdate.update("UPDATE project_measures SET component_uuid=? WHERE project_id=? and component_uuid is null"); + massUpdate.select("select distinct pm.snapshot_id, s.component_uuid from project_measures pm inner join snapshots s on s.id=pm.snapshot_id where pm.component_uuid is null"); + massUpdate.update("UPDATE project_measures SET component_uuid=? WHERE snapshot_id=? and component_uuid is null"); massUpdate.rowPluralName("measures"); massUpdate.execute(this::handle); } public boolean handle(Select.Row row, SqlStatement update) throws SQLException { - long projectId = row.getLong(1); - + long snapshotId = row.getLong(1); String componentUuid = row.getString(2); + update.setString(1, componentUuid); - update.setLong(2, projectId); + update.setLong(2, snapshotId); return true; }