initial
This commit is contained in:
37
database/models.py
Normal file
37
database/models.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class Cartoon(Base):
|
||||
__tablename__ = 'cartoons'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
seasons = relationship("Season", backref="cartoon", order_by="Season.season_number")
|
||||
|
||||
|
||||
class Season(Base):
|
||||
__tablename__ = 'seasons'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
season_number = Column(Integer, nullable=False)
|
||||
cartoon_id = Column(Integer, ForeignKey('cartoons.id'), nullable=False)
|
||||
|
||||
episodes = relationship("Episode", backref="season", order_by="Episode.episode_number")
|
||||
|
||||
|
||||
class Episode(Base):
|
||||
__tablename__ = 'episodes'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
episode_number = Column(Integer, nullable=False)
|
||||
season_id = Column(Integer, ForeignKey('seasons.id'), nullable=False)
|
||||
file = Column(String, nullable=False)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user