config_center/app/models/config_history.py
2025-03-06 13:25:20 +08:00

24 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, func
from sqlalchemy.orm import relationship
from app.models.database import Base
class ConfigHistory(Base):
__tablename__ = "config_history"
history_id = Column(Integer, primary_key=True, index=True, autoincrement=True)
config_id = Column(Integer, ForeignKey("configs.config_id"), nullable=False)
type_id = Column(Integer, ForeignKey("types.type_id"), nullable=False)
key = Column(String, nullable=False)
old_value = Column(String, nullable=False)
new_value = Column(String, nullable=False)
operator = Column(String, nullable=True) # 操作人
operation_type = Column(String, nullable=False) # 操作类型create/update/delete
created_at = Column(DateTime, default=func.now())
# 关联配置
config = relationship("Config")
# 关联类型
type = relationship("Type")
def __repr__(self):
return f"<ConfigHistory(history_id={self.history_id}, config_id={self.config_id}, operation_type='{self.operation_type}')>"