only start automigrator in prod env

This commit is contained in:
shibao 2022-01-22 20:12:32 -05:00 committed by oliviasculley
parent 3674eeaf5a
commit 46eed25a94
3 changed files with 11 additions and 3 deletions

View File

@ -20,6 +20,8 @@ config :lokal, LokalWeb.Endpoint,
pubsub_server: Lokal.PubSub, pubsub_server: Lokal.PubSub,
live_view: [signing_salt: "zOLgd3lr"] live_view: [signing_salt: "zOLgd3lr"]
config :lokal, Lokal.Application, automigrate: false
# Configures the mailer # Configures the mailer
# #
# By default it uses the "Local" adapter which stores the emails # By default it uses the "Local" adapter which stores the emails

View File

@ -18,6 +18,8 @@ config :lokal, Lokal.Repo,
url: "ecto://postgres:postgres@localhost/lokal", url: "ecto://postgres:postgres@localhost/lokal",
pool_size: 10 pool_size: 10
config :lokal, Lokal.Application, automigrate: true
# Do not print debug messages in production # Do not print debug messages in production
config :logger, level: :info config :logger, level: :info

View File

@ -15,13 +15,17 @@ defmodule Lokal.Application do
# Start the PubSub system # Start the PubSub system
{Phoenix.PubSub, name: Lokal.PubSub}, {Phoenix.PubSub, name: Lokal.PubSub},
# Start the Endpoint (http/https) # Start the Endpoint (http/https)
LokalWeb.Endpoint, LokalWeb.Endpoint
# Start a worker by calling: Lokal.Worker.start_link(arg) # Start a worker by calling: Lokal.Worker.start_link(arg)
# {Lokal.Worker, arg} # {Lokal.Worker, arg}
# Automatically migrate on start
Lokal.Repo.Migrator
] ]
# Automatically migrate on start in prod
children =
if Application.get_env(:lokal, Lokal.Application, automigrate: false)[:automigrate],
do: children ++ [Lokal.Repo.Migrator],
else: children
# See https://hexdocs.pm/elixir/Supervisor.html # See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options # for other strategies and supported options
opts = [strategy: :one_for_one, name: Lokal.Supervisor] opts = [strategy: :one_for_one, name: Lokal.Supervisor]