| 1234567891011121314151617181920212223242526272829303132333435363738 |
- from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, UniqueConstraint, Index
- from sqlalchemy.sql import func
- from app.database import Base
- class SystemConfig(Base):
- __tablename__ = "system_config"
- __table_args__ = (
- UniqueConstraint("tenant_id", "config_key", name="uq_system_config_tenant_key"),
- Index("idx_system_config_tenant_id", "tenant_id"),
- {"schema": "aigcspace"},
- )
- id = Column(Integer, primary_key=True, index=True)
- tenant_id = Column(Integer, ForeignKey("aigcspace.tenants.id"), nullable=True, index=True)
- config_key = Column(String(100), nullable=False, index=True)
- config_value = Column(Text, nullable=False)
- config_type = Column(String(20), nullable=False)
- category = Column(String(50), nullable=False, index=True)
- description = Column(String(500))
- updated_by = Column(Integer, ForeignKey("aigcspace.enterprise_admins.id"), nullable=True)
- updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
- created_at = Column(DateTime, default=func.now())
- class ConfigHistory(Base):
- __tablename__ = "config_history"
- __table_args__ = (
- Index("idx_config_history_tenant_id", "tenant_id"),
- {"schema": "aigcspace"},
- )
- id = Column(Integer, primary_key=True, index=True)
- tenant_id = Column(Integer, ForeignKey("aigcspace.tenants.id"), nullable=True, index=True)
- config_key = Column(String(100), nullable=False, index=True)
- old_value = Column(Text)
- new_value = Column(Text, nullable=False)
- updated_by = Column(Integer, ForeignKey("aigcspace.enterprise_admins.id"), nullable=True)
- updated_at = Column(DateTime, default=func.now(), index=True)
|