13 lines
332 B
Ruby
13 lines
332 B
Ruby
module DataUpdateScripts
|
|
class RemoveOrphanedPolls
|
|
def run
|
|
# Delete all Polls belonging to Articles that don't exist anymore
|
|
ActiveRecord::Base.connection.execute(
|
|
<<~SQL.squish,
|
|
DELETE FROM polls
|
|
WHERE article_id NOT IN (SELECT id FROM articles);
|
|
SQL
|
|
)
|
|
end
|
|
end
|
|
end
|