diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-01 16:26:59 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-01 16:26:59 +0200 |
commit | bc058ab2299402a3263dae5fb2ef84eed3c72893 (patch) | |
tree | 586c0c089c0ebac8c04c2ea3e835ec46f710a584 /sonar-server | |
parent | 4b1920d286c4efbf8e912e9310ba070624264fd9 (diff) | |
download | sonarqube-bc058ab2299402a3263dae5fb2ef84eed3c72893.tar.gz sonarqube-bc058ab2299402a3263dae5fb2ef84eed3c72893.zip |
Add primary key to the table RESOURCE_INDEX
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/237_create_table_resource_index.rb | 2 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb | 57 |
2 files changed, 58 insertions, 1 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/237_create_table_resource_index.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/237_create_table_resource_index.rb index c345b5144b6..e2219fec579 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/237_create_table_resource_index.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/237_create_table_resource_index.rb @@ -24,7 +24,7 @@ class CreateTableResourceIndex < ActiveRecord::Migration def self.up - create_table 'resource_index', :id => false do |t| + create_table 'resource_index' do |t| t.column 'kee', :string, :null => false, :limit => 400 t.column 'position', :integer, :null => false t.column 'name_size', :integer, :null => false 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 new file mode 100644 index 00000000000..7ccf03ecad5 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/285_add_resource_index_primary_key.rb @@ -0,0 +1,57 @@ +# +# 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 AddResourceIndexPrimaryKey < ActiveRecord::Migration + + class ResourceIndex < ActiveRecord::Base + set_table_name 'resource_index' + end + + def self.up + ResourceIndex.reset_column_information + unless ResourceIndex.columns_hash.has_key?('id') + + # Release 2.13 creates the table without primary key. + # Unfortunately it's tricky to add a primary key to an existing table, + # particularly on Oracle (note that it's perfectly supported on postgresql). + # For this reason the table is dropped and created again. + remove_index 'resource_index', :name => 'resource_index_key' + remove_index 'resource_index', :name => 'resource_index_rid' + drop_table 'resource_index' + + create_table 'resource_index' do |t| + t.column 'kee', :string, :null => false, :limit => 400 + t.column 'position', :integer, :null => false + t.column 'name_size', :integer, :null => false + t.column 'resource_id', :integer, :null => false + t.column 'root_project_id', :integer, :null => false + t.column 'qualifier', :string, :limit => 10, :null => false + end + + say_with_time 'Indexing projects' do + Java::OrgSonarServerUi::JRubyFacade.getInstance().indexProjects() + end + end + end + +end |