text_storage_only.sql 1.1 KB

123456789101112131415161718192021222324252627
  1. -- 灵越智报 v2.0 补充表结构(兼容 VARCHAR(36) ID 版本)
  2. -- PostgreSQL 15+
  3. -- 兼容 init.sql 中使用的 VARCHAR(36) ID 类型
  4. -- ============================================
  5. -- 6. 文本存储路径表(text_storage)
  6. -- 仅创建核心需要的表
  7. -- ============================================
  8. CREATE TABLE IF NOT EXISTS text_storage (
  9. id VARCHAR(36) PRIMARY KEY DEFAULT replace(gen_random_uuid()::text, '-', ''),
  10. document_id VARCHAR(36) NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
  11. file_path VARCHAR(500) NOT NULL,
  12. file_size BIGINT,
  13. checksum VARCHAR(64),
  14. create_by VARCHAR(36),
  15. create_by_name VARCHAR(100),
  16. create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  17. update_by VARCHAR(36),
  18. update_by_name VARCHAR(100),
  19. update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
  20. );
  21. CREATE INDEX IF NOT EXISTS idx_text_storage_document_id ON text_storage(document_id);
  22. CREATE UNIQUE INDEX IF NOT EXISTS idx_text_storage_document_unique ON text_storage(document_id);
  23. -- 显示创建结果
  24. SELECT 'text_storage 表创建成功,字段与 SimpleModel 兼容' AS result;