Refactor all replace and update queries not to user ORM.
Summary: This differential refactors all replace and update queries not to use ORM.
Test Plan: Execute tests in https://phab.comm.dev/D10711. Replace and update queries are covered there.
Reviewers: kamil, michal
Reviewed By: kamil
Subscribers: ashoat, tomek
Differential Revision: https://phab.comm.dev/D10706