title: POSTGRESQL: ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
body: <p><a href="https://i.stack.imgur.com/Z3dxl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z3dxl.png" alt="enter image description here"></a>I am trying to perform upsert operation against a table named "message_payload", using below query, but get the error: </p>
  
  <blockquote>
    <p>ERROR:  there is no unique or exclusion constraint matching the ON CONFLICT specification
    SQL state: 42P10</p>
  </blockquote>
  
  <p>Query:</p>
  
  <pre><code>    INSERT INTO public.error_message(
      id, created_by, created_dt, modified_by, modified_dt, attempt, message_headers, 
      message_main_topic, message_payload, message_status, message_status_code)
          VALUES (51, null, null, null, null, 1, '{
          "jsonContent": {
              "content-length": "1635",
              "message_status_code": "417",
              "cookie": "JSESSIONID=279AF4C174E6192BDAB11A067768BBD5",
              "postman-token": "f0f33e86-498f-452a-aaf6-18eb84dc5907",
              "kafka_timestampType": "CREATE_TIME",
              "message_id": "21",
              "kafka_receivedMessageKey": "null",
              "kafka_receivedTopic": "error-topic",
              "accept": "*/*",
              "kafka_offset": "33",
              "kafka_consumer": "org.apache.kafka.clients.consumer.KafkaConsumer@5091bb5f",
              "host": "localhost:8082",
              "content-type": "application/json",
              "connection": "keep-alive",
              "cache-control": "no-cache",
              "kafka_receivedPartitionId": "0",
              "kafka_receivedTimestamp": "1552305428711",
              "accept-encoding": "gzip, deflate",
              "message_main_topic": "ldarsQCustomStatistics.1",
              "user-agent": "PostmanRuntime/7.6.1"
          }
      }', 'ldarsQCustomStatistics.1', '{
          "jsonContent": {
              "messageTime": 16772223422,
              "messageRev": 9,
              "businessId": "DB",
              "messageId": "55"
          }
      }', 1, 201)
      ON CONFLICT ((message_payload-&gt;'jsonContent'-&gt;&gt;'message_id'))
      DO UPDATE SET attempt = error_message.attempt + 1, message_headers = EXCLUDED.message_headers, 
                    message_status_code = EXCLUDED.message_status_code, message_status = EXCLUDED.message_status, 
                    created_by = EXCLUDED.created_by, created_dt = EXCLUDED.created_dt, 
                    modified_by = EXCLUDED.modified_by, modified_dt = EXCLUDED.modified_dt, 
                    message_main_topic = EXCLUDED.message_main_topic, message_payload = EXCLUDED.message_payload, 
                    id = DEFAULT
  
  </code></pre>