title: Knex and PostgreSQL: How to drop an unique index?
body: <p>I have an app using knex for migration. Earlier someone made an unique index on one column using <code>knex.raw</code> like this:</p>
  <pre><code>const createProgrammeTable = knex =&gt; knex.raw(`
    CREATE TABLE programme (
      id             serial PRIMARY KEY,
      date           date NOT NULL,
      published      date,
      description    text
    );
    CREATE UNIQUE INDEX programme_date_index ON programme(date);
  `)
  </code></pre>
  <p>When printing out the db using psql I get this info:</p>
  <pre><code>server=# \d programme;
                                Table &quot;public.programme&quot;
    Column   |  Type   | Collation | Nullable |                Default
  -----------+---------+-----------+----------+---------------------------------------
   id        | integer |           | not null | nextval('programme_id_seq'::regclass)
   date      | date    |           | not null |
   published | boolean |           | not null |
  Indexes:
      &quot;programme_pkey&quot; PRIMARY KEY, btree (id)
      &quot;programme_date_index&quot; UNIQUE, btree (date)
  </code></pre>
  <p><strong>Now I want to remove the unique constraint but I'm not sure how.</strong> I've read that I can do this:</p>
  <pre><code>ALTER TABLE programme DROP INDEX programme_date_index;
  </code></pre>
  <p>But doing that using <code>knex.raw</code> gives this error:</p>
  <pre><code>migration failed with error: ALTER TABLE programme DROP INDEX programme_date_index - syntax error at or near &quot;programme_date_index&quot;
  error: ALTER TABLE programme DROP INDEX programme_date_index - syntax error at or near &quot;programme_date_index&quot;
      at Connection.parseE (/Users/my-path/node_modules/pg/lib/connection.js:555:11)
      at Connection.parseMessage (/Users/my-path/node_modules/pg/lib/connection.js:380:19)
      at Socket.&lt;anonymous&gt; (/Users/my-path/node_modules/pg/lib/connection.js:120:22)
      at Socket.emit (events.js:198:13)
      at addChunk (_stream_readable.js:288:12)
      at readableAddChunk (_stream_readable.js:269:11)
      at Socket.Readable.push (_stream_readable.js:224:10)
      at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  error Command failed with exit code 1.
  </code></pre>
  <p>I've also tried using <a href="http://knexjs.org/#Schema-dropUnique" rel="nofollow noreferrer">dropUnique</a> like this:</p>
  <pre><code>exports.up = function(knex, Promise) {
    return knex.schema.alterTable(&quot;programme&quot;, function(t) {
      t.dropUnique(&quot;date&quot;, &quot;programme_date_index&quot;)
    })
  }
  </code></pre>
  <p>which gives the following error:</p>
  <pre><code>migration failed with error: alter table &quot;programme&quot; drop constraint &quot;programme_date_index&quot; - constraint &quot;programme_date_index&quot; of relation &quot;programme&quot; does not exist
  </code></pre>
  <p><strong>Versions</strong></p>
  <p>Knex CLI version: 0.20.15 /
  Knex Local version: 0.20.15</p>
  <pre><code>server=# select version();
                                                       version
  ------------------------------------------------------------------------------------------------------------------
   PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
  </code></pre>
  <p>Can someone please help me/push me in the right direction?</p>