| 123456789101112131415161718192021222324252627 |
- from sqlalchemy import Column, Integer, String, Text, TIMESTAMP, func
- from app.core.database import Base
- class Configuration(Base):
- __tablename__ = "configuration"
- __ddl__ = """
- CREATE TABLE IF NOT EXISTS `configuration` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `config_key` VARCHAR(255) NOT NULL COMMENT '配置键',
- `config_value` MEDIUMTEXT NOT NULL COMMENT '配置值',
- `description` TEXT NULL COMMENT '描述',
- `type` VARCHAR(50) NULL COMMENT '类型',
- `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- PRIMARY KEY (`id`),
- UNIQUE KEY `uq_configuration_config_key` (`config_key`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统配置字典表';
- """
- id = Column(Integer, primary_key=True, autoincrement=True)
- config_key = Column(String(255), unique=True, nullable=False, comment="配置键")
- config_value = Column(Text, nullable=False, comment="配置值")
- description = Column(Text, comment="描述")
- type = Column(String(50), comment="类型")
- created_at = Column(TIMESTAMP, server_default=func.now(), comment="创建时间")
- updated_at = Column(TIMESTAMP, server_default=func.now(), onupdate=func.now(), comment="更新时间")
|