From 0aa3d269a3c7aa3f34f850d3e27fe3900a6674e8 Mon Sep 17 00:00:00 2001 From: qdust41 Date: Fri, 3 Apr 2026 17:59:17 -0400 Subject: [PATCH] changing how we store the database information in the env file --- .env.example | 6 +++++- config/runtime.exs | 13 +++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 718f731..fb69604 100644 --- a/.env.example +++ b/.env.example @@ -5,7 +5,11 @@ PORT=4000 SECRET_KEY_BASE=REPLACE_WITH_64_CHAR_SECRET # generate with: mix phx.gen.secret # Database -DATABASE_URL=ecto://USER:PASSWORD@HOST/DATABASE +DB_USER=postgres +DB_PASS=postgres +DB_HOST=localhost +DB_NAME=mixer +DB_PORT=5432 ECTO_IPV6=false POOL_SIZE=10 diff --git a/config/runtime.exs b/config/runtime.exs index 05cd20d..7cfc3e7 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -23,18 +23,15 @@ end config :mixer, MixerWeb.Endpoint, http: [port: String.to_integer(System.get_env("PORT", "4000"))] if config_env() == :prod do - database_url = - System.get_env("DATABASE_URL") || - raise """ - environment variable DATABASE_URL is missing. - For example: ecto://USER:PASS@HOST/DATABASE - """ - maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] config :mixer, Mixer.Repo, # ssl: true, - url: database_url, + username: System.get_env("DB_USER") || raise("Missing environment variable `DB_USER`!"), + password: System.get_env("DB_PASS") || raise("Missing environment variable `DB_PASS`!"), + host: System.get_env("DB_HOST") || raise("Missing environment variable `DB_HOST`!"), + database: System.get_env("DB_NAME") || raise("Missing environment variable `DB_NAME`!"), + port: String.to_integer(System.get_env("DB_PORT", "5432")), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), # For machines with several cores, consider starting multiple pools of `pool_size` # pool_count: 4,