UniqueConstraint should not be for the model class, but for its table. You can __table_args__ do this:
class PostsSubscribe(Base): __tablename__ = 'posts_subscribe' id = Column(Integer, primary_key = True) post_id = Column(Integer, ForeignKey('posts_posts.id'), nullable=False) persona_id = Column(Integer, ForeignKey('personas_personas.id'), nullable=False) __table_args__ = (UniqueConstraint('post_id', 'persona_id', name='_person_post_uc'), )
source share