Using a Repo in an Ecto migration
问题 I've got an Ecto migration where I'd like to modify some columns but also migrate some data. For example: import Ecto.Query defmodule MyApp.Repo.Migrations.AddStatus do alter table(:foo) do add(:status, :text) end foos = from(f in MyApp.Foo, where: ...) |> MyApp.Repo.all Enum.each(foos, fn(foo) -> # There's then some complex logic here to work # out how to set the status based on other attributes of `foo` end) end Now, the problem here is that by calling MyApp.Repo.all the migration