only automigrate in prod env

This commit is contained in:
shibao 2022-01-22 20:16:19 -05:00
parent 820ceed6bb
commit 7567281449
3 changed files with 12 additions and 4 deletions

View File

@ -21,6 +21,8 @@ config :cannery, CanneryWeb.Endpoint,
live_view: [signing_salt: "zOLgd3lr"],
registration: System.get_env("REGISTRATION") || "invite"
config :cannery, Cannery.Application, automigrate: false
config :cannery, :generators,
migration: true,
binary_id: true,

View File

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

View File

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