Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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