aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-migration/src/main/java/org/sonar
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-10-03 18:00:49 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-10-04 15:34:23 +0200
commitd42b199206f3b61624695e5d72109618e1dd0ecf (patch)
tree87f2a120dd57c68470750d4f87534fd014bb7e65 /server/sonar-db-migration/src/main/java/org/sonar
parent92509d3e37cc6b5f857e255e861854f0006223c0 (diff)
downloadsonarqube-d42b199206f3b61624695e5d72109618e1dd0ecf.tar.gz
sonarqube-d42b199206f3b61624695e5d72109618e1dd0ecf.zip
SONAR-9881 Purge unused settings in database
Diffstat (limited to 'server/sonar-db-migration/src/main/java/org/sonar')
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java4
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java63
2 files changed, 66 insertions, 1 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
index bbaf6c984bf..6ab87afd264 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
@@ -39,6 +39,8 @@ public class DbVersion66 implements DbVersion {
.add(1810, "Add ce_activity.error_type", AddErrorTypeColumnToCeActivityTable.class)
.add(1811, "Create table qprofile_edit_users", CreateTableQProfileEditUsers.class)
.add(1812, "Create table qprofile_edit_groups", CreateTableQProfileEditGroups.class)
- .add(1813, "Drop PR columns from project_brances", DropPrColumnsFromProjectBranches.class);
+ .add(1813, "Drop PR columns from project_branches", DropPrColumnsFromProjectBranches.class)
+ .add(1814, "Purge table properties", PurgeTableProperties.class)
+ ;
}
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java
new file mode 100644
index 00000000000..28e4dec494a
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PurgeTableProperties.java
@@ -0,0 +1,63 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class PurgeTableProperties extends DataChange {
+
+ public PurgeTableProperties(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ deleteByKey(context, "views.analysisDelayingInMinutes");
+ deleteByKey(context, "views.status");
+ deleteByKey(context, "sonar.issuesdensity.weight");
+ deleteByKey(context, "sonar.core.version");
+ deleteByKeyPrefix(context, "sonar.reports.");
+ deleteByKeyPrefix(context, "sonar.report.license");
+ deleteByKeyPrefix(context, "sonar.sqale.");
+ deleteByKeyPrefix(context, "sqale.license");
+ deleteByKeyPrefix(context, "devcockpit.");
+ deleteByKeyPrefix(context, "masterproject.");
+ deleteByKeyPrefix(context, "sonar.natural.");
+ deleteByKeyPrefix(context, "sonarsource.natural.");
+ deleteByKeyPrefix(context, "sonarsource.identity.");
+ deleteByKeyPrefix(context, "sonar.build-stability.");
+ }
+
+ private static void deleteByKey(Context context, String key) throws SQLException {
+ context.prepareUpsert("delete from properties where prop_key = ?")
+ .setString(1, key)
+ .execute()
+ .commit();
+ }
+
+ private static void deleteByKeyPrefix(Context context, String key) throws SQLException {
+ context.prepareUpsert("delete from properties where prop_key like ?")
+ .setString(1, key + "%")
+ .execute()
+ .commit();
+ }
+}