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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="idi527" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  idi527
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Can you give an example how that would  work with phoneix pubsub? I have searched the forum but couldn’t find one.</p>
<p>Ideally, I wish I could put phoenix pubsub in it’s own app <code>apps/pubsub</code> and point <code>apps/web</code> to it.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">config :web, Test.Web.Endpoint,
  url: [host: "localhost"],
  secret_key_base: "...",
  render_errors: [view: Test.Web.ErrorView, accepts: ~w(html json)],
  pubsub: [app: :pubsub] # where :pubsub is an app in umbrella
</code></pre>
<p>The problem I’m having with pubsub being in <code>apps/web</code> is that I can’t be sure that <code>Test.Web.Endpoint</code> is loaded when I make a call to it like <code>Test.Web.Endpoint.subscribe</code> from some other app like <code>apps/user</code>.</p>
<p>And if I am to use <code>Phoenix.PubSub.subscribe</code> from inside <code>apps/user</code>, then that (I think) requires me to add <code>phoenix_pubsub</code> as a dependency to <code>apps/user</code>.</p>
<p>Now that I think about it, it might be better to leave phoenix pubsub to deal with websockets and the like, and either write a global distributed registry/pubsub myself or use something like swarn [0]. Not sure though.</p>
<p>I am also not sure how some things are implemented in phoenix pubsub (I’ve been planning to read it, but I’m afraid I don’t know elixir well enough to understand it fully), for example, does it batch messages when passing between nodes or not? Because it seems it can be somewhat of a bottleneck [1] if every message is sent with <code>send</code>.</p>
<p>[0] <a href="https://github.com/bitwalker/swarm" class="inline-onebox" rel="noopener nofollow ugc">GitHub - bitwalker/swarm: Easy clustering, registration, and distribution of worker processes for Erlang/Elixir · GitHub</a><br>
[1] <a href="http://www.ostinelli.net/boost-message-passing-between-erlang-nodes/" rel="noopener nofollow ugc">http://www.ostinelli.net/boost-message-passing-between-erlang-nodes/</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="30746" 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/how-to-determine-contexts-with-phoenix-1-3/4367/63">Post #62</a>
	                </div>
	            </div>
              <div id="likers-container-30746" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="30746"
                     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 #62"></div>
  </section>
</div>
    <div class="postbit" id="30749" data-post-id="30749">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Something on the following should work:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def MyApp.MyPubSubListener do
  use GenServer
  alias Phoenix.PubSub

  def publish(what), do: PubSub.broadcast SomeName, "channel_to_send_receive_messages", what

  # Callbacks

  def init() do
    PubSub.subscribe SomeName, self, "channel_to_send_receive_messages"
    {:ok, %{}} # The initial state of this GenServer.
  end

  def handle_info(message, state) do
    #  ... do something with your message/state ...

    {:no_reply, state}
  end
end
</code></pre>
<p>That should do the trick. Do not forget to start it in a supervision tree of sorts. And remember to create one for each channel/topic you want to subscribe.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="30749" 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/how-to-determine-contexts-with-phoenix-1-3/4367/64">Post #63</a>
	                </div>
	            </div>
              <div id="likers-container-30749" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="30749"
                     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 #63"></div>
  </section>
</div>
    <div class="postbit" id="33094" data-post-id="33094">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="LostKobrakai" data-post="28" data-topic="4367">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>I’m simply passing the current user into the ticketing context and it’s retrieving the needed data of of the struct. So there’s not really interdependency between the contexts</p>
</blockquote>
</aside>
<p>So what happen when you want to change the database user schema? Since individual user schemas are all over the contexts and you don’t have a single point of truth, will that become a headache when you introduce changes to these denormalized schemas?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="33094" 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/how-to-determine-contexts-with-phoenix-1-3/4367/65">Post #64</a>
	                </div>
	            </div>
              <div id="likers-container-33094" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="33094"
                     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 #64"></div>
  </section>
</div>
    <div class="postbit" id="33105" data-post-id="33105">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Posted by <a class="mention" href="/u/michalmuskala" rel="nofollow">@michalmuskala</a> earlier:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://michal.muskala.eu/2017/05/16/putting-contexts-in-context.html">
  <header class="source">
      <img src="https://michal.muskala.eu/images/favicon.svg" class="site-icon" alt="" width="32" height="32">

      <a href="https://michal.muskala.eu/2017/05/16/putting-contexts-in-context.html" target="_blank" rel="noopener nofollow" title="09:09AM - 16 May 2017">Michał Muskała – 16 May 17</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/459;"><img src="https://michal.muskala.eu/images/sunbeam-2761911_1280.jpg" class="thumbnail" alt="" width="690" height="459"></div>

<h3><a href="https://michal.muskala.eu/2017/05/16/putting-contexts-in-context.html" target="_blank" rel="noopener nofollow">Putting Contexts in Context | Michał Muskała</a></h3>

  <p>The recent changes around Phoenix 1.3, especially the introduction of contexts, seem to be confusing for many - I decided to write a bit more about my perspective on this, and hopefully, remove a bit of the confusion.
The initial draft of this post...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="33105" 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/how-to-determine-contexts-with-phoenix-1-3/4367/66">Post #65</a>
	                </div>
	            </div>
              <div id="likers-container-33105" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="33105"
                     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 #65"></div>
  </section>
</div>
    <div class="postbit" id="33124" data-post-id="33124">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="ivawzh" data-post="65" data-topic="4367" 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/ivawzh/48/35884_2.png" class="avatar"> ivawzh:</div>
<blockquote>
<aside class="quote no-group" data-username="LostKobrakai" data-post="28" data-topic="4367">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lostkobrakai/48/3072_2.png" class="avatar"> LostKobrakai:</div>
<blockquote>
<p>I’m simply passing the current user into the ticketing context and it’s retrieving the needed data of of the struct. So there’s not really interdependency between the contexts</p>
</blockquote>
</aside>
<p>So what happen when you want to change the database user schema? Since individual user schemas are all over the contexts and you don’t have a single point of truth, will that become a headache when you introduce changes to these denormalized schemas?</p>
</blockquote>
</aside>
<p>I believe that it is important to delineate the difference between a <em>normalized</em> data model, a <em>denormalized</em> data model, a <em>document-oriented</em> data model and a <em>segregated</em> data model.</p>
<p><strong>Normalized</strong>: This is the ‘old school’ approach to creating relational database structures, where fields are stored in separate tables and relations between them (such as JOINS) are used to gather the data combination(s) your application might desire.</p>
<p><strong>Denormalized</strong>: Opposed to a normalized relational database, certain pieces of data are replicated in multiple tables, making sure that no inter-table queries are necessary, resulting in faster read speeds, but slower write speeds and a more complicated structure for the developer to maintain (making sure the copies of the data all stay up-to-date).</p>
<p><strong>Document oriented</strong>: Every ‘user’ might have different fields in the database, and care must be taken to handle missing fields. This is the storage approach that some NoSQL databases take.</p>
<p><strong>Segregated</strong>: Here, there is no single point of truth, but this also means that there is no ‘the database user schema’. The different contexts store different aspects of your user, which are referenced by the same symbolic identifier (which might be a UUID, for instance). The outside world does <em>not</em> care about the persistence layer that the different contexts use to store/retrieve their information from. We therefore might be talking about multiple different kinds of databases alltogether!<br>
Of course, when your contexts are separated in a logical fashion (note, YMMV; exactly how to structure your contexts is very application-specific), there will be one context handling general user info, one context handling e.g. the set of products the user manages, one context handling the forum that is part of your app, etc. This means that only the ‘user context’ needs to know about most changes in your user, with the other contexts only knowing about the user’s UUID, and maybe from time to time asking the ‘user context’ if the specific user is authorized to perform a certain action.</p>
<p>So, to answer your question: If your separation of contexts is logical, then this will not become a headache.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="33124" 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/how-to-determine-contexts-with-phoenix-1-3/4367/67">Post #66</a>
	                </div>
	            </div>
              <div id="likers-container-33124" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="33124"
                     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 #66"></div>
  </section>
</div>
    <div class="postbit" id="33267" data-post-id="33267">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Qqwy" data-post="67" data-topic="4367">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/48/1349_2.png" class="avatar"> Qqwy:</div>
<blockquote>
<p>will that become a headache when you introduce changes to these denormalized schemas?</p>
</blockquote>
</aside>
<p>Now I look back, I may or may not have expressed myself correctly. My question could be rephrased to “will that become a headache when you introduce changes to these <strong>fragmented</strong> schemas?”</p>
<p>But your reply kind of also answered this question already. Thanks!</p>
<p>I still have some confusions about contextual schema. Guess it’s quite off topic, so I post a separate question at <a href="https://forum.elixirforum.com/t/contextual-schema-vs-non-contextual-schema-in-phoenix-1-3/5130" class="inline-onebox" rel="nofollow">Contextual schema VS out-of-context schema (in Phoenix 1.3)</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="33267" 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/how-to-determine-contexts-with-phoenix-1-3/4367/68">Post #67</a>
	                </div>
	            </div>
              <div id="likers-container-33267" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="33267"
                     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 #67"></div>
  </section>
</div>
    <div class="postbit" id="34387" data-post-id="34387">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/chrismccord" rel="nofollow">@chrismccord</a> Thank  you and the rest of the contributors for all your work. Elixir / Phoenix is what got me a taste of FP, and I’ve been trying to learn that style of programming ever since.</p>
<p>Now, on to my actual contribution to this thread. I got very lucky when I started learning Phoenix to have happened on <a href="https://www.youtube.com/watch?v=lDKCSheBc-8" rel="noopener nofollow ugc">Lance’s Phoenix is Not Your Application</a> talk before I even knew what Phoenix was. (Not really but you get what I am saying). I keep harping on Lance’s talk as well as <a href="https://www.youtube.com/watch?v=6NTmUQClHrU" rel="noopener nofollow ugc">Wojtek’s talk on umbrellas</a>. Because I built my app this way, I can update to Phoenix 1000 without breaking a sweat.</p>
<p>So, <strong>personally</strong>, I think I would always go the umbrella route. (And I gotta check this <code>--umbrella</code> flag you mentioned). Nonetheless, I commend the Phoenix folks for taking on a lot of work, likely a lot of flak, and nudging end-users to move closer to the umbrella ideal.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="34387" 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/how-to-determine-contexts-with-phoenix-1-3/4367/69">Post #68</a>
	                </div>
	            </div>
              <div id="likers-container-34387" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="34387"
                     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 #68"></div>
  </section>
</div>
    <div class="postbit" id="36311" data-post-id="36311">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="smithaitufe" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  smithaitufe
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/karmajunkie" rel="nofollow">@karmajunkie</a> Thanks for the example you gave. Can you provide a simple sample in GitHub that less experienced programmers like us in elixir can look at?</p>
<p>For me, the truth is using phx is more difficult than Phoenix.</p>
<p>I have not been able to grasp things like handling relationship across context.</p>
<p>I live in my own world here in Nigeria and I have only found one person other than me using elixir. Samples can make things easier for me</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="36311" 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/how-to-determine-contexts-with-phoenix-1-3/4367/70">Post #69</a>
	                </div>
	            </div>
              <div id="likers-container-36311" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="36311"
                     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 #69"></div>
  </section>
</div>
    <div class="postbit" id="38690" data-post-id="38690">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="smithaitufe" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  smithaitufe
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Of importance is how to handle relationships between models.<br>
How do you handle 1:M relationships?<br>
What if a model in a context say A requires certain data available in another model in a different context B?<br>
How do you ensure data integrity, such that changes made to a model A in context A is propagated to model A in context B?</p>
<p>Please your prompt response is highly appreciated</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="38690" 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/how-to-determine-contexts-with-phoenix-1-3/4367/71">Post #70</a>
	                </div>
	            </div>
              <div id="likers-container-38690" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="38690"
                     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 #70"></div>
  </section>
</div>
    <div class="postbit" id="38731" data-post-id="38731">
  <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">
								<blockquote>
<p>What if a model in a context say A requires certain data available in another model in a different context B?</p>
</blockquote>
<p>There’s no correct answer to that question. It’s just the perfect place to ask yourself, why you need to cross those context boundries.</p>
<p>E.g. if one context is the help desk and another one is the sales department then it’s quite strange that one does need to depend on a struct of the other. In that case I’d add a new schema to the help desk requesting just the data the help desk does require from the db (multiple schemas of the same table are no problem in ecto).</p>
<p>If one context is the checkout context and the other your auth context holding the current user and it’s shopping cart, than it’s a relation, which feels quite natural. I personally wouldn’t split that up into multiple context based schemas.</p>
<p>It has to be weighed if it’s better to add more code, but have the ability to evolve both contexts independently (probably the better choice for bigger projects / bigger teams) or to keep things lightweight and use some relations beyond context boundries if they make sense.</p>
<blockquote>
<p>How do you ensure data integrity, such that changes made to a model A in context A is propagated to model A in context B?</p>
</blockquote>
<p>With ecto it’s first and foremost the db. If you query your tables you’ll get the updated data of them. As mentioned above you can have multiple schemas handle the same tables. Everything beyond that is in your own hands, like it was before contexts as well (e.g. two simultaneous update requests might overwrite the first one).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="38731" 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/how-to-determine-contexts-with-phoenix-1-3/4367/72">Post #71</a>
	                </div>
	            </div>
              <div id="likers-container-38731" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="38731"
                     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 #71"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/4367/load_more?page=8">Load more posts (6 remaining)</a>
</div></template></turbo-stream>