Open jfrolich opened 4 years ago
You can simply make 2 repo modules, one with use ExAudit.Repo
and the other with use Ecto.Repo
.
However, beware that each repo has their own connection pool
Yeah it's not as simple as that, as they have their own connection pool, configuration and migrations etc.
your secondary repo doesn't have to have migrations, and the config to both repos can be the same (even coming from the same variable in config.exs).
I agree, a seperate connection pool might be a problem.
You can alternatively call ExAudit.Schema.insert
, etc like this:
ExAudit.Schema.insert(MyRepo, MyRepo.get_dynamic_repo(), my_changeset, [])
ExAudit's wrapper around Ecto.Repo does nothing else really.
I'll consider defining a few important functions like insert, update, delete, history and rollback in the ExAudit
module so it can be used without modifying the repo.
Yes that would be great. I agree it's definitely a solution to have a separate Repo, but there are trade-offs and it would be great to have an explicit API to ExAudit that doesn't involve taking over the Repo module.
It would be great if we can use the modified Repo of
ex_audit
as a separate module that calls the original Repo, so it will not completely replace the Repo, something likeVersionedRepo
. If parts of the app are potentially versioned (for instance a CMS), and other parts are not (the user-facing app), as in our case, I'd like to not have the performance impact of versioning on the user-facing app when I know versioning is not involved there.