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

42 lines
1.5 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.
-- 修复xljk_consultation_schedule表结构
-- 作者:AI Cursor
-- 日期:2025-07-27
-- 检查time_slot列是否存在,如果不存在则添加
SET @column_exists = (
SELECT COUNT(*)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'xljk_consultation_schedule'
AND COLUMN_NAME = 'time_slot'
);
-- 如果time_slot列不存在,添加它
SET @add_time_slot = CONCAT('ALTER TABLE xljk_consultation_schedule ADD COLUMN time_slot char(1) NOT NULL COMMENT \'时段类型(0上午 1下午)\' AFTER schedule_date');
SET @add_start_time = CONCAT('ALTER TABLE xljk_consultation_schedule ADD COLUMN start_time varchar(5) NOT NULL COMMENT \'开始时间(HH:mm)\' AFTER time_slot');
SET @add_end_time = CONCAT('ALTER TABLE xljk_consultation_schedule ADD COLUMN end_time varchar(5) NOT NULL COMMENT \'结束时间(HH:mm)\' AFTER start_time');
SET @modify_status = CONCAT('ALTER TABLE xljk_consultation_schedule MODIFY COLUMN status char(1) NOT NULL DEFAULT \'0\' COMMENT \'状态(0正常 1停用)\'');
-- 执行SQL语句
PREPARE stmt FROM @add_time_slot;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM @add_start_time;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM @add_end_time;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM @modify_status;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- 确认表结构
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_COMMENT
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'xljk_consultation_schedule'
ORDER BY ORDINAL_POSITION;