cloedu87
Hi There,
On the mission to find a ash friendly way to add versioning to my project. I found ash-paper-trail.
My requirements were:
- postgres compatible
- no additional database extensions
- testing friendly (no workaround to run tests)
- support to add versioning to single resources instead of all tables
- option to only store the attributes which changed
after browsing a bit through the forum I found this post which gave me a great idea of whats possible and I started using ash-paper-trail because it ticks all the boxes.
After setting up things and migrating the database, I faced errors while executing my tests:
** (Ash.Error.Invalid) Input Invalid
* Invalid value provided for version_source_id: got invalid prefixed term.
"rec_02vbruyKluKnzDyCkFExo8"
code: assert {:ok, %Record{} = _record} = Record.create(attrs)
stacktrace:
(ash 2.18.2) lib/ash/api/api.ex:2711: Ash.Api.unwrap_or_raise!/3
(ash_paper_trail 0.1.0) lib/resource/changes/create_new_version.ex:93: AshPaperTrail.Resource.Changes.CreateNewVersion.build_notifications/2
(ash_paper_trail 0.1.0) lib/resource/changes/create_new_version.ex:22: anonymous fn/2 in AshPaperTrail.Resource.Changes.CreateNewVersion.create_new_version/1
...
then I checked my resource definition:
...
use Ash.Resource,
data_layer: AshPostgres.DataLayer,
extensions: [
AshUUID,
AshPaperTrail.Resource
]
...
attributes do
uuid_attribute :id, prefix: "rec"
attribute :name, :string
attribute :description, :string
timestamps private?: false, writable?: false
end
paper_trail do
change_tracking_mode :changes_only
store_action_name? true
ignore_attributes [:inserted_at, :updated_at]
end
...
And I was wondering if the use of AshUUID and the prefixed primary key definition leads to the fact that I can’t use ash-paper-trail at all or if I missed the one hint to make it work in this case?
It would be really a shame if it would not work, because it’s such a smooth and nice integration compared to other solutions.
All the Best
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
zachdaniel
I think I see the issue. We aren’t properly copying the type of the attribute that we use for
version_source_id. Let me see what I can do.zachdaniel
okay, can you try out the
mainbranch ofash_paper_trail?cloedu87
oh wow… sure… I’ll try…
cloedu87
using
{:ash_paper_trail, github: "ash-project/ash_paper_trail", branch: "main"}: it seems to be still the same problem.thx anyway for jumping in so quickly!
well appriciated.
the resource I use, is very minimal, so from that side, no side effects should be expected:
Best, C.
cloedu87
checking the code you changed…
… shouldn’t there be a
attribute_type(first_pkey_attr_type)within thebelongs_todefinition to use the correct type for the related resource as well ?zachdaniel
This would configure that attribute:
zachdaniel
I’m surprised you have the same issue…is there a different stack trace?
zachdaniel
@rgraff may have an idea. As far as I can tell, the problem centers around incorrect constraints for that attribute. However, it could also be something that
uuid_attributeis doing strange, I’m not familiar with the inner workings of it.cloedu87
yes it’s exactly the same stack trace. but I can try searching in the direction of
uuid_attribute’s behavior, maybe I can find out something in this corner…Thanks anyway
rgraff
I’m pretty sure Zach’s on the right track. Since I’m not familiar with AshUUID, so this might take some trial and error.