configuration.py 1.4 KB

123456789101112131415161718192021222324252627
  1. from sqlalchemy import Column, Integer, String, Text, TIMESTAMP, func
  2. from app.core.database import Base
  3. class Configuration(Base):
  4. __tablename__ = "configuration"
  5. __ddl__ = """
  6. CREATE TABLE IF NOT EXISTS `configuration` (
  7. `id` INT NOT NULL AUTO_INCREMENT,
  8. `config_key` VARCHAR(255) NOT NULL COMMENT '配置键',
  9. `config_value` MEDIUMTEXT NOT NULL COMMENT '配置值',
  10. `description` TEXT NULL COMMENT '描述',
  11. `type` VARCHAR(50) NULL COMMENT '类型',
  12. `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  13. `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  14. PRIMARY KEY (`id`),
  15. UNIQUE KEY `uq_configuration_config_key` (`config_key`)
  16. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统配置字典表';
  17. """
  18. id = Column(Integer, primary_key=True, autoincrement=True)
  19. config_key = Column(String(255), unique=True, nullable=False, comment="配置键")
  20. config_value = Column(Text, nullable=False, comment="配置值")
  21. description = Column(Text, comment="描述")
  22. type = Column(String(50), comment="类型")
  23. created_at = Column(TIMESTAMP, server_default=func.now(), comment="创建时间")
  24. updated_at = Column(TIMESTAMP, server_default=func.now(), onupdate=func.now(), comment="更新时间")