From ef167914ee481eb3d276fdf4dda81914a7d70b80 Mon Sep 17 00:00:00 2001 From: kenmoh Date: Mon, 4 Dec 2023 12:41:17 +0100 Subject: [PATCH] add type to movie model --- app/models/movie_model.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/movie_model.py b/app/models/movie_model.py index 5b71ba1..02c2a30 100644 --- a/app/models/movie_model.py +++ b/app/models/movie_model.py @@ -1,10 +1,17 @@ from decimal import Decimal +from enum import Enum from sqlalchemy import String, Integer, DECIMAL, ForeignKey, Float from sqlalchemy.orm import Mapped, relationship, mapped_column from app.database import Base +class TypeEnum(str, Enum): + MOVIE = 'movie' + MUSIC = 'music' + BOOK = 'book' + + class Movie(Base): __tablename__ = "movies" @@ -14,7 +21,8 @@ class Movie(Base): description: Mapped[str] = mapped_column(String(100)) cover_image_url: Mapped[str] casts: Mapped[str] - genre: Mapped[str] + genre: Mapped[str] = mapped_column(String, nullable=True) + type: Mapped[str] = mapped_column(String, nullable=True, default=TypeEnum.MOVIE) thriller: Mapped[str] average_rating: Mapped[float] = mapped_column(Float, nullable=True) reviews: Mapped[list["Movie"]] = relationship( @@ -30,7 +38,7 @@ class Review(Base): id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True) author: Mapped[str] - comment: Mapped[str] + comment: Mapped[str] = mapped_column(String(400)) rating: Mapped[int] ip_address: Mapped[str] = mapped_column(String(255)) movie_id: Mapped[int] = mapped_column(ForeignKey("movies.id"), nullable=False)