1+ from typing import TYPE_CHECKING
2+
13from sqlalchemy import BigInteger , Boolean , ForeignKey , Index , String , text
24from sqlalchemy .orm import Mapped , mapped_column , relationship
35
4- from api .models .orm import Jam , User , team_has_users_table
56from api .models .orm .base import Base
7+ from api .models .orm .team_has_users import team_has_users_table
8+
9+ if TYPE_CHECKING :
10+ from api .models .orm import User
611
712
813class Team (Base ):
@@ -11,8 +16,8 @@ class Team(Base):
1116 __tablename__ = "teams"
1217
1318 team_id : Mapped [int ] = mapped_column (primary_key = True )
14- jam_id : Mapped [int ] = mapped_column (ForeignKey (Jam .jam_id ))
15- leader_id : Mapped [int ] = mapped_column (ForeignKey (User .user_id ))
19+ jam_id : Mapped [int ] = mapped_column (ForeignKey ("jams .jam_id" ))
20+ leader_id : Mapped [int ] = mapped_column (ForeignKey ("users .user_id" ))
1621 name : Mapped [str ] = mapped_column (String (), nullable = False )
1722
1823 # These two fields are nullable to accommodate historic data
@@ -23,8 +28,8 @@ class Team(Base):
2328 winner : Mapped [bool ] = mapped_column (Boolean , nullable = True )
2429 first_place_winner : Mapped [bool ] = mapped_column (Boolean , nullable = True )
2530
26- users : Mapped [list [User ]] = relationship (
31+ users : Mapped [list [" User" ]] = relationship (
2732 secondary = team_has_users_table ,
2833 back_populates = "teams" ,
2934 )
30- __table_args__ = Index ("team_name_jam_unique" , text ("lower(name)" ), "jam_id" , unique = True )
35+ __table_args__ = ( Index ("team_name_jam_unique" , text ("lower(name)" ), "jam_id" , unique = True ), )
0 commit comments