class Item(DB.Model): """Item database model""" __tablename__ = 'items' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) create_date = DB.Column(DB.DateTime, nullable=False, default=datetime.utcnow) user_id = DB.Column(DB.Integer, DB.ForeignKey(User.__tablename__ + '.id'), nullable=False) location_id = DB.Column(DB.Integer, DB.ForeignKey(Location.__tablename__ + '.id'), nullable=True) description = DB.Column(DB.Text, nullable=True) name = DB.Column(DB.Text, nullable=False) purchase_date = DB.Column(DB.DateTime, nullable=True) purchase_price = DB.Column(DB.Numeric(precision=19, scale=4, asdecimal=True), nullable=True) sell_date = DB.Column(DB.DateTime, nullable=True) sell_price = DB.Column(DB.Numeric(precision=19, scale=4, asdecimal=True), nullable=True) listed_price = DB.Column(DB.Numeric(precision=19, scale=4, asdecimal=True), nullable=True) pictures = DB.relationship("Picture", cascade="all,delete", backref="item")
class Location(DB.Model): """Location database model""" __tablename__ = 'locations' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) name = DB.Column(DB.String(120), nullable=False) user_id = DB.Column(DB.Integer, DB.ForeignKey(User.__tablename__ + '.id'), nullable=False)
class Hype(DB.Model): """Hype database model""" __tablename__ = 'hypes' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) event_id = DB.Column(DB.Integer, DB.ForeignKey(Event.__tablename__ + '.id', ondelete='CASCADE'), nullable=False) account_id = DB.Column(DB.Integer, DB.ForeignKey(Account.__tablename__ + '.id', ondelete='CASCADE'), nullable=False) create_date = DB.Column(DB.DateTime, nullable=False, default=datetime.utcnow) __table_args__ = (DB.UniqueConstraint( 'event_id', 'account_id', name='_hype_event_account_unique_constraint'), )
class Picture(DB.Model): """Picture database model""" __tablename__ = 'pictures' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) create_date = DB.Column(DB.DateTime, nullable=False, default=datetime.utcnow) item_id = DB.Column(DB.Integer, DB.ForeignKey(Item.__tablename__ + '.id'), nullable=False) path = DB.Column(DB.Text, nullable=False)
class PlayerSession(DB.Model): """Player->Game session database model""" __tablename__ = 'playersession' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) username = DB.Column(DB.String(64), nullable=False) session_key = DB.Column(DB.String(8), nullable=False) buzz_time = DB.Column(DB.DateTime, nullable=True) game_id = DB.Column(DB.Integer, DB.ForeignKey(Game.__tablename__ + '.id', ondelete='CASCADE'), nullable=False) is_creator = DB.Column(DB.Boolean, nullable=False, default=False)
class Event(DB.Model): """Event database model""" __tablename__ = 'events' id = DB.Column(DB.Integer, nullable=False, autoincrement=True, primary_key=True) latitude = DB.Column(DB.Float(precision=32, asdecimal=True), nullable=False) longitude = DB.Column(DB.Float(precision=32, asdecimal=True), nullable=False) account_id = DB.Column(DB.Integer, DB.ForeignKey(Account.__tablename__ + '.id', ondelete='CASCADE'), nullable=False) time = DB.Column(DB.DateTime, nullable=False) group_size_max = DB.Column(DB.Integer, nullable=False) group_size_min = DB.Column(DB.Integer, nullable=False) title = DB.Column(DB.String(50), nullable=False) category = DB.Column(DB.String(50), nullable=False) description = DB.Column(DB.String(140), nullable=False) create_date = DB.Column(DB.DateTime, nullable=False, default=datetime.utcnow)