20140605032822_add_guid_to_agents.rb 319 B

123456789101112131415
  1. class AddGuidToAgents < ActiveRecord::Migration
  2. class Agent < ActiveRecord::Base; end
  3. def change
  4. add_column :agents, :guid, :string
  5. Agent.find_each do |agent|
  6. agent.update_attribute :guid, SecureRandom.hex
  7. end
  8. change_column_null :agents, :guid, false
  9. add_index :agents, :guid
  10. end
  11. end