Gulliver

Gulliver

Hi,
I’m trying to figure out how to use a single database app in my umbrella project to take care of everything db related.

My app structure is like this:

umbrella project
|
– Database_app
|
– Phoenix_app
|
– App_1

Now, I define a schema “Banana” in “App_1” and I would like to use it with a repo from “database app”.
Everything else works ok but I can’t figure out how to deal with migrations? In my example case they should be in “App_1”, but when I try to create a migration with “mix ecto.gen.migration create_bananas” in “App_1” I either get an error “warning: could not find repositories for application …” without anything in my config file, or “(Mix) Could not load Database_App.Repo, error: :nofile. Please configure your app accordingly or pass a repo with the -r option” when I use the following config:

config :App_1, Database_App.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "mydatabase",
  username: "username",
  password: "password",
  hostname: "localhost"
config :app_1, ecto_repos: [Database_App.Repo]

So what am I doing wrong here, how could I config this app_1 so that it would have the schema and the migrations but use the repo from another app, is it even possible?

Showing Posts 1 to 2

wojtekmach

wojtekmach

Hex Core Team

So what am I doing wrong here, how could I config this app_1 so that it would have the schema and the migrations but use the repo from another app, is it even possible?

While it’s possible to access Repo from another app, I’d advise against that in most cases - to me it looks like breaking boundaries between the apps. I don’t know the details about your particular project, but I’d probably start with just 2 apps: App1 & Phoenix_app, and App1 would “own” the data & storage and hide these implementation details (schemas, queries, access to Repo) behind a well defined interface. And in the future if you’d want to add App2 I’d actually create a separate App2.Repo (that can use a different or the same underlying DB). The idea would be that each app is independent and isolated from each other as much as possible an the implementation details (e.g. Repo) don’t leak out.

P.S. you might have a typo in configuration: config :App_1 vs config :app_1 so maybe this is the reason you can’t run the migrations.

Gulliver

Gulliver OP

Thanks for your help. I’ll take your advice and restructure my project in a way that every app talks directly to the db. And about the typo, those names were just something I pulled out of my hat, not from the real project where they are (should be..) correct, but thanks anyway.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews