
- Created user model with SQLAlchemy ORM - Implemented authentication with JWT tokens (access and refresh tokens) - Added password hashing with bcrypt - Created API endpoints for registration, login, and user management - Set up Alembic for database migrations - Added health check endpoint - Created role-based access control (standard users and superusers) - Added comprehensive documentation
15 lines
553 B
Python
15 lines
553 B
Python
from sqlalchemy import Column, DateTime, Integer, func
|
|
from sqlalchemy.ext.declarative import declared_attr
|
|
|
|
|
|
class BaseModel:
|
|
"""Base model class for all SQLAlchemy models"""
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
created_at = Column(DateTime, default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), nullable=False)
|
|
|
|
@declared_attr
|
|
def __tablename__(cls):
|
|
"""Automatically generates table name from class name"""
|
|
return cls.__name__.lower() |