Postgres har ingen MERGE uttalande:
https://www.postgresql.org/docs/current/static /sql-commands.html
Använd INSERT ON CONFLICT DO istället:
https://www.postgresql.org/docs/current/static /sql-insert.html
Det finns en viss rörelse mot MERGER uttalande, men det kommer inte nödvändigtvis att vara något du förväntar dig:
https://wiki.postgresql.org/wiki/SQL_MERGE