From 6d8b7b49cbd77cf6e1773288fab3eac1956387ce Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 22 Aug 2016 23:59:07 +0200 Subject: [PATCH] Remove started sharing notifications where the contact doesn't exist The same as #7009 but now all of them ;) --- ...39_remove_started_sharing_notifications_without_contact.rb} | 3 ++- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename db/migrate/{20160820181334_remove_started_sharing_notifications_without_contact.rb => 20160822212739_remove_started_sharing_notifications_without_contact.rb} (81%) diff --git a/db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb similarity index 81% rename from db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb rename to db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb index 0d9d6c0bb..70a62f68f 100644 --- a/db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb +++ b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb @@ -5,7 +5,8 @@ class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration def up Notification.where(type: "Notifications::StartedSharing", target_type: "Person") .joins("INNER JOIN people ON people.id = notifications.target_id") - .joins("LEFT OUTER JOIN contacts ON contacts.person_id = people.id") + .joins("LEFT OUTER JOIN contacts ON contacts.person_id = people.id " \ + "AND contacts.user_id = notifications.recipient_id") .delete_all("contacts.id IS NULL") end end diff --git a/db/schema.rb b/db/schema.rb index 334178c49..593703cb4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160820181334) do +ActiveRecord::Schema.define(version: 20160822212739) do create_table "account_deletions", force: :cascade do |t| t.string "diaspora_handle", limit: 255