How to get related by 2 fields

I have the next tables: book(id, status_id), status(id), status_history(status_id, book_id)

How can I get statusHistory relation from book AR object according to the current book status?

SQL: select * from book inner join status_history on status_history.book_id = book.id and status_history.status_id = book.status_id

I can’t implement this condition in relation settings: status_history.book_id = book.id and status_history.status_id = book.status_id