title: PostgreSQL there is no unique or exclusion constraint matching the ON CONFLICT specification
body: <p>I am creating a table like this:</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE artist (
      Id serial PRIMARY KEY,
      NameNormalized varchar(256) NOT NULL UNIQUE,
      Name text NOT NULL,
      MusicBrainzId char(36) NULL,
      Rating DECIMAL(2,1),
      CONSTRAINT non_empty CHECK (length(NameNormalized) &gt; 0 and length(Name) &gt; 0)
  );
  </code></pre>
  
  <p>When I try to execute the following INSERT operation, I get an error:</p>
  
  <pre class="lang-sql prettyprint-override"><code>INSERT INTO artist (NameNormalized, Name, MusicBrainzId, Rating)
  VALUES ('test', 'Test', '123456789012345678901234567890123456', 0.5)
  ON CONFLICT (NameNormalized) DO NOTHING;
  </code></pre>
  
  <p>The error message is as follows:</p>
  
  <pre><code>ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification
  </code></pre>
  
  <p>I have done some research but to my knowledge, setting NameNormalized to UNIQUE should be enough for ON CONFLICT to work. Also I am pretty sure this has worked in the past for me.</p>