Closed rodrigues closed 1 year ago
Paper trail fails to create a new version when the application has UUID as migration primary key type:
UUID
config :xyz, XYZ.Repo, migration_primary_key: [type: :binary_id]
** (Postgrex.Error) ERROR 23502 (not_null_violation) null value in column "id" of relation "versions" violates not-null constraint table: versions column: id Failing row contains (null, insert, XYZ, 9a955fe1-74db-4038-aaa5-d3a6390036cf, {"id": "9a955fe1-74db-4038-aaa5-d3a6390036cf", "etc": null, "..., null, xyz, {}, 2023-09-07 09:23:50).
With this PR, we can store versions with autogenerated UUIDs as ids:
config :paper_trail, repo: XYZ.Repo, version_primary_key: {:id, Ecto.UUID, autogenerate: true}
version #=> %PaperTrail.Version{ __meta__: #Ecto.Schema.Metadata<:loaded, "versions">, id: "ab1bfacf-e2f7-4d7d-b1ba-fa8dbfefeace", event: "update", item_type: ...
Do you think this approach makes sense?
Cheers!
Paper trail fails to create a new version when the application has
UUID
as migration primary key type:With this PR, we can store versions with autogenerated UUIDs as ids:
Do you think this approach makes sense?
Cheers!