aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-09 17:51:40 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-09 18:06:58 +0200
commit73f794e93738c82c6fe88d5989e32d202ac9c91a (patch)
tree9de17e75714657604db358a96af4c9857a0c49de
parent151d1a9baa04c0a067c23c4351c7e7df73dc0d15 (diff)
downloadsonarqube-73f794e93738c82c6fe88d5989e32d202ac9c91a.tar.gz
sonarqube-73f794e93738c82c6fe88d5989e32d202ac9c91a.zip
SONAR-5384 Create index on SNAPSHOT_DATA.RESOURCE_ID
-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/541_add_unique_index_on_active_rule_key.rb (renamed from sonar-server/src/main/webapp/WEB-INF/db/migrate/541_create_active_rule_index.rb)8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/542_add_index_on_snapshot_data_resource_id.rb30
5 files changed, 39 insertions, 4 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 0f09ae4b819..ac36c77d277 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 = 541;
+ public static final int LAST_VERSION = 542;
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 8bdde1a7db7..90b0780e6aa 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
@@ -236,6 +236,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('537');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('539');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('540');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('541');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('542');
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 fbb449e9f42..34ea99f7bba 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 "CHARACTERISTICS_ENABLED" ON "CHARACTERISTICS" ("ENABLED");
CREATE UNIQUE INDEX "QUALITY_GATES_UNIQUE" ON "QUALITY_GATES" ("NAME");
CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID");
+
+CREATE INDEX "SNAPSHOT_DATA_RESOURCE_IDS" ON "SNAPSHOT_DATA" ("RESOURCE_ID");
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/541_create_active_rule_index.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/541_add_unique_index_on_active_rule_key.rb
index 1fb12c153c7..e2c508a0c69 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/541_create_active_rule_index.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/541_add_unique_index_on_active_rule_key.rb
@@ -17,16 +17,18 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-class CreateActiveRuleIndex < ActiveRecord::Migration
+class AddUniqueIndexOnActiveRuleKey < ActiveRecord::Migration
- class ActiveRuleParameters < ActiveRecord::Base
+ class ActiveRuleParameter < ActiveRecord::Base
end
class ActiveRule < ActiveRecord::Base
end
def self.up
+ ActiveRule.reset_column_information
+ ActiveRuleParameter.reset_column_information
# Search for all rules activated many times on a same profile
rule_actived_many_times_on_same_profile = ActiveRule.all(
@@ -42,7 +44,7 @@ class CreateActiveRuleIndex < ActiveRecord::Migration
)
# Remove duplication, keep only one active rule (first one)
active_rules.drop(1).each do |active_rule|
- ActiveRuleParameters.delete_all(:active_rule_id => active_rule.id)
+ ActiveRuleParameter.delete_all(:active_rule_id => active_rule.id)
active_rule.delete
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/542_add_index_on_snapshot_data_resource_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/542_add_index_on_snapshot_data_resource_id.rb
new file mode 100644
index 00000000000..289123751d0
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/542_add_index_on_snapshot_data_resource_id.rb
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+class AddIndexOnSnapshotDataResourceId < ActiveRecord::Migration
+
+ def self.up
+ begin
+ add_index :snapshot_data, :resource_id, :name => 'snap_data_resource_id'
+ rescue
+ # already exists
+ end
+ end
+
+end