From 57afa5345eea60c47b4fc44e86f32e73a202d860 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 16 Jul 2016 10:30:45 +0000 Subject: Don't pass conditions to #delete_all. git-svn-id: http://svn.redmine.org/redmine/trunk@15675 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- db/migrate/20101104182107_add_unique_index_on_members.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db/migrate/20101104182107_add_unique_index_on_members.rb') diff --git a/db/migrate/20101104182107_add_unique_index_on_members.rb b/db/migrate/20101104182107_add_unique_index_on_members.rb index 14d1585f7..eabdad86b 100644 --- a/db/migrate/20101104182107_add_unique_index_on_members.rb +++ b/db/migrate/20101104182107_add_unique_index_on_members.rb @@ -1,7 +1,7 @@ class AddUniqueIndexOnMembers < ActiveRecord::Migration def self.up # Clean and reassign MemberRole rows if needed - MemberRole.delete_all("member_id NOT IN (SELECT id FROM #{Member.table_name})") + MemberRole.where("member_id NOT IN (SELECT id FROM #{Member.table_name})").delete_all 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" + @@ -9,7 +9,7 @@ class AddUniqueIndexOnMembers < ActiveRecord::Migration # Remove duplicates Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" + " WHERE m.id > (SELECT min(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i| - Member.delete_all(["id = ?", i]) + Member.where(["id = ?", i]).delete_all end # Then add a unique index -- cgit v1.2.3