debian-mirror-gitlab/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
2019-02-15 15:39:39 +05:30

18 lines
375 B
Ruby

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