Commit 5e73ca41 authored by jplang's avatar jplang

Replaces find(:all) calls.

git-svn-id: https://svn.redmine.org/redmine/trunk@10918 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent c6f9c95d
......@@ -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
......
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
......
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
......
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
......
......@@ -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
......
......@@ -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
......
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}
......
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}
......
......@@ -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
......
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
......
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
......
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
......
......@@ -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
......
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
......
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
......
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment