diff --git a/app/database/muhscheme.txt b/app/database/muhscheme.txt index 2937354..6245514 100644 --- a/app/database/muhscheme.txt +++ b/app/database/muhscheme.txt @@ -1,5 +1,5 @@ This is just a description of the database schema. It's not generated automatically, nor is it used -to automatically generate anything. +to automatically generate anything. For the latest version, check the files in app/models/ user @@ -9,28 +9,30 @@ user order id - location_id HLDS identifier - location_name this allows historical orders to keep the same location name - create_at - close_at - creator_id courier_id + location_id HLDS identifier + location_name this allows historical orders to keep the same location name + starttime + stoptime + public order_item id order_id - item_id HLDS identifier user_id - user_name for users who are not logged in - price this allows historical orders to keep their correct price - product_name - commit_hash Git commit hash to identify HLDS data version + user_name for users who are not logged in + dish_id HLDS identifier + dish_name ) this allows historical orders to keep their correct name and price + price ) + paid + comment + hlds_data_version Git commit hash to identify HLDS data version order_item_choice id - choice_id HLDS identifier - kind single_choice/multi_choice + choice_id HLDS identifier + kind single_choice/multi_choice order_item name description - value just a textual description of the chosen values + value just a textual description of the chosen values diff --git a/app/models/order.py b/app/models/order.py index 17309f4..640965c 100644 --- a/app/models/order.py +++ b/app/models/order.py @@ -11,10 +11,12 @@ class Order(db.Model): "Class used for configuring the Order model in the database" id = db.Column(db.Integer, primary_key=True) courier_id = db.Column(db.Integer, nullable=True) - location_id = db.Column(db.Integer, db.ForeignKey("location.id")) + location_id = db.Column(db.String(64)) + location_name = db.Column(db.String(128)) starttime = db.Column(db.DateTime) stoptime = db.Column(db.DateTime) public = db.Column(db.Boolean, default=True) + items = db.relationship("OrderItem", backref="order", lazy="dynamic") def configure(self, courier: User, location: Location, diff --git a/app/models/orderitem.py b/app/models/orderitem.py index 9850783..78b5546 100644 --- a/app/models/orderitem.py +++ b/app/models/orderitem.py @@ -10,16 +10,17 @@ from .user import User class OrderItem(db.Model): "Class used for configuring the OrderItem model in the database" id = db.Column(db.Integer, primary_key=True) - user_id = db.Column(db.Integer, db.ForeignKey("user.id")) order_id = db.Column(db.Integer, db.ForeignKey("order.id"), nullable=False) - product_id = db.Column( - db.Integer, db.ForeignKey("product.id"), nullable=True - ) # TODO make false after init migration + user_id = db.Column(db.Integer, db.ForeignKey("user.id")) + user_name = db.Column(db.String(120)) + dish_id = db.Column(db.String(120), nullable=True) + dish_name = db.Column(db.String(120), nullable=True) + price = db.Column(db.Integer, nullable=False) paid = db.Column( - db.Boolean, default=False, nullable=True - ) # TODO make false after init migration - extra = db.Column(db.String(254), nullable=True) - name = db.Column(db.String(120)) + db.Boolean, default=False, nullable=False + ) + comment = db.Column(db.String(254), nullable=True) + hlds_data_version = db.Column(db.String(40), nullable=True) def configure(self, user: User, order: Order, product: Product) -> None: "Configure the OrderItem"