]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7780 table PROJECT_MEASURES should use analysis UUID
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 28 Jun 2016 07:27:05 +0000 (09:27 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 28 Jun 2016 21:32:51 +0000 (23:32 +0200)
52 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureToMeasureDto.java
server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureToMeasureDtoTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportComputeMeasureVariationsStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsComputeMeasureVariationsStepTest.java
server/sonar-server/src/test/resources/org/sonar/server/computation/step/FillMeasuresWithVariationsStepTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistDuplicationMeasuresStepTest/persist_duplication_on_same_file-result.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistDuplicationMeasuresStepTest/persist_duplication_on_same_file.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-index-result.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest/insert-from-report-result.xml
server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_person_measures.xml
server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/ignore_quality_model_measures.xml
server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/measure/MeasureFilterExecutorTest/sort_by_alert.xml
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_add_analysis_uuid_column_to_measures.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_populate_analysis_uuid_on_measures.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_clean_measures_with_null_analysis_uuid.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_make_analysis_uuid_not_null_on_measures.rb [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java
sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuid.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasures.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasures.java [new file with mode: 0644]
sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
sonar-db/src/test/java/org/sonar/db/measure/MeasureTesting.java
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest.java [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures.xml
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_person_id.xml
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/select_by_snapshot_and_metric_keys.xml
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/shared.xml
sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/with_some_measures_for_developer.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml
sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml
sonar-db/src/test/resources/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql [new file with mode: 0644]

index bcee6b62bca43dae5eb58c66b82df1c84de49de0..718b3e02c87f60603d131532fb50305f3fe25b6c 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.computation.measure;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import org.sonar.db.measure.MeasureDto;
+import org.sonar.server.computation.analysis.AnalysisMetadataHolder;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.DbIdsRepository;
 import org.sonar.server.computation.component.Developer;
@@ -30,9 +31,11 @@ import org.sonar.server.computation.metric.Metric;
 public class MeasureToMeasureDto {
 
   private final DbIdsRepository dbIdsRepository;
+  private final AnalysisMetadataHolder analysisMetadataHolder;
 
-  public MeasureToMeasureDto(DbIdsRepository dbIdsRepository) {
+  public MeasureToMeasureDto(DbIdsRepository dbIdsRepository, AnalysisMetadataHolder analysisMetadataHolder) {
     this.dbIdsRepository = dbIdsRepository;
+    this.analysisMetadataHolder = analysisMetadataHolder;
   }
 
   @Nonnull
@@ -40,6 +43,7 @@ public class MeasureToMeasureDto {
     MeasureDto out = new MeasureDto();
     out.setMetricId(metric.getId());
     out.setComponentUuid(component.getUuid());
+    out.setAnalysisUuid(analysisMetadataHolder.getUuid());
     out.setSnapshotId(dbIdsRepository.getSnapshotId(component));
     if (measure.hasVariations()) {
       setVariations(out, measure.getVariations());
index 42530009c89aea949b1e7ff6dac88d48c9e799f9..59e55e15855445e7ea5f679dd4f61837c592481f 100644 (file)
@@ -71,6 +71,7 @@ public class MeasureRepositoryImplTest {
   @Rule
   public BatchReportReaderRule reportReader = new BatchReportReaderRule();
 
+  private static final String AN_ANALYSIS_UUID = "a1";
   private static final String FILE_COMPONENT_KEY = "file cpt key";
   private static final ReportComponent FILE_COMPONENT = ReportComponent.builder(Component.Type.FILE, 1).setKey(FILE_COMPONENT_KEY).build();
   private static final ReportComponent OTHER_COMPONENT = ReportComponent.builder(Component.Type.FILE, 2).setKey("some other key").build();
@@ -420,6 +421,7 @@ public class MeasureRepositoryImplTest {
     return new MeasureDto()
       .setComponentUuid(componentUuid)
       .setSnapshotId(snapshotId)
+      .setAnalysisUuid(AN_ANALYSIS_UUID)
       .setData(SOME_DATA)
       .setMetricId(metricId);
   }
index ea336c32f8fe4bbe3b05c38214239345a1474b37..b6c9a5d852e82b371a62a03d07f2bf00d858a44f 100644 (file)
@@ -27,6 +27,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.sonar.db.measure.MeasureDto;
+import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolderRule;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.Developer;
 import org.sonar.server.computation.component.DumbDeveloper;
@@ -51,18 +52,22 @@ public class MeasureToMeasureDtoTest {
   private static final MetricImpl SOME_DOUBLE_METRIC = new MetricImpl(4, "4", "4", Metric.MetricType.FLOAT);
   private static final MetricImpl SOME_STRING_METRIC = new MetricImpl(5, "5", "5", Metric.MetricType.STRING);
   private static final MetricImpl SOME_LEVEL_METRIC = new MetricImpl(6, "6", "6", Metric.MetricType.LEVEL);
-
-  static final Component SOME_COMPONENT = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("uuid_1").build();
+  private static final String ANALYSIS_UUID = "a1";
+  private static final Component SOME_COMPONENT = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("uuid_1").build();
 
   @Rule
   public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(SOME_COMPONENT);
 
-  MeasureToMeasureDto underTest = new MeasureToMeasureDto(dbIdsRepository);
+  @Rule
+  public MutableAnalysisMetadataHolderRule analysisMetadataHolder = new MutableAnalysisMetadataHolderRule();
+
+  MeasureToMeasureDto underTest = new MeasureToMeasureDto(dbIdsRepository, analysisMetadataHolder);
 
   @Before
   public void setUp() throws Exception {
     dbIdsRepository.setComponentId(SOME_COMPONENT, SOME_COMPONENT_ID);
     dbIdsRepository.setSnapshotId(SOME_COMPONENT, SOME_SNAPSHOT_ID);
+    analysisMetadataHolder.setUuid(ANALYSIS_UUID);
   }
 
   @Test(expected = NullPointerException.class)
index 2a823ba206fe2aafc6a54432650059327694bd9f..8c2d769859f547a4224b68cc08792a7d5a544b53 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.rule.RuleDto;
+import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolderRule;
 import org.sonar.server.computation.batch.TreeRootHolderRule;
 import org.sonar.server.computation.component.Component;
 import org.sonar.server.computation.component.Developer;
@@ -80,6 +81,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
   private static final long INTERMEDIATE_1_SNAPSHOT_ID = 4L;
   private static final long INTERMEDIATE_2_SNAPSHOT_ID = 5L;
   private static final long LEAF_SNAPSHOT_ID = 6L;
+  private static final String ANALYSIS_UUID = "a1";
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -92,6 +94,9 @@ public class PersistMeasuresStepTest extends BaseStepTest {
   @Rule
   public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder);
 
+  @Rule
+  public MutableAnalysisMetadataHolderRule analysisMetadataHolder = new MutableAnalysisMetadataHolderRule();
+
   DbClient dbClient = dbTester.getDbClient();
   RuleDto rule;
   ComponentDto rootDto;
@@ -103,7 +108,8 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
   @Before
   public void setUp() {
-    underTest = new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(dbIdsRepository), treeRootHolder, measureRepository);
+    underTest = new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(dbIdsRepository, analysisMetadataHolder), treeRootHolder, measureRepository);
+    analysisMetadataHolder.setUuid(ANALYSIS_UUID);
   }
 
   private void setupReportComponents() {
index a30a26cd2ac69a2812938e5846f3d8b30772a058..9966397b10100ffea5d95af3b5b108316e684ebe 100644 (file)
@@ -51,16 +51,16 @@ import static org.sonar.server.computation.measure.Measure.newMeasureBuilder;
 
 public class ReportComputeMeasureVariationsStepTest {
 
-  static final Metric ISSUES_METRIC = new MetricImpl(1, "violations", "violations", Metric.MetricType.INT);
-  static final Metric DEBT_METRIC = new MetricImpl(2, "sqale_index", "sqale_index", Metric.MetricType.WORK_DUR);
-  static final Metric FILE_COMPLEXITY_METRIC = new MetricImpl(3, "file_complexity", "file_complexity", Metric.MetricType.FLOAT);
-  static final Metric BUILD_BREAKER_METRIC = new MetricImpl(4, "build_breaker", "build_breaker", Metric.MetricType.BOOL);
-  static final Metric NEW_DEBT = new MetricImpl(5, "new_debt", "new_debt", Metric.MetricType.WORK_DUR);
+  private static final Metric ISSUES_METRIC = new MetricImpl(1, "violations", "violations", Metric.MetricType.INT);
+  private static final Metric DEBT_METRIC = new MetricImpl(2, "sqale_index", "sqale_index", Metric.MetricType.WORK_DUR);
+  private static final Metric FILE_COMPLEXITY_METRIC = new MetricImpl(3, "file_complexity", "file_complexity", Metric.MetricType.FLOAT);
+  private static final Metric BUILD_BREAKER_METRIC = new MetricImpl(4, "build_breaker", "build_breaker", Metric.MetricType.BOOL);
+  private static final Metric NEW_DEBT = new MetricImpl(5, "new_debt", "new_debt", Metric.MetricType.WORK_DUR);
+  private static final String ANALYSIS_UUID = "a1";
+  private static final ComponentDto PROJECT_DTO = ComponentTesting.newProjectDto();
+  private static final int PROJECT_REF = 1;
+  private static final Component PROJECT = ReportComponent.builder(Component.Type.PROJECT, PROJECT_REF).setUuid(PROJECT_DTO.uuid()).build();
 
-  static final ComponentDto PROJECT_DTO = ComponentTesting.newProjectDto();
-
-  static final int PROJECT_REF = 1;
-  static final Component PROJECT = ReportComponent.builder(Component.Type.PROJECT, PROJECT_REF).setUuid(PROJECT_DTO.uuid()).build();
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -319,7 +319,12 @@ public class ReportComputeMeasureVariationsStepTest {
   }
 
   private static MeasureDto newMeasureDto(int metricId, String componentUuid, long snapshotId, double value) {
-    return new MeasureDto().setMetricId(metricId).setComponentUuid(componentUuid).setSnapshotId(snapshotId).setValue(value);
+    return new MeasureDto()
+      .setMetricId(metricId)
+      .setComponentUuid(componentUuid)
+      .setSnapshotId(snapshotId)
+      .setAnalysisUuid(ANALYSIS_UUID)
+      .setValue(value);
   }
 
   private static Period newPeriod(int index, SnapshotDto snapshotDto) {
index 4f5cef4e49c9c3ec272ea80bb6e0bb44f8fff165..f014d72529b28b01a4dc49c99d7f6dca8fe29596 100644 (file)
@@ -49,14 +49,13 @@ import static org.sonar.db.component.SnapshotTesting.newSnapshotForView;
 
 public class ViewsComputeMeasureVariationsStepTest {
 
-  static final Metric ISSUES_METRIC = new MetricImpl(1, "violations", "violations", Metric.MetricType.INT);
-  static final Metric DEBT_METRIC = new MetricImpl(2, "sqale_index", "sqale_index", Metric.MetricType.WORK_DUR);
-  static final Metric FILE_COMPLEXITY_METRIC = new MetricImpl(3, "file_complexity", "file_complexity", Metric.MetricType.FLOAT);
-  static final Metric BUILD_BREAKER_METRIC = new MetricImpl(4, "build_breaker", "build_breaker", Metric.MetricType.BOOL);
-
-  static final ComponentDto VIEW_DTO = ComponentTesting.newView();
-
-  static final Component VIEW = ViewsComponent.builder(Component.Type.VIEW, 1).setUuid(VIEW_DTO.uuid()).build();
+  private static final Metric ISSUES_METRIC = new MetricImpl(1, "violations", "violations", Metric.MetricType.INT);
+  private static final Metric DEBT_METRIC = new MetricImpl(2, "sqale_index", "sqale_index", Metric.MetricType.WORK_DUR);
+  private static final Metric FILE_COMPLEXITY_METRIC = new MetricImpl(3, "file_complexity", "file_complexity", Metric.MetricType.FLOAT);
+  private static final Metric BUILD_BREAKER_METRIC = new MetricImpl(4, "build_breaker", "build_breaker", Metric.MetricType.BOOL);
+  private static final ComponentDto VIEW_DTO = ComponentTesting.newView();
+  private static final Component VIEW = ViewsComponent.builder(Component.Type.VIEW, 1).setUuid(VIEW_DTO.uuid()).build();
+  private static final String ANALYSIS_UUID = "a1";
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
@@ -223,7 +222,12 @@ public class ViewsComputeMeasureVariationsStepTest {
   }
 
   private static MeasureDto newMeasureDto(int metricId, String componentUuid, long snapshotId, double value) {
-    return new MeasureDto().setMetricId(metricId).setComponentUuid(componentUuid).setSnapshotId(snapshotId).setValue(value);
+    return new MeasureDto()
+      .setMetricId(metricId)
+      .setComponentUuid(componentUuid)
+      .setSnapshotId(snapshotId)
+      .setAnalysisUuid(ANALYSIS_UUID)
+      .setValue(value);
   }
 
   private static Period newPeriod(int index, SnapshotDto snapshotDto) {
index 289d321734ad8b7558d1c97a16d7dc1abc025456..9a01b234b3346442cfa32eae2c105e68e1a81981 100644 (file)
@@ -91,6 +91,7 @@
                     VALUE="60"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     text_value="[null]"
                     project_id="[null]"
                     person_id="[null]"/>
                     VALUE="80"
                     METRIC_ID="2"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     text_value="[null]"
                     project_id="[null]"
                     person_id="[null]"/>
                     VALUE="20"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1001"
+                    analysis_uuid="u1000"
                     text_value="[null]"
                     project_id="[null]"
                     person_id="[null]"/>
                     VALUE="70"
                     METRIC_ID="2"
                     SNAPSHOT_ID="1001"
+                    analysis_uuid="u1000"
                     text_value="[null]"
                     project_id="[null]"
                     person_id="[null]"/>
index 68809ddb260d39f5f3d8d9b02926f4835bfb8363..f788fbd156e9fd286075b1064ebb0fdae064d390 100644 (file)
@@ -1,11 +1,29 @@
 <dataset>
 
-  <project_measures id="1" snapshot_id="1000" metric_id="10" value="[null]"
+  <project_measures id="1"
+                    snapshot_id="1000"
+                    analysis_uuid="u1000"
+                    metric_id="10"
+                    value="[null]"
                     text_value="&lt;duplications&gt;&lt;g&gt;&lt;b s=&quot;1&quot; l=&quot;5&quot; r=&quot;PROJECT_KEY:file&quot;/&gt;&lt;b s=&quot;6&quot; l=&quot;10&quot; r=&quot;PROJECT_KEY:file&quot;&gt;"
-                    measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" />
+                    measure_data="[null]"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]"/>
 
-  <project_measures id="2" snapshot_id="1000" metric_id="10" value="[null]"
+  <project_measures id="2"
+                    snapshot_id="1000"
+                    analysis_uuid="u1000"
+                    metric_id="10"
+                    value="[null]"
                     text_value="&lt;duplications&gt;&lt;g&gt;&lt;b s=&quot;1&quot; l=&quot;5&quot; r=&quot;PROJECT_KEY:file&quot;/&gt;&lt;b s=&quot;6&quot; l=&quot;10&quot; r=&quot;PROJECT_KEY:file&quot;&gt;"
-                    measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" />
+                    measure_data="[null]"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]"/>
 
 </dataset>
index 53ff5efd294eecb7473adf89bb408e04de87f2fa..0b498bd98ff3267e6ef7f7d70bfdb3bb6ff97cfd 100644 (file)
@@ -1,6 +1,17 @@
 <dataset>
 
-  <metrics id="1" name="duplications_data" val_type="DATA" description="Duplications details" short_name="Duplications details" domain="Duplication"
-           qualitative="[false]" enabled="[true]" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="[false]"/>
+  <metrics id="1"
+           name="duplications_data"
+           val_type="DATA"
+           description="Duplications details"
+           short_name="Duplications details"
+           domain="Duplication"
+           qualitative="[false]"
+           enabled="[true]"
+           worst_value="[null]"
+           optimized_best_value="[null]"
+           best_value="[null]"
+           direction="0"
+           hidden="[false]"/>
 
 </dataset>
index ae4934573a64fe5ad9b1f0a1a3a59242596c9a4b..3006765aa14d1f6b40e00abd33dcfc825e1dbf3c 100644 (file)
@@ -1,6 +1,18 @@
 <dataset>
-  <project_measures snapshot_id="1000" metric_id="10" value="6.0" project_id="[null]" text_value="[null]"
-                    measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]"
-                    variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
-                    alert_status="[null]" alert_text="[null]" description="[null]" person_id="[null]"/>
+  <project_measures snapshot_id="1000"
+                    analysis_uuid="u1000"
+                    metric_id="10"
+                    value="6.0"
+                    project_id="[null]"
+                    text_value="[null]"
+                    measure_data="[null]"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]"
+                    alert_status="[null]"
+                    alert_text="[null]"
+                    description="[null]"
+                    person_id="[null]"/>
 </dataset>
index b6a2431d6e8a2d4ac3df815d2b66442ccca71d23..1cacaf4f14da6035eedab4ed008fbdf41d0f68e2 100644 (file)
@@ -1,6 +1,18 @@
 <dataset>
-  <project_measures snapshot_id="1000" metric_id="10" value="3.0" project_id="[null]" text_value="[null]"
-                    measure_data="[null]" variation_value_1="[null]" variation_value_2="[null]"
-                    variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"
-                    alert_status="[null]" alert_text="[null]" description="[null]" person_id="[null]"/>
+  <project_measures snapshot_id="1000"
+                    analysis_uuid="u1000"
+                    metric_id="10"
+                    value="3.0"
+                    project_id="[null]"
+                    text_value="[null]"
+                    measure_data="[null]"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
+                    variation_value_4="[null]"
+                    variation_value_5="[null]"
+                    alert_status="[null]"
+                    alert_text="[null]"
+                    description="[null]"
+                    person_id="[null]"/>
 </dataset>
index 87064ba708a4870510576a97cbb319c5c29c9836..bf07feecd84000a13ccee1ffaf1d0449e168b08f 100644 (file)
@@ -66,6 +66,7 @@
                     metric_id="1"
                     value="500"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     person_id="[null]"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
@@ -83,6 +84,7 @@
                     metric_id="1"
                     value="300"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     person_id="30000"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     metric_id="1"
                     value="200"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     person_id="40000"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
index ea433b44e9dd30947c2e6dab585f86e790df952d..0634b49b664b7dd936b289b7d60ff381e20bb0b1 100644 (file)
@@ -66,6 +66,7 @@
                     metric_id="1"
                     value="500"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
index 1458d4aa9f97462ed9367759717d8ae4d0ccc15e..2c8e4c9b202d63dd3c141ec5ad47bef66aef6ecc 100644 (file)
                     metric_id="1"
                     value="510"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="1"
                     value="510"
                     snapshot_id="102"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="1"
                     value="500"
                     snapshot_id="103"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="1"
                     value="10"
                     snapshot_id="104"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="2"
                     value="[null]"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="3"
                     value="12.3"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="1"
                     value="5000"
                     snapshot_id="110"
+                    analysis_uuid="u110"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="2"
                     value="[null]"
                     snapshot_id="110"
+                    analysis_uuid="u110"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
index ce6f4f3c9cb2a9b21d2cfa0a010822ee292d268c..9b1af0fa97d94d6bf6e779735c3f5431e19f3aa0 100644 (file)
@@ -68,6 +68,7 @@
                     metric_id="5"
                     value="510"
                     snapshot_id="101"
+                    analysis_uuid="u101"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
                     metric_id="5"
                     value="5000"
                     snapshot_id="110"
+                    analysis_uuid="u110"
                     url="[null]"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     metric_id="5"
                     value="5000"
                     snapshot_id="120"
+                    analysis_uuid="u120"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_add_analysis_uuid_column_to_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1258_add_analysis_uuid_column_to_measures.rb
new file mode 100644 (file)
index 0000000..2054469
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 6.0
+#
+class AddAnalysisUuidColumnToMeasures < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_populate_analysis_uuid_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1259_populate_analysis_uuid_on_measures.rb
new file mode 100644 (file)
index 0000000..8e48589
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 6.0
+#
+class PopulateAnalysisUuidOnMeasures < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.PopulateAnalysisUuidOnMeasures')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_clean_measures_with_null_analysis_uuid.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1260_clean_measures_with_null_analysis_uuid.rb
new file mode 100644 (file)
index 0000000..7cfe63a
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 6.0
+#
+class CleanMeasuresWithNullAnalysisUuid < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.CleanMeasuresWithNullAnalysisUuid')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_make_analysis_uuid_not_null_on_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1261_make_analysis_uuid_not_null_on_measures.rb
new file mode 100644 (file)
index 0000000..2faf467
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 6.0
+#
+class MakeAnalysisUuidNotNullOnMeasures < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnMeasures')
+  end
+end
index b8ffe2469cbf94949030c8b34df2b23254b5f863..7eeb2c77eec3de29e5303c093d8337516e7662c8 100644 (file)
@@ -42,6 +42,7 @@ public class MeasureDto {
   private String description;
   private String componentUuid;
   private Long snapshotId;
+  private String analysisUuid;
   private Integer metricId;
   private Long developerId;
 
@@ -188,6 +189,15 @@ public class MeasureDto {
     return this;
   }
 
+  public String getAnalysisUuid() {
+    return analysisUuid;
+  }
+
+  public MeasureDto setAnalysisUuid(String s) {
+    this.analysisUuid = s;
+    return this;
+  }
+
   /**
    * @deprecated in 5.5. Does nothing. Kept for compatibility with developer cockpit plugin, version 1.10
    */
@@ -240,6 +250,7 @@ public class MeasureDto {
       .add("description", description)
       .add("componentUuid", componentUuid)
       .add("snapshotId", snapshotId)
+      .add("analysisUuid", analysisUuid)
       .add("metricId", metricId)
       .add("developerId", developerId)
       .add("metricKey", metricKey)
index 09e6fd5afd800b15a989c3a9025bd864acc4fe8a..1ab5f63e5370d7e0dfa71929690b4406466d9abf 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.db.MyBatis;
 
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 1_257;
+  public static final int LAST_VERSION = 1_261;
 
   /**
    * The minimum supported version which can be upgraded. Lower
index 5dd6b7e55e7361204544b6f0b5834d6beb97f826..f3a9f9188129319334538667ea0884817cd9e5a3 100644 (file)
@@ -86,6 +86,7 @@ import org.sonar.db.version.v56.FixTypeOfRuleTypeOnMysql;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToDuplicationsIndex;
 import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents;
+import org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures;
 import org.sonar.db.version.v60.AddComponentUuidColumnToDuplicationsIndex;
 import org.sonar.db.version.v60.AddComponentUuidColumnToMeasures;
 import org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots;
@@ -99,6 +100,7 @@ import org.sonar.db.version.v60.CleanEventsWithoutSnapshotId;
 import org.sonar.db.version.v60.CleanOrphanRowsInProjects;
 import org.sonar.db.version.v60.CleanOrphanRowsInResourceIndex;
 import org.sonar.db.version.v60.CleanOrphanRowsInSnapshots;
+import org.sonar.db.version.v60.CleanMeasuresWithNullAnalysisUuid;
 import org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutAnalysis;
 import org.sonar.db.version.v60.DeleteOrphanDuplicationsIndexRowsWithoutComponent;
 import org.sonar.db.version.v60.DeleteOrphanMeasuresWithoutComponent;
@@ -113,6 +115,7 @@ import org.sonar.db.version.v60.DropSnapshotIdColumnsFromDuplicationsIndex;
 import org.sonar.db.version.v60.DropUnusedMeasuresColumns;
 import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnDuplicationsIndex;
 import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents;
+import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnMeasures;
 import org.sonar.db.version.v60.MakeComponentUuidColumnsNotNullOnSnapshots;
 import org.sonar.db.version.v60.MakeComponentUuidNotNullOnDuplicationsIndex;
 import org.sonar.db.version.v60.MakeComponentUuidNotNullOnMeasures;
@@ -123,6 +126,7 @@ import org.sonar.db.version.v60.MakeUuidPathColumnNotNullOnProjects;
 import org.sonar.db.version.v60.PopulateAnalysisUuidColumnOnCeActivity;
 import org.sonar.db.version.v60.PopulateAnalysisUuidOfDuplicationsIndex;
 import org.sonar.db.version.v60.PopulateAnalysisUuidOnEvents;
+import org.sonar.db.version.v60.PopulateAnalysisUuidOnMeasures;
 import org.sonar.db.version.v60.PopulateComponentUuidColumnsOfSnapshots;
 import org.sonar.db.version.v60.PopulateComponentUuidOfDuplicationsIndex;
 import org.sonar.db.version.v60.PopulateComponentUuidOfMeasures;
@@ -275,6 +279,13 @@ public class MigrationStepModule extends Module {
       // PROJECTS.UUID_PATH
       AddUuidPathColumnToProjects.class,
       PopulateUuidPathColumnOnProjects.class,
-      MakeUuidPathColumnNotNullOnProjects.class);
+      MakeUuidPathColumnNotNullOnProjects.class,
+
+      // PROJECT_MEASURES.ANALYSIS_UUID
+      AddAnalysisUuidColumnToMeasures.class,
+      PopulateAnalysisUuidOnMeasures.class,
+      CleanMeasuresWithNullAnalysisUuid.class,
+      MakeAnalysisUuidNotNullOnMeasures.class
+    );
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasures.java
new file mode 100644 (file)
index 0000000..f78c801
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.AddColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class AddAnalysisUuidColumnToMeasures extends DdlChange {
+
+  private static final String TABLE_MEASURES = "project_measures";
+
+  public AddAnalysisUuidColumnToMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES)
+      .addColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(true).build())
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuid.java b/sonar-db/src/main/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuid.java
new file mode 100644 (file)
index 0000000..2def559
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+
+public class CleanMeasuresWithNullAnalysisUuid extends BaseDataChange {
+
+  public CleanMeasuresWithNullAnalysisUuid(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("select id from project_measures where analysis_uuid is null");
+    massUpdate.update("delete from project_measures where id=?");
+    massUpdate.rowPluralName("measures");
+    massUpdate.execute((row, update) -> {
+      update.setLong(1, row.getLong(1));
+      return true;
+    });
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasures.java
new file mode 100644 (file)
index 0000000..c7c0571
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.AlterColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.VarcharColumnDef.UUID_VARCHAR_SIZE;
+import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class MakeAnalysisUuidNotNullOnMeasures extends DdlChange {
+
+  private static final String TABLE_MEASURES = "project_measures";
+
+  public MakeAnalysisUuidNotNullOnMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_MEASURES)
+      .updateColumn(newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).build())
+      .build());
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasures.java b/sonar-db/src/main/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasures.java
new file mode 100644 (file)
index 0000000..8393b12
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.Select;
+import org.sonar.db.version.SqlStatement;
+
+public class PopulateAnalysisUuidOnMeasures extends BaseDataChange {
+
+  public PopulateAnalysisUuidOnMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("select distinct m.snapshot_id, root_snapshots.uuid " +
+      "from project_measures m " +
+      "inner join snapshots s on m.snapshot_id=s.id " +
+      "inner join snapshots root_snapshots on s.root_snapshot_id=root_snapshots.id " +
+      "where m.analysis_uuid is null");
+    massUpdate.update("update project_measures set analysis_uuid=? where snapshot_id=? and analysis_uuid is null");
+    massUpdate.rowPluralName("measures");
+    massUpdate.execute(this::handle);
+  }
+
+  private boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+    long snapshotId = row.getLong(1);
+    String analysisUuid = row.getString(2);
+
+    update.setString(1, analysisUuid);
+    update.setLong(2, snapshotId);
+
+    return true;
+  }
+
+}
index c256b0b34c7ae540175b2e2075dfa0fa7dc3f96c..c98feb9fbcfe34dfde7acc658f6aa06d44e9bf1e 100644 (file)
@@ -8,6 +8,7 @@
     pm.person_id as developerId,
     pm.component_uuid as componentUuid,
     pm.snapshot_id as snapshotId,
+    pm.analysis_uuid as analysisUuid,
     pm.value as value,
     pm.text_value as textValue,
     pm.alert_status as alertStatus,
 
   <insert id="insert" parameterType="Measure" useGeneratedKeys="false">
     INSERT INTO project_measures (
-    value, metric_id, component_uuid, snapshot_id, text_value, alert_status, alert_text, description,
-    person_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4,
-    variation_value_5, measure_data)
+    value,
+    metric_id,
+    component_uuid,
+    snapshot_id,
+    analysis_uuid,
+    text_value,
+    alert_status,
+    alert_text,
+    description,
+    person_id,
+    variation_value_1,
+    variation_value_2,
+    variation_value_3,
+    variation_value_4,
+    variation_value_5,
+    measure_data)
     VALUES (
-    #{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{componentUuid, jdbcType=VARCHAR},
+    #{value, jdbcType=DOUBLE},
+    #{metricId, jdbcType=INTEGER},
+    #{componentUuid, jdbcType=VARCHAR},
     #{snapshotId, jdbcType=INTEGER},
+    #{analysisUuid, jdbcType=VARCHAR},
     #{textValue, jdbcType=VARCHAR},
-    #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR},
+    #{alertStatus, jdbcType=VARCHAR},
+    #{alertText, jdbcType=VARCHAR},
     #{description, jdbcType=VARCHAR},
-    #{developerId, jdbcType=INTEGER}, #{variation1, jdbcType=DOUBLE}, #{variation2, jdbcType=DOUBLE},
+    #{developerId, jdbcType=INTEGER},
+    #{variation1, jdbcType=DOUBLE},
+    #{variation2, jdbcType=DOUBLE},
     #{variation3, jdbcType=DOUBLE},
-    #{variation4, jdbcType=DOUBLE}, #{variation5, jdbcType=DOUBLE}, #{dataValue, jdbcType=BINARY}
+    #{variation4, jdbcType=DOUBLE},
+    #{variation5, jdbcType=DOUBLE},
+    #{dataValue, jdbcType=BINARY}
     )
   </insert>
 
index ce75f9372b6777907aa206c715f8eab527bb3835..0fd0413b98b11427b83d7f729d26d8f989fec1f0 100644 (file)
@@ -464,6 +464,10 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1254');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1255');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1256');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1257');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1258');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1259');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1260');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1261');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482');
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 72e3aa398c76da536dc7c5e26f45d75c65b5f178..12313c12212cab862dbdd5f5f09f38efabe7fedd 100644 (file)
@@ -199,6 +199,7 @@ CREATE TABLE "PROJECT_MEASURES" (
   "VALUE" DOUBLE,
   "METRIC_ID" INTEGER NOT NULL,
   "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
   "SNAPSHOT_ID" INTEGER,
   "TEXT_VALUE" VARCHAR(4000),
   "ALERT_STATUS" VARCHAR(5),
index f2c43e9515cbd0b56c34b9844cec00b205d57a4f..ab4b11eed847997b1ee157825c68ec86fa20a037 100644 (file)
@@ -486,6 +486,7 @@ public class MeasureDaoTest {
       .setValue(value)
       .setComponentUuid(componentDto.uuid())
       .setSnapshotId(snapshotDto.getId())
+      .setAnalysisUuid("u1")
       .setDeveloperId(developerId);
     dbClient.measureDao().insert(dbSession, measureDto);
     dbSession.commit();
@@ -498,6 +499,7 @@ public class MeasureDaoTest {
 
     underTest.insert(dbSession, new MeasureDto()
       .setSnapshotId(2L)
+      .setAnalysisUuid("u2")
       .setMetricId(3)
       .setDeveloperId(23L)
       .setComponentUuid("FILE1")
@@ -522,11 +524,13 @@ public class MeasureDaoTest {
 
     underTest.insert(dbSession, new MeasureDto()
       .setSnapshotId(2L)
+      .setAnalysisUuid("u2")
       .setMetricId(3)
       .setComponentUuid("COMPONENT_1")
       .setValue(2.0d),
       new MeasureDto()
         .setSnapshotId(3L)
+        .setAnalysisUuid("u2")
         .setMetricId(4)
         .setComponentUuid("COMPONENT_2")
         .setValue(4.0d));
index fcecfd476b5eda4f0907ebb4569ef2b343c2939e..9aff2793d0f313e92cafc40cefc89d0eacd0b013 100644 (file)
@@ -37,6 +37,7 @@ public class MeasureTesting {
       .setMetricId(metricDto.getId())
       .setMetricKey(metricDto.getKey())
       .setComponentUuid(snapshot.getComponentUuid())
-      .setSnapshotId(snapshot.getId());
+      .setSnapshotId(snapshot.getId())
+      .setAnalysisUuid(snapshot.getUuid());
   }
 }
index a4d75a54649f0231f908dd66524aedbff66e579c..b72caa7bfbad180dfa1710fd1e4bf6da8839e42c 100644 (file)
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
   public void verify_count_of_added_MigrationStep_types() {
     ComponentContainer container = new ComponentContainer();
     new MigrationStepModule().configure(container);
-    assertThat(container.size()).isEqualTo(113);
+    assertThat(container.size()).isEqualTo(117);
   }
 }
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest.java
new file mode 100644 (file)
index 0000000..9f6f288
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+
+public class AddAnalysisUuidColumnToMeasuresTest {
+
+  private static final String TABLE = "project_measures";
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddAnalysisUuidColumnToMeasuresTest.class, "old_measures.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private AddAnalysisUuidColumnToMeasures underTest = new AddAnalysisUuidColumnToMeasures(db.database());
+
+  @Test
+  public void migration_adds_column_to_empty_table() throws SQLException {
+    underTest.execute();
+
+    verifyAddedColumn();
+  }
+
+  @Test
+  public void migration_adds_column_to_populated_table() throws SQLException {
+    for (int i = 0; i < 9; i++) {
+      db.executeInsert(
+        TABLE,
+        "metric_id", valueOf(i),
+        "value", valueOf(i + 10),
+        "snapshot_id", valueOf(i + 100),
+        "component_uuid", valueOf(i + 1_000)
+        );
+    }
+    db.commit();
+
+    underTest.execute();
+
+    verifyAddedColumn();
+  }
+
+  @Test
+  public void migration_is_not_reentrant() throws SQLException {
+    underTest.execute();
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Fail to execute ");
+    underTest.execute();
+  }
+
+  private void verifyAddedColumn() {
+    db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 50, true);
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest.java
new file mode 100644 (file)
index 0000000..a2d049c
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CleanMeasuresWithNullAnalysisUuidTest {
+
+  private static final String TABLE_MEASURES = "project_measures";
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, CleanMeasuresWithNullAnalysisUuidTest.class,
+    "in_progress_measures.sql");
+
+  private CleanMeasuresWithNullAnalysisUuid underTest = new CleanMeasuresWithNullAnalysisUuid(db.database());
+
+  @Test
+  public void migration_has_no_effect_on_empty_table() throws SQLException {
+    underTest.execute();
+
+    assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0);
+  }
+
+  @Test
+  public void migration_deletes_rows_with_null_analysis_uuid() throws SQLException {
+    insertMeasure(1, "U1");
+    insertMeasure(2, "U1");
+    insertMeasure(3, null);
+    db.commit();
+
+    underTest.execute();
+
+    assertThat(idsOfRows()).containsOnly(1L, 2L);
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    insertMeasure(1, "U1");
+    insertMeasure(2, null);
+    db.commit();
+
+    underTest.execute();
+    assertThat(idsOfRows()).containsOnly(1L);
+
+    underTest.execute();
+    assertThat(idsOfRows()).containsOnly(1L);
+  }
+
+  private void insertMeasure(long id, @Nullable String analysisUuid) {
+    db.executeInsert(
+      TABLE_MEASURES,
+      "ID", valueOf(id),
+      "SNAPSHOT_ID", valueOf(id + 10),
+      "METRIC_ID", valueOf(id + 100),
+      "VALUE", valueOf(id + 200),
+      "COMPONENT_UUID", valueOf(id + 300),
+      "ANALYSIS_UUID", analysisUuid);
+  }
+
+  private List<Long> idsOfRows() {
+    return db.select("select ID from project_measures").stream().map(map -> (Long) map.get("ID")).collect(Collectors.toList());
+  }
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest.java
new file mode 100644 (file)
index 0000000..1c6089b
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+
+
+public class MakeAnalysisUuidNotNullOnMeasuresTest {
+
+  private static final String TABLE_MEASURES = "project_measures";
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeAnalysisUuidNotNullOnMeasuresTest.class,
+    "in_progress_measures.sql");
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private MakeAnalysisUuidNotNullOnMeasures underTest = new MakeAnalysisUuidNotNullOnMeasures(db.database());
+
+  @Test
+  public void migration_makes_analysis_uuid_not_nullable_on_empty_table() throws SQLException {
+    underTest.execute();
+
+    verifyColumnDefinitions();
+  }
+
+  @Test
+  public void migration_makes_analysis_uuid_not_nullable_on_populated_table() throws SQLException {
+    insertMeasure(1, "U1");
+    insertMeasure(2, "U2");
+
+    underTest.execute();
+
+    verifyColumnDefinitions();
+  }
+
+  @Test
+  public void migration_fails_if_some_uuid_columns_are_null() throws SQLException {
+    insertMeasure(2, null);
+
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Fail to execute");
+
+    underTest.execute();
+  }
+
+  private void insertMeasure(long id, @Nullable String analysisUuid) {
+    db.executeInsert(
+      TABLE_MEASURES,
+      "ID", valueOf(id),
+      "SNAPSHOT_ID", valueOf(id + 10),
+      "METRIC_ID", valueOf(id + 100),
+      "VALUE", valueOf(id + 200),
+      "COMPONENT_UUID", valueOf(id + 300),
+      "ANALYSIS_UUID", analysisUuid);
+  }
+
+  private void verifyColumnDefinitions() {
+    db.assertColumnDefinition(TABLE_MEASURES, "analysis_uuid", Types.VARCHAR, 50, false);
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest.java
new file mode 100644 (file)
index 0000000..54c6c68
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.db.version.v60;
+
+import java.sql.SQLException;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+
+import static java.lang.String.valueOf;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PopulateAnalysisUuidOnMeasuresTest {
+
+  private static final String TABLE_MEASURES = "project_measures";
+  private static final String TABLE_SNAPSHOTS = "snapshots";
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, PopulateAnalysisUuidOnMeasuresTest.class,
+    "old_measures.sql");
+
+  private PopulateAnalysisUuidOnMeasures underTest = new PopulateAnalysisUuidOnMeasures(db.database());
+
+  @Test
+  public void migration_has_no_effect_on_empty_tables() throws SQLException {
+    underTest.execute();
+
+    assertThat(db.countRowsOfTable(TABLE_MEASURES)).isEqualTo(0);
+  }
+
+  @Test
+  public void migration_populates_analysis_uuids() throws SQLException {
+    insertSnapshot(1, "U1", Qualifiers.PROJECT, 1);
+    insertSnapshot(2, "U2", Qualifiers.DIRECTORY, 1);
+    insertSnapshot(3, "U3", Qualifiers.FILE, 1);
+    insertMeasure(21, 1);
+    insertMeasure(22, 2);
+    insertMeasure(23, 3);
+    db.commit();
+
+    underTest.execute();
+
+    verifyAnalysisUuid(21, "U1");
+    verifyAnalysisUuid(22, "U1");
+    verifyAnalysisUuid(23, "U1");
+  }
+
+  @Test
+  public void migration_is_reentrant() throws SQLException {
+    insertSnapshot(1, "U1", Qualifiers.PROJECT, 1);
+    insertMeasure(21, 1);
+
+    underTest.execute();
+    verifyAnalysisUuid(21, "U1");
+
+    underTest.execute();
+    verifyAnalysisUuid(21, "U1");
+  }
+
+  private void verifyAnalysisUuid(int measureId, @Nullable String expectedAnalysisUuid) {
+    Map<String, Object> rows = db.selectFirst("select analysis_uuid as \"analysisUuid\" from project_measures where id=" + measureId);
+    assertThat(rows.get("analysisUuid")).isEqualTo(expectedAnalysisUuid);
+  }
+
+  private String insertSnapshot(long id, String uuid, String qualifier, long rootSnapshotId) {
+    db.executeInsert(
+      TABLE_SNAPSHOTS,
+      "ID", valueOf(id),
+      "UUID", uuid,
+      "COMPONENT_UUID", valueOf(id + 10),
+      "ROOT_COMPONENT_UUID", valueOf(id + 10),
+      "ROOT_SNAPSHOT_ID", valueOf(rootSnapshotId),
+      "QUALIFIER", qualifier);
+    return uuid;
+  }
+
+  private void insertMeasure(long id, long snapshotId) {
+    db.executeInsert(
+      TABLE_MEASURES,
+      "ID", valueOf(id),
+      "SNAPSHOT_ID", valueOf(snapshotId),
+      "METRIC_ID", valueOf(id + 100),
+      "VALUE", valueOf(id + 200),
+      "COMPONENT_UUID", valueOf(id + 300));
+  }
+}
index e2080221686931ebef3ceb04b25a27f992b451c5..2072fa6c6a36d210a946a76b311d7eaf575b178c 100644 (file)
@@ -2,6 +2,7 @@
   <project_measures
       id="1"
       snapshot_id="2"
+      analysis_uuid="u2"
       metric_id="3"
       component_uuid="FILE1"
       person_id="23"
index 635d065eadfd8941a5a84cdb72d62473852b3a52..5fb9ee56984c0b1e489c726c847ade541370f3a5 100644 (file)
                     VALUE="60"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="ABCD"/>
 
                     VALUE="80"
                     METRIC_ID="2"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="ABCD"/>
 
                     VALUE="20"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1001"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="BCDE"/>
 
                     VALUE="70"
                     METRIC_ID="2"
                     SNAPSHOT_ID="1001"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="BCDE"/>
 
                     VALUE="5"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1002"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="CDEF"/>
 
                     VALUE="60"
                     METRIC_ID="2"
                     SNAPSHOT_ID="1002"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="CDEF"/>
 
index 90bae0671036b2a0eac57052cabc991dc4d485a4..260f36f3c49f0abeb13f6d6f94ba2fcb8d24a758 100644 (file)
@@ -44,6 +44,7 @@
                     VALUE="60"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     person_id="[null]"
                     component_uuid="ABCD"/>
 
@@ -51,6 +52,7 @@
                     VALUE="20"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     person_id="20"
                     component_uuid="ABCD"/>
 
@@ -58,6 +60,7 @@
                     VALUE="40"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1000"
+                    analysis_uuid="u1000"
                     person_id="21"
                     component_uuid="ABCD"/>
 
index 8c287369351f100d0faa080411145b4f9ad0610e..bdd864aa9eeefa7df9827f788dcf2f80a942b18b 100644 (file)
@@ -22,6 +22,7 @@
 
   <project_measures id="20"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="10"
                     value="[null]"
                     text_value="0123456789012345678901234567890123456789"
@@ -36,6 +37,7 @@
                     component_uuid="FILE1"/>
   <project_measures id="21"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="11"
                     value="[null]"
                     text_value="36=1;37=1;38=1;39=1;43=1;48=1;53=1"
@@ -50,6 +52,7 @@
                     component_uuid="FILE1"/>
   <project_measures id="22"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="12"
                     value="10"
                     text_value="[null]"
index 66240b47fac281d55dc7f34514fa4ae8ed04df32..a85ddeba88cb33fafb4b56dc9e676e950c69fb5a 100644 (file)
@@ -23,6 +23,7 @@
   <project_measures id="20"
                     component_uuid="ABCD"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="10"
                     value="[null]"
                     text_value="0123456789012345678901234567890123456789"
@@ -37,6 +38,7 @@
   <project_measures id="21"
                     component_uuid="ABCD"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="11"
                     value="[null]"
                     text_value="36=1;37=1;38=1;39=1;43=1;48=1;53=1"
@@ -51,6 +53,7 @@
   <project_measures id="22"
                     component_uuid="ABCD"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="12"
                     value="10"
                     text_value="[null]"
index eea4becd304e4c92989d2507e2272e48c5a770c8..4d93914c15fb5f9e97164fab78792e435e37ddc1 100644 (file)
@@ -28,6 +28,7 @@
 
   <project_measures id="20"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="10"
                     value="[null]"
                     text_value="0123456789012345678901234567890123456789"
@@ -43,6 +44,7 @@
                     component_uuid="1"/>
   <project_measures id="21"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="11"
                     value="[null]"
                     text_value="36=1;37=1;38=1;39=1;43=1;48=1;53=1"
@@ -58,6 +60,7 @@
                     component_uuid="1"/>
   <project_measures id="22"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="12"
                     value="10"
                     text_value="[null]"
@@ -74,6 +77,7 @@
   <!--measures for developer 333-->
   <project_measures id="30"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="10"
                     value="[null]"
                     text_value="0123456789012345678901234567890123456789"
@@ -89,6 +93,7 @@
                     component_uuid="1"/>
   <project_measures id="31"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="11"
                     value="[null]"
                     text_value="36=1;37=1;38=1;39=1;43=1;48=1;53=1"
                     component_uuid="1"/>
   <project_measures id="32"
                     snapshot_id="5"
+                    analysis_uuid="u5"
                     metric_id="12"
                     value="10"
                     text_value="[null]"
index ed1010681e73e2fbc6689646087ac1ad3225c049..b8decef6de6881bd515d766f01bce5a6a4113533 100644 (file)
@@ -43,6 +43,7 @@
                     VALUE="10.0"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1"
+                    analysis_uuid="u1"
                     person_id="[null]"
                     text_value="[null]"
                     component_uuid="1"
index 7749f05166803c1e9e596935aa62073ff754d8e9..19d9d045a89fd943ff484782e4f282023f9873fc 100644 (file)
@@ -43,6 +43,7 @@
                     VALUE="10.0"
                     METRIC_ID="1"
                     SNAPSHOT_ID="1"
+                    analysis_uuid="u1"
                     person_id="[null]"
                     text_value="[null]"
                     component_uuid="1"
                     VALUE="10.0"
                     METRIC_ID="1"
                     SNAPSHOT_ID="5"
+                    analysis_uuid="u5"
                     person_id="[null]"
                     text_value="[null]"
                     component_uuid="5"
index 8532d9c55847e51e5398cb97a8af646c5f29982a..e3297878a6e1afd5883153f0778ae35abf0f0472 100644 (file)
@@ -1,37 +1,82 @@
 <dataset>
 
-  <metrics id="1" delete_historical_data="[null]"
-           name="ncloc" val_type="INT" description="[null]" domain="[null]" short_name="" enabled="[true]"
-           worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
-           direction="0" hidden="[false]"/>
+  <metrics id="1"
+           delete_historical_data="[null]"
+           name="ncloc"
+           val_type="INT"
+           description="[null]"
+           domain="[null]"
+           short_name=""
+           enabled="[true]"
+           worst_value="[null]"
+           optimized_best_value="[null]"
+           best_value="[null]"
+           direction="0"
+           hidden="[false]"/>
 
-  <metrics id="2" delete_historical_data="[true]"
-           name="coverage" val_type="INT" description="[null]" domain="[null]" short_name="" enabled="[true]"
-           worst_value="0" optimized_best_value="[true]" best_value="100"
-           direction="1" hidden="[false]"/>
+  <metrics id="2"
+           delete_historical_data="[true]"
+           name="coverage"
+           val_type="INT"
+           description="[null]"
+           domain="[null]"
+           short_name=""
+           enabled="[true]"
+           worst_value="0"
+           optimized_best_value="[true]"
+           best_value="100"
+           direction="1"
+           hidden="[false]"/>
 
   <snapshots id="1"
              uuid="u1"
-             project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
-             build_date="1228222680000" version="[null]" path="[null]"/>
+             project_id="1"
+             parent_snapshot_id="[null]"
+             root_project_id="1"
+             root_snapshot_id="[null]"
+             status="P"
+             islast="[true]"
+             purge_status="[null]"
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- do not delete standard measure -->
   <project_measures id="1"
                     snapshot_id="1"
+                    analysis_uuid="u1"
                     metric_id="1"
                     component_uuid="1"
-                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
                     variation_value_4="[null]"
-                    variation_value_5="[null]" alert_text="[null]" value="10.0"
+                    variation_value_5="[null]"
+                    alert_text="[null]"
+                    value="10.0"
                     person_id="[null]"
-                    text_value="[null]" alert_status="[null]"
-                    description="[null]" measure_data="[null]"/>
+                    text_value="[null]"
+                    alert_status="[null]"
+                    description="[null]"
+                    measure_data="[null]"/>
 
 </dataset>
index 24dc9ac4a3b98c564615cab1c9c8927356020e5d..9e9b5547c89f9e52ac66dfe2f9da6d4c0d7f30df 100644 (file)
@@ -1,14 +1,32 @@
 <dataset>
 
-  <metrics id="1" delete_historical_data="[null]"
-           name="ncloc" val_type="INT" description="[null]" domain="[null]" short_name="" enabled="[true]"
-           worst_value="[null]" optimized_best_value="[null]" best_value="[null]"
-           direction="0" hidden="[false]"/>
+  <metrics id="1"
+           delete_historical_data="[null]"
+           name="ncloc"
+           val_type="INT"
+           description="[null]"
+           domain="[null]"
+           short_name=""
+           enabled="[true]"
+           worst_value="[null]"
+           optimized_best_value="[null]"
+           best_value="[null]"
+           direction="0"
+           hidden="[false]"/>
 
-  <metrics id="2" delete_historical_data="[true]"
-           name="coverage" val_type="INT" description="[null]" domain="[null]" short_name="" enabled="[true]"
-           worst_value="0" optimized_best_value="[true]" best_value="100"
-           direction="1" hidden="[false]"/>
+  <metrics id="2"
+           delete_historical_data="[true]"
+           name="coverage"
+           val_type="INT"
+           description="[null]"
+           domain="[null]"
+           short_name=""
+           enabled="[true]"
+           worst_value="0"
+           optimized_best_value="[true]"
+           best_value="100"
+           direction="1"
+           hidden="[false]"/>
 
   <snapshots id="1"
              uuid="u1"
              parent_snapshot_id="[null]"
              root_component_uuid="uuid_1"
              root_snapshot_id="[null]"
-             status="P" islast="[true]"
+             status="P"
+             islast="[true]"
              purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[null]"
-             period3_mode="[null]" period3_param="[null]" period3_date="[null]"
-             period4_mode="[null]" period4_param="[null]" period4_date="[null]"
-             period5_mode="[null]" period5_param="[null]" period5_date="[null]"
-             depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
-             build_date="1228222680000" version="[null]" path="[null]"/>
+             period1_mode="[null]"
+             period1_param="[null]"
+             period1_date="[null]"
+             period2_mode="[null]"
+             period2_param="[null]"
+             period2_date="[null]"
+             period3_mode="[null]"
+             period3_param="[null]"
+             period3_date="[null]"
+             period4_mode="[null]"
+             period4_param="[null]"
+             period4_date="[null]"
+             period5_mode="[null]"
+             period5_param="[null]"
+             period5_date="[null]"
+             depth="[null]"
+             scope="PRJ"
+             qualifier="TRK"
+             created_at="1228222680000"
+             build_date="1228222680000"
+             version="[null]"
+             path="[null]"/>
 
   <!-- do not delete standard measure -->
   <project_measures id="1"
                     component_uuid="1"
-                    snapshot_id="1" metric_id="1"
-                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    snapshot_id="1"
+                    analysis_uuid="u1"
+                    metric_id="1"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
                     variation_value_4="[null]"
-                    variation_value_5="[null]" alert_text="[null]" value="10.0"
+                    variation_value_5="[null]"
+                    alert_text="[null]"
+                    value="10.0"
                     person_id="[null]"
-                    text_value="[null]" alert_status="[null]"
-                    description="[null]" measure_data="[null]"/>
+                    text_value="[null]"
+                    alert_status="[null]"
+                    description="[null]"
+                    measure_data="[null]"/>
 
   <!-- delete measure on metrics that are flagged with delete_historical_data=true -->
   <project_measures id="6"
                     component_uuid="1"
-                    snapshot_id="1" metric_id="2"
-                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    snapshot_id="1"
+                    analysis_uuid="u1"
+                    metric_id="2"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
                     variation_value_4="[null]"
-                    variation_value_5="[null]" alert_text="[null]" value="10.0"
+                    variation_value_5="[null]"
+                    alert_text="[null]"
+                    value="10.0"
                     person_id="[null]"
-                    text_value="[null]" alert_status="[null]"
-                    description="[null]" measure_data="[null]"/>
+                    text_value="[null]"
+                    alert_status="[null]"
+                    description="[null]"
+                    measure_data="[null]"/>
 
   <!-- delete measure on developers -->
   <project_measures id="7"
                     component_uuid="1"
-                    snapshot_id="1" metric_id="2"
-                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+                    snapshot_id="1"
+                    analysis_uuid="u1"
+                    metric_id="2"
+                    variation_value_1="[null]"
+                    variation_value_2="[null]"
+                    variation_value_3="[null]"
                     person_id="123456"
                     variation_value_4="[null]"
-                    variation_value_5="[null]" alert_text="[null]" value="10.0"
-                    text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
-                    description="[null]" measure_data="[null]"/>
+                    variation_value_5="[null]"
+                    alert_text="[null]"
+                    value="10.0"
+                    text_value="[null]"
+                    tendency="[null]"
+                    measure_date="[null]"
+                    alert_status="[null]"
+                    description="[null]"
+                    measure_data="[null]"/>
 </dataset>
index 25a719d851a3fb9f27928724dcdcfb8cd97a1179..4963f5ed5c49afc7f6308eac2504a15deb62da54 100644 (file)
@@ -48,6 +48,7 @@ Note that measures, events and reviews are not deleted.
   <project_measures ID="1"
                     component_uuid="1"
                     SNAPSHOT_ID="1"
+                    analysis_uuid="u1"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
@@ -113,6 +114,7 @@ Note that measures, events and reviews are not deleted.
   <project_measures ID="2"
                     component_uuid="2"
                     SNAPSHOT_ID="2"
+                    analysis_uuid="u2"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
index a77b0c19077f829b2f2d56cf3ba92da564bb8727..d42dbd85c8bd37af6cf7fe7562d2b27ce408c4a2 100644 (file)
@@ -35,6 +35,7 @@
   <project_measures ID="1"
                     component_uuid="1"
                     SNAPSHOT_ID="1"
+                    analysis_uuid="u1"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
                     variation_value_3="[null]"
   <project_measures ID="2"
                     component_uuid="2"
                     SNAPSHOT_ID="2"
+                    analysis_uuid="u2"
                     characteristic_id="[null]"
                     variation_value_1="[null]"
                     variation_value_2="[null]"
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/AddAnalysisUuidColumnToMeasuresTest/old_measures.sql
new file mode 100644 (file)
index 0000000..2f91874
--- /dev/null
@@ -0,0 +1,18 @@
+CREATE TABLE "PROJECT_MEASURES" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "VALUE" DOUBLE,
+  "METRIC_ID" INTEGER NOT NULL,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "SNAPSHOT_ID" INTEGER,
+  "TEXT_VALUE" VARCHAR(4000),
+  "ALERT_STATUS" VARCHAR(5),
+  "ALERT_TEXT" VARCHAR(4000),
+  "DESCRIPTION" VARCHAR(4000),
+  "PERSON_ID" INTEGER,
+  "VARIATION_VALUE_1" DOUBLE,
+  "VARIATION_VALUE_2" DOUBLE,
+  "VARIATION_VALUE_3" DOUBLE,
+  "VARIATION_VALUE_4" DOUBLE,
+  "VARIATION_VALUE_5" DOUBLE,
+  "MEASURE_DATA" BINARY(167772150)
+  );
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/CleanMeasuresWithNullAnalysisUuidTest/in_progress_measures.sql
new file mode 100644 (file)
index 0000000..5f58ad5
--- /dev/null
@@ -0,0 +1,20 @@
+CREATE TABLE "PROJECT_MEASURES" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "VALUE" DOUBLE,
+  "METRIC_ID" INTEGER NOT NULL,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "SNAPSHOT_ID" INTEGER,
+  // NULLABLE at that time
+  "ANALYSIS_UUID" VARCHAR(50),
+  "TEXT_VALUE" VARCHAR(4000),
+  "ALERT_STATUS" VARCHAR(5),
+  "ALERT_TEXT" VARCHAR(4000),
+  "DESCRIPTION" VARCHAR(4000),
+  "PERSON_ID" INTEGER,
+  "VARIATION_VALUE_1" DOUBLE,
+  "VARIATION_VALUE_2" DOUBLE,
+  "VARIATION_VALUE_3" DOUBLE,
+  "VARIATION_VALUE_4" DOUBLE,
+  "VARIATION_VALUE_5" DOUBLE,
+  "MEASURE_DATA" BINARY(167772150)
+  );
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnMeasuresTest/in_progress_measures.sql
new file mode 100644 (file)
index 0000000..5f58ad5
--- /dev/null
@@ -0,0 +1,20 @@
+CREATE TABLE "PROJECT_MEASURES" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "VALUE" DOUBLE,
+  "METRIC_ID" INTEGER NOT NULL,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "SNAPSHOT_ID" INTEGER,
+  // NULLABLE at that time
+  "ANALYSIS_UUID" VARCHAR(50),
+  "TEXT_VALUE" VARCHAR(4000),
+  "ALERT_STATUS" VARCHAR(5),
+  "ALERT_TEXT" VARCHAR(4000),
+  "DESCRIPTION" VARCHAR(4000),
+  "PERSON_ID" INTEGER,
+  "VARIATION_VALUE_1" DOUBLE,
+  "VARIATION_VALUE_2" DOUBLE,
+  "VARIATION_VALUE_3" DOUBLE,
+  "VARIATION_VALUE_4" DOUBLE,
+  "VARIATION_VALUE_5" DOUBLE,
+  "MEASURE_DATA" BINARY(167772150)
+  );
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/PopulateAnalysisUuidOnMeasuresTest/old_measures.sql
new file mode 100644 (file)
index 0000000..203419a
--- /dev/null
@@ -0,0 +1,54 @@
+CREATE TABLE "SNAPSHOTS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "UUID" VARCHAR(50) NOT NULL,
+  "CREATED_AT" BIGINT,
+  "BUILD_DATE" BIGINT,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "PARENT_SNAPSHOT_ID" INTEGER,
+  "STATUS" VARCHAR(4) NOT NULL DEFAULT 'U',
+  "PURGE_STATUS" INTEGER,
+  "ISLAST" BOOLEAN NOT NULL DEFAULT FALSE,
+  "SCOPE" VARCHAR(3),
+  "QUALIFIER" VARCHAR(10),
+  "ROOT_SNAPSHOT_ID" INTEGER,
+  "VERSION" VARCHAR(500),
+  "PATH" VARCHAR(500),
+  "DEPTH" INTEGER,
+  "ROOT_COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "PERIOD1_MODE" VARCHAR(100),
+  "PERIOD1_PARAM" VARCHAR(100),
+  "PERIOD1_DATE" BIGINT,
+  "PERIOD2_MODE" VARCHAR(100),
+  "PERIOD2_PARAM" VARCHAR(100),
+  "PERIOD2_DATE" BIGINT,
+  "PERIOD3_MODE" VARCHAR(100),
+  "PERIOD3_PARAM" VARCHAR(100),
+  "PERIOD3_DATE" BIGINT,
+  "PERIOD4_MODE" VARCHAR(100),
+  "PERIOD4_PARAM" VARCHAR(100),
+  "PERIOD4_DATE" BIGINT,
+  "PERIOD5_MODE" VARCHAR(100),
+  "PERIOD5_PARAM" VARCHAR(100),
+  "PERIOD5_DATE" BIGINT
+);
+
+CREATE TABLE "PROJECT_MEASURES" (
+  "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "VALUE" DOUBLE,
+  "METRIC_ID" INTEGER NOT NULL,
+  "COMPONENT_UUID" VARCHAR(50) NOT NULL,
+  "SNAPSHOT_ID" INTEGER,
+  // NULLABLE at that time
+  "ANALYSIS_UUID" VARCHAR(50),
+  "TEXT_VALUE" VARCHAR(4000),
+  "ALERT_STATUS" VARCHAR(5),
+  "ALERT_TEXT" VARCHAR(4000),
+  "DESCRIPTION" VARCHAR(4000),
+  "PERSON_ID" INTEGER,
+  "VARIATION_VALUE_1" DOUBLE,
+  "VARIATION_VALUE_2" DOUBLE,
+  "VARIATION_VALUE_3" DOUBLE,
+  "VARIATION_VALUE_4" DOUBLE,
+  "VARIATION_VALUE_5" DOUBLE,
+  "MEASURE_DATA" BINARY(167772150)
+  );