diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-10-31 14:56:55 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-10-31 16:14:37 +0100 |
commit | 0ffd9d683485c9a179e83ed4a466370c6036d1fe (patch) | |
tree | d476c4a82f414c0fd315cbf43cd1dad1978bd111 /sonar-core/src | |
parent | 44545af5e1f35e18525c05672c3e1c68b1a8dbd4 (diff) | |
download | sonarqube-0ffd9d683485c9a179e83ed4a466370c6036d1fe.tar.gz sonarqube-0ffd9d683485c9a179e83ed4a466370c6036d1fe.zip |
SONAR-5814 Add updated_at column on snapshot_sources
Diffstat (limited to 'sonar-core/src')
8 files changed, 80 insertions, 5 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 0c03ea7641c..93d65401b9e 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 710; + public static final int LAST_VERSION = 712; /** * List of all the tables. * This list is hardcoded because we didn't succeed in using java.sql.DatabaseMetaData#getTables() in the same way diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java index e5e9af6a2a7..c06489a7f3c 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java @@ -123,4 +123,19 @@ public interface Migration50Mapper { @Options(useGeneratedKeys = false) void updateComponentUuids(Component component); + @Select("SELECT " + + " ss.id as \"id\", " + + " ss.updated_at as \"updatedAt\", " + + " s.build_date as \"snapshotBuildDate\" " + + "FROM snapshot_sources ss " + + " INNER JOIN snapshots s ON s.id = ss.snapshot_id " + + " WHERE ss.updated_at IS NULL") + @Result(javaType = SnapshotSource.class) + List<SnapshotSource> selectSnapshotSources(); + + @Update("UPDATE snapshot_sources " + + " SET updated_at=#{updatedAt} " + + " WHERE id=#{id}") + @Options(useGeneratedKeys = false) + void updateSnapshotSource(SnapshotSource snapshotSource); } diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/SnapshotSource.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/SnapshotSource.java new file mode 100644 index 00000000000..4132cacb4b5 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/SnapshotSource.java @@ -0,0 +1,57 @@ +/* + * 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.core.persistence.migration.v50; + +import javax.annotation.CheckForNull; + +import java.util.Date; + +public class SnapshotSource { + + private Long id; + private Date updatedAt; + private Date snapshotBuildDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @CheckForNull + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public Date getSnapshotBuildDate() { + return snapshotBuildDate; + } + + public void setSnapshotBuildDate(Date snapshotBuildDate) { + this.snapshotBuildDate = snapshotBuildDate; + } + +} diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index fa04f902cf1..b7118612b8a 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -270,6 +270,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('707'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('708'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('709'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('710'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('711'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('712'); 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/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index b7c6a74457c..4db09659428 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -247,6 +247,7 @@ CREATE TABLE "PROJECT_MEASURES" ( CREATE TABLE "SNAPSHOT_SOURCES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "SNAPSHOT_ID" INTEGER NOT NULL, + "UPDATED_AT" TIMESTAMP, "DATA" CLOB(2147483647) ); diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml index 9987056896c..d2aaf6dba28 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml @@ -13,7 +13,7 @@ parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="[false]" path="[null]"/> - <snapshot_sources ID="1" SNAPSHOT_ID="1" DATA="foo"/> + <snapshot_sources ID="1" SNAPSHOT_ID="1" DATA="foo" UPDATED_AT="[null]"/> <project_measures ID="1" 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]" diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml index f2ab60752db..3144614ec52 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml @@ -58,7 +58,7 @@ Note that measures, events and reviews are not deleted. period5_mode="[null]" period5_param="[null]" period5_date="[null]" depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> - <snapshot_sources ID="2" SNAPSHOT_ID="2" DATA="foo"/> + <snapshot_sources ID="2" SNAPSHOT_ID="2" DATA="foo" UPDATED_AT="[null]"/> <project_measures ID="2" project_id="2" SNAPSHOT_ID="2" RULE_ID="[null]" characteristic_id="[null]" url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml index c7004b60f81..13f1e235793 100644 --- a/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml @@ -5,8 +5,8 @@ <snapshots id="10" project_id="1" islast="[false]"/> <snapshots id="11" project_id="1" islast="[true]"/> - <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}"/> + <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}" updated_at="[null]"/> - <snapshot_sources id="102" snapshot_id="11" data="bar"/> + <snapshot_sources id="102" snapshot_id="11" data="bar" updated_at="[null]"/> </dataset> |