SQLAlchemy支持创建partial indexes in postgresql。
是否可以通过SQLAlchemy创建partial unique index?
假设一个表/模型是这样的:
class ScheduledPayment(Base):
invoice_id = Column(Integer)
is_canceled = Column(Boolean, default=False)
我想要一个唯一的索引,其中只能有一个“活动”的时间表为给定的发票付款。
我可以在postgres中手动创建:
CREATE UNIQUE INDEX only_one_active_invoice on scheduled_payment
(invoice_id, is_canceled) where not is_canceled;
我想知道如何使用SQLAlchemy 0.9将其添加到我的SQLAlchemy模型中。
目前没有回答
相关问题 更多 >
编程相关推荐