Files
2025-05-30 21:42:44 +08:00

96 lines
4.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### 合同分类
```
CREATE TABLE "public"."contract_categories" (
"id" int4 NOT NULL DEFAULT nextval('contract_categories_id_seq'::regclass),
"name" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"icon" varchar(100) COLLATE "pg_catalog"."default",
"description" text COLLATE "pg_catalog"."default",
"sort_order" int4 DEFAULT 0,
"created_at" timestamptz(6) DEFAULT now(),
"updated_at" timestamptz(6) DEFAULT now(),
CONSTRAINT "contract_categories_pkey" PRIMARY KEY ("id")
)
;
ALTER TABLE "public"."contract_categories"
OWNER TO "root";
CREATE TRIGGER "update_contract_categories_updated_at" BEFORE UPDATE ON "public"."contract_categories"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_updated_at_column"();
COMMENT ON COLUMN "public"."contract_categories"."id" IS '分类ID(主键)';
COMMENT ON COLUMN "public"."contract_categories"."name" IS '分类名称';
COMMENT ON COLUMN "public"."contract_categories"."icon" IS '图标类名(如 font-awesome 类名)';
COMMENT ON COLUMN "public"."contract_categories"."description" IS '分类描述';
COMMENT ON COLUMN "public"."contract_categories"."sort_order" IS '排序顺序';
COMMENT ON COLUMN "public"."contract_categories"."created_at" IS '创建时间(带时区)';
COMMENT ON COLUMN "public"."contract_categories"."updated_at" IS '最后更新时间(带时区)';
COMMENT ON TABLE "public"."contract_categories" IS '合同分类表';
```
### 合同模板表
```
CREATE TABLE "public"."contract_templates" (
"id" int8 NOT NULL DEFAULT nextval('contract_templates_id_seq'::regclass),
"template_code" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"title" varchar(200) COLLATE "pg_catalog"."default" NOT NULL,
"category_id" int4 NOT NULL,
"description" text COLLATE "pg_catalog"."default",
"file_path" varchar(500) COLLATE "pg_catalog"."default",
"file_format" varchar(10) COLLATE "pg_catalog"."default" DEFAULT 'docx'::character varying,
"is_featured" bool DEFAULT false,
"created_at" timestamptz(6) DEFAULT now(),
"updated_at" timestamptz(6) DEFAULT now(),
"pdf_file_path" varchar(500) COLLATE "pg_catalog"."default",
CONSTRAINT "contract_templates_pkey" PRIMARY KEY ("id"),
CONSTRAINT "fk_category_id" FOREIGN KEY ("category_id") REFERENCES "public"."contract_categories" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT "contract_templates_template_code_key" UNIQUE ("template_code"),
CONSTRAINT "valid_file_format" CHECK (file_format::text = ANY (ARRAY['docx'::character varying, 'pdf'::character varying, 'txt'::character varying]::text[]))
)
;
ALTER TABLE "public"."contract_templates"
OWNER TO "root";
CREATE INDEX "idx_contract_templates_category_id" ON "public"."contract_templates" USING btree (
"category_id" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE TRIGGER "update_contract_templates_updated_at" BEFORE UPDATE ON "public"."contract_templates"
FOR EACH ROW
EXECUTE PROCEDURE "public"."update_updated_at_column"();
COMMENT ON COLUMN "public"."contract_templates"."id" IS '模板ID(主键)';
COMMENT ON COLUMN "public"."contract_templates"."template_code" IS '模板编号(唯一标识)';
COMMENT ON COLUMN "public"."contract_templates"."title" IS '模板标题';
COMMENT ON COLUMN "public"."contract_templates"."category_id" IS '所属分类ID(外键)';
COMMENT ON COLUMN "public"."contract_templates"."description" IS '模板描述';
COMMENT ON COLUMN "public"."contract_templates"."file_path" IS '文件存储路径';
COMMENT ON COLUMN "public"."contract_templates"."file_format" IS '文件格式(docx/pdf/txt';
COMMENT ON COLUMN "public"."contract_templates"."is_featured" IS '是否推荐模板';
COMMENT ON COLUMN "public"."contract_templates"."created_at" IS '创建时间(带时区)';
COMMENT ON COLUMN "public"."contract_templates"."updated_at" IS '最后更新时间(带时区)';
COMMENT ON COLUMN "public"."contract_templates"."pdf_file_path" IS 'pdf文件存储路径';
COMMENT ON TABLE "public"."contract_templates" IS '合同模板表';
```