Commit 56274741
Changed files (1)
db
db/migrate/20140921024709_migrate_avatars_to_photos.rb
@@ -0,0 +1,14 @@
+class MigrateAvatarsToPhotos < ActiveRecord::Migration
+ def change
+ blob_storage = BlogStorage.new
+ Avatar.includes(:user).find_each do |avatar|
+ user = avatar.user
+ key = avatar.avatar.path
+ blob_storage.download(key) do |file|
+ user.avatar = Photo.create!
+ user.avatar.upload(file.path, blob_storage)
+ user.avatar.save!
+ end
+ end
+ end
+end