Add formatting tools
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, Float
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
from enum import Enum
|
||||
|
||||
from enums import MinigameEnum, CourseEnum, StrEnumType
|
||||
from sqlalchemy import Boolean, Column, Float, ForeignKey, Integer, String
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from enums import CourseEnum, MinigameEnum, StrEnumType
|
||||
|
||||
|
||||
class User(Base):
|
||||
@@ -14,9 +15,13 @@ class User(Base):
|
||||
username = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
|
||||
high_scores = relationship("HighScore", back_populates="owner", cascade="all, delete", lazy="dynamic")
|
||||
course_progress = relationship("CourseProgress", back_populates="owner", cascade="all, delete", lazy="dynamic")
|
||||
|
||||
high_scores = relationship(
|
||||
"HighScore", back_populates="owner", cascade="all, delete", lazy="dynamic"
|
||||
)
|
||||
course_progress = relationship(
|
||||
"CourseProgress", back_populates="owner", cascade="all, delete", lazy="dynamic"
|
||||
)
|
||||
|
||||
# add a new column to store the high_score IDs
|
||||
high_score_ids = Column(ARRAY(Integer), default=[])
|
||||
|
||||
@@ -34,7 +39,6 @@ class HighScore(Base):
|
||||
owner = relationship("User", back_populates="high_scores")
|
||||
|
||||
|
||||
|
||||
class CourseProgress(Base):
|
||||
__tablename__ = "course_progress"
|
||||
|
||||
@@ -43,4 +47,3 @@ class CourseProgress(Base):
|
||||
course = Column(StrEnumType(CourseEnum), nullable=False)
|
||||
owner_id = Column(Integer, ForeignKey("users.user_id"))
|
||||
owner = relationship("User", back_populates="course_progress")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user