Has one through association

Hi, i’m trying to make these associations work but I can’t figure out what’s wrong. The has_one through association in the orders relation gives me the error KeyError: :order_id attribute doesn't exist in contracts schema and that’s right, it doesn’t, the foreign key is in the orders table. Could anyone point me to right path?

class Orders < ROM::Relation[:sql]
  schema(:orders, infer: true) do
    associations do
      belongs_to :contract
      has_one :organization, through: :contracts
    end
  end
end


class Contracts < ROM::Relation[:sql]
  schema(:contracts, infer: true) do
    associations do
      belongs_to :organization
      has_many :orders
    end
  end
end


class Organizations < ROM::Relation[:sql]
  schema(:organizations, infer: true) do
    associations do
      has_many :contracts
    end
  end
end