Creating partial unique index with sqlalchemy on Postgres
问题 SQLAlchemy supports creating partial indexes in postgresql. Is it possible to create a partial unique index through SQLAlchemy? Imagine a table/model as so: class ScheduledPayment(Base): invoice_id = Column(Integer) is_canceled = Column(Boolean, default=False) I'd like a unique index where there can be only one "active" ScheduledPayment for a given invoice. I can create this manually in postgres: CREATE UNIQUE INDEX only_one_active_invoice on scheduled_payment (invoice_id, is_canceled) where