Update models
This commit is contained in:
parent
d564808417
commit
ecb0550fdd
3 changed files with 28 additions and 23 deletions
|
@ -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,28 +9,30 @@ user
|
||||||
|
|
||||||
order
|
order
|
||||||
id
|
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
|
courier_id
|
||||||
|
location_id HLDS identifier
|
||||||
|
location_name this allows historical orders to keep the same location name
|
||||||
|
starttime
|
||||||
|
stoptime
|
||||||
|
public
|
||||||
|
|
||||||
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
|
||||||
choice_id HLDS identifier
|
choice_id HLDS identifier
|
||||||
kind single_choice/multi_choice
|
kind single_choice/multi_choice
|
||||||
order_item
|
order_item
|
||||||
name
|
name
|
||||||
description
|
description
|
||||||
value just a textual description of the chosen values
|
value just a textual description of the chosen values
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in a new issue