Add multi-tenant architecture and advanced document parsing capabilities
This commit is contained in:
@@ -4,8 +4,9 @@ User model for authentication and user management.
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from sqlalchemy import Column, String, DateTime, Boolean, Text, Enum
|
||||
from sqlalchemy import Column, String, DateTime, Boolean, Text, Enum, ForeignKey
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.orm import relationship
|
||||
import uuid
|
||||
import enum
|
||||
|
||||
@@ -58,6 +59,9 @@ class User(Base):
|
||||
oauth_provider = Column(String(50), nullable=True) # auth0, cognito, etc.
|
||||
oauth_id = Column(String(255), nullable=True)
|
||||
|
||||
# Tenant relationship
|
||||
tenant_id = Column(UUID(as_uuid=True), ForeignKey("tenants.id"), nullable=False)
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
@@ -68,6 +72,9 @@ class User(Base):
|
||||
language = Column(String(10), default="en")
|
||||
notification_preferences = Column(Text, nullable=True) # JSON string
|
||||
|
||||
# Relationships
|
||||
tenant = relationship("Tenant", back_populates="users")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<User(id={self.id}, email='{self.email}', role='{self.role}')>"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user