mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 13:03:14 +12:00
fix: properly add prod config in installer
This commit is contained in:
parent
5d9f2cd693
commit
384344ab6b
1 changed files with 28 additions and 27 deletions
|
@ -78,33 +78,34 @@ defmodule Mix.Tasks.AshPostgres.Install do
|
|||
|> Igniter.Code.Common.move_to_cursor_match_in_scope(patterns)
|
||||
|> case do
|
||||
{:ok, zipper} ->
|
||||
case Igniter.Code.Function.move_to_function_call_in_current_scope(
|
||||
zipper,
|
||||
:=,
|
||||
2,
|
||||
fn call ->
|
||||
Igniter.Code.Function.argument_matches_pattern?(
|
||||
call,
|
||||
0,
|
||||
{:database_url, _, ctx} when is_atom(ctx)
|
||||
)
|
||||
end
|
||||
) do
|
||||
{:ok, zipper} ->
|
||||
zipper
|
||||
|> Igniter.Project.Config.modify_configuration_code(
|
||||
[repo, :url],
|
||||
otp_app,
|
||||
{:database_url, [], nil}
|
||||
)
|
||||
|> Igniter.Project.Config.modify_configuration_code(
|
||||
[repo, :pool_size],
|
||||
otp_app,
|
||||
Sourceror.parse_string!("""
|
||||
String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
""")
|
||||
)
|
||||
|> then(&{:ok, &1})
|
||||
case Igniter.Code.Function.move_to_function_call_in_current_scope(
|
||||
zipper,
|
||||
:=,
|
||||
2,
|
||||
fn call ->
|
||||
Igniter.Code.Function.argument_matches_pattern?(
|
||||
call,
|
||||
0,
|
||||
{:database_url, _, ctx} when is_atom(ctx)
|
||||
)
|
||||
end
|
||||
) do
|
||||
{:ok, _zipper} ->
|
||||
zipper
|
||||
|> Igniter.Project.Config.modify_configuration_code(
|
||||
[repo, :url],
|
||||
otp_app,
|
||||
{:database_url, [], nil}
|
||||
)
|
||||
|> Igniter.Project.Config.modify_configuration_code(
|
||||
[repo, :pool_size],
|
||||
otp_app,
|
||||
Sourceror.parse_string!("""
|
||||
String.to_integer(System.get_env("POOL_SIZE") || "10")
|
||||
""")
|
||||
)
|
||||
|> then(&{:ok, &1})
|
||||
|
||||
_ ->
|
||||
Igniter.Code.Common.add_code(zipper, """
|
||||
database_url =
|
||||
|
|
Loading…
Reference in a new issue