diff --git a/domain/entity/shift_position.py b/domain/entity/shift_position.py index 435c850d..ee41a167 100644 --- a/domain/entity/shift_position.py +++ b/domain/entity/shift_position.py @@ -17,4 +17,5 @@ class ShiftPosition(Base): role = relationship("Role") # One-to-one relationship with ShiftRequestVolunteer using backref - volunteer = relationship("ShiftRequestVolunteer", uselist=False, backref="shift_position") \ No newline at end of file + volunteer = relationship("ShiftRequestVolunteer", uselist=False, backref="shift_position", + primaryjoin="ShiftPosition.id == ShiftRequestVolunteer.position_id") diff --git a/domain/entity/shift_request_volunteer.py b/domain/entity/shift_request_volunteer.py index b73447f0..93f2de9b 100644 --- a/domain/entity/shift_request_volunteer.py +++ b/domain/entity/shift_request_volunteer.py @@ -13,7 +13,7 @@ class ShiftRequestVolunteer(Base): id = Column(Integer, primary_key=True, autoincrement=True) user_id = Column(Integer, ForeignKey('user.id'), name='user_id', nullable=False) request_id = Column(Integer, ForeignKey('shift_request.id'), name='request_id', nullable=False) - position_id = Column(Integer, ForeignKey('role.id'), name="role_id", nullable=False) + position_id = Column(Integer, ForeignKey('shift_position.id'), name="position_id", nullable=False) status = Column(Enum(ShiftVolunteerStatus), name='status', nullable=False, default=ShiftVolunteerStatus.PENDING) update_date_time = Column(DateTime, name='last_update_datetime', default=datetime.now(), nullable=False) insert_date_time = Column(DateTime, name='created_datetime', default=datetime.now(), nullable=False)