Skip to content

Commit 904b3fa

Browse files
authored
fix: Remove a postgresql specific configuration from ash_sqlite.install (#103)
1 parent c755ff9 commit 904b3fa

File tree

2 files changed

+12
-64
lines changed

2 files changed

+12
-64
lines changed

lib/data_layer.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ defmodule AshSqlite.DataLayer do
357357
end
358358
end
359359

360-
Mix.Task.run("ash_postgres.rollback", args ++ ["-r", inspect(repo), "-n", to_string(n)])
361-
Mix.Task.reenable("ash_postgres.rollback")
360+
Mix.Task.run("ash_sqlite.rollback", args ++ ["-r", inspect(repo), "-n", to_string(n)])
361+
Mix.Task.reenable("ash_sqlite.rollback")
362362
end
363363
end
364364

lib/mix/tasks/ash_sqlite.install.ex

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,7 @@ defmodule Mix.Tasks.AshSqlite.Install do
107107
import Config
108108
109109
if config_env() == :prod do
110-
database_url =
111-
System.get_env("DATABASE_URL") ||
112-
raise \"\"\"
113-
environment variable DATABASE_URL is missing.
114-
For example: ecto://USER:PASS@HOST/DATABASE
115-
\"\"\"
116-
117110
config #{inspect(otp_app)}, #{inspect(repo)},
118-
url: database_url,
119111
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
120112
end
121113
"""
@@ -142,63 +134,20 @@ defmodule Mix.Tasks.AshSqlite.Install do
142134
|> Igniter.Code.Common.move_to_cursor_match_in_scope(patterns)
143135
|> case do
144136
{:ok, zipper} ->
145-
case Igniter.Code.Function.move_to_function_call_in_current_scope(
146-
zipper,
147-
:=,
148-
2,
149-
fn call ->
150-
Igniter.Code.Function.argument_matches_pattern?(
151-
call,
152-
0,
153-
{:database_url, _, ctx} when is_atom(ctx)
154-
)
155-
end
156-
) do
157-
{:ok, _zipper} ->
158-
zipper
159-
|> Igniter.Project.Config.modify_configuration_code(
160-
[repo, :url],
161-
otp_app,
162-
{:database_url, [], nil}
163-
)
164-
|> Igniter.Project.Config.modify_configuration_code(
165-
[repo, :pool_size],
166-
otp_app,
167-
Sourceror.parse_string!("""
168-
String.to_integer(System.get_env("POOL_SIZE") || "10")
169-
""")
170-
)
171-
|> then(&{:ok, &1})
172-
173-
_ ->
174-
Igniter.Code.Common.add_code(zipper, """
175-
database_url =
176-
System.get_env("DATABASE_URL") ||
177-
raise \"\"\"
178-
environment variable DATABASE_URL is missing.
179-
For example: ecto://USER:PASS@HOST/DATABASE
180-
\"\"\"
181-
182-
config #{inspect(otp_app)}, Helpdesk.Repo,
183-
url: database_url,
184-
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
185-
""")
186-
end
137+
zipper
138+
|> Igniter.Project.Config.modify_configuration_code(
139+
[repo, :pool_size],
140+
otp_app,
141+
Sourceror.parse_string!("""
142+
String.to_integer(System.get_env("POOL_SIZE") || "10")
143+
""")
144+
)
145+
|> then(&{:ok, &1})
187146

188-
:error ->
147+
_ ->
189148
Igniter.Code.Common.add_code(zipper, """
190-
if config_env() == :prod do
191-
database_url =
192-
System.get_env("DATABASE_URL") ||
193-
raise \"\"\"
194-
environment variable DATABASE_URL is missing.
195-
For example: ecto://USER:PASS@HOST/DATABASE
196-
\"\"\"
197-
198149
config #{inspect(otp_app)}, Helpdesk.Repo,
199-
url: database_url,
200150
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
201-
end
202151
""")
203152
end
204153
end
@@ -213,7 +162,6 @@ defmodule Mix.Tasks.AshSqlite.Install do
213162
[repo, :database],
214163
"../path/to/your.db"
215164
)
216-
|> Igniter.Project.Config.configure_new("dev.exs", otp_app, [repo, :port], 5432)
217165
|> Igniter.Project.Config.configure_new(
218166
"dev.exs",
219167
otp_app,

0 commit comments

Comments
 (0)