Files
huike-back/htykc_models/migrations/2024-01-17-094242_init_tbls/up.sql
T
weli 44c320d8fa chore add core rust project files and diesel migrations
Track required workspace crates, scripts, and historical diesel migrations so the repository contains the complete runnable backend baseline.

Made-with: Cursor
2026-04-23 17:20:01 +08:00

74 lines
2.3 KiB
SQL

-- Your SQL goes here
create table kecheng
(
id varchar not null
constraint kecheng_teacher_pk
primary key,
kecheng_name varchar not null,
kecheng_status varchar not null,
kecheng_desc varchar,
start_from timestamp not null,
end_by timestamp not null,
duration integer,
root_id varchar not null
constraint kecheng_teacher_kecheng_teacher_id_fk
references kecheng,
kecheng_type varchar,
parent_id varchar not null
constraint kecheng_kecheng_id_fk
references kecheng,
created_by varchar,
created_at timestamp
);
comment on column kecheng.duration is '课程时长(分钟)';
comment on column kecheng.kecheng_type is '未来可能用前端的在线上课功能';
comment on column kecheng.parent_id is '第一条数据的`parent_id`是自己。';
create unique index kecheng_teacher_id_uindex
on kecheng (id);
create table kecheng_repeat
(
id varchar not null
primary key,
kecheng_id varchar not null
constraint kecheng_repeat_kecheng_id_fk
references kecheng,
start_from timestamp,
end_by timestamp,
repeat_start timestamp,
repeat_cycle_days integer not null,
repeat_end timestamp,
repeat_status varchar not null
);
comment on column kecheng_repeat.start_from is '课程当天开始时间';
comment on column kecheng_repeat.end_by is '课程的当天结束时间';
comment on column kecheng_repeat.repeat_start is '不需要`repeat_end`了,因为同一组`kecheng_root_id`的数据按照`repeat_start`时间排列,后一个就是前一个的end时间。';
comment on column kecheng_repeat.repeat_end is '重复课程的结束时间';
comment on column kecheng_repeat.repeat_status is 'ON_GOING / STOPPED / PENDING / ... / STATUS优先级大于`repeat_end`';
create table kecheng_users
(
id varchar not null
primary key,
user_id varchar not null,
kecheng_id varchar not null
constraint kecheng_users_kecheng_id_fk
references kecheng,
kecheng_status varchar not null,
user_type varchar not null
);
comment on column kecheng_users.user_type is '老师,学生,助教,等等';