Sharing Ecto Models Between Projects

540 views
Skip to first unread message

Eric Lathrop

unread,
Oct 12, 2015, 4:44:38 PM10/12/15
to elixir-lang-talk
My company is building out a Phoenix app, and we're adding other applications to do data import and background processing. These apps all need to connect to the same database, which is also being used by a Rails app. I'm wondering what the current best practice is for sharing these models.

The few options I've come up with are:

  1. Combine all the background processing inside the phoenix app, making a large monolith. This doesn't feel very Elixir-y to me, but might be the easiest way to get started.
  2. Put all the apps under an umbrella app and make them depend on the Phoenix app so they can use the models. This feels better than #1, but still icky reaching into the Phoenix app just to use the models.
  3. Move all the models into a separate "models" app, making all the apps depend on it. This seems like the best idea, but I'm worried about what Phoenix tooling I'll break by not having any models inside the Phoenix app.

I'm wondering if any of these are the the right option, or if there's some even more Elixir way to do it that I don't see because I'm too new.


If anyone's tackled this before I'd appreciate hearing how you solved it.


Thanks,

  Eric

José Valim

unread,
Oct 12, 2015, 9:03:54 PM10/12/15
to elixir-l...@googlegroups.com
Move all the models into a separate "models" app, making all the apps depend on it. This seems like the best idea, but I'm worried about what Phoenix tooling I'll break by not having any models inside the Phoenix app.

That sounds like the way to go for me too and it should work just fine™. You should be able to move all things related to the repo (the config and the supervision tree) to a separate app and build on top of that. The only downside I can think of is that changes in the umbrella are not automatically reloaded by Phoenix so I would move only the repo + "core" models.



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

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/61eded5e-c948-43c1-aa89-30b078675992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Lathrop

unread,
Oct 12, 2015, 9:23:55 PM10/12/15
to elixir-l...@googlegroups.com
Awesome, thanks for the pointers!
Reply all
Reply to author
Forward
0 new messages