generated from admin/template
podex-api completed with swagger & docker compose
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
from sqlalchemy import Column, Integer, String, Numeric, Text, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from .database import Base
|
||||
|
||||
|
||||
class Pokemon(Base):
|
||||
__tablename__ = "pokemons"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False, index=True)
|
||||
height_m = Column(Numeric, nullable=True)
|
||||
weight_kg = Column(Numeric, nullable=True)
|
||||
image_url = Column(Text, nullable=True)
|
||||
description = Column(Text, nullable=True)
|
||||
|
||||
stats = relationship("PokemonStat", back_populates="pokemon", uselist=False)
|
||||
types = relationship("PokemonType", back_populates="pokemon")
|
||||
|
||||
|
||||
class Type(Base):
|
||||
__tablename__ = "types"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
color_hex = Column(String, nullable=True)
|
||||
|
||||
|
||||
class PokemonType(Base):
|
||||
__tablename__ = "pokemon_types"
|
||||
|
||||
pokemon_id = Column(Integer, ForeignKey("pokemons.id"), primary_key=True)
|
||||
type_id = Column(Integer, ForeignKey("types.id"), primary_key=True)
|
||||
|
||||
pokemon = relationship("Pokemon", back_populates="types")
|
||||
type = relationship("Type")
|
||||
|
||||
|
||||
class PokemonStat(Base):
|
||||
__tablename__ = "pokemon_stats"
|
||||
|
||||
pokemon_id = Column(Integer, ForeignKey("pokemons.id"), primary_key=True)
|
||||
hp = Column(Integer, nullable=True)
|
||||
atk = Column(Integer, nullable=True)
|
||||
def_ = Column("def", Integer, nullable=True)
|
||||
satk = Column(Integer, nullable=True)
|
||||
sdef = Column(Integer, nullable=True)
|
||||
spd = Column(Integer, nullable=True)
|
||||
|
||||
pokemon = relationship("Pokemon", back_populates="stats")
|
||||
|
||||
|
||||
class MoveCategory(Base):
|
||||
__tablename__ = "move_categories"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
|
||||
class Move(Base):
|
||||
__tablename__ = "moves"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
type_id = Column(Integer, ForeignKey("types.id"), nullable=True)
|
||||
category_id = Column(Integer, ForeignKey("move_categories.id"), nullable=True)
|
||||
power = Column(Integer, nullable=True)
|
||||
accuracy = Column(Integer, nullable=True)
|
||||
description = Column(Text, nullable=True)
|
||||
|
||||
|
||||
class LearnMethod(Base):
|
||||
__tablename__ = "learn_methods"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
|
||||
class PokemonMove(Base):
|
||||
__tablename__ = "pokemon_moves"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
pokemon_id = Column(Integer, ForeignKey("pokemons.id"), nullable=False)
|
||||
move_id = Column(Integer, ForeignKey("moves.id"), nullable=False)
|
||||
level_learned = Column(Integer, nullable=True)
|
||||
learn_method_id = Column(Integer, ForeignKey("learn_methods.id"), nullable=True)
|
||||
Reference in New Issue
Block a user