Problem 1: Add role_id FK column to User model (references roles.id, nullable, ondelete SET NULL)

This commit is contained in:
2026-07-03 19:48:39 +00:00
parent 5138590277
commit 530cfd485f
+6
View File
@@ -27,6 +27,12 @@ class User(Base, TenantMixin):
name: Mapped[str] = mapped_column(String(200), nullable=False)
password_hash: Mapped[str] = mapped_column(String(255), nullable=False)
role: Mapped[str] = mapped_column(String(50), nullable=False, default="viewer")
role_id: Mapped[uuid.UUID | None] = mapped_column(
PGUUID(as_uuid=True),
ForeignKey("roles.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
preferences: Mapped[dict[str, Any]] = mapped_column(JSONB, default=dict, nullable=False)