class Item(db.Model): __tablename__ = 'item' id = db.Column(UUIDType(binary=False), primary_key=True) name = db.Column(db.Text) unit_price = db.Column(db.Numeric) def __init__(self, id=None, name=None, unit_price=None): self.id = id self.name = name self.unit_price = unit_price def __repr__(self): return "<Item %r>" % self.id
class Store(db.Model): __tablename__ = 'store' id = db.Column(UUIDType(binary=False), primary_key=True) name = db.Column(db.Text) address = db.Column(db.Text) def __init__(self, id=None, name=None, address=None): self.id = id self.name = name self.address = address def __repr__(self): return "<Store %r>" % self.id
class OrderItem(db.Model): __tablename__ = 'order_item' id = db.Column(UUIDType(binary=False), primary_key=True) order_id = db.Column(UUIDType(binary=False), ForeignKey('order.id')) item_id = db.Column(UUIDType(binary=False), ForeignKey('item.id')) order = relationship("Order", backref=backref('order_item', order_by=id)) item = relationship("Item", backref=backref('order_item', order_by=id)) def __init__(self, id=None, order_id=None, item_id=None): self.id = id self.order_id = order_id self.item_id = item_id def __repr__(self): return "<OrderItem %r>" % self.id
class User(db.Model): __tablename__ = 'user' id = db.Column(UUIDType(binary=False), primary_key=True) name = db.Column(db.Text) gender = db.Column(db.Text) age = db.Column(db.Numeric) ages = db.Column(db.Numeric) phone = db.Column(db.Text) birthdate = db.Column(db.Date) def __init__(self, id=None, name=None, gender=None, age=None, ages=None, phone=None, birthdate=None): self.id = id self.name = name self.gender = gender self.age = age self.ages = ages self.phone = phone self.birthdate = birthdate def __repr__(self): return "<User %r>" % self.id
class Order(db.Model): __tablename__ = 'order' id = db.Column(UUIDType(binary=False), primary_key=True) created_at = db.Column(db.TIMESTAMP) store_id = db.Column(UUIDType(binary=False), ForeignKey('store.id')) user_id = db.Column(UUIDType(binary=False), ForeignKey('user.id')) user = relationship("User", backref=backref('order', order_by=id)) store = relationship("Store", backref=backref('order', order_by=id)) def __init__(self, id=None, created_at=None, store_id=None, user_id=None): self.id = id self.created_at = created_at self.store_id = store_id self.user_id = user_id def __repr__(self): return "<Order %r>" % self.id