Hi
I'm trying to setup unique partial indexes so that constraint violation is only thrown when a a certain column is true. This is the index I'm using:
__table_args__ = (
Index(
"idx_one_active_fulfillment",
member_id,
status,
unique=True,
postgres_where=(status == 'ACTIVE'),
),
)
As long as the status is not 'ACTIVE', a member can have multiple entries i.e
member_id, status
1, 'COMPLETED'
1, 'COMPLETED'
2, 'ACTIVE'
However, this is not the case. Once I insert an entry e.g 1, 'COMPLETED'; I can't insert it again since it throws an error of 'duplicate key value violates unique constraint'
The weird thing is that, if I run all the queries using psql, it works properly. Is there something I'm missing? I'm trying to see what `create_all` executes but it seems setting echo=True doesn't affect it.
Cheers.