Files
hzdyjs/docs/设计文档/database/心理咨询预约/update_consultation_tables.sql
T

46 lines
2.0 KiB
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.
-- 修改心理咨询预约表结构
-- 作者:AI Cursor
-- 日期:2025-07-27
-- 1. 删除不再使用的表(如果存在)
-- 注意:我们保留这些表,但在代码中不再使用它们
-- DROP TABLE IF EXISTS xljk_consultation_record;
-- DROP TABLE IF EXISTS xljk_consultation_no_show;
-- DROP TABLE IF EXISTS xljk_consultation_counselor;
-- 2. 修改xljk_consultation_appointment表,添加咨询记录相关字段
ALTER TABLE xljk_consultation_appointment
DROP COLUMN student_name,
DROP COLUMN student_no,
DROP COLUMN phone,
DROP COLUMN major,
DROP COLUMN class_name,
DROP COLUMN time_slot,
DROP COLUMN apply_time,
DROP COLUMN process_time,
DROP COLUMN process_remark,
ADD COLUMN appointment_time varchar(20) NOT NULL COMMENT '预约时间段',
ADD COLUMN reason varchar(500) DEFAULT NULL COMMENT '咨询原因',
MODIFY COLUMN status char(1) NOT NULL DEFAULT '0' COMMENT '状态(0待咨询 1已完成 2已取消 3未到访)',
ADD COLUMN actual_visit_time datetime DEFAULT NULL COMMENT '实际到访时间',
ADD COLUMN communication_duration int DEFAULT NULL COMMENT '沟通时长(分钟)',
ADD COLUMN consultation_content text DEFAULT NULL COMMENT '咨询内容',
ADD COLUMN counselor_suggestion text DEFAULT NULL COMMENT '咨询师建议';
-- 3. 修改xljk_consultation_schedule表,简化时段设置
ALTER TABLE xljk_consultation_schedule
DROP COLUMN morning_enabled,
DROP COLUMN morning_start_time,
DROP COLUMN morning_end_time,
DROP COLUMN afternoon_enabled,
DROP COLUMN afternoon_start_time,
DROP COLUMN afternoon_end_time,
DROP COLUMN max_appointments,
DROP COLUMN current_appointments,
ADD COLUMN time_slot char(1) NOT NULL COMMENT '时段类型(0上午 1下午)',
ADD COLUMN start_time varchar(5) NOT NULL COMMENT '开始时间(HH:mm)',
ADD COLUMN end_time varchar(5) NOT NULL COMMENT '结束时间(HH:mm)',
MODIFY COLUMN status char(1) NOT NULL DEFAULT '0' COMMENT '状态(0正常 1停用)';
-- 4. 添加菜单和权限(如果需要)
-- 这部分可以根据需要添加到sys_menu表中