| 12345678910111213141516171819202122232425 |
- """
- 历史记录基类
- """
- from datetime import datetime
- from app.utils.timezone import beijing_now_naive
- from sqlalchemy import Column, Integer, String, DateTime
- from app.database import Base
- class HistoryBase(Base):
- """主表基类:提供 id、created_at、updated_at 等通用字段"""
- __abstract__ = True
- id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID")
- created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间")
- updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间")
- class HistoryRecord(Base):
- """历史记录基类"""
- __abstract__ = True
-
- # 原表所有字段的副本
- his_created_at = Column(DateTime, default=beijing_now_naive, comment="历史记录创建时间")
- his_operation = Column(String(10), nullable=False, comment="操作类型: INSERT/UPDATE/DELETE/RENEW")
|