class Item(Model): __tablename__ = 'items' item_id = Database.Column(Database.Integer, primary_key=True, nullable=False) item_name = Database.Column(Database.String(100), nullable=True) image_url = Database.Column(Database.String(200), nullable=False)
class Hero(Model): __tablename__ = 'heroes' hero_id = Database.Column(Database.Integer, primary_key=True, nullable=False) hero_name = Database.Column(Database.String(100), nullable=True) portrait_url = Database.Column(Database.String(200), nullable=False)
class History(Model): __tablename__ = 'histories' id = Database.Column(Database.Integer, primary_key=True, nullable=False, autoincrement=True) last_match_id = Database.Column(Database.Integer, nullable=False)
class Player(Model): __tablename__ = 'players' account_id = Database.Column(Database.BigInteger, primary_key=True, nullable=False) steam_id = Database.Column(Database.BigInteger, nullable=False, index=True) real_name = Database.Column(Database.String(200), nullable=True) persona_name = Database.Column(Database.String(100), nullable=True) avatar = Database.Column(Database.String(200), nullable=True) profile_url = Database.Column(Database.String(200), nullable=False)
class MatchHero(Model): __tablename__ = 'match_heroes' id = Database.Column(Database.Integer, primary_key=True, nullable=False, autoincrement=True) match_id = Database.Column(Database.Integer, nullable=False, index=True) account_id = Database.Column(Database.BigInteger, nullable=False, index=True) player_win = Database.Column(Database.Boolean, nullable=False) hero_id = Database.Column(Database.Integer, nullable=False)
class MatchHeroSummary(Model): __tablename__ = 'match_hero_summaries' account_id = Database.Column(Database.BigInteger, primary_key=True, nullable=False) hero_id = Database.Column(Database.Integer, Database.ForeignKey('heroes.hero_id'), primary_key=True, nullable=False) player_win = Database.Column(Database.Integer, nullable=False) matches = Database.Column(Database.Integer, nullable=False) win_rate = Database.Column(Database.Numeric(precision=5, scale=2), nullable=False) hero = Database.relationship(Hero)
class MatchItemSummary(Model): __tablename__ = 'match_item_summaries' account_id = Database.Column(Database.BigInteger, primary_key=True, nullable=False) item_id = Database.Column(Database.Integer, Database.ForeignKey('items.item_id'), primary_key=True, nullable=False) player_win = Database.Column(Database.Integer, nullable=False) matches = Database.Column(Database.Integer, nullable=False) win_rate = Database.Column(Database.Numeric(precision=5, scale=2), nullable=False) item = Database.relationship(Item)
def initialise_database(): Database.create_all()