23 lines
858 B
Python
23 lines
858 B
Python
from sqlalchemy import Integer, String, Text, Index
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.models.base import Base, TimestampMixin
|
|
|
|
|
|
class OperationLog(Base, TimestampMixin):
|
|
__tablename__ = "operation_logs"
|
|
|
|
id: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
user_id: Mapped[str] = mapped_column(String(32), index=True)
|
|
username: Mapped[str] = mapped_column(String(64))
|
|
action: Mapped[str] = mapped_column(String(128))
|
|
method: Mapped[str] = mapped_column(String(10))
|
|
path: Mapped[str] = mapped_column(String(256))
|
|
detail: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
ip: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
|
|
__table_args__ = (
|
|
Index('idx_oplog_user_created', 'user_id', 'created_at'),
|
|
Index('idx_oplog_created', 'created_at'),
|
|
)
|