Skip to content

Commit

Permalink
DEV: Avoid subquery in the ensure-consistency onceoff
Browse files Browse the repository at this point in the history
  • Loading branch information
nattsw committed Aug 2, 2024
1 parent 4ebcd11 commit 2202986
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion db/post_migrate/20240711102255_ensure_consistency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def up
# delete votes associated with no user
DB.exec(<<~SQL)
DELETE FROM topic_voting_votes
WHERE user_id NOT IN (SELECT id FROM users)
USING topic_voting_votes tvv
LEFT JOIN users u ON tvv.user_id = u.id
WHERE u.id IS NULL;
SQL

# delete votes associated with no topics
Expand Down

0 comments on commit 2202986

Please sign in to comment.