32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, DateTime, ForeignKey, String, Text, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class AuditEventRecord(Base):
|
|
__tablename__ = "audit_events"
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
audit_event_id: Mapped[str] = mapped_column(String(32), unique=True, index=True, nullable=False)
|
|
|
|
scheme_id: Mapped[str] = mapped_column(
|
|
String(32),
|
|
ForeignKey("schemes.scheme_id", ondelete="RESTRICT"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
|
|
event_type: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
object_type: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
object_ref: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
details_json: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=func.now(),
|
|
)
|