[Proposal] mix run --recursive

61 views
Skip to first unread message

Michał Muskała

unread,
Aug 12, 2016, 4:00:23 AM8/12/16
to elixir-l...@googlegroups.com
Hello everybody,

Today I encountered an interesting problem. We're doing seeding for our applications with a custom mix alias: "run priv/repo/seeds/**/*", which works great. The problem is we're using umbrella applications with multiple ecto repos, so each application has it's own seeds. You can imagine how annoying it is having to run seeds for each application separately.

I would like to propose adding --recursive flag to the run task, that would make it apply it's arguments in each application separately. This would allow creating an alias in the top-level mix.exs to run seeds in each application.

What do you think?

Michał.
signature.asc

José Valim

unread,
Aug 12, 2016, 4:26:54 AM8/12/16
to elixir-l...@googlegroups.com
I am -1 because you can solve it with aliases OR by using "mix cmd mix run priv/repo/seeds.ex" (which runs a command on all children apps).



José Valim
Skype: jv.ptec
Founder and Director of R&D


Michał.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/70E6F291-32AD-422C-BE60-27F493E423F1%40muskala.eu.
For more options, visit https://groups.google.com/d/optout.

Michał Muskała

unread,
Aug 12, 2016, 4:46:58 AM8/12/16
to elixir-l...@googlegroups.com

> On 12 Aug 2016, at 10:26, José Valim <jose....@plataformatec.com.br> wrote:
>
> I am -1 because you can solve it with aliases OR by using "mix cmd mix run priv/repo/seeds.ex" (which runs a command on all children apps).
>

I cannot solve this with an alias - I can't create a recursive alias in the root of umbrella.

I didn't knew mix cmd existed. It indeed covers this use case. Thank you.

Michał
signature.asc

Renan Ranelli

unread,
Aug 15, 2016, 7:54:00 PM8/15/16
to elixir-l...@googlegroups.com
I have solved a similar problem with a little bit of shell hackery. We also have *a lot* of seed scripts.

What I did is something in the lines of:

```
for f in $(find $seedDirs -name seeds*.exs); do cd $somewhere && mix run $f; done
```

I don't have the exact command right now, but its not far away from that.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages