21 lines
848 B
Python
21 lines
848 B
Python
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.database import Base
|
|
|
|
|
|
class Match(Base):
|
|
|
|
match_id = Column(Integer, primary_key=True)
|
|
team_1 = Column(ForeignKey("team.id"), nullable=False)
|
|
team_2 = Column(ForeignKey("team.id"), nullable=False)
|
|
day = Column(ForeignKey("matchday.id"), nullable=False)
|
|
winner = Column(ForeignKey("team.team_id"), nullable=True)
|
|
team_1_result = Column(Integer, nullable=True)
|
|
team_2_result = Column(Integer, nullable=True)
|
|
|
|
matchday = relationship("Matchday")
|
|
team = relationship("Team", primaryjoin="Match.team_1 == Team.team_id")
|
|
team1 = relationship("Team", primaryjoin="Match.team_2 == Team.team_id")
|
|
team2 = relationship("Team", primaryjoin="Match.winner == Team.team_id")
|