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.
11 lines
247 B
Ruby
Executable File
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
|