comparison .svn/pristine/d1/d1fe1a10e719bee9e65cf063fc9ec9a0c05f2327.svn-base @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 class AddProjectsTrackersUniqueIndex < ActiveRecord::Migration
2 def self.up
3 remove_duplicates
4 add_index :projects_trackers, [:project_id, :tracker_id], :name => :projects_trackers_unique, :unique => true
5 end
6
7 def self.down
8 remove_index :projects_trackers, :name => :projects_trackers_unique
9 end
10
11 # Removes duplicates in projects_trackers table
12 def self.remove_duplicates
13 Project.all.each do |project|
14 ids = project.trackers.collect(&:id)
15 unless ids == ids.uniq
16 project.trackers.clear
17 project.tracker_ids = ids.uniq
18 end
19 end
20 end
21 end