@@ -1,4 +1,7 @@
 class AddUserImageFingerprint < ActiveRecord::Migration[4.2]
+  class User < ActiveRecord::Base
+  end
+
   def up
     add_column :users, :image_fingerprint, :string, :null => true
 
class AddUserImageFingerprint < ActiveRecord::Migration[4.2]
  def up
    add_column :users, :image_fingerprint, :string, :null => true

    User.where("image_file_name IS NOT NULL").find_each do |user|
      image = user.image

      user.image_fingerprint = image.generate_fingerprint(image)
      user.save!
    end
  end

  def down
    remove_column :users, :image_fingerprint
  end
end

I don't think this will work if there are any users in the database because the migration relies on being able to access the images attached to the user via the paperclip attachment, which has not been declared here. That of course gets even more fun once we remove paperclip from the Gemfile...