Run migration command twice inside aliases in mix file

Inside the aliases in mix file. If we define migration command like this:

defp aliases do
[
 "ecto.migrate": [
      "ecto.migrate  data/priv/repo/migrations",
      "ecto.migrate --migrations-path apps/al/priv/repo/migrations"
  ]

]

If we run mix ecto.migrate . only first command executed and second ignored.
I know mix don’t allow run same task twice. And I don’t think Mix.task.rerun or reenable will work here because its not custom task.
Is there any way to override it so both commands will execute?
Thanks

mix won’t run tasks again that already have been run. You need to run them separately.

Sorry to resurrect an old thread, but in case anyone else comes across this…

If all you are wanting to do is run migrations from two different directories, then you don’t need ecto.migrate to run again, you can make an alias that runs both:

"ecto.migrate_all": [
  "ecto.migrate --migrations-path=priv/repo/migrations --migrations-path=priv/repo/data_migrations"
]

But, if you need to do something else between running migrations in multiple folders (like running seeds), then you’ll need to reenable ecto.migrate:

"alias_name": [
  "ecto.migrate",
  "run priv/repo/seeds.exs",
  "run -e 'Mix.Task.reenable(\"ecto.migrate\")'",
  "ecto.migrate --migrations-path=priv/repo/data_migrations"
]
2 Likes