23 lines
745 B
Python
23 lines
745 B
Python
"""
|
|
Database models for authentication and core Newzy functionality.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from .database import Base, utcnow
|
|
|
|
|
|
class User(Base):
|
|
"""User model for authentication."""
|
|
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
|
username: Mapped[str] = mapped_column(String(60), unique=True, index=True)
|
|
password_hash: Mapped[str] = mapped_column(String(128))
|
|
is_admin: Mapped[bool] = mapped_column(Boolean, default=False, index=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|