forked from potsda.mn/mobilizon
Merge branch 'fix-migrations-without-starting-mbz' into 'main'
Fix: Don't start mobilizon server when running migrations Closes #743, #1166 et #1126 See merge request framasoft/mobilizon!1291
This commit is contained in:
commit
d8103fb1a5
|
@ -26,7 +26,9 @@ defmodule Mix.Tasks.Mobilizon.Ecto.Migrate do
|
||||||
migrations_path: :string
|
migrations_path: :string
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@app :mobilizon
|
||||||
@repo Mobilizon.Storage.Repo
|
@repo Mobilizon.Storage.Repo
|
||||||
|
@start_apps [:logger, :ssl, :postgrex, :ecto]
|
||||||
|
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Changes `Logger` level to `:info` before start migration.
|
Changes `Logger` level to `:info` before start migration.
|
||||||
|
@ -37,12 +39,12 @@ defmodule Mix.Tasks.Mobilizon.Ecto.Migrate do
|
||||||
mix mobilizon.ecto.migrate [OPTIONS]
|
mix mobilizon.ecto.migrate [OPTIONS]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
- see https://hexdocs.pm/ecto/2.0.0/Mix.Tasks.Ecto.Migrate.html
|
- see https://hexdocs.pm/ecto_sql/Mix.Tasks.Ecto.Migrate.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def run(args \\ []) do
|
def run(args \\ []) do
|
||||||
start_mobilizon()
|
load_app()
|
||||||
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
||||||
|
|
||||||
if Application.get_env(:mobilizon, @repo)[:ssl] do
|
if Application.get_env(:mobilizon, @repo)[:ssl] do
|
||||||
|
@ -68,4 +70,12 @@ defmodule Mix.Tasks.Mobilizon.Ecto.Migrate do
|
||||||
|
|
||||||
Logger.configure(level: level)
|
Logger.configure(level: level)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp load_app do
|
||||||
|
IO.puts("Loading app..")
|
||||||
|
Application.load(@app)
|
||||||
|
IO.puts("Starting dependencies..")
|
||||||
|
Enum.each(@start_apps, &Application.ensure_all_started/1)
|
||||||
|
if mix_task?(), do: Mix.Task.run("app.config")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue