Created a flag for disabling ash_paper_trail#228
Merged
zachdaniel merged 3 commits intoash-project:mainfrom Feb 13, 2026
Merged
Created a flag for disabling ash_paper_trail#228zachdaniel merged 3 commits intoash-project:mainfrom
zachdaniel merged 3 commits intoash-project:mainfrom
Conversation
of versioning for a specific action at runtime
zachdaniel
reviewed
Feb 11, 2026
| else | ||
| changeset | ||
| end | ||
| create_new_version(changeset) |
Contributor
There was a problem hiding this comment.
We should leave this logic here. We can add an additional check inside of the after_action callback.
Contributor
Author
There was a problem hiding this comment.
Sounds good, I will go in and make these changes and commit them soon
the flag to the after_action callback so that it works for both the action and the call site.
dallingson
commented
Feb 12, 2026
|
|
||
| @impl true | ||
| def change(changeset, _, _) do | ||
| create_new_version(changeset) |
Contributor
Author
There was a problem hiding this comment.
Here are the changes... did I get this right? Let me know if there is anything else I need to change.
zachdaniel
reviewed
Feb 12, 2026
| defp create_new_version(changeset) do | ||
| Ash.Changeset.after_action(changeset, fn changeset, result -> | ||
| changed? = changed?(changeset, result) | ||
| unless changeset.context[:ash_paper_trail_disabled?] do |
Contributor
There was a problem hiding this comment.
Lets switch to if, because unless is deprecated in newer elixir versions. Otherwise this looks great!
also fixed a typo in my tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add runtime flag to disable paper trail versioning per action
What
Adds a context flag
ash_paper_trail_disabled?so you can skip creating versions for specific actions.Why
There was no way to turn off versioning for migrations, imports, or other operations where you don't want audit history.
How to use
Option 1 – when calling the action:
Option 2 – on the action definition:
Changes
create_new_version.ex– Check the flag invalid_for_tracking?and run that check after all changes so both call-site and action-level usage work.should_record_version_for_action?/2andversion_context/1to remove duplication.Contributor checklist
Leave anything that you believe does not apply unchecked.