mirror of
https://github.com/diaspora/diaspora.git
synced 2026-01-09 15:18:11 -05:00
Cleanup invalid likes without target
This commit is contained in:
13
db/migrate/20170914202650_cleanup_invalid_likes.rb
Normal file
13
db/migrate/20170914202650_cleanup_invalid_likes.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CleanupInvalidLikes < ActiveRecord::Migration[5.1]
|
||||
class Like < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
Like.where(target_type: "Post").joins("LEFT OUTER JOIN posts ON posts.id = likes.target_id")
|
||||
.where("posts.id IS NULL").delete_all
|
||||
Like.where(target_type: "Comment").joins("LEFT OUTER JOIN comments ON comments.id = likes.target_id")
|
||||
.where("comments.id IS NULL").delete_all
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user