Initial Phoenix App with Fly.io
This commit is contained in:
36
lib/osuuspuutarha/application.ex
Normal file
36
lib/osuuspuutarha/application.ex
Normal file
@@ -0,0 +1,36 @@
|
||||
defmodule Osuuspuutarha.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
# Start the Ecto repository
|
||||
Osuuspuutarha.Repo,
|
||||
# Start the Telemetry supervisor
|
||||
OsuuspuutarhaWeb.Telemetry,
|
||||
# Start the PubSub system
|
||||
{Phoenix.PubSub, name: Osuuspuutarha.PubSub},
|
||||
# Start the Endpoint (http/https)
|
||||
OsuuspuutarhaWeb.Endpoint
|
||||
# Start a worker by calling: Osuuspuutarha.Worker.start_link(arg)
|
||||
# {Osuuspuutarha.Worker, arg}
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Osuuspuutarha.Supervisor]
|
||||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
# Tell Phoenix to update the endpoint configuration
|
||||
# whenever the application is updated.
|
||||
@impl true
|
||||
def config_change(changed, _new, removed) do
|
||||
OsuuspuutarhaWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
3
lib/osuuspuutarha/mailer.ex
Normal file
3
lib/osuuspuutarha/mailer.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule Osuuspuutarha.Mailer do
|
||||
use Swoosh.Mailer, otp_app: :osuuspuutarha
|
||||
end
|
||||
28
lib/osuuspuutarha/release.ex
Normal file
28
lib/osuuspuutarha/release.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
defmodule Osuuspuutarha.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :osuuspuutarha
|
||||
|
||||
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
|
||||
5
lib/osuuspuutarha/repo.ex
Normal file
5
lib/osuuspuutarha/repo.ex
Normal file
@@ -0,0 +1,5 @@
|
||||
defmodule Osuuspuutarha.Repo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :osuuspuutarha,
|
||||
adapter: Ecto.Adapters.Postgres
|
||||
end
|
||||
Reference in New Issue
Block a user