in this situation Parent and OtherParent schema point to the same table in two different contexts
and I need to explicitly set foreign_key to get the right name parent_id for the unnatural context
but I get the warning
invalid association `tables` in schema App.OtherParent: associated schema App.Table does not have field `parent_id
and there is no runtime error
defmodule App.Table do
alias App.Parent
schema "table"
belongs_to :parent, Parent # by default foreign_key "parent_id"
end
end
defmodule App.Parent do
alias App.Table
schema "parents"
has_many :tables, Table # by default foreign_key: "parent_id"
end
end
defmodule App.Otherparent do
alias App.Table
schema "parents"
has_many :tables, Table, foreign_key: "parent_id" # by default otherparent_id
end
end