Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to use the original Repo #33

Open
jfrolich opened this issue Mar 4, 2020 · 5 comments
Open

A way to use the original Repo #33

jfrolich opened this issue Mar 4, 2020 · 5 comments

Comments

@jfrolich
Copy link

jfrolich commented Mar 4, 2020

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 like VersionedRepo. 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.

@narrowtux
Copy link
Contributor

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

@jfrolich
Copy link
Author

jfrolich commented Mar 4, 2020

Yeah it's not as simple as that, as they have their own connection pool, configuration and migrations etc.

@narrowtux
Copy link
Contributor

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.

@narrowtux
Copy link
Contributor

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.

@jfrolich
Copy link
Author

jfrolich commented Mar 6, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants