Add deployment

This commit is contained in:
2023-11-26 22:23:19 +00:00
parent 3b0ee83188
commit c12ded9318
13 changed files with 228 additions and 3 deletions

View File

@@ -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)

View File

@@ -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
View 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