-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: deprecate exclude_upsert_actions, as it had unintended s…
…ide effects docs: document how to handle upserts & identities with `ash_archival`
- Loading branch information
1 parent
7d3e4db
commit f8e405c
Showing
8 changed files
with
44 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Upserts & Identities | ||
|
||
Its important to consider identities when using AshArchival _without_ a `base_filter` set up. | ||
|
||
If you are using a `base_filter`, then all identities implicitly include that `base_filter` in their | ||
`where` (handled by the data layer). | ||
|
||
Take the following identities, for example: | ||
|
||
```elixir | ||
identities do | ||
identity :unique_email, [:email], where: expr(is_nil(archived_at)) | ||
# and | ||
identity :unique_email, [:email] | ||
end | ||
``` | ||
|
||
## With `is_nil(archived_at)` | ||
|
||
Using this identity allows multiple archived records with the same email, but only one _non-archived_ record per email. | ||
It enables reuse of archived email addresses for new active records, maintaining data integrity by preventing duplicate | ||
active records while preserving archived data. | ||
|
||
When you upsert a record using this identity, it will only consider active records. | ||
|
||
## Without `is_nil(archived_at)` | ||
|
||
This identity configuration enforces strict email uniqueness across all records. Once an email is used, it can't be used | ||
again, even after that record is archived. | ||
|
||
When you upsert a record using this identity, it will consider all records. |
21 changes: 0 additions & 21 deletions
21
lib/ash_archival/resource/changes/filter_archived_for_upserts.ex
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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