Migration to Shrine attachment handling

This commit is contained in:
Christoph Haas 2020-11-01 15:07:16 +01:00
parent 2d53397dda
commit c4f5741b0c
13 changed files with 175 additions and 181 deletions

View file

@ -0,0 +1,27 @@
#require 'paperclip_shrine_synchronization'
namespace :debshots do
desc "Convert images from Paperclip (deprecated) to Shrine"
task paperclip_to_shrine: :environment do
Screenshot.find_each do |screenshot|
puts "Screenshot… #{screenshot.id}"
path = screenshot.image.path
puts "Image path… #{path}"
# Skip run if there is a Shrine attachment already (idempotency)
next if screenshot.simage
# Upload file as Shrine
screenshot.simage = File.open(path)
puts "Creating derivatives…"
screenshot.simage_derivatives!
screenshot.save!
puts "------------"
end
end
end