Replaces find(:all) calls.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10918 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-12-02 20:28:37 +00:00
parent 536747b747
commit abd921736b
16 changed files with 21 additions and 21 deletions

View File

@ -28,7 +28,7 @@ class CreateJournals < ActiveRecord::Migration
Permission.create :controller => "issues", :action => "history", :description => "label_history", :sort => 1006, :is_public => true, :mail_option => 0, :mail_enabled => 0
# data migration
IssueHistory.find(:all, :include => :issue).each {|h|
IssueHistory.all.each {|h|
j = Journal.new(:journalized => h.issue, :user_id => h.author_id, :notes => h.notes, :created_on => h.created_on)
j.details << JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :value => h.status_id)
j.save

View File

@ -1,7 +1,7 @@
class AddIssueStatusPosition < ActiveRecord::Migration
def self.up
add_column :issue_statuses, :position, :integer, :default => 1
IssueStatus.find(:all).each_with_index {|status, i| status.update_attribute(:position, i+1)}
IssueStatus.all.each_with_index {|status, i| status.update_attribute(:position, i+1)}
end
def self.down

View File

@ -1,7 +1,7 @@
class AddTrackerPosition < ActiveRecord::Migration
def self.up
add_column :trackers, :position, :integer, :default => 1
Tracker.find(:all).each_with_index {|tracker, i| tracker.update_attribute(:position, i+1)}
Tracker.all.each_with_index {|tracker, i| tracker.update_attribute(:position, i+1)}
end
def self.down

View File

@ -1,6 +1,6 @@
class SerializePossiblesValues < ActiveRecord::Migration
def self.up
CustomField.find(:all).each do |field|
CustomField.all.each do |field|
if field.possible_values and field.possible_values.is_a? String
field.possible_values = field.possible_values.split('|')
field.save

View File

@ -2,7 +2,7 @@ class AddSettingsUpdatedOn < ActiveRecord::Migration
def self.up
add_column :settings, :updated_on, :timestamp
# set updated_on
Setting.find(:all).each(&:save)
Setting.all.each(&:save)
end
def self.down

View File

@ -7,7 +7,7 @@ class CreateEnabledModules < ActiveRecord::Migration
add_index :enabled_modules, [:project_id], :name => :enabled_modules_project_id
# Enable all modules for existing projects
Project.find(:all).each do |project|
Project.all.each do |project|
project.enabled_module_names = Redmine::AccessControl.available_project_modules
end
end

View File

@ -1,7 +1,7 @@
class AddEnumerationsPosition < ActiveRecord::Migration
def self.up
add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position')
Enumeration.find(:all).group_by(&:opt).each do |opt, enums|
Enumeration.all.group_by(&:opt).each do |opt, enums|
enums.each_with_index do |enum, i|
# do not call model callbacks
Enumeration.update_all "position = #{i+1}", {:id => enum.id}

View File

@ -1,7 +1,7 @@
class AddCustomFieldsPosition < ActiveRecord::Migration
def self.up
add_column(:custom_fields, :position, :integer, :default => 1)
CustomField.find(:all).group_by(&:type).each do |t, fields|
CustomField.all.group_by(&:type).each do |t, fields|
fields.each_with_index do |field, i|
# do not call model callbacks
CustomField.update_all "position = #{i+1}", {:id => field.id}

View File

@ -7,8 +7,8 @@ class CreateProjectsTrackers < ActiveRecord::Migration
add_index :projects_trackers, :project_id, :name => :projects_trackers_project_id
# Associates all trackers to all projects (as it was before)
tracker_ids = Tracker.find(:all).collect(&:id)
Project.find(:all).each do |project|
tracker_ids = Tracker.all.collect(&:id)
Project.all.each do |project|
project.tracker_ids = tracker_ids
end
end

View File

@ -1,12 +1,12 @@
class AddCommitAccessPermission < ActiveRecord::Migration
def self.up
Role.find(:all).select { |r| not r.builtin? }.each do |r|
Role.all.select { |r| not r.builtin? }.each do |r|
r.add_permission!(:commit_access)
end
end
def self.down
Role.find(:all).select { |r| not r.builtin? }.each do |r|
Role.all.select { |r| not r.builtin? }.each do |r|
r.remove_permission!(:commit_access)
end
end

View File

@ -1,12 +1,12 @@
class AddViewWikiEditsPermission < ActiveRecord::Migration
def self.up
Role.find(:all).each do |r|
Role.all.each do |r|
r.add_permission!(:view_wiki_edits) if r.has_permission?(:view_wiki_pages)
end
end
def self.down
Role.find(:all).each do |r|
Role.all.each do |r|
r.remove_permission!(:view_wiki_edits)
end
end

View File

@ -1,12 +1,12 @@
class AddDeleteWikiPagesAttachmentsPermission < ActiveRecord::Migration
def self.up
Role.find(:all).each do |r|
Role.all.each do |r|
r.add_permission!(:delete_wiki_pages_attachments) if r.has_permission?(:edit_wiki_pages)
end
end
def self.down
Role.find(:all).each do |r|
Role.all.each do |r|
r.remove_permission!(:delete_wiki_pages_attachments)
end
end

View File

@ -10,7 +10,7 @@ class AddProjectsTrackersUniqueIndex < ActiveRecord::Migration
# Removes duplicates in projects_trackers table
def self.remove_duplicates
Project.find(:all).each do |project|
Project.all.each do |project|
ids = project.trackers.collect(&:id)
unless ids == ids.uniq
project.trackers.clear

View File

@ -1,7 +1,7 @@
class PopulateMemberRoles < ActiveRecord::Migration
def self.up
MemberRole.delete_all
Member.find(:all).each do |member|
Member.all.each do |member|
MemberRole.create!(:member_id => member.id, :role_id => member.role_id)
end
end

View File

@ -1,12 +1,12 @@
class AddViewIssuesPermission < ActiveRecord::Migration
def self.up
Role.find(:all).each do |r|
Role.all.each do |r|
r.add_permission!(:view_issues)
end
end
def self.down
Role.find(:all).each do |r|
Role.all.each do |r|
r.remove_permission!(:view_issues)
end
end

View File

@ -1,6 +1,6 @@
class EnableCalendarAndGanttModulesWhereAppropriate < ActiveRecord::Migration
def self.up
EnabledModule.find(:all, :conditions => ["name = ?", 'issue_tracking']).each do |e|
EnabledModule.where(:name => 'issue_tracking').all.each do |e|
EnabledModule.create(:name => 'calendar', :project_id => e.project_id)
EnabledModule.create(:name => 'gantt', :project_id => e.project_id)
end