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

Support for multi schema versioning #39

Open
adolfosilva opened this issue May 13, 2020 · 2 comments
Open

Support for multi schema versioning #39

adolfosilva opened this issue May 13, 2020 · 2 comments

Comments

@adolfosilva
Copy link

adolfosilva commented May 13, 2020

Hi!

I have a need to track changes of entities in different schemas.

Currently, we define version_schema in config :ex_audit. But this forces a single version table in a given schema. Is there a way to have multiple version tables, one per schema?

Is this something of interest to somebody else?

Thanks for all the hard work.

@narrowtux
Copy link
Contributor

I have thought of this as well, mainly to be able to track schemas that have a different set of primary keys (for example the intermediate tables in many-to-many relationships).

I'd have to think about it a little more, but feel free to come up with suggestions!

@adolfosilva
Copy link
Author

adolfosilva commented May 28, 2020

My original use case was to track tables on multiple Postgres schemas.

I was thinking of moving the responsibility of tracking to the schemas themselves. We could still have a default version schema defined via configuration but the onus of deciding which schemas to track would be left to the schemas.

e.g:

config :ex_audit,  version_schema: MyApp.Version
defmodule MyApp.User do
  use Ecto.Schema

  use ExAudit.Track, with: MyApp.UserVersion

  schema "users" do
    field :email, :string
    field :name, :string

    timestamps()
  end
end

MyApp.UserVersion would set @schema_prefix to whatever the user wanted.

This of course does not address your comment about composite primary keys but it would lay the foundation for such work. This change would be a major rewrite so I don't know if you're interested.

Do you see any compatibility problems with the other features currently provided?

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

No branches or pull requests

2 participants