-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
22 lines (19 loc) · 1 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from app import db
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(150), nullable=False, unique=True)
password_hash = db.Column(db.String(128), nullable=False)
email = db.Column(db.String(150), nullable=False, unique=True)
role = db.Column(db.String(50), nullable=False) # 'admin' or 'customer'
class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(150), nullable=False)
description = db.Column(db.String(500), nullable=False)
price = db.Column(db.Float, nullable=False)
stock = db.Column(db.Integer, nullable=False)
class Order(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
product_id = db.Column(db.Integer, db.ForeignKey('product.id'), nullable=False)
quantity = db.Column(db.Integer, nullable=False)
status = db.Column(db.String(50), nullable=False) # 'pending', 'shipped', etc.