18 lines
661 B
Python
18 lines
661 B
Python
from sqlalchemy import Column, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
from app.api.db.database import Base
|
|
|
|
class User(Base):
|
|
__tablename__ = 'user'
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String, unique=True, nullable=False)
|
|
email = Column(String, unique=True, nullable=False)
|
|
password_hash = Column(String, nullable=False)
|
|
is_active = Column(Integer, default=1)
|
|
bio = Column(Text, nullable=True)
|
|
|
|
posts = relationship("Post", back_populates="author")
|
|
|
|
def __repr__(self):
|
|
return f"User(id={self.id}, username='{self.username}', email='{self.email}')" |