Skip to content

Commit

Permalink
Allow to configure Originator Field Options
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Oct 26, 2020
1 parent 675d502 commit 4f7de25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions lib/version.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4f7de25

Please sign in to comment.