user collection model
This commit is contained in:
parent
ac79aefa36
commit
c86fd6dd8e
|
@ -2,7 +2,6 @@ from typing import List
|
|||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.task import Task
|
||||
from app.models.user import User
|
||||
from app.extensions import db
|
||||
|
||||
class Session(db.Model):
|
||||
|
@ -10,7 +9,6 @@ class Session(db.Model):
|
|||
name: Mapped[str] = mapped_column(unique=True)
|
||||
|
||||
authorized: Mapped[bool]
|
||||
users: Mapped[List[User]] = relationship("User", cascade="all, delete-orphan", back_populates="session")
|
||||
|
||||
tasks: Mapped[List[Task]] = relationship("Task", cascade="all, delete-orphan", back_populates="session")
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ class Task(db.Model):
|
|||
|
||||
session_id = Column(Integer, ForeignKey("session.id"))
|
||||
session: Mapped['Session'] = relationship("Session", back_populates="tasks")
|
||||
|
||||
collection_id = Column(Integer, ForeignKey("collection.id"))
|
||||
collection: Mapped['UsersCollection'] = relationship('UsersCollection', back_populates='task')
|
||||
|
||||
datetime: Mapped[DateTime] = Column(DateTime, default=datetime.datetime.utcnow())
|
||||
status: Mapped[str]
|
||||
status_message: Mapped[str]
|
||||
|
|
|
@ -15,5 +15,5 @@ class User(db.Model):
|
|||
phone: Mapped[str] = mapped_column(nullable=True, unique=True)
|
||||
username: Mapped[str] = mapped_column(nullable=True, unique=True)
|
||||
|
||||
session_id = Column(Integer, ForeignKey("session.id"))
|
||||
session: Mapped["Session"] = relationship("Session", back_populates="users")
|
||||
collection_id = Column(Integer, ForeignKey("collection.id"))
|
||||
collection: Mapped["UsersCollection"] = relationship("UsersCollection", back_populates="users")
|
|
@ -0,0 +1,13 @@
|
|||
from typing import List
|
||||
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.task import Task
|
||||
from app.models.user import User
|
||||
|
||||
class UsersCollection(db.Model):
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
|
||||
Mapped[List[Task]] = relationship("Task", back_populates="collection")
|
||||
users: Mapped[List[User]] = relationship("User", cascade="all, delete-orphan", back_populates="collection")
|
Loading…
Reference in New Issue