retrospring/db/migrate/20220708204200_remove_orphaned_notifications.rb
2022-07-09 01:15:31 +02:00

9 lines
366 B
Ruby

# 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