-- =====================================================
-- 修复 task_feedback 表与 BaseEntity 字段对齐
-- 版本: V47
-- 日期: 2026-03-20
-- 说明: 添加 create_by、update_by，将 deleted_at 改为 deleted
--       解决 POST /api/v1/teacher/tasks/completions/{id}/feedback 报错
--       "Unknown column 'create_by' in 'field list'"
-- =====================================================

-- 1. 添加 create_by、update_by 审计字段
ALTER TABLE task_feedback ADD COLUMN create_by VARCHAR(50) DEFAULT NULL COMMENT '创建人';
ALTER TABLE task_feedback ADD COLUMN update_by VARCHAR(50) DEFAULT NULL COMMENT '更新人';

-- 2. 添加 deleted 字段（与 BaseEntity 一致）
ALTER TABLE task_feedback ADD COLUMN deleted TINYINT DEFAULT 0 COMMENT '删除标识(0-未删除,1-已删除)';

-- 3. 迁移 deleted_at 数据到 deleted
UPDATE task_feedback SET deleted = 1 WHERE deleted_at IS NOT NULL;

-- 4. 删除 deleted_at 列
ALTER TABLE task_feedback DROP COLUMN deleted_at;
