Files
012-kaopeilian/backend/scripts/alter_exams_add_rounds.sql
111 998211c483 feat: 初始化考培练系统项目
- 从服务器拉取完整代码
- 按框架规范整理项目结构
- 配置 Drone CI 测试环境部署
- 包含后端(FastAPI)、前端(Vue3)、管理端

技术栈: Vue3 + TypeScript + FastAPI + MySQL
2026-01-24 19:33:28 +08:00

37 lines
986 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 增量脚本为exams表增加三轮得分字段
-- 创建时间2025-10-12
-- 说明:简化三轮考试机制,一条考试记录存储三轮得分
USE kaopeilian;
-- 1. 为exams表增加三轮得分字段
ALTER TABLE exams
ADD COLUMN round1_score FLOAT NULL COMMENT '第一轮得分' AFTER score,
ADD COLUMN round2_score FLOAT NULL COMMENT '第二轮得分' AFTER round1_score,
ADD COLUMN round3_score FLOAT NULL COMMENT '第三轮得分' AFTER round2_score;
-- 2. 为已存在的考试记录设置默认值将score复制到round1_score
UPDATE exams
SET round1_score = score
WHERE score IS NOT NULL AND round1_score IS NULL;
-- 3. 验证结果
SELECT
COUNT(*) as total_exams,
COUNT(round1_score) as has_round1,
COUNT(round2_score) as has_round2,
COUNT(round3_score) as has_round3
FROM exams;
-- 输出结果示例
SELECT
id,
exam_name,
score,
round1_score,
round2_score,
round3_score
FROM exams
LIMIT 5;