Files
danbooru/script/fixes/085_fix_invalid_favorites.rb
evazion 3814aa21b3 favorites: delete favorites for expunged posts.
Delete favorites that have an invalid post_id because they belong to an
expunged post.

This bug of not deleting favorites after a post is expunged was fixed
long ago, but old favorites were never cleaned up.

Fixes #4711: Some users have incorrect fav count.
2022-01-08 20:55:55 -06:00

11 lines
247 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "../../config/environment"
Favorite.transaction do
Favorite.left_outer_joins(:post).where("posts.id": nil).destroy_all
print "Commit? (yes/no): "
raise "abort" unless STDIN.readline.chomp == "yes"
end