> ad-hoc SQL functions in the database
If you use tools like Sqitch, Metagration or any other suitable migration management system then functions in your database stop being scary.
Sqitch: https://sqitch.org/ Metagration: https://github.com/michelp/metagration