aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-07-11 10:34:53 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-07-11 10:34:53 +0200
commiteff6924c72adb4f6c6677b0bfd3bef849c5d54e4 (patch)
tree5a27f6c48f568b795561af9b606a77ffa5c761c6
parent28287efade86c3b7ada5d38481c0b6b644fe6c0a (diff)
downloadsonarqube-eff6924c72adb4f6c6677b0bfd3bef849c5d54e4.tar.gz
sonarqube-eff6924c72adb4f6c6677b0bfd3bef849c5d54e4.zip
SONAR-4361 Add index on columns plugin_rule_key and plugin_name of the Rules table
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql1
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/419_add_index_to_rules_plugin_rule_key_and_plugin_name.rb34
4 files changed, 38 insertions, 1 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 5b10ab4f0bd..c59df69feb3 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 = 418;
+ public static final int LAST_VERSION = 419;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
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 9409bfda3db..e55347bdf3b 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
@@ -186,6 +186,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('415');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('416');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('417');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('418');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('419');
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 958224d5b56..2624837ac89 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
@@ -691,3 +691,5 @@ CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN");
CREATE INDEX "SNAPSHOTS_ROOT_PROJECT_ID" ON "SNAPSHOTS" ("ROOT_PROJECT_ID");
CREATE INDEX "GROUP_ROLES_ROLE" ON "GROUP_ROLES" ("ROLE");
+
+CREATE UNIQUE INDEX "RULES_PLUGIN_KEY_AND_NAME" ON "RULES" ("PLUGIN_RULE_KEY", "PLUGIN_NAME");
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/419_add_index_to_rules_plugin_rule_key_and_plugin_name.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/419_add_index_to_rules_plugin_rule_key_and_plugin_name.rb
new file mode 100644
index 00000000000..19740823f24
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/419_add_index_to_rules_plugin_rule_key_and_plugin_name.rb
@@ -0,0 +1,34 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2013 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.
+#
+
+#
+# @since SonarQube 3.7
+#
+class AddIndexToRulesPluginRuleKeyAndPluginName < ActiveRecord::Migration
+
+ def self.up
+ begin
+ add_index :rules, [:plugin_rule_key, :plugin_name], :unique => true, :name => 'rules_plugin_key_and_name'
+ rescue
+ # already exists
+ end
+ end
+
+end