class SystemConfig(db.Model): """SytemConfig is a table with various configuration options that are coded into the db""" sid = db.Column(db.Integer(), db.Sequence('sid', start=1, increment=1), primary_key=True) block_clients_below_version_android = db.Column( 'block_clients_below_version_android', db.String(100), nullable=False, primary_key=False) block_clients_below_version_ios = db.Column( 'block_clients_below_version_ios', db.String(100), nullable=False, primary_key=False) update_available_below_version_android = db.Column( 'update_available_below_version_android', db.String(100), nullable=False, primary_key=False) update_available_below_version_ios = db.Column( 'update_available_below_version_ios', db.String(100), nullable=False, primary_key=False) categories_extra_data = db.Column( db.JSON) # all sorts of extra global data pertaining to categories
class BackupQuestion(db.Model): """the BackupQuestion model represents a single backup question. these are essentially hardcoded into the db. """ sid = db.Column(db.Integer(), db.Sequence('sid', start=1, increment=1), primary_key=True) question_text = db.Column('question_text', db.String(300), unique=True) updated_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now()) def __repr__(self): return '<sid: %s, question_text: %s' \ ' updated_at: %s>' % (self.sid, self.question_text, self.updated_at)
class User(db.Model): ''' the user model ''' sid = db.Column(db.Integer(), db.Sequence('sid', start=1, increment=1), primary_key=False) user_id = db.Column(UUIDType(binary=False), primary_key=True, nullable=False) os_type = db.Column(db.String(10), primary_key=False, nullable=False) device_model = db.Column(db.String(40), primary_key=False, nullable=False) push_token = db.Column(db.String(200), primary_key=False, nullable=True) time_zone = db.Column(db.String(10), primary_key=False, nullable=False) device_id = db.Column(db.String(40), primary_key=False, nullable=True) created_at = db.Column(db.DateTime(timezone=False), server_default=db.func.now()) onboarded = db.Column(db.Boolean, unique=False, default=False) def __repr__(self): return '<sid: %s, user_id: %s, os_type: %s, device_model: %s, push_token: %s, time_zone: %s, device_id: %s, onboarded: %s>' % (self.sid, self.user_id, self.os_type, self.device_model, self.push_token, self.time_zone, self.device_id, self.onboarded)
class Good(db.Model): '''the Good class represent a single goods (as in, the singular of Goods). Goods are pre-populated into the db and have a limited number of instances. Each good instance is a row in the db. ''' sid = db.Column(db.Integer(), db.Sequence('sid', start=1, increment=1), primary_key=True) offer_id = db.Column('offer_id', db.String(40), db.ForeignKey("offer.offer_id"), primary_key=False, nullable=False, unique=False) #order_id = db.Column('order_id', db.String(config.ORDER_ID_LENGTH), db.ForeignKey("order.order_id"), primary_key=False, nullable=True, unique=True) # TODO the order_id should be a foreign key, but that implies that orders are created BEFORE the good is allocated. this # needs to be improved somehow. order_id = db.Column(db.String(40), primary_key=False, nullable=True, unique=True) value = db.Column(db.JSON(), nullable=False) good_type = db.Column(db.String(40), primary_key=False, nullable=False) tx_hash = db.Column('tx_hash', db.String(100), db.ForeignKey("transaction.tx_hash"), primary_key=False, nullable=True) created_at = db.Column(ArrowType) updated_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now(), onupdate=db.func.now()) def __repr__(self): return '<sid: %s, offer_id: %s, order_id: %s, type: %s, tx_hash: %s, created_at: %s, updated_at: %s>' % (self.sid, self.offer_id, self.order_id, self.good_type, self.tx_hash, self.created_at, self.updated_at)