From 4f7de256d6c329cd9aeafd426c76d50075e9392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Mon, 26 Oct 2020 16:42:19 +0000 Subject: [PATCH] Allow to configure Originator Field Options --- README.md | 3 ++- lib/version.ex | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e601eda6..d90a5fc7 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,8 @@ the PaperTrail.Version schema to use it. ```elixir config :paper_trail, item_type: Ecto.UUID, - originator_type: Ecto.UUID + originator_type: Ecto.UUID, + originator_options: [references: :uuid] ``` Remember to edit the types accordingly in the generated migration. diff --git a/lib/version.ex b/lib/version.ex index f4234c1c..dd454042 100644 --- a/lib/version.ex +++ b/lib/version.ex @@ -25,9 +25,11 @@ defmodule PaperTrail.Version do belongs_to( PaperTrail.RepoClient.originator()[:name], PaperTrail.RepoClient.originator()[:model], - define_field: false, - foreign_key: :originator_id, - type: Application.get_env(:paper_trail, :originator_type, :integer) + Keyword.merge(Application.get_env(:paper_trail, :originator_options, []), + define_field: false, + foreign_key: :originator_id, + type: Application.get_env(:paper_trail, :originator_type, :integer) + ) ) end