I am following a phoenix book which says:
Be careful. The ecto.migrate task will migrate the database for your current environment. So far, we’ve been running the dev environment. To change the environment, you’d set the MIX_ENV operating-system environment variable.
But I dont know which is mi current environment, I print echo MIX_ENV variable and it's empty, how can I knowwhich environment I am in and/or change from environments?
If the MIX_ENV
environment variable is empty Mix.env
defaults to :dev
:
$ iex -S mix
> Mix.env
# => :dev
If you set MIX_ENV
to another existing environment (test or prod, then Mix.env
will return it:
$ MIX_ENV=test iex -S mix
> Mix.env
# => :test
There's no need to define another config.
To get something from your config use for example Application.get_env/2
:
Application.get_env(:your_app_name, YourAppName)[:adapter]
# => Ecto.Adapters.Postgres
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With