Skip to content

Instantly share code, notes, and snippets.

@acuppy
Created July 11, 2016 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acuppy/2e42e29fac5a541f6f551797714a8b03 to your computer and use it in GitHub Desktop.
Save acuppy/2e42e29fac5a541f6f551797714a8b03 to your computer and use it in GitHub Desktop.
class AddFirstNameAndLastNameToUsers < Arborist::Migration
model :User
data do
model.find_each do |user|
first_name, last_name = user.full_name.split ' '
user.first_name = first_name
user.last_name = last_name
user.save!
end
end
schema do
add_column :users, :first_name, :string
add_column :users, :last_name, :string
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment