summaryrefslogtreecommitdiff
path: root/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
blob: a25d15a81efcdd4de6f05b59ecbad18028542188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class RemoveTodosForDeletedIssues < ActiveRecord::Migration[4.2]
  def up
    execute <<-SQL
      DELETE FROM todos
      WHERE todos.target_type = 'Issue'
        AND NOT EXISTS (
              SELECT *
              FROM issues
              WHERE issues.id = todos.target_id
                AND issues.deleted_at IS NULL
            )
    SQL
  end

  def down
  end
end