In my umbrella app, with currently two apps, each based on its own DB...
I have a schema in app2
referencing a uuid
from an object of app1
.
DB1 :
Table : parent
parent_id: uuid
name: string
DB2 :
Table : child
child_id: uuid
parent_id: uuid
name: string
Then the schema :
schema "child" do
field :name, :string
belongs_to(:parent, Parent, type: :binary_id)
timestamps()
end
How to have the changeset validate that parent_id
is valid and exists in its table ? I tried some things, like assoc_constraint(:parent)
but tbh I knew it wouldn't work... Maybe I just should rethink the relationship and how it works.
Thanks ahead.