Spaces:
Sleeping
Sleeping
| """ | |
| User Document Link Model | |
| """ | |
| from sqlalchemy import Column, String, Text, Date | |
| from sqlalchemy.dialects.postgresql import UUID, JSONB | |
| from datetime import datetime | |
| from app.core.database import Base | |
| import uuid | |
| class UserDocumentLink(Base): | |
| """ | |
| User Document Link model - Links users to their identity/compliance documents | |
| """ | |
| __tablename__ = "user_document_links" | |
| id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) | |
| user_id = Column(UUID(as_uuid=True), nullable=False) | |
| document_id = Column(UUID(as_uuid=True), nullable=False) | |
| # Document type | |
| document_link_type = Column(Text, nullable=False) # 'national_id', 'driver_license', etc. | |
| # Expiry tracking | |
| issued_at = Column(Date) | |
| expires_at = Column(Date) | |
| # Metadata | |
| notes = Column(Text) | |
| additional_metadata = Column(JSONB, default=dict) | |
| # Timestamps | |
| created_at = Column(String(50), default=lambda: datetime.utcnow().isoformat()) | |
| updated_at = Column(String(50), default=lambda: datetime.utcnow().isoformat()) | |
| def __repr__(self): | |
| return f"<UserDocumentLink(user_id='{self.user_id}', type='{self.document_link_type}')>" | |