]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5580 Migration issue to SQ 4.4 when the quality profile used to analyze the...
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 15 Sep 2014 13:54:45 +0000 (15:54 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 15 Sep 2014 13:54:45 +0000 (15:54 +0200)
13 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigration.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationTest.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest.java [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationTest/measure_on_deleted_profile.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/584_delete_measures_on_deleted_profiles.rb [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java
sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql

index e42b945d93e64463482a905157c4c349926193be..5d280b4f7a28b887f8df49b0d1797f248de2070d 100644 (file)
@@ -36,6 +36,7 @@ import org.sonar.server.db.migrations.v44.FeedQProfileKeysMigration;
 import org.sonar.server.db.migrations.v44.IssueActionPlanKeyMigration;
 import org.sonar.server.db.migrations.v44.MeasureDataMigration;
 import org.sonar.server.db.migrations.v45.AddMissingRuleParameterDefaultValuesMigration;
+import org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigration;
 
 import java.util.List;
 
@@ -65,7 +66,8 @@ public interface DatabaseMigrations {
     ConvertProfileMeasuresMigration.class,
 
     // 4.5
-    AddMissingRuleParameterDefaultValuesMigration.class
+    AddMissingRuleParameterDefaultValuesMigration.class,
+    DeleteMeasuresOnDeletedProfilesMigration.class
   );
 
 }
index 0c2f6f522fcd240105f51266e771bab4cc6542c8..994e8f15f4afb2af72bb50ec7ed9b05be92887d7 100644 (file)
@@ -54,6 +54,7 @@ public class ConvertProfileMeasuresMigration implements DatabaseMigration {
       Date now = new Date();
       Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
       for (ProfileMeasure profileMeasure : mapper.selectProfileMeasures()) {
+        boolean updated = false;
         Integer version = mapper.selectProfileVersion(profileMeasure.getSnapshotId());
         QProfileDto44 profile = mapper.selectProfileById(profileMeasure.getProfileId());
         if (profile != null) {
@@ -76,10 +77,14 @@ public class ConvertProfileMeasuresMigration implements DatabaseMigration {
             .endArray()
             .close();
           mapper.updateProfileMeasure(profileMeasure.getId(), writer.toString());
-          if (i % 100 == 0) {
-            session.commit();
-            i++;
-          }
+          updated = true;
+        }
+        if (!updated) {
+          mapper.deleteProfileMeasure(profileMeasure.getId());
+        }
+        if (i % 100 == 0) {
+          session.commit();
+          i++;
         }
       }
       session.commit();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigration.java
new file mode 100644 (file)
index 0000000..0a79bd6
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v45;
+
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.migration.v44.Migration44Mapper;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.DatabaseMigration;
+
+/**
+ * See http://jira.codehaus.org/browse/SONAR-5580
+ * {@link org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigration} 
+ * introduced a regression in 4.4. Measures on orphan profiles were kept 
+ * in old format (no JSON data but numeric value of profile id)
+ * 
+ * @see org.sonar.server.db.migrations.v44.ConvertProfileMeasuresMigration
+ * @since 4.5
+ */
+public class DeleteMeasuresOnDeletedProfilesMigration implements DatabaseMigration {
+
+  private final DbClient db;
+
+  public DeleteMeasuresOnDeletedProfilesMigration(DbClient db) {
+    this.db = db;
+  }
+
+  @Override
+  public void execute() {
+    DbSession session = db.openSession(false);
+    try {
+      Migration44Mapper mapper = session.getMapper(Migration44Mapper.class);
+      for (Long measureId : mapper.selectMeasuresOnDeletedQualityProfiles()) {
+        mapper.deleteProfileMeasure(measureId);
+      }
+      session.commit();
+
+    } finally {
+      session.close();
+    }
+  }
+}
index 0614f58a36da5bc1127c8b387519ffb91d52ac44..d521bded4579e2f71ba44258a8e02cf5dadd558a 100644 (file)
@@ -89,4 +89,26 @@ public class ConvertProfileMeasuresMigrationTest {
       connection.close();
     }
   }
+
+  /**
+   * http://jira.codehaus.org/browse/SONAR-5580
+   */
+  @Test
+  public void delete_measure_when_profile_does_not_exist() throws Exception {
+    db.prepareDbUnit(getClass(), "measure_on_deleted_profile.xml");
+
+    migration.execute();
+
+    Connection connection = db.openConnection();
+    Statement stmt = connection.createStatement();
+    ResultSet rs = stmt.executeQuery("select * from project_measures where id=2");
+    try {
+      // measure is deleted
+      assertThat(rs.next()).isFalse();
+    } finally {
+      rs.close();
+      stmt.close();
+      connection.close();
+    }
+  }
 }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest.java
new file mode 100644 (file)
index 0000000..4910e6b
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v45;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.core.persistence.TestDatabase;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.db.migrations.DatabaseMigration;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DeleteMeasuresOnDeletedProfilesMigrationTest {
+
+  @ClassRule
+  public static TestDatabase db = new TestDatabase().schema(DeleteMeasuresOnDeletedProfilesMigrationTest.class, "schema.sql");
+
+  DatabaseMigration migration;
+
+  @Before
+  public void setUp() throws Exception {
+    DbClient dbClient = new DbClient(db.database(), db.myBatis());
+    migration = new DeleteMeasuresOnDeletedProfilesMigration(dbClient);
+  }
+
+  @Test
+  public void delete_measures_with_no_json_data() throws Exception {
+    db.prepareDbUnit(getClass(), "before.xml");
+
+    migration.execute();
+
+    Connection connection = db.openConnection();
+    Statement stmt = connection.createStatement();
+    ResultSet rs = stmt.executeQuery("select id from project_measures");
+    try {
+      assertThat(rs.next()).isTrue();
+      assertThat(rs.getInt(1)).isEqualTo(2);
+      assertThat(rs.next()).isFalse();
+    } finally {
+      rs.close();
+      stmt.close();
+      connection.close();
+    }
+  }
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationTest/measure_on_deleted_profile.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v44/ConvertProfileMeasuresMigrationTest/measure_on_deleted_profile.xml
new file mode 100644 (file)
index 0000000..5307116
--- /dev/null
@@ -0,0 +1,31 @@
+<dataset>
+  <metrics id="1" 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]" delete_historical_data="[null]" />
+  <metrics  id="2" name="profile" VAL_TYPE="DATA" DESCRIPTION="[null]"  domain="[null]" short_name=""
+            enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/>
+
+  <!-- last snapshot -->
+  <snapshots purge_status="[null]" id="1001" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
+             scope="PRJ" qualifier="TRK" created_at="2009-11-01 13:58:00.00" build_date="2009-11-01 13:58:00.00" version="[null]" path=""
+             status="P" islast="[true]" depth="0"
+             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]" />
+
+
+  <!-- last measures : ncloc, deleted profile -->
+
+  <project_measures id="1" VALUE="60" METRIC_ID="1" SNAPSHOT_ID="1001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
+                    RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+                    alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[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" VALUE="22" text_value="Sonar way" METRIC_ID="2" SNAPSHOT_ID="1001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
+                    RULE_ID="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+                    alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
+                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
+
+
+  <!-- quality profiles -->
+  <rules_profiles id="20" name="Sonar way" language="java" kee="java-sonar-way" parent_kee="[null]"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/before.xml
new file mode 100644 (file)
index 0000000..224c28d
--- /dev/null
@@ -0,0 +1,23 @@
+<dataset>
+  <metrics  id="1" name="quality_profiles" VAL_TYPE="DATA" DESCRIPTION="[null]"  domain="[null]" short_name=""
+           enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/>
+
+  <!-- old format, references a numeric value which is profile id -->
+  <project_measures id="1" VALUE="60" METRIC_ID="1" SNAPSHOT_ID="1001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
+                    RULE_ID="[null]" text_value="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+                    alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
+                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
+
+  <!-- new format, json data -->
+  <project_measures id="2" VALUE="[null]" text_value="{json}" METRIC_ID="1" SNAPSHOT_ID="1001" alert_text="[null]" RULES_CATEGORY_ID="[null]"
+                    RULE_ID="[null]" tendency="[null]" measure_date="[null]" project_id="[null]"
+                    alert_status="[null]" description="[null]" rule_priority="[null]" characteristic_id="[null]" url="[null]"
+                    variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]"/>
+
+  <!-- last snapshot -->
+  <snapshots purge_status="[null]" id="1001" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
+             scope="PRJ" qualifier="TRK" created_at="2009-11-01 13:58:00.00" build_date="2009-11-01 13:58:00.00" version="[null]" path=""
+             status="P" islast="[true]" depth="0"
+             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]" />
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v45/DeleteMeasuresOnDeletedProfilesMigrationTest/schema.sql
new file mode 100644 (file)
index 0000000..912fd08
--- /dev/null
@@ -0,0 +1,77 @@
+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,
+  "SNAPSHOT_ID" INTEGER,
+  "RULE_ID" INTEGER,
+  "RULES_CATEGORY_ID" INTEGER,
+  "TEXT_VALUE" VARCHAR(4000),
+  "TENDENCY" INTEGER,
+  "MEASURE_DATE" TIMESTAMP,
+  "PROJECT_ID" INTEGER,
+  "ALERT_STATUS" VARCHAR(5),
+  "ALERT_TEXT" VARCHAR(4000),
+  "URL" VARCHAR(2000),
+  "DESCRIPTION" VARCHAR(4000),
+  "RULE_PRIORITY" INTEGER,
+  "CHARACTERISTIC_ID" INTEGER,
+  "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)
+);
+
+CREATE TABLE "METRICS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "NAME" VARCHAR(64) NOT NULL,
+  "DESCRIPTION" VARCHAR(255),
+  "DIRECTION" INTEGER NOT NULL DEFAULT 0,
+  "DOMAIN" VARCHAR(64),
+  "SHORT_NAME" VARCHAR(64),
+  "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE,
+  "VAL_TYPE" VARCHAR(8),
+  "USER_MANAGED" BOOLEAN DEFAULT FALSE,
+  "ENABLED" BOOLEAN DEFAULT TRUE,
+  "ORIGIN" VARCHAR(3),
+  "WORST_VALUE" DOUBLE,
+  "BEST_VALUE" DOUBLE,
+  "OPTIMIZED_BEST_VALUE" BOOLEAN,
+  "HIDDEN" BOOLEAN,
+  "DELETE_HISTORICAL_DATA" BOOLEAN
+);
+
+CREATE TABLE "SNAPSHOTS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "CREATED_AT" TIMESTAMP,
+  "BUILD_DATE" TIMESTAMP,
+  "PROJECT_ID" INTEGER 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_PROJECT_ID" INTEGER,
+  "PERIOD1_MODE" VARCHAR(100),
+  "PERIOD1_PARAM" VARCHAR(100),
+  "PERIOD1_DATE" TIMESTAMP,
+  "PERIOD2_MODE" VARCHAR(100),
+  "PERIOD2_PARAM" VARCHAR(100),
+  "PERIOD2_DATE" TIMESTAMP,
+  "PERIOD3_MODE" VARCHAR(100),
+  "PERIOD3_PARAM" VARCHAR(100),
+  "PERIOD3_DATE" TIMESTAMP,
+  "PERIOD4_MODE" VARCHAR(100),
+  "PERIOD4_PARAM" VARCHAR(100),
+  "PERIOD4_DATE" TIMESTAMP,
+  "PERIOD5_MODE" VARCHAR(100),
+  "PERIOD5_PARAM" VARCHAR(100),
+  "PERIOD5_DATE" TIMESTAMP
+);
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/584_delete_measures_on_deleted_profiles.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/584_delete_measures_on_deleted_profiles.rb
new file mode 100644 (file)
index 0000000..f414494
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# 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 4.5
+#
+class DeleteMeasuresOnDeletedProfiles < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration 'org.sonar.server.db.migrations.v45.DeleteMeasuresOnDeletedProfilesMigration'
+  end
+
+end
index ee7e376fa5279ec733288576adb7b5be9ed9b0fb..105c8c5b58fdfabdaebff5b2f9e209f7be8992c9 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 583;
+  public static final int LAST_VERSION = 584;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 19075d6e9db8513797a097dd7138151388c68abb..8bffe19dd17c81a2be0738fd6d5900dba19f1167 100644 (file)
@@ -40,6 +40,8 @@ public interface Migration44Mapper {
 
   void updateProfileMeasure(@Param("measureId") long measureId, @Param("json") String json);
 
+  void deleteProfileMeasure(long profileMeasureId);
+
   @CheckForNull
   QProfileDto44 selectProfileById(int id);
 
@@ -56,4 +58,6 @@ public interface Migration44Mapper {
 
   // migrate changeLog to Activities
   List<ChangeLog> selectActiveRuleChange(@Nullable @Param("enabled") Boolean enabled);
+
+  List<Long> selectMeasuresOnDeletedQualityProfiles();
 }
index f2c0c203b091fd12648fc43e86ae524eb0167963..eeb24110187d8191ef5114ac7a1e1d492726ff46 100644 (file)
     where id=#{measureId}
   </update>
 
+  <delete id="deleteProfileMeasure" parameterType="long">
+    delete from project_measures where id=#{id}
+  </delete>
+
+  <select id="selectMeasuresOnDeletedQualityProfiles" resultType="long">
+     select pm.id from project_measures pm
+      inner join snapshots as s on s.id=pm.snapshot_id and s.islast=${_true}
+      where
+        pm.metric_id=(select id from metrics where name='quality_profiles')
+        and pm.value is not null
+  </select>
+
   <select id="selectProfileUpdatedAt" resultType="date" parameterType="int">
     select max(change_date) from active_rule_changes
     where profile_id=#{id}
index 9634897e73f856ce34e0f34a811b95be43b9c7c0..d9ea9b3d667edd861f386ac55b04131968b69c2e 100644 (file)
@@ -253,6 +253,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('580');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('581');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('582');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('583');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('584');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;