Skip to content

Commit

Permalink
Run migrations on application startup
Browse files Browse the repository at this point in the history
  - Gigalixir leverages distillery, and we don't have access to mix tasks in distillery releases
  - solution found at:
    - bitwalker/exrm#67 (comment)
      and
    - bitwalker/exrm#67 (comment)
  • Loading branch information
vanderhoop committed Mar 31, 2018
1 parent 5e4e78a commit f3306c1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/remote_retro.ex
@@ -1,5 +1,6 @@
defmodule RemoteRetro do
use Application
require Logger

# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
Expand All @@ -21,7 +22,15 @@ defmodule RemoteRetro do
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: RemoteRetro.Supervisor]
Supervisor.start_link(children, opts)

result = Supervisor.start_link(children, opts)

path_to_migrations = Path.join([:code.priv_dir(:remote_retro), "repo/migrations"])

Logger.info "Running migrations..."
Ecto.Migrator.run(RemoteRetro.Repo, path_to_migrations, :up, all: true)

result
end

# Tell Phoenix to update the endpoint configuration
Expand Down

0 comments on commit f3306c1

Please sign in to comment.