]> git.openstreetmap.org Git - rails.git/blob - db/migrate/20120219161649_add_user_image_fingerprint.rb
Merge branch 'master' into moderation
[rails.git] / db / migrate / 20120219161649_add_user_image_fingerprint.rb
1 class AddUserImageFingerprint < ActiveRecord::Migration
2   def up
3     add_column :users, :image_fingerprint, :string, :null => true
4
5     User.where("image_file_name IS NOT NULL").find_each do |user|
6       image = user.image
7
8       user.image_fingerprint = image.generate_fingerprint(image)
9       user.save!
10     end
11   end
12
13   def down
14     remove_column :users, :image_fingerprint
15   end
16 end