Created
February 22, 2026 06:48
-
-
Save navinpeiris/d9b011fe39c90b919fce71f7085cb74d to your computer and use it in GitHub Desktop.
test.exs config for branch specific db's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git_branch = | |
| case System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]) do | |
| {branch, 0} -> String.trim(branch) | |
| _ -> "" | |
| end | |
| db_suffix = | |
| if git_branch == "main" do | |
| "" | |
| else | |
| "_#{git_branch}" | |
| |> String.replace("/", "_") | |
| |> String.replace("-", "_") | |
| |> String.downcase() | |
| end | |
| db_suffix = "#{db_suffix}#{System.get_env("MIX_TEST_PARTITION")}" | |
| config :xyz, Xyz.Repo, | |
| username: "postgres", | |
| password: "postgres", | |
| hostname: "localhost", | |
| database: "xyz_test#{db_suffix}", | |
| pool: Ecto.Adapters.SQL.Sandbox, | |
| pool_size: System.schedulers_online() * 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment