diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-04 15:09:28 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-04 15:09:28 +0200 |
commit | ebb88505550b103814bacc0660313ab5d8fc2f7e (patch) | |
tree | 8e3ead59065b04da1795643811dfa3352efac857 | |
parent | 3f357f30e5b4a9a7b5092464a855cd5e09b9861e (diff) | |
download | sonarqube-ebb88505550b103814bacc0660313ab5d8fc2f7e.tar.gz sonarqube-ebb88505550b103814bacc0660313ab5d8fc2f7e.zip |
Fix upgrade from version 2.13 with Oracle
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java | 2 | ||||
-rw-r--r-- | sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql | 1 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb | 8 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/286_add_indices_to_resource_index.rb | 44 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/287_index_projects.rb (renamed from sonar-server/src/main/webapp/WEB-INF/db/migrate/286_index_projects.rb) | 0 |
5 files changed, 52 insertions, 3 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 9b9131586a9..745919a8ee8 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 @@ -32,7 +32,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 286; + public static final int LAST_VERSION = 287; 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-derby.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql index 621b7bda167..40512362c2f 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql @@ -186,6 +186,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('283'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('284'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('285'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('286'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('287'); 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-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb index 3b0180903c9..aa5ca2f5ae2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb @@ -48,9 +48,9 @@ class AddResourceIndexPrimaryKey < ActiveRecord::Migration t.column 'root_project_id', :integer, :null => false t.column 'qualifier', :string, :limit => 10, :null => false end - add_index 'resource_index', 'kee', :name => 'resource_index_key' - add_index 'resource_index', 'resource_id', :name => 'resource_index_rid' + # for unknown reason, indices can't be created here for Oracle (and as usual for Oracle only). + # These indices are moved to script 286. end end @@ -58,6 +58,10 @@ class AddResourceIndexPrimaryKey < ActiveRecord::Migration def self.remove_indices begin remove_index 'resource_index', :name => 'resource_index_key' + rescue + #ignore + end + begin remove_index 'resource_index', :name => 'resource_index_rid' rescue #ignore diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/286_add_indices_to_resource_index.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/286_add_indices_to_resource_index.rb new file mode 100644 index 00000000000..ad75ab81b83 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/286_add_indices_to_resource_index.rb @@ -0,0 +1,44 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2012 SonarSource +# mailto:contact AT sonarsource DOT com +# +# Sonar 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. +# +# Sonar 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 Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# + +# +# Sonar 2.15 +# +class AddIndicesToResourceIndex < ActiveRecord::Migration + + class ResourceIndex < ActiveRecord::Base + set_table_name 'resource_index' + end + + def self.up + ResourceIndex.reset_column_information + + begin + add_index 'resource_index', 'kee', :name => 'resource_index_key' + rescue + #ignore, already exists + end + begin + add_index 'resource_index', 'resource_id', :name => 'resource_index_rid' + rescue + #ignore, already exists + end + end +end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/286_index_projects.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/287_index_projects.rb index ad29a9a0de7..ad29a9a0de7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/286_index_projects.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/287_index_projects.rb |