switch to sqlite, generate new project as 'quip'
This commit is contained in:
44
lib/quip/application.ex
Normal file
44
lib/quip/application.ex
Normal file
@@ -0,0 +1,44 @@
|
||||
defmodule Quip.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 = [
|
||||
QuipWeb.Telemetry,
|
||||
Quip.Repo,
|
||||
{Ecto.Migrator,
|
||||
repos: Application.fetch_env!(:quip, :ecto_repos),
|
||||
skip: skip_migrations?()},
|
||||
{DNSCluster, query: Application.get_env(:quip, :dns_cluster_query) || :ignore},
|
||||
{Phoenix.PubSub, name: Quip.PubSub},
|
||||
# Start the Finch HTTP client for sending emails
|
||||
{Finch, name: Quip.Finch},
|
||||
# Start a worker by calling: Quip.Worker.start_link(arg)
|
||||
# {Quip.Worker, arg},
|
||||
# Start to serve requests, typically the last entry
|
||||
QuipWeb.Endpoint
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Quip.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
|
||||
QuipWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
|
||||
defp skip_migrations?() do
|
||||
# By default, sqlite migrations are run when using a release
|
||||
System.get_env("RELEASE_NAME") != nil
|
||||
end
|
||||
end
|
3
lib/quip/mailer.ex
Normal file
3
lib/quip/mailer.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule Quip.Mailer do
|
||||
use Swoosh.Mailer, otp_app: :quip
|
||||
end
|
28
lib/quip/release.ex
Normal file
28
lib/quip/release.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
defmodule Quip.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :quip
|
||||
|
||||
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/quip/repo.ex
Normal file
5
lib/quip/repo.ex
Normal file
@@ -0,0 +1,5 @@
|
||||
defmodule Quip.Repo do
|
||||
use Ecto.Repo,
|
||||
otp_app: :quip,
|
||||
adapter: Ecto.Adapters.SQLite3
|
||||
end
|
Reference in New Issue
Block a user