diff --git a/Changelog.md b/Changelog.md index 262f7bcabb50a909af66d48d72eedad685bb70e2..38ebeabc2c76f5d5cd0d47678ea9840a1daec553 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Refactor * Add unique index to poll participations on `poll_id` and `author_id` [#7798](https://github.com/diaspora/diaspora/pull/7798) * Add 'completed at' date to account migrations [#7805](https://github.com/diaspora/diaspora/pull/7805) +* Handle duplicates for TagFollowing on account merging [#7807](https://github.com/diaspora/diaspora/pull/7807) ## Bug fixes diff --git a/app/models/account_migration.rb b/app/models/account_migration.rb index 3d4a40d0ba395c97d07372f3d4324399ffdd25b8..0be2ae932f708389f3936915d0c794c4d714405a 100644 --- a/app/models/account_migration.rb +++ b/app/models/account_migration.rb @@ -194,6 +194,10 @@ class AccountMigration < ApplicationRecord .joins("INNER JOIN contacts as c2 ON (contacts.person_id = c2.person_id AND contacts.user_id=#{old_user.id} AND"\ " c2.user_id=#{new_user.id})") .destroy_all + TagFollowing + .joins("INNER JOIN tag_followings as t2 ON (tag_followings.tag_id = t2.tag_id AND"\ + " tag_followings.user_id=#{old_user.id} AND t2.user_id=#{new_user.id})") + .destroy_all end def update_person_references diff --git a/spec/models/account_migration_spec.rb b/spec/models/account_migration_spec.rb index 0bf1b36a69f2d2bbef494e2f421c6aefcd57f559..a5fd24f0a65b7f2ff86864701149dfa9229fc84a 100644 --- a/spec/models/account_migration_spec.rb +++ b/spec/models/account_migration_spec.rb @@ -210,6 +210,11 @@ describe AccountMigration, type: :model do user: new_person.owner, person: FactoryGirl.create(:contact, user: old_person.owner).person ) + FactoryGirl.create( + :tag_following, + user: new_person.owner, + tag: FactoryGirl.create(:tag_following, user: old_person.owner).tag + ) end it "runs without errors" do