Deleting intermediary table record in a many_to_many relationship

In this example (https://hexdocs.pm/ash/2.6.18/managing-relationships.html) that Post and Tag have a many_to_many relationshp through PostTag, how do I make it so that the deletion of Post also deletes the record in PostTag , but not Tag? In post.ex, I have this action
destroy :delete_post do
end
destroy :delete_post do
end
which issues this error.
** (Ash.Error.Invalid) Input Invalid
* Invalid value provided for id: would leave records behind.
nil
** (Ash.Error.Invalid) Input Invalid
* Invalid value provided for id: would leave records behind.
nil
I tried adding manage_relationship with various type options to this but couldn't get it to do what I want.
4 Replies
ZachDaniel
ZachDaniel2y ago
You want the references section in ash_postgres
ZachDaniel
ZachDaniel2y ago
You can configure the deletion behavior at the database level.
Jason
JasonOP2y ago
Got it. Thank you!

Did you find this page helpful?