From e8e13145497bb920921ae4fe11b09f0903f1d298 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Wed, 15 Feb 2017 18:41:37 +0100 Subject: [PATCH] SONAR-8728 do index create/drop in dedicated Ruby migrations --- .../1155_add_index_project_measures.rb | 31 +++++++++++++++++++ ... => 1156_clean_usurper_root_components.rb} | 4 +-- .../1157_drop_index_project_measures.rb | 31 +++++++++++++++++++ .../org/sonar/db/version/DatabaseVersion.java | 2 +- .../sonar/db/version/MigrationStepModule.java | 2 ++ .../org/sonar/db/version/rows-h2.sql | 3 ++ 6 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1155_add_index_project_measures.rb rename server/sonar-web/src/main/webapp/WEB-INF/db/migrate/{1154_clean_usurper_root_components.rb => 1156_clean_usurper_root_components.rb} (86%) create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1157_drop_index_project_measures.rb diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1155_add_index_project_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1155_add_index_project_measures.rb new file mode 100644 index 00000000000..b694eaf27ca --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1155_add_index_project_measures.rb @@ -0,0 +1,31 @@ +# +# 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. +# + +# +# SonarQube 5.6.6 +# SONAR-8454 +# +class AddIndexProjectMeasures < ActiveRecord::Migration + + def self.up + add_index 'project_measures', 'project_id', :name => 'tmp_measures_project_id' + end + +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1154_clean_usurper_root_components.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1156_clean_usurper_root_components.rb similarity index 86% rename from server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1154_clean_usurper_root_components.rb rename to server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1156_clean_usurper_root_components.rb index b15d00b7d13..2fc8501cfbc 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1154_clean_usurper_root_components.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1156_clean_usurper_root_components.rb @@ -19,16 +19,14 @@ # # -# SonarQube 5.6.4 +# SonarQube 5.6.6 # SONAR-8454 # class CleanUsurperRootComponents < ActiveRecord::Migration def self.up - add_index 'project_measures', 'project_id', :name => 'tmp_measures_project_id' execute_java_migration('org.sonar.db.version.v564.FixProjectUuidOfDeveloperProjects') execute_java_migration('org.sonar.db.version.v564.CleanUsurperRootComponents') - remove_index 'project_measures', :name => 'tmp_measures_project_id' end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1157_drop_index_project_measures.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1157_drop_index_project_measures.rb new file mode 100644 index 00000000000..7073cd6982d --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1157_drop_index_project_measures.rb @@ -0,0 +1,31 @@ +# +# 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. +# + +# +# SonarQube 5.6.6 +# SONAR-8454 +# +class DropIndexProjectMeasures < ActiveRecord::Migration + + def self.up + remove_index 'project_measures', :name => 'tmp_measures_project_id' + end + +end 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 4c2266f0c1e..286f7f6313e 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_154; + public static final int LAST_VERSION = 1_157; /** * 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 97179941d14..5863f4beee0 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 @@ -173,6 +173,8 @@ public class MigrationStepModule extends Module { // 5.6.4 FixProjectUuidOfDeveloperProjects.class, + + // 5.6.6 CleanUsurperRootComponents.class ); } 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 d89da588e1f..5daa7046cc3 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 @@ -408,6 +408,9 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1151'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1152'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1153'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1154'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1155'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1156'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1157'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; -- 2.39.5