-
-
Save edwardloveall/11d56af9beeada461235c291223d6d9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GenerateUsernamesForUsers::V20190120141952 < LuckyRecord::Migrator::Migration::V1 | |
class TempUser < BaseModel | |
table :users do | |
column email : String | |
column username : String? | |
end | |
end | |
def migrate | |
TempUser::BaseQuery.all.each do |user| | |
new_username = user.email.split("@").first | |
TempUser::BaseForm.update!(user, username: new_username) | |
puts "Generated username #{new_username} for #{user.email}" | |
end | |
end | |
def rollback | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment