Files
danbooru/script/fixes/059_fix_favorites.rb
2019-12-22 21:23:37 -06:00

15 lines
405 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "../../config/environment"
def fix_favorites
Favorite.without_timeout do
# delete favorites with a nonexistent post_id
Favorite.where("NOT EXISTS (SELECT 1 FROM posts WHERE posts.id = favorites.post_id)").delete_all
end
end
def fix_migrations
ApplicationRecord.connection.execute("DELETE FROM scheme_migrations WHERE version = '201704142336170'")
end