aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/101_add_hash_to_info_request.rb
blob: e38384cd66ad6f642d00a9bcb4b7d8148cf60a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'digest/sha1'

class AddHashToInfoRequest < ActiveRecord::Migration
    def self.up
        add_column :info_requests, :idhash, :string

        # Create the missing events for requests already sent
        InfoRequest.all.each do |info_request|
            info_request.idhash = Digest::SHA1.hexdigest(info_request.id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
            info_request.save!
        end
        change_column :info_requests, :idhash, :string, :null => false
    end
    def self.down
        remove_column :info_requests, :idhash
    end
end