retrospring/db/migrate/20220708204200_remove_orphaned_notifications.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

10 lines
366 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class RemoveOrphanedNotifications < ActiveRecord::Migration[6.1]
def up
execute "DELETE FROM notifications WHERE target_type = 'Appendable' AND target_id NOT IN (SELECT id FROM appendables)"
execute "DELETE FROM notifications WHERE target_type = 'Relationship' AND target_id NOT IN (SELECT id FROM relationships)"
end
end