summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20101104182107_add_unique_index_on_members.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/db/migrate/20101104182107_add_unique_index_on_members.rb b/db/migrate/20101104182107_add_unique_index_on_members.rb
index 6b07e4647..ff7297084 100644
--- a/db/migrate/20101104182107_add_unique_index_on_members.rb
+++ b/db/migrate/20101104182107_add_unique_index_on_members.rb
@@ -1,6 +1,7 @@
class AddUniqueIndexOnMembers < ActiveRecord::Migration
def self.up
- # Reassign MemberRole rows if needed
+ # Clean and reassign MemberRole rows if needed
+ MemberRole.delete_all("member_id NOT IN (SELECT id FROM #{Member.table_name})")
MemberRole.update_all("member_id =" +
" (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" +
" WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" +