#9 Active Storage - migration
This commit is contained in:
parent
911457de79
commit
de4806498e
@ -84,7 +84,7 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0]
|
|||||||
# Migrate attachments
|
# Migrate attachments
|
||||||
ActiveStorage::Attachment.find_each do |a|
|
ActiveStorage::Attachment.find_each do |a|
|
||||||
r = a.record
|
r = a.record
|
||||||
new_path = disk_file
|
new_path = disk_file(r)
|
||||||
unless File.exist?(new_path)
|
unless File.exist?(new_path)
|
||||||
a.blob.open do |f|
|
a.blob.open do |f|
|
||||||
# Move the attachment
|
# Move the attachment
|
||||||
@ -140,7 +140,7 @@ class ActiveStorageMigration < ActiveRecord::Migration[7.0]
|
|||||||
end
|
end
|
||||||
|
|
||||||
def disk_file(dmsf_file_revision)
|
def disk_file(dmsf_file_revision)
|
||||||
path = storage_base_path
|
path = storage_base_path(dmsf_file_revision)
|
||||||
begin
|
begin
|
||||||
FileUtils.mkdir_p path
|
FileUtils.mkdir_p path
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user