title: Rails Migration Update existing records while creating entries in another table
body: <p>I am trying to set up Beta Invites for my Rails application. I have an Invitation model and a User model.</p>
  
  <p>User has one invitation_id. I am validating that user must have an invitation_id and it should be unique. I want to write a migration so that I can update my existing users to have an invitation_id.</p>
  
  <p>Here is my invitation model:</p>
  
  <pre><code># Table name: invitations
  #
  #  id              :integer         not null, primary key
  #  sender_id       :integer
  #  recipient_email :string(255)
  #  token           :string(255)
  #  sent_at         :datetime
  #  created_at      :datetime
  #  updated_at      :datetime
  </code></pre>
  
  <p>To guarantee uniqueness, I will have to create records in invitation table and also assign the corresponding ids to the user records.</p>
  
  <p>Can someone please suggest a migration for the same?</p>
  
  <p>Thanks in advance!</p>