This commit is contained in:
2026-07-04 19:27:17 +09:00
parent 34cd5ad2e7
commit ba6a0b2c17
30 changed files with 2935 additions and 247 deletions
+14 -5
View File
@@ -1,15 +1,24 @@
import Config
# Configure your database
# Configure your database.
#
# The connection is read from the DATABASE_URL environment variable (see .env)
# when present, otherwise it falls back to a local Postgres instance.
config :rsh26pool, Rsh26pool.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "rsh26pool_dev",
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10
if url = System.get_env("DATABASE_URL") do
config :rsh26pool, Rsh26pool.Repo, url: url
else
config :rsh26pool, Rsh26pool.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "rsh26pool_dev"
end
# For development, we disable any cache and enable
# debugging and code reloading.
#
+40 -7
View File
@@ -5,13 +5,46 @@ import Config
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more information.
config :rsh26pool, Rsh26pool.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "rsh26pool_test#{System.get_env("MIX_TEST_PARTITION")}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
#
# When DATABASE_URL is set (see .env) we reuse its server but connect to a
# dedicated "<db>_test" database so tests never touch development data.
partition = System.get_env("MIX_TEST_PARTITION")
if url = System.get_env("DATABASE_URL") do
uri = URI.parse(url)
{username, password} =
case uri.userinfo do
nil ->
{"postgres", "postgres"}
info ->
case String.split(info, ":", parts: 2) do
[u, p] -> {u, p}
[u] -> {u, nil}
end
end
base = uri.path |> to_string() |> String.trim_leading("/")
base = if base == "", do: "rsh26pool", else: base
config :rsh26pool, Rsh26pool.Repo,
username: username,
password: password,
hostname: uri.host || "localhost",
port: uri.port || 5432,
database: "#{base}_test#{partition}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
else
config :rsh26pool, Rsh26pool.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "rsh26pool_test#{partition}",
pool: Ecto.Adapters.SQL.Sandbox,
pool_size: System.schedulers_online() * 2
end
# We don't run a server during test. If one is required,
# you can enable the server option below.