From 16117de1917e76a62ec47055013cf74e0cda7922 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 28 Oct 2014 12:27:43 +0100 Subject: [PATCH] SONAR-5530 Set project UUID on components without UUID --- .../migrations/v50/PopulateProjectsUuidColumnsMigration.java | 1 + .../v50/PopulateProjectsUuidColumnsMigrationTest.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java index 098b4a6ace7..e5ad598c6bb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java @@ -153,6 +153,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { for (Component component : mapper.selectComponentsWithoutUuid()) { String uuid = UUID.randomUUID().toString(); component.setUuid(uuid); + component.setProjectUuid(uuid); mapper.updateComponentUuids(component); counter.getAndIncrement(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java index 53250c0b561..a61d93c52c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java @@ -277,14 +277,14 @@ public class PopulateProjectsUuidColumnsMigrationTest { // Module with a snapshot having no islast=true Component module = mapper.selectComponentByKey("org.struts:struts-core"); assertThat(module.getUuid()).isNotNull(); - assertThat(module.getProjectUuid()).isNull(); + assertThat(module.getProjectUuid()).isEqualTo(module.getUuid()); assertThat(module.getModuleUuid()).isNull(); assertThat(module.getModuleUuidPath()).isNull(); // File linked on a no more existing project Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(file.getUuid()).isNotNull(); - assertThat(file.getProjectUuid()).isNull(); + assertThat(file.getProjectUuid()).isEqualTo(file.getUuid()); assertThat(file.getModuleUuid()).isNull(); assertThat(file.getModuleUuidPath()).isNull(); } -- 2.39.5