Guest User

Untitled

a guest
Oct 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. OldFoo
  2. |> Repo.stream()
  3. |> Stream.each(fn foo ->
  4.  
  5. new_foo =
  6. NewFoo
  7. |> where([nf], nf.name == ^foo.name)
  8. |> Repo.one()
  9.  
  10. Bar
  11. |> where([b], b.foo_id == ^foo.id)
  12. |> Repo.stream()
  13. |> Stream.each(fn bar ->
  14. Bar.update(bar, %{foo_id: new_foo.id})
  15. end
  16. |> Stream.run
  17. end)
  18. |> Stream.run
Add Comment
Please, Sign In to add comment