summaryrefslogtreecommitdiff
path: root/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
blob: a9a851cfe638ff95941ce57c97eaabff2159c25a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# rubocop:disable all
class RemoveTodosForDeletedIssues < ActiveRecord::Migration
  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