pg.sql 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. DROP TABLE IF EXISTS log_error;
  12. CREATE TABLE log_error (
  13. id bigserial PRIMARY KEY, -- 主键
  14. "exception" text NULL, -- 异常
  15. message text NULL, -- 异常消息
  16. error_info text NULL, -- 异常详细消息
  17. error_stack_trace text NULL, -- 异常堆栈
  18. create_time timestamp(0) DEFAULT now() NULL -- 创建时间
  19. );
  20. COMMENT ON COLUMN log_error.id IS '主键';
  21. COMMENT ON COLUMN log_error."exception" IS '异常';
  22. COMMENT ON COLUMN log_error.message IS '异常消息';
  23. COMMENT ON COLUMN log_error.error_info IS '异常详细消息';
  24. COMMENT ON COLUMN log_error.error_stack_trace IS '异常堆栈';
  25. COMMENT ON COLUMN log_error.create_time IS '创建时间';
  26. DROP TABLE IF EXISTS chat_history;
  27. CREATE TABLE chat_history (
  28. id bigserial PRIMARY KEY, -- 主键
  29. user_id text NULL, -- 用户id
  30. "user_Q" text NULL, -- 用户提问
  31. "chat_A" text NULL, -- chat回答
  32. create_time timestamp(0) DEFAULT now() NULL, -- 创建时间
  33. update_time timestamp(0) DEFAULT now() NULL, -- 更改时间
  34. is_deleted int2 DEFAULT 0 NULL -- 是否删除
  35. );
  36. COMMENT ON COLUMN chat_history.id IS '主键';
  37. COMMENT ON COLUMN chat_history.user_id IS '用户id';
  38. COMMENT ON COLUMN chat_history."user_Q" IS '用户提问';
  39. COMMENT ON COLUMN chat_history."chat_A" IS 'chat回答';
  40. COMMENT ON COLUMN chat_history.create_time IS '创建时间';
  41. COMMENT ON COLUMN chat_history.update_time IS '更改时间';
  42. COMMENT ON COLUMN chat_history.is_deleted IS '是否删除';
  43. DROP TABLE IF EXISTS user_list;
  44. CREATE TABLE user_list (
  45. id bigserial primary key, -- 主键
  46. user_id text not null, -- 用户id
  47. user_name text, -- 用户名
  48. user_password text NULL, -- 密码
  49. create_time timestamp(0) DEFAULT now() NULL, -- 创建时间
  50. update_time timestamp(0) DEFAULT now() NULL, -- 更新时间
  51. is_deleted int2 default 0, -- 是否删除
  52. UNIQUE (user_name, is_deleted)
  53. );
  54. COMMENT ON TABLE user_list IS '用户列表';
  55. -- Column comments
  56. COMMENT ON COLUMN user_list.id IS '主键';
  57. COMMENT ON COLUMN user_list.user_id IS '用户id';
  58. COMMENT ON COLUMN user_list.user_name IS '用户名';
  59. COMMENT ON COLUMN user_list.user_password IS '密码';
  60. COMMENT ON COLUMN user_list.create_time IS '创建时间';
  61. COMMENT ON COLUMN user_list.update_time IS '更新时间';
  62. COMMENT ON COLUMN user_list.is_deleted IS '是否删除';