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

[Feature Request / Looking for Solution] How to utilize Ecto's Multi + Create Version #48

Closed
stonehz opened this issue Jul 6, 2018 · 1 comment

Comments

@stonehz
Copy link

stonehz commented Jul 6, 2018

We are trying to find a way on how to wrap multiple updates on a transaction + build the version but not sure what would be the right approach.
We have the following scenario:

I have a user and address schema.
A user may have many addresses.
When someone updates their address, i would also like to update the user's 'last_updated_at' date field (in the user table).
We currently have wrapped both updates on a Multi and they will be executed in a transaction.
Now we want to introduce versioning on the User Model but we see 1-2 ways that can be done:

  1. Get access to private function make_version_struct (https://github.com/izelnakri/paper_trail/blob/master/lib/paper_trail.ex#L295 ) and add it on our existing multi (bypassing all other paper_trail logic which can not guarantee future-compatibility)
  2. Implement something like PaperTrail.multi? (that means that we need to provide which changesets are to be stored as versions or if the whole thing will be treated as one, etc)
@izelnakri
Copy link
Owner

Feel free to submit a pull request, I'm interested in the second approach!

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