Hey guys,
I am migrating a legacy database from a PHP application, wich uses the Doctrine2 ORM, to Elixir using Phoenix and Ecto.
But I am facing a problem. The Doctrine2 ORM supports Join-Table inheritance, wich uses data from multiple tables to compose a model and btw, it was used a lot on the old application. Eg.: The database has three tables, "people", "students" and "teachers". The only table wich has a PRIMARY_KEY is "people", the other two actually have FOREIGN_KEYs in their "id" field pointing to the "id" field on the "people" table, that also has a "dtype" field of type "string" that says if some specific line is a Student or a Teacher. When I ask Doctrine2 to load a Student, it then fetches data from "student" and from "people" tables using a INNER JOIN and builds a single model with the returned data, so that when I query, load, update and save the model I don't have to worry about how this will be done.
Chatting on the #ecto channel on the Elixir Slack, I was given the idea of using a regular association to the "people" table, virtual fields for the inherited properties and callbacks to load and save the data to the right place, but writing the queries would still be a pain and the loading times would increase considerably, specially on large collections.
It would be nice to have this builtin into the ORM, as it is a great feature and maybe a key selling point for developers trying to convince their bosses to migrate their codebase :D
I love the Elixir lang and I am loving the community around it and how it is growing, so, if I can help with anything in the development, I would also love to do so ^^
If it is decided to implement this feature, I was thinking of something adapter-dependent, where each adapter could work this out in it's own way (Pg could use it's native table inheritance, while MySql and Sqlite could use Join-Table inheritance).
What do you think?