How can I migrate files from the old upload scheme (default/XXX) to the new one (default/original/{1,2}X)?

But that’s true for new sites as well, because of stock images like:

=> [#<Upload:0x000055f79be02ac0
  id: -1,
  user_id: -1,
  original_filename: "d-logo-sketch.png",
  filesize: 14461,
  width: nil,
  height: nil,
  url: "/images/d-logo-sketch.png",
  created_at: Thu, 14 Mar 2019 12:13:08 UTC +00:00,
  updated_at: Thu, 14 Mar 2019 12:13:08 UTC +00:00,
  sha1: nil,
  origin: nil,
  retain_hours: nil,
  extension: "png",
  thumbnail_width: nil,
  thumbnail_height: nil,
  etag: nil>,

So I think that test should be:

Upload.where("url NOT LIKE '//%' AND url NOT LIKE '/uploads/default/original/_X/%' and id>0").exists?

Best I can tell, running Jobs::MigrateUploadScheme.new.execute(nil) won’t fix them. And that keeps rake uploads:migrate_from_s3 from running.

2 Likes