aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-backend/src/orm/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'thallium-backend/src/orm/base.py')
-rw-r--r--thallium-backend/src/orm/base.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/thallium-backend/src/orm/base.py b/thallium-backend/src/orm/base.py
index ec79d99..5fd70d6 100644
--- a/thallium-backend/src/orm/base.py
+++ b/thallium-backend/src/orm/base.py
@@ -32,10 +32,15 @@ class Base(AsyncAttrs, DeclarativeBase):
setattr(self, key, value)
+class UUIDBase:
+ """Adds a pre-populated UUID as the tables PK."""
+
+ id: Mapped[UUID] = mapped_column(server_default=text("gen_random_uuid()"), primary_key=True)
+
+
class AuditBase:
"""Common columns for a table with UUID PK and datetime audit columns."""
- id: Mapped[UUID] = mapped_column(server_default=text("gen_random_uuid()"), primary_key=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),