aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-23 16:57:21 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-29 11:06:00 +0200
commitc6f2f2e15367862195f3e0424b73ac5f1f2af844 (patch)
tree48619740e3d41aad00344651c1e38198125870bf /sonar-db/src/main
parent8823c53764c4304a32b39c4b9a2506a7e8ffc4e2 (diff)
downloadsonarqube-c6f2f2e15367862195f3e0424b73ac5f1f2af844.tar.gz
sonarqube-c6f2f2e15367862195f3e0424b73ac5f1f2af844.zip
SONAR-7794 add column RULES_PROFILES.USER_UPDATED_AT
Diffstat (limited to 'sonar-db/src/main')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java11
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/AddUserUpdatedAtToRulesProfiles.java45
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml21
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql1
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl3
7 files changed, 78 insertions, 7 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java
index 944b3353c8a..43dd95e99ce 100644
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDto.java
@@ -34,6 +34,7 @@ public class QualityProfileDto extends Dto<String> {
private String parentKee;
private String rulesUpdatedAt;
private Long lastUsed;
+ private Long userUpdatedAt;
private boolean isDefault;
/**
@@ -123,6 +124,16 @@ public class QualityProfileDto extends Dto<String> {
return this;
}
+ @CheckForNull
+ public Long getUserUpdatedAt() {
+ return userUpdatedAt;
+ }
+
+ public QualityProfileDto setUserUpdatedAt(@Nullable Long userUpdatedAt) {
+ this.userUpdatedAt = userUpdatedAt;
+ return this;
+ }
+
public boolean isDefault() {
return isDefault;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
index 1ab5f63e537..857ced783b4 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
@@ -30,7 +30,7 @@ import org.sonar.db.MyBatis;
public class DatabaseVersion {
- public static final int LAST_VERSION = 1_261;
+ public static final int LAST_VERSION = 1_262;
/**
* The minimum supported version which can be upgraded. Lower
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
index 15292be30f8..e975696a8a4 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
@@ -91,6 +91,7 @@ import org.sonar.db.version.v60.AddComponentUuidColumnToMeasures;
import org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots;
import org.sonar.db.version.v60.AddLastUsedColumnToRulesProfiles;
import org.sonar.db.version.v60.AddProfileKeyToActivities;
+import org.sonar.db.version.v60.AddUserUpdatedAtToRulesProfiles;
import org.sonar.db.version.v60.AddUuidColumnToSnapshots;
import org.sonar.db.version.v60.AddUuidColumnsToProjects;
import org.sonar.db.version.v60.AddUuidColumnsToResourceIndex;
@@ -247,6 +248,7 @@ public class MigrationStepModule extends Module {
AddProfileKeyToActivities.class,
PopulateProfileKeyOfActivities.class,
MakeProfileKeyNotNullOnActivities.class,
+ AddUserUpdatedAtToRulesProfiles.class,
// SNAPSHOTS.UUID
AddUuidColumnToSnapshots.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddUserUpdatedAtToRulesProfiles.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddUserUpdatedAtToRulesProfiles.java
new file mode 100644
index 00000000000..4935ab7ad15
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/AddUserUpdatedAtToRulesProfiles.java
@@ -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.BigDecimalColumnDef.newBigDecimalColumnDefBuilder;
+
+public class AddUserUpdatedAtToRulesProfiles extends DdlChange {
+
+ private static final String TABLE_QUALITY_PROFILES = "rules_profiles";
+
+ public AddUserUpdatedAtToRulesProfiles(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_QUALITY_PROFILES)
+ .addColumn(newBigDecimalColumnDefBuilder().setColumnName("user_updated_at").setIsNullable(true).build())
+ .build());
+ }
+
+}
diff --git a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml
index e33f92db1d2..381c53dba54 100644
--- a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml
@@ -13,13 +13,23 @@
p.created_at as createdAt,
p.updated_at as updatedAt,
p.rules_updated_at as rulesUpdatedAt,
- p.last_used as lastUsed
+ p.last_used as lastUsed,
+ p.user_updated_at as userUpdatedAt
</sql>
<insert id="insert" parameterType="QualityProfile" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO rules_profiles (kee, parent_kee, name, language, is_default, created_at, updated_at, rules_updated_at, last_used)
- VALUES (#{kee, jdbcType=VARCHAR}, #{parentKee,jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{language, jdbcType=VARCHAR}, #{isDefault, jdbcType=BOOLEAN},
- #{createdAt, jdbcType=TIMESTAMP}, #{updatedAt, jdbcType=TIMESTAMP}, #{rulesUpdatedAt, jdbcType=VARCHAR}, #{lastUsed, jdbcType=BIGINT})
+ INSERT INTO rules_profiles (kee, parent_kee, name, language, is_default, created_at, updated_at, rules_updated_at, last_used, user_updated_at)
+ VALUES (
+ #{kee, jdbcType=VARCHAR},
+ #{parentKee, jdbcType=VARCHAR},
+ #{name, jdbcType=VARCHAR},
+ #{language, jdbcType=VARCHAR},
+ #{isDefault, jdbcType=BOOLEAN},
+ #{createdAt, jdbcType=TIMESTAMP},
+ #{updatedAt, jdbcType=TIMESTAMP},
+ #{rulesUpdatedAt, jdbcType=VARCHAR},
+ #{lastUsed, jdbcType=BIGINT},
+ #{userUpdatedAt, jdbcType=BIGINT})
</insert>
<update id="update" parameterType="QualityProfile">
@@ -30,7 +40,8 @@
parent_kee=#{parentKee, jdbcType=VARCHAR},
updated_at=#{updatedAt, jdbcType=TIMESTAMP},
rules_updated_at=#{rulesUpdatedAt, jdbcType=VARCHAR},
- last_used=#{lastUsed, jdbcType=BIGINT}
+ last_used=#{lastUsed, jdbcType=BIGINT},
+ user_updated_at=#{userUpdatedAt, jdbcType=BIGINT}
WHERE id=#{id}
</update>
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
index 0f997903b43..0fd0413b98b 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
+++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
@@ -467,6 +467,7 @@ 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;
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
index b89ca216e4e..6c8476ee4f7 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
+++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
@@ -22,7 +22,8 @@ CREATE TABLE "RULES_PROFILES" (
"IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE,
"CREATED_AT" TIMESTAMP,
"UPDATED_AT" TIMESTAMP,
- "LAST_USED" BIGINT
+ "LAST_USED" BIGINT,
+ "USER_UPDATED_AT" BIGINT
);
CREATE TABLE "PROJECT_QPROFILES" (