On duplicate key update. Ограничение данных с помощью where. duplicate key value violates unique constraint.