ash_postgres/lib/repo.ex

31 lines
751 B
Elixir
Raw Normal View History

2020-05-31 17:51:41 +12:00
defmodule AshPostgres.Repo do
2020-06-04 17:27:26 +12:00
@moduledoc """
Resources that use the `AshPostgres` data layer use a `Repo` to access the database.
This repo is a slightly modified version of an ecto repo.
2020-06-04 17:27:26 +12:00
"""
2020-05-31 17:51:41 +12:00
@callback installed_extensions() :: [String.t()]
defmacro __using__(opts) do
quote bind_quoted: [opts: opts] do
otp_app = opts[:otp_app] || raise("Must configure OTP app")
use Ecto.Repo,
adapter: Ecto.Adapters.Postgres,
otp_app: otp_app
2020-06-03 14:47:41 +12:00
def installed_extensions do
2020-05-31 17:51:41 +12:00
[]
end
2020-06-28 07:11:28 +12:00
def init(_, config) do
2020-05-31 17:51:41 +12:00
new_config = Keyword.put(config, :installed_extensions, installed_extensions())
{:ok, new_config}
end
defoverridable installed_extensions: 0
end
end
end