20 lines
822 B
Python
20 lines
822 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class OperationLog(Base):
|
|
__tablename__ = "operation_logs"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
admin_user_id: Mapped[int | None] = mapped_column(nullable=True, index=True)
|
|
action: Mapped[str] = mapped_column(String(64), index=True)
|
|
object_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
object_id: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
ip_address: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
detail_json: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|