diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-12-19 16:07:56 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-12-19 19:32:53 +0400 |
commit | fe5480b895f576efb36e3659a2b5a0fe5dc60430 (patch) | |
tree | b15f95ce68da523b52d70c197a69d2350e82a128 | |
parent | 17a932cde5030121ddec6094b9b89852152cefde (diff) | |
download | sonarqube-fe5480b895f576efb36e3659a2b5a0fe5dc60430.tar.gz sonarqube-fe5480b895f576efb36e3659a2b5a0fe5dc60430.zip |
SONAR-3090 Remove DUPLICATIONS_INDEX.ID
In order to do this - remove entity DuplicationBlock and use native
query in PurgeUtils.
15 files changed, 76 insertions, 161 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeUtils.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeUtils.java index 20bcb0f6241..d6598a62619 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeUtils.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/api/PurgeUtils.java @@ -33,7 +33,6 @@ import org.sonar.api.database.model.Snapshot; import org.sonar.api.database.model.SnapshotSource; import org.sonar.api.design.DependencyDto; import org.sonar.api.utils.TimeProfiler; -import org.sonar.jpa.entity.DuplicationBlock; /** * @since 2.5 @@ -70,7 +69,7 @@ public final class PurgeUtils { deleteSnapshots(session, snapshotIds); } - public static void deleteDependencies(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteDependencies(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete dependencies", snapshotIds, "delete from " + DependencyDto.class.getSimpleName() + " d where d.fromSnapshotId in (:ids)"); executeQuery(session, "delete dependencies", snapshotIds, "delete from " + DependencyDto.class.getSimpleName() + " d where d.toSnapshotId in (:ids)"); } @@ -78,7 +77,7 @@ public final class PurgeUtils { /** * Delete all measures, including MEASURE_DATA */ - public static void deleteMeasuresBySnapshotId(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteMeasuresBySnapshotId(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete measures by snapshot id", snapshotIds, "delete from " + MeasureData.class.getSimpleName() + " m where m.snapshotId in (:ids)"); executeQuery(session, "delete measures by snapshot id", snapshotIds, "delete from " + MeasureModel.class.getSimpleName() + " m where m.snapshotId in (:ids)"); } @@ -86,7 +85,7 @@ public final class PurgeUtils { /** * Delete all measures, including MEASURE_DATA */ - public static void deleteMeasuresById(DatabaseSession session, List<Integer> measureIds) { + public static void deleteMeasuresById(DatabaseSession session, List<Integer> measureIds) { executeQuery(session, "delete measures by id", measureIds, "delete from " + MeasureData.class.getSimpleName() + " m where m.measure.id in (:ids)"); executeQuery(session, "delete measures by id", measureIds, "delete from " + MeasureModel.class.getSimpleName() + " m where m.id in (:ids)"); } @@ -94,58 +93,73 @@ public final class PurgeUtils { /** * Delete SNAPSHOT_SOURCES table */ - public static void deleteSources(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteSources(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete sources", snapshotIds, "delete from " + SnapshotSource.class.getSimpleName() + " e where e.snapshotId in (:ids)"); } /** * Delete violations (RULE_FAILURES table) */ - public static void deleteViolations(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteViolations(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete violations", snapshotIds, "delete from " + RuleFailureModel.class.getSimpleName() + " e where e.snapshotId in (:ids)"); } /** + * Delete DUPLICATIONS_INDEX table + * * @since 2.11 */ private static void deleteDuplicationBlocks(DatabaseSession session, List<Integer> snapshotIds) { - executeQuery(session, "delete duplication blocks", snapshotIds, "delete from " + DuplicationBlock.class.getSimpleName() + " e where e.snapshotId in (:ids)"); + executeNativeQuery(session, "delete duplication blocks", snapshotIds, "delete from duplications_index e where e.snapshot_id in (:ids)"); } /** * Delete EVENTS table */ - public static void deleteEvents(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteEvents(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete events", snapshotIds, "delete from " + Event.class.getSimpleName() + " e where e.snapshot.id in (:ids)"); } /** * Delete SNAPSHOTS table */ - public static void deleteSnapshots(DatabaseSession session, List<Integer> snapshotIds) { + public static void deleteSnapshots(DatabaseSession session, List<Integer> snapshotIds) { executeQuery(session, "delete snapshots", snapshotIds, "delete from " + Snapshot.class.getSimpleName() + " s where s.id in (:ids)"); } /** * Paginate execution of SQL requests to avoid exceeding size of rollback segment */ - public static void executeQuery(DatabaseSession session, String description, List<Integer> ids, String hql) { + public static void executeQuery(DatabaseSession session, String description, List<Integer> ids, String hql) { if (ids == null || ids.isEmpty()) { return; } + executeQuery(session, description, ids, session.createQuery(hql)); + } - TimeProfiler profiler = new TimeProfiler().setLevelToDebug().start("Execute " + description); + /** + * @since 2.13 + */ + private static void executeNativeQuery(DatabaseSession session, String description, List<Integer> ids, String sql) { + if (ids == null || ids.isEmpty()) { + return; + } + executeQuery(session, description, ids, session.createNativeQuery(sql)); + } + /** + * @since 2.13 + */ + private static void executeQuery(DatabaseSession session, String description, List<Integer> ids, Query query) { + TimeProfiler profiler = new TimeProfiler().setLevelToDebug().start("Execute " + description); int index = 0; while (index < ids.size()) { - Query query = session.createQuery(hql); List<Integer> paginedSids = ids.subList(index, Math.min(ids.size(), index + MAX_IN_ELEMENTS)); query.setParameter("ids", paginedSids); query.executeUpdate(); index += MAX_IN_ELEMENTS; session.commit(); } - profiler.stop(); } diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml index cc74ed382d4..767062ce46a 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots-result.xml @@ -114,8 +114,8 @@ <!--parent_dependency_id="[null]" project_snapshot_id="1"--> <!--dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL"/>--> - <!--<duplications_index id="1" project_snapshot_id="1" snapshot_id="3" hash="bb" index_in_file="0" start_line="0" end_line="0" />--> - <!--<duplications_index id="2" project_snapshot_id="1" snapshot_id="4" hash="bb" index_in_file="0" start_line="0" end_line="0" />--> + <!--<duplications_index project_snapshot_id="1" snapshot_id="3" hash="bb" index_in_file="0" start_line="0" end_line="0" />--> + <!--<duplications_index project_snapshot_id="1" snapshot_id="4" hash="bb" index_in_file="0" start_line="0" end_line="0" />--> <events id="1" name="Version 1.0" resource_id="1" snapshot_id="1" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]"/> <!--events id="2" name="Version 2.0" resource_id="3" snapshot_id="3" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]"/--> diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml index 09e1ecd3edf..4e2999bcb46 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml +++ b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/api/PurgeUtilsTest/purgeSnapshots.xml @@ -120,8 +120,8 @@ parent_dependency_id="[null]" project_snapshot_id="1" dep_usage="INHERITS" dep_weight="1" from_scope="FIL" to_scope="FIL"/> - <duplications_index id="1" project_snapshot_id="1" snapshot_id="3" hash="bb" index_in_file="0" start_line="0" end_line="0"/> - <duplications_index id="2" project_snapshot_id="1" snapshot_id="4" hash="bb" index_in_file="0" start_line="0" end_line="0"/> + <duplications_index project_snapshot_id="1" snapshot_id="3" hash="bb" index_in_file="0" start_line="0" end_line="0"/> + <duplications_index project_snapshot_id="1" snapshot_id="4" hash="bb" index_in_file="0" start_line="0" end_line="0"/> <events id="1" name="Version 1.0" resource_id="1" snapshot_id="1" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]"/> <events id="2" name="Version 2.0" resource_id="3" snapshot_id="3" category="VERSION" description="[null]" event_date="2008-12-02 13:58:00.00" CREATED_AT="[null]"/> diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/DuplicationBlock.java b/sonar-core/src/main/java/org/sonar/jpa/entity/DuplicationBlock.java deleted file mode 100644 index 4e4ea87e4c7..00000000000 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/DuplicationBlock.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.jpa.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * @since 2.11 - */ -@Entity -@Table(name = "duplications_index") -public class DuplicationBlock { - - public static final int BLOCK_HASH_SIZE = 50; - - @Id - @Column(name = "id") - @GeneratedValue - private Integer id; - - @Column(name = "snapshot_id", updatable = false, nullable = false) - private Integer snapshotId; - - @Column(name = "project_snapshot_id", updatable = false, nullable = false) - private Integer projectSnapshotId; - - @Column(name = "hash", updatable = false, nullable = false, length = BLOCK_HASH_SIZE) - private String hash; - - @Column(name = "index_in_file", updatable = false, nullable = false) - private Integer indexInFile; - - @Column(name = "start_line", updatable = false, nullable = false) - private Integer startLine; - - @Column(name = "end_line", updatable = false, nullable = false) - private Integer endLine; - - public DuplicationBlock() { - } - - public DuplicationBlock(Integer projectSnapshotId, Integer snapshotId, String hash, Integer indexInFile, Integer startLine, Integer endLine) { - this.projectSnapshotId = projectSnapshotId; - this.snapshotId = snapshotId; - this.hash = hash; - this.indexInFile = indexInFile; - this.startLine = startLine; - this.endLine = endLine; - } - - public Integer getId() { - return id; - } - - public Integer getSnapshotId() { - return snapshotId; - } - - public Integer getProjectSnapshotId() { - return projectSnapshotId; - } - - public String getHash() { - return hash; - } - - public Integer getIndexInFile() { - return indexInFile; - } - - public Integer getStartLine() { - return startLine; - } - - public Integer getEndLine() { - return endLine; - } - -} diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java index a6e83a345f1..67661c1ce02 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java @@ -42,7 +42,7 @@ public class SchemaMigration { - complete the Derby DDL file used for unit tests : sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl */ - public static final int LAST_VERSION = 238; + public static final int LAST_VERSION = 239; public final static String TABLE_NAME = "schema_migrations"; diff --git a/sonar-core/src/main/java/org/sonar/persistence/duplication/DuplicationUnitDto.java b/sonar-core/src/main/java/org/sonar/persistence/duplication/DuplicationUnitDto.java index 94f5d05fda2..868c66c43c6 100644 --- a/sonar-core/src/main/java/org/sonar/persistence/duplication/DuplicationUnitDto.java +++ b/sonar-core/src/main/java/org/sonar/persistence/duplication/DuplicationUnitDto.java @@ -24,8 +24,6 @@ package org.sonar.persistence.duplication; */ public final class DuplicationUnitDto { - private Long id; - private Integer snapshotId; private Integer projectSnapshotId; @@ -48,14 +46,6 @@ public final class DuplicationUnitDto { this.endLine = endLine; } - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - public Integer getSnapshotId() { return snapshotId; } diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml index 2d427ffec04..17940cd5f5b 100644 --- a/sonar-core/src/main/resources/META-INF/persistence.xml +++ b/sonar-core/src/main/resources/META-INF/persistence.xml @@ -36,7 +36,6 @@ <class>org.sonar.api.rules.ActiveRuleParamChange</class> <class>org.sonar.jpa.entity.Review</class> <class>org.sonar.jpa.entity.NotificationQueueElement</class> - <class>org.sonar.jpa.entity.DuplicationBlock</class> <properties> <property name="hibernate.current_session_context_class" value="thread"/> diff --git a/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-mssql.xml b/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-mssql.xml index ff100644a9c..c2577c58ef8 100644 --- a/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-mssql.xml +++ b/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-mssql.xml @@ -16,7 +16,7 @@ </if> </select> - <insert id="batchInsert" parameterType="DuplicationUnit" keyColumn="id" useGeneratedKeys="false"> + <insert id="batchInsert" parameterType="DuplicationUnit" useGeneratedKeys="false"> INSERT INTO duplications_index (snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line) VALUES (#{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine}) </insert> diff --git a/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-oracle.xml b/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-oracle.xml index 98520444a07..c2577c58ef8 100644 --- a/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-oracle.xml +++ b/sonar-core/src/main/resources/org/sonar/persistence/duplication/DuplicationMapper-oracle.xml @@ -16,9 +16,9 @@ </if> </select> - <insert id="batchInsert" parameterType="DuplicationUnit" keyColumn="id" useGeneratedKeys="false"> - INSERT INTO duplications_index (id, snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line) - VALUES (duplications_index_seq.NEXTVAL, #{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine}) + <insert id="batchInsert" parameterType="DuplicationUnit" useGeneratedKeys="false"> + INSERT INTO duplications_index (snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line) + VALUES (#{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine}) </insert> </mapper> diff --git a/sonar-core/src/main/resources/org/sonar/persistence/rows-derby.sql b/sonar-core/src/main/resources/org/sonar/persistence/rows-derby.sql index d7e195a9ace..2be852b3d1c 100644 --- a/sonar-core/src/main/resources/org/sonar/persistence/rows-derby.sql +++ b/sonar-core/src/main/resources/org/sonar/persistence/rows-derby.sql @@ -167,6 +167,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('235'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('236'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('237'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('238'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('239'); 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; diff --git a/sonar-core/src/main/resources/org/sonar/persistence/schema-derby.ddl b/sonar-core/src/main/resources/org/sonar/persistence/schema-derby.ddl index 693b15d635c..02ae63063d2 100644 --- a/sonar-core/src/main/resources/org/sonar/persistence/schema-derby.ddl +++ b/sonar-core/src/main/resources/org/sonar/persistence/schema-derby.ddl @@ -223,7 +223,6 @@ CREATE TABLE "PROJECT_LINKS" ( ); CREATE TABLE "DUPLICATIONS_INDEX" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "PROJECT_SNAPSHOT_ID" INTEGER NOT NULL, "SNAPSHOT_ID" INTEGER NOT NULL, "HASH" VARCHAR(50) NOT NULL, @@ -591,8 +590,6 @@ ALTER TABLE "RULES" ADD CONSTRAINT "SQL110927104437080" PRIMARY KEY ("ID"); ALTER TABLE "USER_ROLES" ADD CONSTRAINT "SQL110927104437940" PRIMARY KEY ("ID"); -ALTER TABLE "DUPLICATIONS_INDEX" ADD CONSTRAINT "SQL110927104441080" PRIMARY KEY ("ID"); - ALTER TABLE "SNAPSHOT_SOURCES" ADD CONSTRAINT "SQL110927104437590" PRIMARY KEY ("ID"); ALTER TABLE "NOTIFICATIONS" ADD CONSTRAINT "SQL110927104441030" PRIMARY KEY ("ID"); diff --git a/sonar-core/src/test/java/org/sonar/persistence/duplication/DuplicationDaoTest.java b/sonar-core/src/test/java/org/sonar/persistence/duplication/DuplicationDaoTest.java index 9621999dc85..88632baf0a1 100644 --- a/sonar-core/src/test/java/org/sonar/persistence/duplication/DuplicationDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/persistence/duplication/DuplicationDaoTest.java @@ -20,7 +20,6 @@ package org.sonar.persistence.duplication; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import java.util.Arrays; @@ -28,13 +27,10 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.sonar.jpa.test.AbstractDbUnitTestCase; import org.sonar.persistence.DaoTestCase; import org.sonar.persistence.duplication.DuplicationDao; import org.sonar.persistence.duplication.DuplicationUnitDto; -import com.google.common.collect.Lists; - public class DuplicationDaoTest extends DaoTestCase { private DuplicationDao dao; @@ -72,18 +68,4 @@ public class DuplicationDaoTest extends DaoTestCase { checkTables("shouldInsert", "duplications_index"); } - @Test - public void testBatchInsert() { - List<DuplicationUnitDto> duplications = Lists.newArrayList(); - for (int i = 0; i < 50; i++) { - duplications.add(new DuplicationUnitDto(i, i, "hash", 2, 30, 40)); - } - dao.insert(duplications); - - for (DuplicationUnitDto duplication : duplications) { - // batch insert : faster but generated ids are not returned - assertThat(duplication.getId(), nullValue()); - } - } - } diff --git a/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldGetByHash.xml b/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldGetByHash.xml index 8edbe99067b..4f821a44e31 100644 --- a/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldGetByHash.xml +++ b/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldGetByHash.xml @@ -22,26 +22,26 @@ <!-- Old snapshot of another project --> <!-- bar-old --> - <duplications_index id="1" project_snapshot_id="1" snapshot_id="2" hash="bb" index_in_file="0" start_line="0" end_line="0" /> + <duplications_index project_snapshot_id="1" snapshot_id="2" hash="bb" index_in_file="0" start_line="0" end_line="0" /> <!-- Last snapshot of another project --> <!-- bar-last --> - <duplications_index id="2" project_snapshot_id="3" snapshot_id="4" hash="aa" index_in_file="0" start_line="1" end_line="2" /> + <duplications_index project_snapshot_id="3" snapshot_id="4" hash="aa" index_in_file="0" start_line="1" end_line="2" /> <!-- Old snapshot of current project --> <!-- foo-old --> - <duplications_index id="3" project_snapshot_id="5" snapshot_id="6" hash="bb" index_in_file="0" start_line="0" end_line="0" /> + <duplications_index project_snapshot_id="5" snapshot_id="6" hash="bb" index_in_file="0" start_line="0" end_line="0" /> <!-- Last snapshot of current project --> <!-- foo-last --> - <duplications_index id="4" project_snapshot_id="7" snapshot_id="8" hash="aa" index_in_file="0" start_line="0" end_line="0" /> + <duplications_index project_snapshot_id="7" snapshot_id="8" hash="aa" index_in_file="0" start_line="0" end_line="0" /> <!-- New snapshot of current project --> <!-- foo --> - <duplications_index id="5" project_snapshot_id="9" snapshot_id="10" hash="aa" index_in_file="0" start_line="0" end_line="0" /> + <duplications_index project_snapshot_id="9" snapshot_id="10" hash="aa" index_in_file="0" start_line="0" end_line="0" /> <!-- Note that there is two blocks with same hash for current analysis to verify that we use "SELECT DISTINCT", --> <!-- without "DISTINCT" we will select block from "bar-last" two times. --> - <duplications_index id="6" project_snapshot_id="9" snapshot_id="10" hash="aa" index_in_file="1" start_line="1" end_line="1" /> + <duplications_index project_snapshot_id="9" snapshot_id="10" hash="aa" index_in_file="1" start_line="1" end_line="1" /> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldInsert-result.xml b/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldInsert-result.xml index 619646c1821..7149a08ee8c 100644 --- a/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldInsert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/persistence/duplication/DuplicationDaoTest/shouldInsert-result.xml @@ -4,6 +4,6 @@ <snapshots id="2" status="U" islast="0" project_id="1" /> <projects id="1" kee="foo" enabled="1" scope="FIL" qualifier="CLA" /> - <duplications_index id="1" project_snapshot_id="1" snapshot_id="2" hash="bb" index_in_file="0" start_line="1" end_line="2" /> + <duplications_index project_snapshot_id="1" snapshot_id="2" hash="bb" index_in_file="0" start_line="1" end_line="2" /> </dataset> diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/239_delete_duplications_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/239_delete_duplications_id.rb new file mode 100644 index 00000000000..96eeaab7d88 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/239_delete_duplications_id.rb @@ -0,0 +1,32 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2011 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.13 +# +class DeleteDuplicationsId < ActiveRecord::Migration + + def self.up + begin + remove_column('duplications_index', 'id') + end + end + +end |