rob_marsh

rob_marsh

Sharing Ecto schemas between projects

Hi all,

I’m looking for some advice on how to structure an application I’m building. It should eventually contain an importer that runs daily and a Phoenix application to display the information. Seeing as both applications use the same data I decided to try out an umbrella application containing a “core library” that acts as a Data Access Layer whilst allowing the schema to be shared. The application hierarchy currently looks like the following…

hull_cinema_club
  | apps
    | hcc_core
    | movie_importer
    | phoenix_app

This works well enough on my dev machine, however I’m having a hard time deploying using edeliver and am wondering whether that it a sign that there is a more optimal way to structure that application.

I’m pretty new to Elixir so any feedback or advice on sharing schemas between projects would be greatly appreciated.

Thanks!

Most Liked

pedroassumpcao

pedroassumpcao

Also, if you already have started the project as umbrella without the web piece, you can use mix phx.new.web generator inside apps to create the web layer using Phoenix. The generator will identify the umbrella project and will remove everything you don’t need in the web app.

kokolegorille

kokolegorille

Looking at your structure, I guess You use mix new … --umbrella, then go to apps and build phoenix app.

But there is also another way of doing this

mix phx.new hull_cinema_club --umbrella

After, You build the movie_importer, You will get this structure

hull_cinema_club_umbrella
  | apps
    | movie_importer
    | hull_cinema_club
    | hull_cinema_club_web

WIth hull_cinema_club acting as core. I tend to prefer this, as it simplify struct a little bit, as there is no need to build phoenix_app and hcc_core by hand. And also, the web part is configured only for web. While the core is the db part.

Also configuring tests is automatic, while in your case, You will need to make it by hand.

It’s just a matter of taste, I used the same structure as yours before…

rob_marsh

rob_marsh

Thanks for the advice - I hadn’t thought to create the umbrella project using phoenix but I can definitely see how that makes things tidier. Also good to know that I’m not completely on the wrong track.

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement