mirror of
https://ghfast.top/https://github.com/discourse/discourse-topic-voting.git
synced 2026-07-16 11:26:36 +08:00
19 lines
432 B
Ruby
19 lines
432 B
Ruby
# frozen_string_literal: true
|
|
|
|
class RemoveVotesOfDeletedUsers < ActiveRecord::Migration[6.0]
|
|
def up
|
|
DB.exec <<~SQL
|
|
DELETE FROM discourse_voting_votes
|
|
WHERE user_id IN (
|
|
SELECT votes.user_id
|
|
FROM discourse_voting_votes votes
|
|
LEFT JOIN users ON users.id = votes.user_id
|
|
WHERE users.id IS NULL
|
|
)
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|