30 lines
926 B
Python
30 lines
926 B
Python
"""
|
|
系统配置数据模型
|
|
"""
|
|
|
|
from sqlalchemy import Column, String, DateTime, Index
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
from ..core.database import Base
|
|
|
|
|
|
class SystemConfig(Base):
|
|
"""系统配置表模型"""
|
|
|
|
__tablename__ = "system_config"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
config_key = Column(String(100), unique=True, nullable=False, comment="配置键")
|
|
config_value = Column(JSONB, nullable=False, comment="配置值")
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="更新时间")
|
|
|
|
# 索引
|
|
__table_args__ = (
|
|
Index('idx_system_config_key', 'config_key'),
|
|
Index('idx_system_config_updated_at', 'updated_at'),
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<SystemConfig(key={self.config_key})>" |