From 90a55e659d0b74a17c8e9ef9082a3d9b1f6804ee Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 28 Oct 2014 16:23:08 +0100 Subject: [PATCH] SONAR-5755 Move creation of projects.uuid index after uuid columns have been populated --- .../migrate/704_add_project_uuid_columns.rb | 2 -- .../db/migrate/708_add_project_uuid_index.rb | 30 +++++++++++++++++++ .../core/persistence/DatabaseVersion.java | 2 +- .../org/sonar/core/persistence/rows-h2.sql | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/708_add_project_uuid_index.rb diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/704_add_project_uuid_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/704_add_project_uuid_columns.rb index fd07ca0a1c8..82ca5270063 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/704_add_project_uuid_columns.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/704_add_project_uuid_columns.rb @@ -28,8 +28,6 @@ class AddProjectUuidColumns < ActiveRecord::Migration add_column 'projects', :project_uuid, :string, :limit => 50, :null => true add_column 'projects', :module_uuid, :string, :limit => 50, :null => true add_column 'projects', :module_uuid_path, :string, :limit => 4000, :null => true - - add_index 'projects', 'uuid', :name => 'projects_uuid', :unique => true end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/708_add_project_uuid_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/708_add_project_uuid_index.rb new file mode 100644 index 00000000000..5d81bd096c6 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/708_add_project_uuid_index.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. +# + +# +# SonarQube 5.0 +# SONAR-5753 +# +class AddProjectUuidIndex < ActiveRecord::Migration + def self.up + add_index 'projects', 'uuid', :name => 'projects_uuid', :unique => true + end +end + 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 8bba4326899..67d12f924f6 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 = 707; + public static final int LAST_VERSION = 708; /** * List of all the tables. * This list is hardcoded because we didn't succeed in using java.sql.DatabaseMetaData#getTables() in the same way 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 e06d8bbef12..53ae285d061 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 @@ -267,6 +267,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('704'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('705'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('706'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('707'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('708'); 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; -- 2.39.5