Skip to content

Instantly share code, notes, and snippets.

@rossta
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save rossta/9621855 to your computer and use it in GitHub Desktop.

Select an option

Save rossta/9621855 to your computer and use it in GitHub Desktop.
Notes for orphaned flag datafix
# flags orphaned from forum topics (discussions)
Flag.joins("LEFT OUTER JOIN forum_topics ON flags.flaggable_id = forum_topics.id").where('forum_topics.id IS NULL').where(flaggable_type: 'ForumTopic')
# flags orphaned from comments
Flag.joins("LEFT OUTER JOIN comments ON flags.flaggable_id = comments.id").where('comments.id IS NULL').where(flaggable_type: 'Comment')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment