system_config_his.py 1.4 KB

12345678910111213141516171819202122232425
  1. """
  2. 系统配置历史记录模型(与 system_config 镜像 + his 字段)
  3. """
  4. from sqlalchemy import Column, Integer, String, DateTime, SmallInteger, Enum
  5. from app.database import Base
  6. from app.utils.timezone import beijing_now
  7. class SystemConfigHis(Base):
  8. """系统配置表历史记录(与 system_config 镜像)"""
  9. __tablename__ = "system_config_his"
  10. id = Column(Integer, primary_key=True, comment="原表主键ID")
  11. config_key = Column(String(100), nullable=False, index=True, comment="配置键名")
  12. config_value = Column(String(500), nullable=False, comment="配置值")
  13. config_type = Column(Enum('int', 'string', 'bool', 'json'), default='string', comment="配置值类型")
  14. app_name = Column(String(100), default='backend-admin', comment="所属应用")
  15. description = Column(String(255), comment="配置描述")
  16. is_system = Column(SmallInteger, default=1, comment="是否为系统配置:1-是,0-否")
  17. is_editable = Column(SmallInteger, default=1, comment="是否可编辑:1-是,0-否")
  18. is_deleted = Column(SmallInteger, default=0, comment="是否删除:0-否,1-是")
  19. created_at = Column(DateTime, comment="创建时间")
  20. updated_at = Column(DateTime, comment="更新时间")
  21. his_created_at = Column(DateTime, primary_key=True, default=beijing_now, comment="历史记录创建时间")
  22. his_operation = Column(String(10), nullable=False, comment="操作类型:INSERT/UPDATE/DELETE")