Commit 00296ffd authored by Benjamin Neff's avatar Benjamin Neff

Cleanup invalid likes without target

parent 028199a6
# frozen_string_literal: true
class CleanupInvalidLikes < ActiveRecord::Migration[5.1]
class Like < ApplicationRecord
def up
Like.where(target_type: "Post").joins("LEFT OUTER JOIN posts ON = likes.target_id")
.where(" IS NULL").delete_all
Like.where(target_type: "Comment").joins("LEFT OUTER JOIN comments ON = likes.target_id")
.where(" IS NULL").delete_all
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment