# \#upsert

**URL:** https://forum.elixirforum.com/tag/upsert/2373.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [Upsert on Postgres without migrating an identiy?](https://forum.elixirforum.com/t/upsert-on-postgres-without-migrating-an-identiy/70742)

<div class="topic-metadata">

**Author:** [@user20230119](https://forum.elixirforum.com/u/user20230119)\
**Replies:** 4\
**Last updated:** [May 5, 2025, 8:14pm UTC](https://forum.elixirforum.com/t/upsert-on-postgres-without-migrating-an-identiy/70742 "2025-05-05T20:14:27Z")

</div>

How can I upsert without creating an identity on Postgres? I want to check if a record exists with a combination of parent\_id and name for some records, but I do not want to enforce it with Postgres. postgres do t…

---

## [Publishing an event with the previous value of an attribute with PubSub](https://forum.elixirforum.com/t/publishing-an-event-with-the-previous-value-of-an-attribute-with-pubsub/59755)

<div class="topic-metadata">

**Author:** [@rbino](https://forum.elixirforum.com/u/rbino)\
**Replies:** 3\
**Last updated:** [November 16, 2023, 1:04pm UTC](https://forum.elixirforum.com/t/publishing-an-event-with-the-previous-value-of-an-attribute-with-pubsub/59755 "2023-11-16T13:04:52Z")

</div>

Hey everyone! In my app I have this resource (some parts omitted): defmodule MyApp.Vote do use Ash.Resource, data\_layer: AshPostgres.DataLayer actions do create :cast do argument :poll\_id, :uuid, all…

---

## [Result of upsert has different binary\_id, but this is corrected after the upsert?](https://forum.elixirforum.com/t/result-of-upsert-has-different-binary-id-but-this-is-corrected-after-the-upsert/58398)

<div class="topic-metadata">

**Author:** [@Pistrie](https://forum.elixirforum.com/u/Pistrie)\
**Replies:** 2\
**Last updated:** [September 20, 2023, 1:05pm UTC](https://forum.elixirforum.com/t/result-of-upsert-has-different-binary-id-but-this-is-corrected-after-the-upsert/58398 "2023-09-20T13:05:47Z")

</div>

So I have the following test: Post #1 has a title and a body, and is present in the database. Post #2 has the same title but a different body, and is not yet present in the database. I have the following upsert logic: …

---

## [Can I upsert with cast\_assoc?](https://forum.elixirforum.com/t/can-i-upsert-with-cast-assoc/32185)

<div class="topic-metadata">

**Author:** [@Adzz](https://forum.elixirforum.com/u/Adzz)\
**Replies:** 0\
**Last updated:** [June 8, 2020, 9:34am UTC](https://forum.elixirforum.com/t/can-i-upsert-with-cast-assoc/32185 "2020-06-08T09:34:52Z")

</div>

Is it possible to use cast\_assoc upsert relations? I did this: changes = %{"id" =\> 1, "thing" =\> \[%{"id" =\> 1}\], "name" =\> "hi"} Ecto.Changeset.cast(%MyStruct{}, changes, MyStruct.\_\_schema\_\_(:fields)) |\> Ecto.Changeset.…
