from sqlalchemy.sql import func from app import db class PlayerCaughtPlayer(db.Model): __tablename__ = 'player_caught_player' id = db.Column(db.Integer, primary_key=True, autoincrement=True, server_default='-1') catching_player_id = db.Column(db.Integer, db.ForeignKey('game_player.id'), nullable=False) caught_player_id = db.Column(db.Integer, db.ForeignKey('game_player.id'), nullable=False) photo_reference = db.Column(db.String(128), unique=True, nullable=False) timestamp = db.Column(db.DateTime, server_default=func.now(), nullable=False) catching_player = db.relationship('GamePlayer', back_populates='player_caught_by_players', foreign_keys=[catching_player_id]) caught_player = db.relationship('GamePlayer', back_populates='player_caught_players', foreign_keys=[caught_player_id])