Created
April 21, 2021 22:20
-
-
Save tsatsujnr139/61b621dfbdb112a7f093e76de383abc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from uuid import uuid4 | |
from app.db.base_class import Base | |
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String | |
from sqlalchemy.dialects.postgresql import UUID | |
from sqlalchemy.orm import relationship | |
class User(Base): | |
""" | |
Database Model for an application user | |
""" | |
id = Column( | |
UUID(as_uuid=True), primary_key=True, index=True, default=uuid4 | |
) | |
full_name = Column(String(255), index=True) | |
email = Column(String(100), unique=True, index=True, nullable=False) | |
phone_number = Column(String(13), unique=True, index=True, nullable=True) | |
hashed_password = Column(String(255), nullable=False) | |
is_active = Column(Boolean(), default=True) | |
created_at = Column(DateTime, default=datetime.datetime.utcnow) | |
updated_at = Column( | |
DateTime, | |
default=datetime.datetime.utcnow, | |
onupdate=datetime.datetime.utcnow, | |
) | |
account_id = Column( | |
UUID(as_uuid=True), ForeignKey("accounts.id"), nullable=True | |
) | |
user_role = relationship("UserRole", back_populates="user", uselist=False) | |
account = relationship("Account", back_populates="users") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment