Given the following Ecto schema struct with a nested association:
blah =
%Foo{
...
bars: [
%Bar{
...
},
%Bar{
...
}
]
}
How can I reference a conflict target constraint in the blah.bars schema?
Repo.insert(Foo, blah,
on_conflict: :replace,
conflict_target: {:constraint, :bar_unique_contraint_name}
)
This code obviously doesn’t work because it looks for the constraint named “bar_unique_contraint_name” in the “Foo” schema. What I would like it to do is look for that constraint in the nested foo.bars “Bar” schema during the insert.