Just to reframe the discussion a little bit:
I am not looking for one way to implement inverse polymorphic associations, I already provided some implementations in the initial question. Instead, I’d like to get a sense of the pros and cons of each implementation, and eventually have a proposal for a recommended implementation with a list of reasons why it is recommended.
I feel like it’s a question that comes back frequently in Ecto’s community:
- https://stackoverflow.com/questions/33184593/inverse-polymorphic-with-ecto
- https://stackoverflow.com/questions/44072836/polymorphic-has-many-in-ecto
- Abstract model / Polymorphism?
- Polymorphism in Ecto schemas
And so far, I haven’t been able to find a good answer to this question. I hope we can bring a definitive answer with this post
EDIT: @kokolegorille suggestion to use an abstract table seemed like a good one. What would an actual implementation look like and what would be the advantages compared to other approaches?