-- 应用配置表
CREATE TABLE app_config (
  config_id INT PRIMARY KEY AUTO_INCREMENT COMMENT '配置ID',
  website_id INT NOT NULL COMMENT '应用ID',
  config_key VARCHAR(100) NOT NULL COMMENT '配置键',
  config_value TEXT NOT NULL COMMENT '配置值（JSON或字符串）',
  config_type VARCHAR(50) NOT NULL DEFAULT 'general' COMMENT '配置类型：general/api/callback/wechat/payment/git等',
  is_encrypted TINYINT DEFAULT 0 COMMENT '是否加密 0否 1是',
  is_secret TINYINT DEFAULT 0 COMMENT '是否敏感信息 0否 1是',
  description VARCHAR(500) DEFAULT '' COMMENT '配置说明',
  sort_number INT DEFAULT 0 COMMENT '排序号',
  tenant_id BIGINT NOT NULL DEFAULT 0 COMMENT '租户id',
  created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  deleted TINYINT DEFAULT 0 COMMENT '是否删除 0否 1是',
  UNIQUE KEY uk_website_key (website_id, config_key, deleted),
  INDEX idx_website_type (website_id, config_type),
  INDEX idx_tenant (tenant_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用配置表';
