0

I have table schema as:

table_a:
    id
    active boolean
 
table_b:
    id
    table_a_id ForeignKey

I want to apply a partial unique index on table_b but only if active=True for table_a_id.

Is this feasible in postgres?

kushj
  • 117
  • 1
  • 7

1 Answers1

3

Not possible. From the manual:

The expression used in the WHERE clause can refer only to columns of the underlying table, but it can use all columns, not just the ones being indexed.

Frank Heikens
  • 117,544
  • 24
  • 142
  • 135