Remove all data from Active Storage?

This question challenged me, so I did some test on my dummy app with local storage.

I have the usual model User which has_one_attached :avatar

On local storage files are saved on /storage folder, under subfolders named randomly with a string of two characters.

Informations related to files are stored in two tables:

  • ActiveStorage::Attachment
  • ActiveStorage::Blob

To completely clean the two tables, I did in rails console:

ActiveStorage::Attachment.all.each { |attachment| attachment.purge }

This command deletes

  • All record in that table: ActiveStorage::Attachment.any? #=> false
  • All the blobs: ActiveStorage::Blob.any? #=> false
  • All the files located under /storage subfolders; of course, subfolders are still there empty.

The ActiveStorage still works poperly.

I expect the same behaviour for remote storage, having the right privileges.