diff --git a/db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb b/db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb new file mode 100644 index 0000000000000000000000000000000000000000..0d9d6c0bb8604ab9acecd76b5a46110ee93dfc13 --- /dev/null +++ b/db/migrate/20160820181334_remove_started_sharing_notifications_without_contact.rb @@ -0,0 +1,11 @@ +class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration + class Notification < ActiveRecord::Base + end + + 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") + .delete_all("contacts.id IS NULL") + end +end diff --git a/db/schema.rb b/db/schema.rb index d78733848fbe3b34dedf064cf3c4b300d2f700ba..334178c497144b2809c9fe0224036c8279972b50 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: 20160813115514) do +ActiveRecord::Schema.define(version: 20160820181334) do create_table "account_deletions", force: :cascade do |t| t.string "diaspora_handle", limit: 255