Skip to content

Instantly share code, notes, and snippets.

@chrisortman
Created January 1, 2017 20:09
Show Gist options
  • Save chrisortman/c0b039eb82203eb2cc94d9bb6cc1a908 to your computer and use it in GitHub Desktop.
Save chrisortman/c0b039eb82203eb2cc94d9bb6cc1a908 to your computer and use it in GitHub Desktop.
How to bulk generate UUID values for a new column
for id <- Repo.all( from r in "recipients", select: r.id ),
{id, uid} = {id, Ecto.UUID.bingenerate},
do: from(r in "recipients", where: r.id == ^id, update: [set: [uid: ^uid]])
|> Repo.update_all([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment