update
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy import Column, ForeignKey, Integer, String, Table
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
|
||||
video_profiles = Table(
|
||||
"video_profiles",
|
||||
Base.metadata,
|
||||
Column("video_id", Integer, ForeignKey("videos.id", ondelete="CASCADE")),
|
||||
Column("profile_id", Integer, ForeignKey("profiles.id", ondelete="CASCADE")),
|
||||
)
|
||||
|
||||
|
||||
class Profile(Base):
|
||||
__tablename__ = "profiles"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String, nullable=False, unique=True)
|
||||
|
||||
|
||||
class Video(Base):
|
||||
__tablename__ = "videos"
|
||||
@@ -12,3 +27,4 @@ class Video(Base):
|
||||
thumbnail_url = Column(String, nullable=False)
|
||||
youtube_url = Column(String, nullable=False)
|
||||
file_path = Column(String, nullable=True)
|
||||
profiles = relationship("Profile", secondary=video_profiles, backref="videos")
|
||||
|
||||
Reference in New Issue
Block a user