このコミットが含まれているのは:
2026-06-26 00:51:40 +09:00
コミット 4da3f0afba
+13 -1
ファイルの表示
@@ -1,3 +1,5 @@
require 'json'
class BackfillInitialMaterialVersions < ActiveRecord::Migration[8.0]
class MigrationMaterial < ActiveRecord::Base
self.table_name = 'materials'
@@ -143,7 +145,7 @@ class BackfillInitialMaterialVersions < ActiveRecord::Migration[8.0]
file_content_type: blob.content_type,
file_byte_size: blob.byte_size,
file_checksum: blob.checksum,
file_sha256: blob.metadata['sha256']
file_sha256: blob_metadata(blob)['sha256']
}
end
end
@@ -156,4 +158,14 @@ class BackfillInitialMaterialVersions < ActiveRecord::Migration[8.0]
file_checksum: nil,
file_sha256: nil }
end
def blob_metadata blob
metadata = blob.metadata
return metadata if metadata.is_a?(Hash)
return { } if metadata.blank?
JSON.parse(metadata)
rescue JSON::ParserError
{ }
end
end