Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bondarolik/4d6a33dc5246a445a12f9a3c24d53597 to your computer and use it in GitHub Desktop.
Save bondarolik/4d6a33dc5246a445a12f9a3c24d53597 to your computer and use it in GitHub Desktop.
User Table Creation and Data Population within Rake task
# Run rake task from migration file
class CreateUsers < ActiveRecord::Migration [7.0]
def change
create_table :users do It| t.string :first_name t.string :last_name
t. string email, index: { unique: true }
# other columns
t. timestamps
end
up_only do
# just an example, don't @ me
Rake: :Task[ users :populate_known_emails ']. invoke end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment