
Features: - User authentication with JWT - Client management with CRUD operations - Invoice generation and management - SQLite database with Alembic migrations - Detailed project documentation
28 lines
740 B
Python
28 lines
740 B
Python
from sqlalchemy import Column, Integer, DateTime, func
|
|
from sqlalchemy.ext.declarative import declared_attr
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class TimestampMixin:
|
|
"""
|
|
Mixin that adds created_at and updated_at columns to models
|
|
"""
|
|
created_at = Column(DateTime, default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), nullable=False)
|
|
|
|
|
|
class ModelBase(Base):
|
|
"""
|
|
Base class for all models
|
|
"""
|
|
__abstract__ = True
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
@declared_attr
|
|
def __tablename__(cls) -> str:
|
|
"""
|
|
Generate __tablename__ automatically from class name
|
|
"""
|
|
return cls.__name__.lower() |