diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-11-06 11:49:45 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-11-06 11:49:45 +0000 |
commit | b67e4a87e4cb9051c806afa190a9644abed1e678 (patch) | |
tree | 9194ab95a5e1024221ffeacfe13ba90d1fed4325 /db/migrate | |
parent | c50b611f851303f97c83c8eb080f3c051c957395 (diff) | |
download | redmine-b67e4a87e4cb9051c806afa190a9644abed1e678.tar.gz redmine-b67e4a87e4cb9051c806afa190a9644abed1e678.zip |
Clean up member_roles if needed.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4370 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20101104182107_add_unique_index_on_members.rb | 3 |
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" + |