mirror of
https://github.com/StepanovPlaton/torrent_backend.git
synced 2026-04-04 04:40:40 +04:00
Update database architecture. Add genres and actors
This commit is contained in:
24
database/models/movie_actors.py
Normal file
24
database/models/movie_actors.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from sqlalchemy import Column, Integer, ForeignKey, PrimaryKeyConstraint, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class MovieActor(Base):
|
||||
__tablename__ = "movie_actors"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
actor = Column(String, nullable=False, unique=True)
|
||||
|
||||
movies = relationship("Movies", secondary="movie_to_actor",
|
||||
lazy="selectin")
|
||||
|
||||
|
||||
class MovieToActor(Base):
|
||||
__tablename__ = "movie_to_actor"
|
||||
__table_args__ = (
|
||||
PrimaryKeyConstraint("movie_id", "actor_id"),
|
||||
)
|
||||
|
||||
movie_id = Column(Integer, ForeignKey("movies.id"), nullable=False)
|
||||
actor_id = Column(Integer, ForeignKey("movie_actors.id"), nullable=False)
|
||||
Reference in New Issue
Block a user