2016-06-09 12:39:16 +00:00
|
|
|
# rubocop:disable all
|
2016-03-24 02:14:02 +00:00
|
|
|
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
|