| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709 |
- --
- -- PostgreSQL database dump
- --
- \restrict ESQ1NFAz6xVH1qNjdPPTbrmPbtepjMOr7SzmqGUWW2SDRd1pbhCctBfDStfCiB2
- -- Dumped from database version 16.14 (Debian 16.14-1.pgdg12+1)
- -- Dumped by pg_dump version 16.14 (Debian 16.14-1.pgdg12+1)
- SET statement_timeout = 0;
- SET lock_timeout = 0;
- SET idle_in_transaction_session_timeout = 0;
- SET client_encoding = 'UTF8';
- SET standard_conforming_strings = on;
- SELECT pg_catalog.set_config('search_path', '', false);
- SET check_function_bodies = false;
- SET xmloption = content;
- SET client_min_messages = warning;
- SET row_security = off;
- --
- -- Name: vector; Type: EXTENSION; Schema: -; Owner: -
- --
- CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA public;
- --
- -- Name: EXTENSION vector; Type: COMMENT; Schema: -; Owner: -
- --
- COMMENT ON EXTENSION vector IS 'vector data type and ivfflat and hnsw access methods';
- SET default_tablespace = '';
- SET default_table_access_method = heap;
- --
- -- Name: answer_records; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.answer_records (
- id integer NOT NULL,
- user_id integer NOT NULL,
- question_id character varying(64) NOT NULL,
- user_answer character varying(16) NOT NULL,
- is_correct boolean NOT NULL,
- study_mode character varying(32) NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: answer_records_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.answer_records_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: answer_records_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.answer_records_id_seq OWNED BY public.answer_records.id;
- --
- -- Name: conversations; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.conversations (
- id integer NOT NULL,
- conversation_id character varying(64) NOT NULL,
- user_id integer,
- title character varying(256),
- created_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: conversations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.conversations_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: conversations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.conversations_id_seq OWNED BY public.conversations.id;
- --
- -- Name: drug_chunks; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.drug_chunks (
- id integer NOT NULL,
- drug_id character varying(64) NOT NULL,
- section character varying(64),
- content text NOT NULL,
- source text,
- chunk_index integer NOT NULL,
- embedding json,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- vec public.vector(1024)
- );
- --
- -- Name: drug_chunks_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.drug_chunks_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: drug_chunks_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.drug_chunks_id_seq OWNED BY public.drug_chunks.id;
- --
- -- Name: drugs; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.drugs (
- id integer NOT NULL,
- drug_id character varying(64) NOT NULL,
- name character varying(256) NOT NULL,
- name_en character varying(256),
- pinyin character varying(256),
- category character varying(64),
- subcategory character varying(128),
- approval_number character varying(64),
- sections jsonb,
- source_version character varying(32),
- source_volume character varying(512),
- source_page character varying(256),
- is_active boolean NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- updated_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: drugs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.drugs_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: drugs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.drugs_id_seq OWNED BY public.drugs.id;
- --
- -- Name: knowledge_points; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.knowledge_points (
- id integer NOT NULL,
- point_id character varying(64) NOT NULL,
- subject character varying(64) NOT NULL,
- chapter_id character varying(64) NOT NULL,
- chapter_name character varying(256) NOT NULL,
- title character varying(512) NOT NULL,
- content text NOT NULL,
- difficulty integer NOT NULL,
- frequency character varying(16),
- related_drugs jsonb,
- source text,
- vector_id character varying(128),
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- updated_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: knowledge_points_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.knowledge_points_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: knowledge_points_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.knowledge_points_id_seq OWNED BY public.knowledge_points.id;
- --
- -- Name: messages; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.messages (
- id integer NOT NULL,
- conversation_id character varying(64) NOT NULL,
- role character varying(32) NOT NULL,
- content text NOT NULL,
- intent character varying(32),
- sources json,
- feedback character varying(32),
- created_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.messages_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.messages_id_seq OWNED BY public.messages.id;
- --
- -- Name: questions; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.questions (
- id integer NOT NULL,
- question_id character varying(64) NOT NULL,
- question_type character varying(8) NOT NULL,
- subject character varying(64) NOT NULL,
- chapter_id character varying(64) NOT NULL,
- difficulty integer NOT NULL,
- content text NOT NULL,
- options jsonb NOT NULL,
- answer character varying(16) NOT NULL,
- explanation text NOT NULL,
- knowledge_point_ids jsonb,
- source text,
- frequency character varying(16),
- audited boolean NOT NULL,
- correct_count integer NOT NULL,
- attempt_count integer NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: questions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.questions_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: questions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.questions_id_seq OWNED BY public.questions.id;
- --
- -- Name: user_progress; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.user_progress (
- id integer NOT NULL,
- user_id integer NOT NULL,
- subject character varying(64),
- chapter_id character varying(64),
- knowledge_point_id character varying(64),
- questions_answered integer NOT NULL,
- questions_correct integer NOT NULL,
- study_seconds integer NOT NULL,
- last_study_at timestamp with time zone,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- updated_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: user_progress_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.user_progress_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: user_progress_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.user_progress_id_seq OWNED BY public.user_progress.id;
- --
- -- Name: users; Type: TABLE; Schema: public; Owner: -
- --
- CREATE TABLE public.users (
- id integer NOT NULL,
- openid character varying(128) NOT NULL,
- nickname character varying(128),
- avatar_url character varying(512),
- role character varying(32) NOT NULL,
- created_at timestamp with time zone DEFAULT now() NOT NULL,
- updated_at timestamp with time zone DEFAULT now() NOT NULL
- );
- --
- -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
- --
- CREATE SEQUENCE public.users_id_seq
- AS integer
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
- --
- -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
- --
- ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
- --
- -- Name: answer_records id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.answer_records ALTER COLUMN id SET DEFAULT nextval('public.answer_records_id_seq'::regclass);
- --
- -- Name: conversations id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.conversations ALTER COLUMN id SET DEFAULT nextval('public.conversations_id_seq'::regclass);
- --
- -- Name: drug_chunks id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.drug_chunks ALTER COLUMN id SET DEFAULT nextval('public.drug_chunks_id_seq'::regclass);
- --
- -- Name: drugs id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.drugs ALTER COLUMN id SET DEFAULT nextval('public.drugs_id_seq'::regclass);
- --
- -- Name: knowledge_points id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.knowledge_points ALTER COLUMN id SET DEFAULT nextval('public.knowledge_points_id_seq'::regclass);
- --
- -- Name: messages id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.messages ALTER COLUMN id SET DEFAULT nextval('public.messages_id_seq'::regclass);
- --
- -- Name: questions id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.questions ALTER COLUMN id SET DEFAULT nextval('public.questions_id_seq'::regclass);
- --
- -- Name: user_progress id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.user_progress ALTER COLUMN id SET DEFAULT nextval('public.user_progress_id_seq'::regclass);
- --
- -- Name: users id; Type: DEFAULT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
- --
- -- Name: answer_records answer_records_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.answer_records
- ADD CONSTRAINT answer_records_pkey PRIMARY KEY (id);
- --
- -- Name: conversations conversations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.conversations
- ADD CONSTRAINT conversations_pkey PRIMARY KEY (id);
- --
- -- Name: drug_chunks drug_chunks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.drug_chunks
- ADD CONSTRAINT drug_chunks_pkey PRIMARY KEY (id);
- --
- -- Name: drugs drugs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.drugs
- ADD CONSTRAINT drugs_pkey PRIMARY KEY (id);
- --
- -- Name: knowledge_points knowledge_points_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.knowledge_points
- ADD CONSTRAINT knowledge_points_pkey PRIMARY KEY (id);
- --
- -- Name: messages messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.messages
- ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
- --
- -- Name: questions questions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.questions
- ADD CONSTRAINT questions_pkey PRIMARY KEY (id);
- --
- -- Name: user_progress user_progress_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.user_progress
- ADD CONSTRAINT user_progress_pkey PRIMARY KEY (id);
- --
- -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.users
- ADD CONSTRAINT users_pkey PRIMARY KEY (id);
- --
- -- Name: idx_drug_chunks_vec; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX idx_drug_chunks_vec ON public.drug_chunks USING ivfflat (vec) WITH (lists='10');
- --
- -- Name: ix_answer_records_question_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_answer_records_question_id ON public.answer_records USING btree (question_id);
- --
- -- Name: ix_answer_records_user_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_answer_records_user_id ON public.answer_records USING btree (user_id);
- --
- -- Name: ix_conversations_conversation_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE UNIQUE INDEX ix_conversations_conversation_id ON public.conversations USING btree (conversation_id);
- --
- -- Name: ix_drug_chunks_drug_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_drug_chunks_drug_id ON public.drug_chunks USING btree (drug_id);
- --
- -- Name: ix_drugs_category; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_drugs_category ON public.drugs USING btree (category);
- --
- -- Name: ix_drugs_drug_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE UNIQUE INDEX ix_drugs_drug_id ON public.drugs USING btree (drug_id);
- --
- -- Name: ix_drugs_name; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_drugs_name ON public.drugs USING btree (name);
- --
- -- Name: ix_knowledge_points_chapter_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_knowledge_points_chapter_id ON public.knowledge_points USING btree (chapter_id);
- --
- -- Name: ix_knowledge_points_point_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE UNIQUE INDEX ix_knowledge_points_point_id ON public.knowledge_points USING btree (point_id);
- --
- -- Name: ix_knowledge_points_subject; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_knowledge_points_subject ON public.knowledge_points USING btree (subject);
- --
- -- Name: ix_knowledge_points_vector_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_knowledge_points_vector_id ON public.knowledge_points USING btree (vector_id);
- --
- -- Name: ix_messages_conversation_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_messages_conversation_id ON public.messages USING btree (conversation_id);
- --
- -- Name: ix_questions_chapter_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_questions_chapter_id ON public.questions USING btree (chapter_id);
- --
- -- Name: ix_questions_question_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE UNIQUE INDEX ix_questions_question_id ON public.questions USING btree (question_id);
- --
- -- Name: ix_questions_subject; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_questions_subject ON public.questions USING btree (subject);
- --
- -- Name: ix_user_progress_chapter_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_user_progress_chapter_id ON public.user_progress USING btree (chapter_id);
- --
- -- Name: ix_user_progress_knowledge_point_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_user_progress_knowledge_point_id ON public.user_progress USING btree (knowledge_point_id);
- --
- -- Name: ix_user_progress_subject; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_user_progress_subject ON public.user_progress USING btree (subject);
- --
- -- Name: ix_user_progress_user_id; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_user_progress_user_id ON public.user_progress USING btree (user_id);
- --
- -- Name: ix_users_openid; Type: INDEX; Schema: public; Owner: -
- --
- CREATE UNIQUE INDEX ix_users_openid ON public.users USING btree (openid);
- --
- -- Name: ix_drugs_sections_gin; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_drugs_sections_gin ON public.drugs USING gin (sections);
- --
- -- Name: ix_drugs_source_version; Type: INDEX; Schema: public; Owner: -
- --
- CREATE INDEX ix_drugs_source_version ON public.drugs USING btree (source_version);
- --
- -- Name: answer_records answer_records_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.answer_records
- ADD CONSTRAINT answer_records_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
- --
- -- Name: messages messages_conversation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.messages
- ADD CONSTRAINT messages_conversation_id_fkey FOREIGN KEY (conversation_id) REFERENCES public.conversations(conversation_id);
- --
- -- Name: user_progress user_progress_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
- --
- ALTER TABLE ONLY public.user_progress
- ADD CONSTRAINT user_progress_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
- --
- -- PostgreSQL database dump complete
- --
- \unrestrict ESQ1NFAz6xVH1qNjdPPTbrmPbtepjMOr7SzmqGUWW2SDRd1pbhCctBfDStfCiB2
|