You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/dsls/DSL-AshPaperTrail.Resource.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ A section for configuring how versioning is derived for the resource.
34
34
|[`relationship_opts`](#paper_trail-relationship_opts){: #paper_trail-relationship_opts } |`keyword`|| Options to pass to the has_many :paper_trail_versions relationship that is created on this resource. For example, `public?: true` to expose the relationship over graphql. See `d:Ash.Resource.Dsl.relationships.has_many`. |
35
35
|[`store_action_name?`](#paper_trail-store_action_name?){: #paper_trail-store_action_name? } |`boolean`|`false`| Whether or not to add the `version_action_name` attribute to the version resource. This is useful for auditing purposes. The `version_action_type` attribute is always stored. |
36
36
|[`store_action_inputs?`](#paper_trail-store_action_inputs?){: #paper_trail-store_action_inputs? } |`boolean`|`false`| Whether or not to add the `version_action_inputs` attribute to the version resource, which will store all attributes and arguments for the called action, redacting any sensitive values. This is useful for auditing purposes. The `version_action_inputs` attribute is always stored. |
37
+
|[`create_version_on_destroy?`](#paper_trail-create_version_on_destroy?){: #paper_trail-create_version_on_destroy? } |`boolean`|`true`| Whether or not to create a version on destroy. You will need to set this to `false` unless you are doing soft destroys (like with `AshArchival`) |
37
38
|[`store_resource_identifier?`](#paper_trail-store_resource_identifier?){: #paper_trail-store_resource_identifier? } |`boolean`|`false`| Whether or not to add the `version_resource_identifier` attribute to the version resource. This is useful for auditing purposes. |
38
39
|[`resource_identifier`](#paper_trail-resource_identifier){: #paper_trail-resource_identifier } |`atom`|| A name to use for this resource in the `version_resource_identifier`. Defaults to `Ash.Resource.Info.short_name/1`. |
39
40
|[`version_extensions`](#paper_trail-version_extensions){: #paper_trail-version_extensions } |`keyword`|`[]`| Extensions that should be used by the version resource. For example: `extensions: [AshGraphql.Resource], notifier: [Ash.Notifiers.PubSub]`|
2. use the version mixin to set `on_delete: :delete` on the underlying reference to the parent resource.
80
87
81
-
...
88
+
First, create a paper trail mixin if you haven't already
82
89
90
+
```elixir
83
91
defmoduleMyApp.MyResource.PaperTrailMixindo
84
92
defmixindo
85
93
# quote here is because we are returning code to be evaluated inside of the
@@ -96,17 +104,33 @@ end
96
104
```
97
105
98
106
99
-
2. use something like `AshArchival` in conjunction with this resource to ensure that destroy actions are `soft?` and do not actually result in row deletion
3. configure `AshPaperTrail` to ignore the reference, via:
118
+
Manually implement soft deletion, or use something like [`AshArchival`](https://hexdocs.pm/ash_archival) to ensure that destroy actions are `soft?` and do not actually result in row deletion
119
+
120
+
### Disable Foreign Keys (not recommended)
121
+
122
+
configure `AshPaperTrail` to ignore the reference, like so:
102
123
103
124
```elixir
104
125
paper_trail do
105
126
reference_source? false
106
127
end
107
128
```
108
129
109
-
and you could then use the `mixin` described below to add `on_delete` options to the reference.
130
+
This will make it skip creating a foreign key for the version source attribute
Copy file name to clipboardExpand all lines: lib/resource/resource.ex
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,12 @@ defmodule AshPaperTrail.Resource do
115
115
doc:
116
116
"Whether or not to add the `version_action_inputs` attribute to the version resource, which will store all attributes and arguments for the called action, redacting any sensitive values. This is useful for auditing purposes. The `version_action_inputs` attribute is always stored."
117
117
],
118
+
create_version_on_destroy?: [
119
+
type: :boolean,
120
+
default: true,
121
+
doc:
122
+
"Whether or not to create a version on destroy. You will need to set this to `false` unless you are doing soft destroys (like with `AshArchival`)"
0 commit comments