Update models

This commit is contained in:
Midgard 2020-01-26 02:39:58 +01:00
parent d564808417
commit ecb0550fdd
Signed by: midgard
GPG key ID: 511C112F1331BBB4
3 changed files with 28 additions and 23 deletions

View file

@ -1,5 +1,5 @@
This is just a description of the database schema. It's not generated automatically, nor is it used 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 user
@ -9,22 +9,24 @@ user
order order
id id
courier_id
location_id HLDS identifier location_id HLDS identifier
location_name this allows historical orders to keep the same location name location_name this allows historical orders to keep the same location name
create_at starttime
close_at stoptime
creator_id public
courier_id
order_item order_item
id id
order_id order_id
item_id HLDS identifier
user_id user_id
user_name for users who are not logged in user_name for users who are not logged in
price this allows historical orders to keep their correct price dish_id HLDS identifier
product_name dish_name ) this allows historical orders to keep their correct name and price
commit_hash Git commit hash to identify HLDS data version price )
paid
comment
hlds_data_version Git commit hash to identify HLDS data version
order_item_choice order_item_choice
id id

View file

@ -11,10 +11,12 @@ class Order(db.Model):
"Class used for configuring the Order model in the database" "Class used for configuring the Order model in the database"
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
courier_id = db.Column(db.Integer, nullable=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) starttime = db.Column(db.DateTime)
stoptime = db.Column(db.DateTime) stoptime = db.Column(db.DateTime)
public = db.Column(db.Boolean, default=True) public = db.Column(db.Boolean, default=True)
items = db.relationship("OrderItem", backref="order", lazy="dynamic") items = db.relationship("OrderItem", backref="order", lazy="dynamic")
def configure(self, courier: User, location: Location, def configure(self, courier: User, location: Location,

View file

@ -10,16 +10,17 @@ from .user import User
class OrderItem(db.Model): class OrderItem(db.Model):
"Class used for configuring the OrderItem model in the database" "Class used for configuring the OrderItem model in the database"
id = db.Column(db.Integer, primary_key=True) 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) order_id = db.Column(db.Integer, db.ForeignKey("order.id"), nullable=False)
product_id = db.Column( user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
db.Integer, db.ForeignKey("product.id"), nullable=True user_name = db.Column(db.String(120))
) # TODO make false after init migration 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( paid = db.Column(
db.Boolean, default=False, nullable=True db.Boolean, default=False, nullable=False
) # TODO make false after init migration )
extra = db.Column(db.String(254), nullable=True) comment = db.Column(db.String(254), nullable=True)
name = db.Column(db.String(120)) hlds_data_version = db.Column(db.String(40), nullable=True)
def configure(self, user: User, order: Order, product: Product) -> None: def configure(self, user: User, order: Order, product: Product) -> None:
"Configure the OrderItem" "Configure the OrderItem"