How to use AshPostgres when our repo already uses Appsignal.Ecto.Repo?

Our Repo is already defined like this. How to make it use also the AshPostgres.Repo? Thank you. :slight_smile:

defmodule MyApp.Repo do
  use Appsignal.Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Postgres

I would do use AshPostgres, then just add in the things the app signal repo does in their use macro.

1 Like

There is an undocumented option (that we should document) called

define_ecto_repo?

use Appsignal.Repo, adapter: ..., otp_app: :otp_app

use AshPostgres.Repo, define_ecto_repo?: false

the relevant code:

  if Keyword.get(opts, :define_ecto_repo?, true) do
    otp_app = opts[:otp_app] || raise("Must configure OTP app")

    use Ecto.Repo,
      adapter: opts[:adapter] || Ecto.Adapters.Postgres,
      otp_app: otp_app
  end

A PR to document it would be very welcome :heart:

4 Likes