Hello Felas,
I come accross the following problem and I need thoughts.
I have a simple ecto schema with a signle string field seted as the primary key Parent.
This has a has_many relation with a normal ecto schema Child.
I have been creating Childs usually using Parents primary key
%Child{parent_string_field: “some_p_key”}
and ecto hanldes the association within the noramal cast macro and this has been working quit nice for the time.
My problem is what happens if for any reason I would like change the only field and pkey of the parent and would like to re-assign all the children to the new pkey.
Is there any way to handle that gracefully without hacking ?
Is this just a bad design decission ony my part ?
Is there any way to even generate a changeset error automatically when a Parent has already childs associated with it (I have been looking at foreign_key_consraint but it looks like this something you use in the Child Schema would it be possible to propagete that to the Parent changeset somehow)?
Any thougs are welcome.Preformatted text