<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="121602" data-post-id="121602">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fireproofsocks" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fireproofsocks/120/7669_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fireproofsocks
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>I’m skeptical there should be multiple Repos at all.</p>
</blockquote>
<p>Yes, that’s exactly the conclusion I’ve come to.  When I started building the apps individually, it made sense for them to have their own Repo and database because it made it easy to dev and test in isolation and each app didn’t need to know about the umbrella at all.</p>
<p>In practice, however, those individual repos are inefficient when they all are pointed at the same database when they get run under the umbrella.  The more efficient solution, which you outlined, is to have a repo shared by all the apps (most of the apps?). If one app needs to use a separate repo (e.g. something other than PostGres, or maybe just to point to a separate instance for reasons of performance/security/???), then it would be relatively simple to replace the shared App.Repo with a different adapter.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121602" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-practices-umbrella-app-with-multiple-repos/21113/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-121602" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121602"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="121604" data-post-id="121604">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gregvaughn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/120/954_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gregvaughn
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="BenMorganIO" data-post="10" data-topic="21113" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benmorganio/48/6523_2.png" class="avatar"> BenMorganIO:</div>
<blockquote>
<p>That’s what I thought too but it was very much explained in the slack that they are just a single app and people should be using ponchos.</p>
</blockquote>
</aside>
<p>Yet ironically, just within the past hour the <a class="hashtag-cooked" href="/tag/phoenix/133" data-type="tag" data-slug="phoenix" data-id="133" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>phoenix</span></a> channel on slack has given accurate information on umbrellas.</p>
<p>I wonder if the advice you got was related to needing 2 different version of phoenix and somehow got overgeneralized in your head. Or it’s possible whoever was around when you asked the question answered with more confidence than they should</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121604" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-practices-umbrella-app-with-multiple-repos/21113/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-121604" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121604"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="121655" data-post-id="121655">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="LostKobrakai" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/LostKobrakai/120/3072_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  LostKobrakai
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="BenMorganIO" data-post="7" data-topic="21113">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/benmorganio/48/6523_2.png" class="avatar"> BenMorganIO:</div>
<blockquote>
<p>The idea of a poncho app is really simple. It’s just like an umbrella app but instead of a single OTP app ruling everything, you have mulitple mix.lock files instead of a single mix.lock that can cause issues.</p>
</blockquote>
</aside>
<p>Just to make this clear, there’s not a “single OTP app” in an umbrella. The top abstractions on the beam is an otp app and umbrella and poncho are both ways to compose multiple otp applications together. The difference is that an umbrella is a single mix project, which combines multiple nested “mix projects” into one – starting any of them by default, while poncho’s approach is developing each application in it’s own mix project and using simple <code>{:dep, path: "…"}</code> dependencies between each other, where there’s one “root” application, which depends on all the sub applications.</p>
<aside class="quote no-group" data-username="fireproofsocks" data-post="12" data-topic="21113">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fireproofsocks/48/7669_2.png" class="avatar"> fireproofsocks:</div>
<blockquote>
<p>Yes, that’s exactly the conclusion I’ve come to. When I started building the apps individually, it made sense for them to have their own Repo and database because it made it easy to dev and test in isolation and each app didn’t need to know about the umbrella at all.</p>
</blockquote>
</aside>
<p>This sounds like you’re missing some abstraction here. For me <code>MyApp.Repo</code> is mostly a runtime construct handling db connections to a certain database (pooling and all that stuff). And it sounds like you want to reduce coupling to the app holding that module. Normally you’d do that by inversion of control. Create a behaviour in each app, which handles the concern of “accessing a db” and use configuration to let it use <code>MyApp.Repo</code> in prod and some other implementation in development/testing. If you want you could even reuse <code>Ecto.Repo</code> as the needed behaviour, as ecto already has a behaviour in front of the actual implementation within the library.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121655" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-practices-umbrella-app-with-multiple-repos/21113/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-121655" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121655"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="121732" data-post-id="121732">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="fireproofsocks" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fireproofsocks/120/7669_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  fireproofsocks
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, some abstraction here would be helpful…</p>
<p>Let’s say my umbrella has some apps that require a PostGres Repo and some apps require a MySQL Repo.  Instead of the <code>application.ex</code> having something like <code>supervisor(AppOne.Repo, []),</code> I could instead create a couple dedicated apps under the umbrella for <code>PostGres.Repo</code> and <code>MySQL.Repo</code> and then in <code>app_one</code> I could define a config something like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">config :app_one, repo: PostGres.Repo
</code></pre>
<p>And then I could reference it in my contexts something like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule AppOne.Contexts.SomethingContext do
  
  import Ecto.Query, warn: false

  @repo Application.get_env(:app_one, :repo)
  
  alias AppOne.Schemas.Something


  def get(id), do: @repo.get(id)

end
</code></pre>
<p>I think that will work and provide useful abstraction.  Is that what you were thinking?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121732" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/best-practices-umbrella-app-with-multiple-repos/21113/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-121732" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121732"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>