Add deployment
This commit is contained in:
@@ -8,7 +8,7 @@ defmodule Wish.Accounts.UserNotifier do
|
||||
email =
|
||||
new()
|
||||
|> to(recipient)
|
||||
|> from({"Wish", "contact@example.com"})
|
||||
|> from({"Wish", "wish@danielpatterson.dev"})
|
||||
|> subject(subject)
|
||||
|> text_body(body)
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ defmodule Wish.Application do
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
Wish.Release.migrate()
|
||||
|
||||
children = [
|
||||
WishWeb.Telemetry,
|
||||
Wish.Repo,
|
||||
{Ecto.Migrator,
|
||||
repos: Application.fetch_env!(:wish, :ecto_repos),
|
||||
skip: skip_migrations?()},
|
||||
repos: Application.fetch_env!(:wish, :ecto_repos), skip: skip_migrations?()},
|
||||
{DNSCluster, query: Application.get_env(:wish, :dns_cluster_query) || :ignore},
|
||||
{Phoenix.PubSub, name: Wish.PubSub},
|
||||
# Start the Finch HTTP client for sending emails
|
||||
|
||||
28
lib/wish/release.ex
Normal file
28
lib/wish/release.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
defmodule Wish.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :wish
|
||||
|
||||
def migrate do
|
||||
load_app()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
Application.load(@app)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user