pg.sql 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. CREATE EXTENSION IF NOT EXISTS vector;
  2. CREATE EXTENSION IF NOT EXISTS hstore;
  3. CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
  4. CREATE TABLE IF NOT EXISTS vector_store (
  5. id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
  6. content text,
  7. metadata json,
  8. embedding vector(768)
  9. );
  10. CREATE INDEX IF NOT EXISTS spring_ai_vector_index ON vector_store USING hnsw (embedding vector_cosine_ops);
  11. CREATE TABLE IF NOT EXISTS log_error (
  12. id bigserial PRIMARY KEY, -- 主键
  13. "exception" text NULL, -- 异常
  14. message text NULL, -- 异常消息
  15. error_stack_trace text NULL, -- 异常堆栈
  16. create_time timestamp(0) DEFAULT now() NULL -- 创建时间
  17. );
  18. COMMENT ON COLUMN log_error.id IS '主键';
  19. COMMENT ON COLUMN log_error."exception" IS '异常';
  20. COMMENT ON COLUMN log_error.message IS '异常消息';
  21. COMMENT ON COLUMN log_error.error_stack_trace IS '异常堆栈';
  22. COMMENT ON COLUMN log_error.create_time IS '创建时间';
  23. CREATE TABLE IF NOT EXISTS chat_history (
  24. id bigserial PRIMARY KEY, -- 主键
  25. user_id text NULL, -- 用户id
  26. user_q text NULL, -- 用户提问
  27. chat_a text NULL, -- chat回答
  28. create_time timestamp(0) DEFAULT now() NULL, -- 创建时间
  29. update_time timestamp(0) DEFAULT now() NULL, -- 更改时间
  30. is_deleted int2 DEFAULT 0 NULL -- 是否删除
  31. );
  32. COMMENT ON COLUMN chat_history.id IS '主键';
  33. COMMENT ON COLUMN chat_history.user_id IS '用户id';
  34. COMMENT ON COLUMN chat_history."user_q" IS '用户提问';
  35. COMMENT ON COLUMN chat_history."chat_a" IS 'chat回答';
  36. COMMENT ON COLUMN chat_history.create_time IS '创建时间';
  37. COMMENT ON COLUMN chat_history.update_time IS '更改时间';
  38. COMMENT ON COLUMN chat_history.is_deleted IS '是否删除';
  39. CREATE TABLE IF NOT EXISTS user_list (
  40. id bigserial primary key, -- 主键
  41. user_id text not null, -- 用户id
  42. user_name text, -- 用户名
  43. user_password text NULL, -- 密码
  44. create_time timestamp(0) DEFAULT now() NULL, -- 创建时间
  45. update_time timestamp(0) DEFAULT now() NULL, -- 更新时间
  46. is_deleted int2 default 0, -- 是否删除
  47. UNIQUE (user_name, is_deleted)
  48. );
  49. COMMENT ON TABLE user_list IS '用户列表';
  50. COMMENT ON COLUMN user_list.id IS '主键';
  51. COMMENT ON COLUMN user_list.user_id IS '用户id';
  52. COMMENT ON COLUMN user_list.user_name IS '用户名';
  53. COMMENT ON COLUMN user_list.user_password IS '密码';
  54. COMMENT ON COLUMN user_list.create_time IS '创建时间';
  55. COMMENT ON COLUMN user_list.update_time IS '更新时间';
  56. COMMENT ON COLUMN user_list.is_deleted IS '是否删除';