insert into base.versions(id,version,updated_at,description)
values(next_id('base.versions'),'0.21.0',now(),'整合sin,std,stu,hr等schema');

create schema qos;
alter table edu.clazz_question_type_stats set schema qos;
alter table edu.teacher_remessages set schema qos;
alter table edu.clazz_question_stats set schema qos;
alter table edu.options set schema qos;
alter table edu.course_question_type_stats set schema qos;
alter table edu.teacher_option_stats set schema qos;
alter table edu.depart_option_stats set schema qos;
alter table edu.final_teacher_scores set schema qos;
alter table edu.factor_segments set schema qos;
alter table edu.question_types set schema qos;
alter table edu.depart_eval_stats set schema qos;
alter table edu.teacher_question_stats set schema qos;
alter table edu.clazz_option_stats set schema qos;
alter table edu.school_question_stats set schema qos;
alter table edu.questionnaires set schema qos;
alter table edu.question_results set schema qos;
alter table edu.teacher_question_type_stats set schema qos;
alter table edu.school_option_stats set schema qos;
alter table edu.depart_question_type_stats set schema qos;
alter table edu.teacher_remessages_students set schema qos;
alter table edu.school_eval_stats set schema qos;
alter table edu.depart_question_stats set schema qos;
alter table edu.questionnaires_questions set schema qos;
alter table edu.questions set schema qos;
alter table edu.questionnaire_clazzes set schema qos;
alter table edu.text_evaluations set schema qos;
alter table edu.evaluation_criteria_items set schema qos;
alter table edu.evaluate_results set schema qos;
alter table edu.option_groups set schema qos;
alter table edu.course_question_stats set schema qos;
alter table edu.teacher_eval_stats set schema qos;
alter table edu.school_question_type_stats set schema qos;
alter table edu.teaching_loads set schema qos;
alter table edu.clazz_eval_stats set schema qos;
alter table edu.course_eval_stats set schema qos;
alter table edu.capacity_factors set schema qos;
alter table edu.teaching_loads_clazz_tags set schema qos;
alter table edu.evaluation_criterias set schema qos;
alter table edu.course_option_stats set schema qos;

drop table hr.post_infoes cascade;
drop table hr.telephones cascade;
drop table hr.urls cascade;
drop table hr.contacts cascade;
drop table hr.xtendeds cascade;
drop table hr.healths cascade;
drop table hr.notes cascade;
drop table hr.emails cascade;
drop table hr.timezones cascade;
drop table hr.photos cascade;
drop table hr.titles cascade;
drop table hr.family_members cascade;
drop table hr.relateds cascade;
drop table hr.geos cascade;
drop table hr.roles cascade;
drop table hr.impps cascade;
drop table hr.nicknames cascade;
drop table hr.orgs cascade;
drop table hr.addresses cascade;

alter table edu.teaching_loads set schema hr;
alter table edu.capacity_factors set schema hr;
alter table edu.factor_segments set schema hr;
alter table hr.staffs drop code cascade;
alter table hr.staffs add column user_id bigint;
alter table hr.staffs alter user_id set not null;
alter table hr.staffs add column school_id integer;
alter table hr.staffs alter school_id set not null;
alter table hr.staffs add constraint fk_7fi8qjxmgmkp1ideqkdpvfsxy foreign key (school_id) references base.schools (id);
alter table hr.staffs add constraint fk_amgwfug55gkfkjidp88wyaj37 foreign key (user_id) references base.users (id);

create table code.whereto_goes (id integer not null, begin_on date not null, code varchar(20) not null unique, en_name varchar(300), end_on date, name varchar(100) not null, remark varchar(200), updated_at timestamp not null);
comment on table code.whereto_goes is '毕业去向';
comment on column code.whereto_goes.id is '非业务主键:auto_increment';
comment on column code.whereto_goes.begin_on is '生效日期';
comment on column code.whereto_goes.code is '代码';
comment on column code.whereto_goes.en_name is '英文名称';
comment on column code.whereto_goes.end_on is '失效日期';
comment on column code.whereto_goes.name is '名称';
comment on column code.whereto_goes.remark is '备注';
comment on column code.whereto_goes.updated_at is '修改时间';
alter table code.whereto_goes add constraint pk_4613lax8xj9thcny8sbdbs84j primary key (id);

alter table stu.punishments set schema std;

drop schema sin cascade;

create table std.minors (school_id integer not null, updated_at timestamp not null, major_name varchar(255) not null, major_category_id integer not null, id bigint not null, std_id bigint not null, en_major_name varchar(255));
alter table std.minors add constraint pk_tokfs2m4b9fdrpsc0dqqost3m primary key (id);
comment on column std.minors.en_major_name is '主修专业英文名';
comment on column std.minors.id is '非业务主键:datetime';
comment on column std.minors.major_category_id is '主修专业学科门类ID';
comment on column std.minors.major_name is '主修专业';
comment on column std.minors.school_id is '主修学校ID';
comment on column std.minors.std_id is '学籍信息实现ID';
comment on column std.minors.updated_at is '更新时间';

