/* 用户视图：医生、患者、用户微信状态、微信系统access_token*/
create or replace view doctors as 
select code id, name, sex, birthday birthdate, photo avatar, hospital_name, level
from wlyy.wlyy_doctor;

create or replace view patients as 
select code id, name, sex, birthday birthdate, photo avatar, openid
from wlyy.wlyy_patient;

CREATE OR REPLACE VIEW user_tokens AS
SELECT id, user, platform, timeout, imei, token
FROM wlyy.wlyy_token;

create or replace view wechat_status as
select code user_id, openid openid
from wlyy.wlyy_patient;

create or replace view wechat_access_tokens as
select access_token, expires_in, add_timestamp from wlyy.wx_access_token;

/*三师后台咨询消息ID字段类型修改*/
ALTER TABLE wlyy.wlyy_consult_team
  MODIFY COLUMN `end_msg_id`  varchar(50) NULL DEFAULT NULL AFTER `guidance`,
  MODIFY COLUMN `start_msg_id`  varchar(50) NULL DEFAULT NULL AFTER `end_msg_id`;