Create unique (partial) index with condition

Viewed 19

I'm trying to achieve the following query with Knex

CREATE UNIQUE INDEX unique_index
ON table (column_a, column_b)
WHERE deleted_at IS NULL;

I've tried with both

k.schema.alterTable('table', (t) => {
  t.unique(['column_a', 'column_b'], {
    indexName: 'unique_index',
  })
})
k.schema.alterTable('table', (t) => {
  t.index(['column_a', 'column_b'], 'unique_index', 'UNIQUE')
})

but they both don't seem to accept additional conditions

0 Answers
Related