title: Postgres add a unique constraint ignore current values
body: <p>Sorry if this a duplicate but I can't seem to find an answer elsewhere.</p>
  <pre><code> up: async (queryInterface, Sequelize) =&gt; {
      // this migration fixes the unique constraint error
      Promise.all([
        queryInterface.removeConstraint(
          &quot;Notes&quot;,
          &quot;Notes_led_key&quot;
        ),
      ]);
    },
  
    down: async (queryInterface, Sequelize) =&gt; {
      Promise.all([
        // this will cause a DB error if there are duplicate entries
        queryInterface.addConstraint(&quot;Notes&quot;, {
          type: &quot;unique,
          fields: [&quot;led&quot;],
          name: &quot;Notes_led_key&quot;,
        }),
      ]);
    },
  </code></pre>
  <p>I am currently using a Postgres db that has a unique constraint on a column. I wrote a migration to rid the constraint as we no longer need it. My issue is the rollback function. If we need to rollback and we suddenly have duplicates in this field it causes a constraint error.</p>
  <p>I tried using &quot;NOT VALID&quot; but I get an error saying it can't be used with unique. How can I add back this constraint without causing an error?</p>