Postgres has no MERGE statement:
https://www.postgresql.org/docs/current/static/sql-commands.html
Use INSERT ON CONFLICT DO instead:
https://www.postgresql.org/docs/current/static/sql-insert.html
There are some movement towards MERGER statement, but it will not necessarily be smth that you expect:
https://wiki.postgresql.org/wiki/SQL_MERGE