aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-backend/src
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-08-16 19:04:08 +0100
committerGravatar Chris Lovering <[email protected]>2024-08-16 19:05:30 +0100
commitcb25697c23c1b271e5b8efc78c2c3d5df7321dd3 (patch)
tree799938ed51692e686c80cc6366c9f31ee775a72f /thallium-backend/src
parentAdd a database backend and migrations (diff)
Add users and products to the database
Diffstat (limited to 'thallium-backend/src')
-rw-r--r--thallium-backend/src/orm/products.py18
-rw-r--r--thallium-backend/src/orm/users.py12
2 files changed, 30 insertions, 0 deletions
diff --git a/thallium-backend/src/orm/products.py b/thallium-backend/src/orm/products.py
new file mode 100644
index 0000000..2c07b75
--- /dev/null
+++ b/thallium-backend/src/orm/products.py
@@ -0,0 +1,18 @@
+from decimal import Decimal
+
+from sqlalchemy.orm import Mapped, mapped_column
+from sqlalchemy.types import LargeBinary
+
+from .base import AuditBase, Base
+
+
+class Product(AuditBase, Base):
+ """A product available to be ordered."""
+
+ __tablename__ = "products"
+
+ product_id: Mapped[int] = mapped_column(primary_key=True)
+ name: Mapped[str]
+ description: Mapped[str]
+ price: Mapped[Decimal]
+ image: Mapped[bytes] = mapped_column(LargeBinary, deferred=True)
diff --git a/thallium-backend/src/orm/users.py b/thallium-backend/src/orm/users.py
new file mode 100644
index 0000000..065519a
--- /dev/null
+++ b/thallium-backend/src/orm/users.py
@@ -0,0 +1,12 @@
+from sqlalchemy.orm import Mapped, mapped_column
+
+from .base import AuditBase, Base
+
+
+class User(AuditBase, Base):
+ """An authenticated user of the service."""
+
+ __tablename__ = "users"
+
+ user_id: Mapped[int] = mapped_column(primary_key=True)
+ is_admin: Mapped[bool]