Setup database upfront rather than lazily

This commit is contained in:
José Valim 2024-04-10 23:43:22 +02:00
parent dc8b771408
commit b2eebcabbe
2 changed files with 15 additions and 10 deletions

View file

@ -145,7 +145,7 @@ defmodule Livebook.Hubs.TeamClientTest do
} = app_deployment}
# force app deployment to be deleted
erpc_call(node, :stop_app_deployment, [app_deployment.id, team.org_id])
erpc_call(node, :toggle_app_deployment, [app_deployment.id, team.org_id])
assert_receive {:app_deployment_stopped, ^app_deployment}
end

View file

@ -13,7 +13,20 @@ defmodule Livebook.TeamsServer do
def setup do
if available?() do
mix(%__MODULE__{}, ["compile"])
:ok =
mix(%__MODULE__{}, [
"do",
"compile",
"+",
"ecto.drop",
"--quiet",
"+",
"ecto.create",
"--quiet",
"+",
"ecto.migrate",
"--quiet"
])
end
end
@ -48,8 +61,6 @@ defmodule Livebook.TeamsServer do
@impl true
def handle_continue(:start_app, state) do
ensure_app_dir!()
prepare_database(state)
{:noreply, %{state | port: start_app(state)}}
end
@ -182,12 +193,6 @@ defmodule Livebook.TeamsServer do
"http://localhost:#{port}"
end
defp prepare_database(state) do
:ok = mix(state, ["ecto.drop", "--quiet"])
:ok = mix(state, ["ecto.create", "--quiet"])
:ok = mix(state, ["ecto.migrate", "--quiet"])
end
defp ensure_app_dir! do
dir = app_dir()