Skip to content

Commit

Permalink
Run migration before starting application
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Mar 30, 2023
1 parent bc9b1b2 commit c86de31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/archethic/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ defmodule Archethic.Application do

alias Archethic.Metrics.MetricSupervisor, as: MetricSupervisor

alias Mix.Tasks.Archethic.Migrate

require Logger

def start(_type, _args) do
Expand Down Expand Up @@ -102,6 +104,10 @@ defmodule Archethic.Application do
Supervisor.start_link(Utils.configurable_children(children), opts)
end

def start_phase(:migrate, :normal, _options) do
Application.spec(:archethic, :vsn) |> Migrate.run()
end

defp try_open_port(nil), do: :ok

defp try_open_port(conf) do
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ defmodule Archethic.MixProject do
:xmerl,
:crypto
],
mod: {Archethic.Application, []}
mod: {Archethic.Application, []},
start_phases: [migrate: []]
]
end

Expand Down

0 comments on commit c86de31

Please sign in to comment.