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.
This commit is contained in:
10
script/fixes/085_fix_invalid_favorites.rb
Executable file
10
script/fixes/085_fix_invalid_favorites.rb
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user