/*
 Navicat Premium Data Transfer

 Source Server         : 智慧法务
 Source Server Type    : PostgreSQL
 Source Server Version : 170005
 Source Host           : nas.7bm.co:54302
 Source Catalog        : docauditai
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 170005
 File Encoding         : 65001

 Date: 09/07/2025 10:25:50
*/


-- ----------------------------
-- Table structure for evaluation_results
-- ----------------------------
DROP TABLE IF EXISTS "public"."evaluation_results";
CREATE TABLE "public"."evaluation_results" (
  "id" int4 NOT NULL DEFAULT nextval('evaluation_results_id_seq'::regclass),
  "document_id" int4 NOT NULL,
  "evaluation_point_id" int4 NOT NULL,
  "status" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "extracted_results" jsonb NOT NULL,
  "rules_results" jsonb NOT NULL,
  "evaluated_results" jsonb NOT NULL,
  "created_at" timestamptz(6) DEFAULT now(),
  "updated_at" timestamptz(6) DEFAULT now(),
  "evaluated_point_results_log" jsonb
)
;
COMMENT ON COLUMN "public"."evaluation_results"."id" IS '主键，自增';
COMMENT ON COLUMN "public"."evaluation_results"."document_id" IS '文档ID，外键引用documents表，非空';
COMMENT ON COLUMN "public"."evaluation_results"."evaluation_point_id" IS '评查点ID，外键引用evaluation_points表，非空';
COMMENT ON COLUMN "public"."evaluation_results"."status" IS '结果状态，非空（pending/extracted/evaluated/failed）';
COMMENT ON COLUMN "public"."evaluation_results"."extracted_results" IS '抽取结果，JSONB格式，非空';
COMMENT ON COLUMN "public"."evaluation_results"."rules_results" IS '规则判断结果，JSONB格式，非空';
COMMENT ON COLUMN "public"."evaluation_results"."evaluated_results" IS '评查结果，JSONB格式，非空';
COMMENT ON COLUMN "public"."evaluation_results"."created_at" IS '创建时间，带时区，默认当前时间';
COMMENT ON COLUMN "public"."evaluation_results"."updated_at" IS '更新时间，带时区，默认当前时间';
COMMENT ON COLUMN "public"."evaluation_results"."evaluated_point_results_log" IS '记录每个评查点规则的评查记录';
COMMENT ON TABLE "public"."evaluation_results" IS '评查点结果表';

-- ----------------------------
-- Triggers structure for table evaluation_results
-- ----------------------------
CREATE TRIGGER "update_evaluation_results_updated_at" BEFORE UPDATE ON "public"."evaluation_results"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_updated_at_column"();

-- ----------------------------
-- Primary Key structure for table evaluation_results
-- ----------------------------
ALTER TABLE "public"."evaluation_results" ADD CONSTRAINT "evaluation_results_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Keys structure for table evaluation_results
-- ----------------------------
ALTER TABLE "public"."evaluation_results" ADD CONSTRAINT "evaluation_results_evaluation_point_id_fkey" FOREIGN KEY ("evaluation_point_id") REFERENCES "public"."evaluation_points" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
