title: Conditional ON CONFLICT
body: <p>I wonder whether it is possible in postgres to make ON CONFLICT (in INSERT) logic work conditionally.
  I mean specify some condition, and if it is satisfied ON CONFLICT logic is executed, otherwise conflict error is returned.</p>
  
  <p>That's what i tried:</p>
  
  <pre><code>INSERT INTO "%s" (
      "id",
      "color",
      "is_enabled"
  ) VALUES ($1, $2, true) 
  ON CONFLICT(id) WHERE is_enabled=false
  DO UPDATE SET color=$2, is_enabled = true
  </code></pre>
  
  <p>I want to insert new record if there is no one with such id.
  Update if there is one, but it is disabled.
  Get conflict error if there is one and it is enabled.</p>
  
  <p>Current sql doesn't work, i guess because in WHERE clause one can put only clauses related to partial indexes. (i am not sure, docs are confusing for me at this point...)</p>
  
  <p>But is it possible to achieve logic that i want to have with one sql query?</p>