From 4caa52ae171e9af7fdc81f11fe5bcb665862dbdb Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 18 Jan 2012 17:16:35 +0100 Subject: [PATCH] Remove some useless database migrations because upgrade from 1.x to 2.x is not supported --- .../WEB-INF/db/migrate/001_initial_schema.rb | 2 +- .../db/migrate/035_create_snapshot_sources.rb | 2 +- .../migrate/052_remove_columns_views_table.rb | 85 ------------------- .../migrate/089_set_default_project_roles.rb | 22 ----- .../db/migrate/090_add_name_to_users.rb | 36 -------- ...96_mssql_change_text_columns_to_varchar.rb | 39 --------- 6 files changed, 2 insertions(+), 184 deletions(-) delete mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/052_remove_columns_views_table.rb delete mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/090_add_name_to_users.rb delete mode 100644 sonar-server/src/main/webapp/WEB-INF/db/migrate/096_mssql_change_text_columns_to_varchar.rb diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb index 17b093f9229..c199fecb76f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/001_initial_schema.rb @@ -96,7 +96,7 @@ class InitialSchema < ActiveRecord::Migration t.column :plugin_rule_key, :string, :null => false, :limit => 200 t.column :plugin_config_key, :string, :null => false, :limit => 200 t.column :plugin_name, :string, :null => false, :limit => 255 - t.column :description, :text + t.column :description, :text, :null => true t.column :priority, :integer, :null => true end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/035_create_snapshot_sources.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/035_create_snapshot_sources.rb index b7b6224e5ed..ec3fed4ccd9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/035_create_snapshot_sources.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/035_create_snapshot_sources.rb @@ -22,7 +22,7 @@ class CreateSnapshotSources < ActiveRecord::Migration def self.up create_table :snapshot_sources do |t| t.column :snapshot_id, :integer, :null => false - t.column :data, :text + t.column :data, :text, :null => true end add_index :snapshot_sources, :snapshot_id, :name => 'snap_sources_snapshot_id' end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/052_remove_columns_views_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/052_remove_columns_views_table.rb deleted file mode 100644 index c51257c12e7..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/052_remove_columns_views_table.rb +++ /dev/null @@ -1,85 +0,0 @@ -# -# 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 -# -class RemoveColumnsViewsTable < ActiveRecord::Migration - - def self.up - begin - migrate_columns_selected - migrate_column_default_sort - migrate_treemap_enable - - drop_table "columns_views" - rescue - end - end - - class ColumnsView052 < ActiveRecord::Base - set_table_name "columns_views" - end - - - private - - def self.migrate_columns_selected - dashboard_configuration = Sonar::ComponentsConfiguration.new(nil) - - columns_text = "" - ColumnsView052.find(:all).each do |col| - column = find_column_by_name_or_by_id(col.name, dashboard_configuration) - columns_text << column.col_type + Sonar::ComponentsConfiguration::COLUMN_SEPARATOR + column.id + Sonar::ComponentsConfiguration::COLUMNS_SEPARATOR if column - end - create_property(Sonar::ComponentsConfiguration::COLUMNS_SELECTED_KEY.to_s, columns_text) - end - - def self.migrate_column_default_sort - dashboard_configuration = Sonar::ComponentsConfiguration.new(nil) - - default_sort_column = ColumnsView052.find(:first, :conditions => {:sort_default => true}) - column = find_column_by_name_or_by_id(default_sort_column.name, dashboard_configuration) if default_sort_column - create_property(Sonar::ComponentsConfiguration::COLUMNS_DEFAULT_SORT_KEY, column.id) if column - end - - def self.migrate_treemap_enable - treemap_enable = ColumnsView052.find(:first, :conditions => {:name => "Treemap"}) - is_enabled = treemap_enable ? "true" : "false" - create_property(Sonar::ComponentsConfiguration::TREEMAP_ENABLED_KEY, is_enabled) - end - - - def self.find_column_by_name_or_by_id(column_name_or_id, dashboard_configuration) - dashboard_configuration.available_columns.each_pair do |domain, columns| - columns.each do |column| - if (column.name == column_name_or_id) or (column.id == column_name_or_id) - return column - end - end - end - nil - end - - def self.create_property(prop_key, prop_value) - property = Property.new - property.prop_key = prop_key - property.prop_value = prop_value - property.save! - end - - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb index fde5fc3ed14..70cf1c1992f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/089_set_default_project_roles.rb @@ -21,9 +21,6 @@ class SetDefaultProjectRoles < ActiveRecord::Migration def self.up - projects=Project.find(:all, - :conditions => {:enabled=>true, :qualifier=> [Project::QUALIFIER_VIEW, Project::QUALIFIER_SUBVIEW, Project::QUALIFIER_PROJECT]}) - administrators=Group.find_by_name('sonar-administrators') users=Group.find_by_name('sonar-users') @@ -33,25 +30,6 @@ class SetDefaultProjectRoles < ActiveRecord::Migration GroupRole.create(:resource_id => nil, :role => 'default-user', :group_id => nil) GroupRole.create(:resource_id => nil, :role => 'default-codeviewer', :group_id => users.id) GroupRole.create(:resource_id => nil, :role => 'default-codeviewer', :group_id => nil) - - - projects.each do |project| - # admin - GroupRole.create(:resource_id => project.id, :role => 'admin', :group_id => administrators.id) - - # Anyone can view the project - GroupRole.create(:resource_id => project.id, :role => 'user', :group_id => nil) - GroupRole.create(:resource_id => project.id, :role => 'user', :group_id => users.id) - - # Anyone can browse sources - GroupRole.create(:resource_id => project.id, :role => 'codeviewer', :group_id => nil) - GroupRole.create(:resource_id => project.id, :role => 'codeviewer', :group_id => users.id) - end end - def self.down - - end - - end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/090_add_name_to_users.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/090_add_name_to_users.rb deleted file mode 100644 index 9ddaa48a671..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/090_add_name_to_users.rb +++ /dev/null @@ -1,36 +0,0 @@ -# -# 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.0 -class AddNameToUsers < ActiveRecord::Migration - - def self.up - begin - unless User.column_names.include?('name') - add_column(:users, :name, :string, :null => true, :limit => 200) - User.reset_column_information - User.update_all("name='Administrator'", "login='admin'") - end - rescue - # already created in migration 010 - end - - end - -end diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/096_mssql_change_text_columns_to_varchar.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/096_mssql_change_text_columns_to_varchar.rb deleted file mode 100644 index 43d2be4f3ac..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/096_mssql_change_text_columns_to_varchar.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# 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.0 -class MssqlChangeTextColumnsToVarchar < ActiveRecord::Migration - - def self.up - dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"] - say "Detected dialect: #{dialect}" - - case dialect - when "sqlserver" - change_column 'rules', 'description', :text, :null => true - change_column 'snapshot_sources', 'data', :text, :null => true - change_column 'properties', 'text_value', :text, :null => true - end - - end - - def self.down - - end -end -- 2.39.5