fix: specify foreign_keys on User.admin_roles_rel to resolve ambiguous join

UserRole has two FKs to users (user_id and assigned_by), causing
SQLAlchemy AmbiguousForeignKeysError on mapper initialization.
This commit is contained in:
Fringg
2026-02-25 03:23:41 +03:00
parent 1646f04bde
commit bc7d0612f1

View File

@@ -1061,7 +1061,7 @@ class User(Base):
promo_group = relationship('PromoGroup', back_populates='users')
user_promo_groups = relationship('UserPromoGroup', back_populates='user', cascade='all, delete-orphan')
poll_responses = relationship('PollResponse', back_populates='user')
admin_roles_rel = relationship('UserRole', back_populates='user')
admin_roles_rel = relationship('UserRole', foreign_keys='[UserRole.user_id]', back_populates='user')
notification_settings = Column(JSON, nullable=True, default=dict)
last_pinned_message_id = Column(Integer, nullable=True)