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

LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
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
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement