title: postgres insert on conflict error - there is no unique or exclusion constraint
body: <p>I have two tables in postgres <code>daily_report</code> and <code>summary_songs</code>.</p>
  
  <p>Sql file for creating the tables is here: <a href="https://nofile.io/f/Ef94rMFRh6C/file.sql" rel="noreferrer">https://nofile.io/f/Ef94rMFRh6C/file.sql</a></p>
  
  <p>I want to update the <code>summary_songs</code> at the end of each day with below conditions:</p>
  
  <ul>
  <li>If the <code>userid</code> already does not exist, then record from <code>daily_report</code> need to be inserted into <code>summary_songs</code></li>
  <li>If the <code>userid</code> exists, then <code>summary_songs.countid = summary_songs.countid+ daily_report.countid</code>.</li>
  </ul>
  
  <p>I used below query to update <code>summary_songs</code>:</p>
  
  <pre><code>insert into summary_songs 
  (select * from daily_report as B)
  on conflict (userid, songd) 
  do update set countid = countid+excluded.countid ;  
  </code></pre>
  
  <p>I get below error:</p>
  
  <blockquote>
    <p>ERROR:  there is no unique or exclusion constraint matching the ON CONFLICT specification</p>
  </blockquote>