class MigrateMaterialPhotosToFiles < ActiveRecord::DataMigration def up photos = ActiveStorage::Attachment.where(name: "photos", record_type: "MaterialRelease") photos.each do |photo| photo.update(name: "files") end end end