# How to make an image orphaned so that it gets removed?

**URL:** <https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231>\
**Category:** Product Support\
**Created:** [January 29, 2018, 12:52am UTC](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231 "2018-01-29T00:52:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [February 19, 2019, 10:18am UTC](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231/4 "2019-02-19T10:18:38Z")

</div>

I was investigating a case where an upload is not deleted while it belongs to a post that has been deleted over 48 hours ago.

But … neither the `CleanUpUploads` job nor the soft deletion code for a post seem to handle this case ?

The job checks for `pu.upload_id IS NULL` but while an `Upload` has `has_many :post_uploads, dependent: :destroy` , a `Post` does not have this cascading delete?

What am I overlooking? Or is this really not handled?

---

_[View the full topic](https://meta.discourse.org/t/how-to-make-an-image-orphaned-so-that-it-gets-removed/79231)._
