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
This commit is contained in:
2026-04-23 17:20:01 +08:00
parent c843fecbce
commit 44c320d8fa
392 changed files with 11786 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
[package]
name = "htyws_models"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
htycommons = { workspace = true }
htyuc_models = { git = "https://github.com/alchemy-studio/AuthCore.git", package = "htyuc_models" }
anyhow = { workspace = true }
chrono = { workspace = true }
diesel = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
+5
View File
@@ -0,0 +1,5 @@
# For documentation on how to configure this file,
# see diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/schema.rs" #
View File
@@ -0,0 +1,6 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
DROP FUNCTION IF EXISTS diesel_set_updated_at();
@@ -0,0 +1,36 @@
-- This file was automatically created by Diesel to setup helper functions
-- and other internal bookkeeping. This file is safe to edit, any future
-- changes will be added to existing projects as new migrations.
-- Sets up a trigger for the given table to automatically set a column called
-- `updated_at` whenever the row is modified (unless `updated_at` was included
-- in the modified columns)
--
-- # Example
--
-- ```sql
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
--
-- SELECT diesel_manage_updated_at('users');
-- ```
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
BEGIN
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
BEGIN
IF (
NEW IS DISTINCT FROM OLD AND
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
) THEN
NEW.updated_at := current_timestamp;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,191 @@
-- Your SQL goes here
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.3
-- Dumped by pg_dump version 13.3
CREATE TABLE lianxi
(
id character varying NOT NULL,
video_url character varying,
video_id character varying,
create_at timestamp without time zone,
jihua_qumu_section_id character varying NOT NULL,
audio_question_url character varying,
audio_question_id character varying,
text_question text
);
CREATE TABLE jihua
(
id character varying NOT NULL,
start_date timestamp without time zone NOT NULL,
end_date timestamp without time zone NOT NULL,
student_id character varying NOT NULL,
teacher_id character varying NOT NULL,
beizhu character varying
);
CREATE TABLE jihua_qumu_section
(
id character varying NOT NULL,
jihua_id character varying NOT NULL,
qumu_section_id character varying NOT NULL,
meta jsonb
);
CREATE TABLE piyue
(
id character varying NOT NULL,
lianxi_id character varying NOT NULL,
content jsonb NOT NULL,
teacher_id character varying NOT NULL,
rating jsonb
);
CREATE TABLE piyue_info
(
id character varying NOT NULL,
piyue_id character varying NOT NULL,
lianxi_video_pos jsonb,
qupu_pos jsonb,
comment text
);
CREATE TABLE qumu
(
name character varying NOT NULL,
id character varying NOT NULL,
qumu_type integer NOT NULL
);
CREATE TABLE qumu_info
(
id character varying NOT NULL,
meta jsonb,
qumu_id character varying NOT NULL,
created_by character varying NOT NULL
);
CREATE TABLE qumu_section
(
id character varying NOT NULL,
created_by character varying NOT NULL,
qupu_id character varying,
qupu_url character varying,
shifan_id character varying,
shifan_url character varying,
section_name character varying NOT NULL,
qumu_id character varying NOT NULL,
task jsonb
);
CREATE TABLE teacher_student
(
teacher_id character varying NOT NULL,
student_id character varying NOT NULL,
id character varying NOT NULL
);
ALTER TABLE ONLY piyue_info
ADD CONSTRAINT piyue_info_pk PRIMARY KEY (id);
ALTER TABLE ONLY piyue
ADD CONSTRAINT piyue_pk PRIMARY KEY (id);
ALTER TABLE ONLY jihua_qumu_section
ADD CONSTRAINT jihua_qumu_section_pk PRIMARY KEY (id);
ALTER TABLE ONLY qumu_info
ADD CONSTRAINT qumu_meta_pk PRIMARY KEY (id);
ALTER TABLE ONLY qumu
ADD CONSTRAINT qumu_pk PRIMARY KEY (id);
ALTER TABLE ONLY qumu_section
ADD CONSTRAINT qumu_section_pk PRIMARY KEY (id);
ALTER TABLE ONLY teacher_student
ADD CONSTRAINT teacher_student_pk PRIMARY KEY (id);
ALTER TABLE ONLY jihua
ADD CONSTRAINT jihua_pk PRIMARY KEY (id);
ALTER TABLE ONLY lianxi
ADD CONSTRAINT lianxi_pk PRIMARY KEY (id);
CREATE UNIQUE INDEX piyue_id_uindex ON piyue USING btree (id);
CREATE UNIQUE INDEX piyue_info_id_uindex ON piyue_info USING btree (id);
CREATE UNIQUE INDEX qumu_id_uindex ON qumu USING btree (id);
CREATE UNIQUE INDEX qumu_meta_id_uindex ON qumu_info USING btree (id);
CREATE UNIQUE INDEX qumu_name_uindex ON qumu USING btree (name);
CREATE UNIQUE INDEX jihua_id_uindex ON jihua USING btree (id);
CREATE UNIQUE INDEX lianxi_id_uindex ON lianxi USING btree (id);
ALTER TABLE ONLY lianxi
ADD CONSTRAINT jihua_qumu_section_id_fk FOREIGN KEY (jihua_qumu_section_id) REFERENCES jihua_qumu_section (id);
ALTER TABLE ONLY piyue_info
ADD CONSTRAINT piyue_info_piyue_id_fk FOREIGN KEY (piyue_id) REFERENCES piyue (id);
ALTER TABLE ONLY piyue
ADD CONSTRAINT piyue_lianxi_id_fk FOREIGN KEY (lianxi_id) REFERENCES lianxi (id);
ALTER TABLE ONLY jihua_qumu_section
ADD CONSTRAINT jihua_qumu_section_jihua_id_fk FOREIGN KEY (jihua_id) REFERENCES jihua (id);
ALTER TABLE ONLY jihua_qumu_section
ADD CONSTRAINT jihua_qumu_section_qumu_section_id_fk FOREIGN KEY (qumu_section_id) REFERENCES qumu_section (id);
ALTER TABLE ONLY qumu_info
ADD CONSTRAINT qumu_info_qumu_id_fk FOREIGN KEY (qumu_id) REFERENCES qumu (id);
ALTER TABLE ONLY qumu_section
ADD CONSTRAINT qumu_section_qumu_id_fk FOREIGN KEY (qumu_id) REFERENCES qumu (id);
--
-- PostgreSQL database dump complete
--
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,2 @@
alter table lianxi
add task jsonb;-- Your SQL goes here
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,10 @@
-- Your SQL goes here
alter table qumu
add created_by varchar not null;
alter table qumu
add created_at timestamp not null;
drop index qumu_name_uindex;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,8 @@
-- Your SQL goes here
alter table qumu
alter column created_by drop not null;
alter table qumu
alter column created_at drop not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,7 @@
-- Your SQL goes here
alter table lianxi
add qupu_id varchar;
alter table lianxi
add qupu_url varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,3 @@
-- Your SQL goes here
alter table piyue
add answer jsonb;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,3 @@
-- Your SQL goes here
alter table piyue_info
add serial varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,4 @@
-- Your SQL goes here
alter table lianxi
add lianxi_type varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,15 @@
-- Your SQL goes here
create table daka
(
id varchar not null
constraint daka_pk
primary key,
daka_date timestamp not null,
student_id varchar not null,
beizhu varchar
);
create unique index daka_id_uindex
on daka (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,18 @@
-- Your SQL goes here
create table daka_qumu_section
(
id varchar not null
constraint daka_qumu_section_pk
primary key,
daka_id varchar not null
constraint daka_qumu_section_daka_id_fk
references daka,
qumu_section_id varchar not null
constraint daka_qumu_section_qumu_section_id_fk
references qumu_section,
meta jsonb
);
create unique index daka_qumu_section_id_uindex
on daka_qumu_section (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,11 @@
-- Your SQL goes here
alter table lianxi
alter column jihua_qumu_section_id drop not null;
alter table lianxi
add daka_qumu_section_id varchar;
alter table lianxi
add constraint daka_qumu_section_id_fk
foreign key (daka_qumu_section_id) references daka_qumu_section;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,17 @@
-- Your SQL goes here
create table ref_resources
(
id varchar not null
constraint ref_resources_pk
primary key,
hty_resource_id varchar not null,
ref_id varchar not null,
ref_type varchar not null,
resource_url varchar,
resource_type varchar
);
create unique index ref_resources_id_uindex
on ref_resources (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table qumu
alter column qumu_type type varchar using qumu_type::varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,4 @@
-- Your SQL goes here
alter table qumu
alter column qumu_type drop not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,2 @@
-- Your SQL goes here
alter table piyue_info alter column comment type jsonb using comment::jsonb;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,3 @@
-- Your SQL goes here
alter table piyue drop column content;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table jihua_qumu_section
add created_at timestamp;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,16 @@
-- Your SQL goes here
create table user_groups
(
id varchar not null
constraint user_groups_pk
primary key,
group_name varchar not null,
group_type varchar not null,
owner_id varchar not null,
group_members jsonb
);
create unique index user_groups_id_uindex
on user_groups (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,23 @@
-- Your SQL goes here
alter table daka
drop column daka_date;
alter table daka
add start_date timestamp not null;
alter table daka
drop column student_id;
alter table daka
rename column beizhu to "desc";
alter table daka
add duration_days int not null;
alter table daka
add name varchar not null;
alter table daka
add owner_id varchar not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,16 @@
-- Your SQL goes here
create table daka_queue
(
id varchar not null
constraint daka_queue_pk
primary key,
qumu_section_queue jsonb,
daka_id varchar not null
constraint daka_queue_daka_id_fk
references daka
);
create unique index daka_queue_id_uindex
on daka_queue (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,9 @@
-- Your SQL goes here
alter table daka_queue
add group_id varchar;
alter table daka_queue
add constraint daka_queue_user_groups_id_fk
foreign key (group_id) references user_groups;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table qumu_section
add qumu_type varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table jihua
add lianxi_count int;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,4 @@
-- Your SQL goes here
alter table teacher_student
add status varchar default 'Approved' not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table qumu_section
add qumu_name varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,19 @@
-- Your SQL goes here
create table comments
(
id varchar not null
constraint comments_pk
primary key,
ref_id varchar not null,
ref_type varchar not null,
parent_id varchar,
created_at timestamp not null,
created_by varchar not null,
creator_name varchar,
content jsonb
);
create unique index comments_id_uindex
on comments (id);
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table qumu_section
add created_at timestamp;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,3 @@
-- Your SQL goes here
alter table qumu_section
add hidden bool default false not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table teacher_student
add created_at timestamp;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table lianxi
rename column create_at to created_at;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,8 @@
-- Your SQL goes here
alter table piyue
add created_at timestamp;
alter table piyue_info
add created_at timestamp;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table piyue
add teacher_name varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,8 @@
-- Your SQL goes here
alter table piyue
drop column answer;
alter table piyue_info
drop column comment;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table jihua
add is_yanqi bool;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,5 @@
-- Your SQL goes here
alter table lianxi
add has_piyue bool;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,6 @@
-- Your SQL goes here
alter table qumu_section
add is_delete boolean default false;
update qumu_section set is_delete='false';
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,6 @@
-- Your SQL goes here
alter table jihua_qumu_section
add is_delete boolean default false;
update jihua_qumu_section set is_delete='false';
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,9 @@
-- Your SQL goes here
alter table jihua
add parent_id varchar;
alter table jihua
add constraint jihua_jihua_id_fk
foreign key (parent_id) references jihua;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,6 @@
-- Your SQL goes here
alter table jihua
add is_delete boolean;
update jihua set is_delete='false';
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,19 @@
-- Your SQL goes here
alter table daka
add created_by varchar not null;
alter table daka
rename column owner_id to created_at;
alter table daka
alter column created_at type timestamp using created_at::timestamp;
alter table daka
add teacher_id varchar not null;
alter table daka
add group_id varchar not null;
alter table daka
add is_delete bool not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,4 @@
-- Your SQL goes here
alter table daka_qumu_section
add is_delete bool not null;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,6 @@
-- Your SQL goes here
drop table daka_queue;
drop table user_groups;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,8 @@
-- Your SQL goes here
alter table daka
add teacher_name varchar;
alter table daka
add group_name varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,17 @@
-- Your SQL goes here
alter table piyue
add is_delete bool;
alter table comments
add is_delete bool;
alter table lianxi
add is_delete bool;
alter table piyue_info
add is_delete bool;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,6 @@
-- Your SQL goes here
update lianxi set is_delete='false';
update piyue set is_delete='false';
update comments set is_delete='false';
update piyue_info set is_delete='false';
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,8 @@
-- Your SQL goes here
alter table comments
add comment_type varchar;
alter table comments
add comment_status varchar;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
@@ -0,0 +1,4 @@
-- Your SQL goes here
alter table qumu
add is_delete bool;
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

Some files were not shown because too many files have changed in this diff Show More