Use execute-sql instead of update to apply changes

This previous question might help you: Facing Unterminated dollar quote started at position 3 in SQL DO $$ for postgresql migration