Skip to content

Commit

Permalink
add type to movie model
Browse files Browse the repository at this point in the history
  • Loading branch information
kenmoh committed Dec 4, 2023
1 parent 294f747 commit ef16791
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/models/movie_model.py
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit ef16791

Please sign in to comment.