Running ecto migrations without running the app


I would like to migrate my database with Ecto without starting the application, as it will very slow to start if only the database is started (it will try to connect to Kafka and RabbitMQ on startup but they would not be up).

I tried the following:

** (Mix) Could not invoke task "ecto.migrate": 1 error found!
--no-start : Unknown option```

Is there a simple way to do it? Otherwise I can write a custom migrator of course.

Thank you

Hi @lud , AFAIK, running mix ecto.migrate would only start process for migrated Ecto Repo process, without touching any other aspect of your application dependency (Kafka, RabbitMQ). in fact just now i try running mix ecto.migrate without necessary dependency for application (SQS, Redis, another Ecto Repo to other service, etc) and it just work. but i can’t run mix app.start without these depedency

This is the behaviour I was expecting but I see something different. Thank you for confirming that ecto.migrate does not start the app. I must have a piece of code somewhere that is executed for some reason.

Oh, good luck finding it then, you might want to trace which part in your codebase which actually start Kafka/RabbitMQ. also, might want to check if anything was wrong at mix.exs. sometime people can alias common task like mix ecto.migrate and add additional task before it


Yes silly me … the alias that I use has the call to run the seeds in it :smiley: though I do not use seeds.


1 Like