BigW Consortium Gitlab

20160324020319_remove_todos_for_deleted_issues.rb 392 Bytes
Newer Older
1
# rubocop:disable all
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
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