From 92f20a22eb41ddbc6e765ed1794325551694a043 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 16 Sep 2013 09:39:00 +0200 Subject: [PATCH] SONAR-4659 Create an DB index on 'characteristics.enabled' column (cherry picked from commit 5abfd9d) --- .../core/persistence/DatabaseVersion.java | 2 +- .../org/sonar/core/persistence/rows-h2.sql | 1 + .../org/sonar/core/persistence/schema-h2.ddl | 2 ++ ...33_add_index_to_characteristics_enabled.rb | 35 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/433_add_index_to_characteristics_enabled.rb 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 d43610feba2..3e4b2bb227b 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 = 432; + public static final int LAST_VERSION = 433; 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 09c80a569ee..f4d2b9031be 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 @@ -175,6 +175,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('419'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('430'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('431'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('432'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('433'); 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 96471330f05..52355a26659 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 @@ -693,3 +693,5 @@ 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"); + +CREATE INDEX "CHARACTERISTICS_ENABLED" ON "CHARACTERISTICS" ("ENABLED"); diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/433_add_index_to_characteristics_enabled.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/433_add_index_to_characteristics_enabled.rb new file mode 100644 index 00000000000..0fdd2de36bf --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/433_add_index_to_characteristics_enabled.rb @@ -0,0 +1,35 @@ +# +# Sonar, entreprise quality control 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. +# + +# +# Sonar 3.7.1 +# SONAR-4659 +# +class AddIndexToCharacteristicsEnabled < ActiveRecord::Migration + + def self.up + begin + add_index :characteristics, :enabled, :name => 'characteristics_enabled' + rescue + # already exists + end + end +end + -- 2.39.5