require 'set'
class InverseRuleKeyIndex < ActiveRecord::Migration
- class Rule < ActiveRecord::Base
- end
class ActiveRule < ActiveRecord::Base
+ set_table_name 'active_rules'
+ end
+
+ class Characteristic < ActiveRecord::Base
+ set_table_name 'characteristics'
+ end
+
+ class Issue < ActiveRecord::Base
+ set_table_name 'issues'
+ end
+
+ class ActiveRuleChange < ActiveRecord::Base
+ set_table_name 'active_rule_changes'
end
class ProjectMeasure < ActiveRecord::Base
set_table_name 'project_measures'
end
+ class Rule < ActiveRecord::Base
+ end
+
class RuleParameter < ActiveRecord::Base
set_table_name 'rules_parameters'
end
private
def self.delete_duplicated_rules
- Rule.reset_column_information
ActiveRule.reset_column_information
+ ActiveRuleChange.reset_column_information
+ Characteristic.reset_column_information
+ Issue.reset_column_information
ProjectMeasure.reset_column_information
+ Rule.reset_column_information
RuleParameter.reset_column_information
say_with_time 'Delete duplicated rules' do
key = "#{rule.plugin_name}:#{rule.plugin_rule_key}"
if existing_keys.include?(key)
say "Delete duplicated rule '#{key}' (id=#{rule.id})"
- rule.destroy
ActiveRule.delete_all(['rule_id=?', rule.id])
+ ActiveRuleChange.delete_all(['rule_id=?', rule.id])
+ Characteristic.delete_all(['rule_id=?', rule.id])
+ Issue.delete_all(['rule_id=?', rule.id])
ProjectMeasure.delete_all(['rule_id=?', rule.id])
RuleParameter.delete_all(['rule_id=?', rule.id])
+ rule.destroy
else
existing_keys.add(key)
end
set_table_name 'groups_users'
end
+ class Dashboard < ActiveRecord::Base
+ set_table_name 'dashboards'
+ has_many :active_dashboards, :dependent => :destroy, :inverse_of => :dashboard
+ end
+
class ActiveDashboard < ActiveRecord::Base
+ set_table_name 'active_dashboards'
+ belongs_to :dashboard
end
class PermTemplatesUser < ActiveRecord::Base
set_table_name 'perm_templates_users'
end
+ class MeasureFilter < ActiveRecord::Base
+ set_table_name 'measure_filters'
+ has_many :measure_filter_favourites, :dependent => :delete_all
+ end
+
+ class MeasureFilterFavourite < ActiveRecord::Base
+ set_table_name 'measure_filter_favourites'
+ belongs_to :measure_filter
+ end
+
def self.up
unless index_exists?(:users, :login, nil)
delete_duplicated_users
UserRole.reset_column_information
Property.reset_column_information
GroupsUsers.reset_column_information
+ Dashboard.reset_column_information
ActiveDashboard.reset_column_information
PermTemplatesUser.reset_column_information
+ MeasureFilter.reset_column_information
+ MeasureFilterFavourite.reset_column_information
say_with_time 'Delete duplicated users' do
existing_logins = Set.new
UserRole.delete_all(['user_id=?', user.id])
Property.delete_all(['user_id=?', user.id])
GroupsUsers.delete_all(['user_id=?', user.id])
- ActiveDashboard.delete_all(['user_id=?', user.id])
- PermTemplatesUser.delete_all(['user_id=?', user.id])
+ Dashboard.destroy_all(['user_id=?', user.id])
+ ActiveDashboard.destroy_all(['user_id=?', user.id])
+ PermTemplatesUser.destroy_all(['user_id=?', user.id])
+ MeasureFilter.destroy_all(['user_id=?', user.id])
+ MeasureFilterFavourite.destroy_all(['user_id=?', user.id])
user.destroy
else
existing_logins.add(user.login)