Elixir & Erlang versions (elixir --version):
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.5.1
Operating system: macOS Sierra 10.12.6
On Cargo app,
# config.exs
config :straw_hat_cargo,
ecto_repos: [
StrawHat.Cargo.Repo,
StrawHat.IAM.Repo,
StrawHat.Map.Repo
]
# mix.exs
defp aliases do
[
"ecto.setup": [
"ecto.create -r StrawHat.Cargo.Repo",
"ecto.create -r StrawHat.Map.Repo",
"ecto.create -r StrawHat.IAM.Repo",
"ecto.migrate -r StrawHat.Cargo.Repo",
"ecto.migrate -r StrawHat.Map.Repo",
"ecto.migrate -r StrawHat.IAM.Repo",
"run priv/repo/seeds.exs"
],
"ecto.reset": [
"ecto.drop -r StrawHat.Cargo.Repo",
"ecto.drop -r StrawHat.Map.Repo",
"ecto.drop -r StrawHat.IAM.Repo",
"ecto.setup"
],
"test": ["ecto.create --quiet", "ecto.migrate", "test"],
]
end
Console output
Compiling 26 files (.ex)
Generated straw_hat_cargo app
The database for StrawHat.Cargo.Repo has been dropped
The database for StrawHat.Cargo.Repo has been created
16:49:58.180 [info] == Running StrawHat.Cargo.Repo.Migrations.CreateWarehouseTable.change/0 forward
# keep going until it failed because of the database setup is wrong
I am running mix ecto.reset it should run all the commands so I should see that it drops the 3 repos and then create 3 repos and then run the migration for each repo.
@yordis the issue is that Mix tasks were designed to run only once. So follow up calls are not going to work. Instead pass the -r flag multiple times. I will improve the docs for the Ecto tasks. :heart:
@josevalim if I do multiple call manually would work? Just thinking in the use case that I dont have some task like the Ecto once that allow me to pass multiple values
@yordis you can use something like Mix.Task.rerun or reenable to be able to call it again.
@josevalim is that documented? That would be nice to highlight
Those functions and how tasks behave are all documented.
Most helpful comment
Those functions and how tasks behave are all documented.