hectorsq
I am developing an umbrella application with one ecto app and multiple web apps. This application has to run against mssql and postgres.
Currently, I have two deps functions inside each app, one for postgres and the other for mssql.
When I want to change the database, I have to change by hand the call to deps from deps(:postgres) to deps(:mssql) in all my mix.exs files.
I want to use targets so I have changed my deps function to something like this:
defp deps() do
[
{:phoenix, "~> 1.4.0"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_ecto, "~> 4.0", targets: :postgres},
{:phoenix_ecto, "~> 3.0", targets: :mssql},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:medik_ecto, in_umbrella: true}
]
end
However, I am stuck because I do not how to handle the environment variable when I run MIX_TARGET=postgres mix deps.get from the command line.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
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
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hectorsq
I get the following error:
cohawk
I was unaware of and haven’t used targets yet, but taking a quick look it appears in your deps() you should use
target:instead of pluraltargets:?hectorsq
I tried using target: with no success
cohawk
What version of Elixir are you running? And do you have an example repo online to try and reproduce?
I had a need for this a while ago, but worked around it - so I am kind of blindly making suggestions. I will try to reimplement this afternoon in a project of mine and let you know here what I find.
hectorsq
@cohawk I am using Elixir 1.8.1.
I will create an example repo as soon as possible.
Thank you!
cohawk
Thanks for the reminder - got kinda busy today
No need to create an example repo - it’s easily enough reproducible.
So the digging around the
Mix.targetPR commit: Introduce Mix.target (#8443) · elixir-lang/elixir@2e576f6 · GitHubtargets:is the correct syntax (since you can also pass a listtargets: [:postgres, :absinthe]). I think before I was looking at some pre-merged code.Anyways:
is the correct syntax to fetch target deps instead of
MIX_TARGET=postgres mix deps.getAnd with that it does give us a couple warnings:
But it does appear to pull the correct target version:
and then for the mssql target:
and then confirm with the target deps.tree:
Then you execute using the
MIX_TARGETvariable:and where I thought it would get murky about remembering the version from which target I had last fetched the deps for, it reminds you at compile time:
Good stuff.
hectorsq
@cohawk, I appreciate a lot your support.
Where is what I’ve done..
I added an
IO.inspect(Mix.target())inside each of my deps functions. I have multiple functions because I am working in an umbrella project.Running mix deps.get using an environment variable I get
or
However when I pass the target as an option
In any case I always get the same error:
I will test on a non umbrella project over the weekend.
cohawk
You have
targetsinstead oftarget- from the CLI you can only setup for a single target.:host is the default target when you do not set the
targetflagYou want:
hectorsq
cohawk
Yeah, you might be right that the ‘target’ does not propagate through umbrella apps.
Here is my repo from the tests in the above posts - GitHub - cohawk/phx_targets_test: Introduce `Mix.target` test - https://github.com/elixir-lang/elixir/issues/8063 · GitHub
I can try with an umbrella app sometime this weekend - time permitting.
Cheers