24 lines
887 B
Python
24 lines
887 B
Python
from sqlalchemy import Column, String, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
from .simple_base import Base
|
|
import uuid
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
first_name = Column(String(150), nullable=False)
|
|
last_name = Column(String(150), nullable=False)
|
|
username = Column(String(150), nullable=False, unique=True)
|
|
hashed_password = Column(String(256), nullable=False)
|
|
|
|
group_id = Column(UUID(as_uuid=True), ForeignKey("group.id", ondelete="SET NULL"), nullable=True)
|
|
organization_id = Column(UUID(as_uuid=True), ForeignKey("organization.id", ondelete="SET NULL"), nullable=True)
|
|
|
|
group = relationship("Group", foreign_keys=[group_id])
|
|
organization = relationship("Organization", foreign_keys=[organization_id])
|
|
|
|
__all__ = ["Base", "User"]
|
|
|