eds_dict.sql 2.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. -- 电子数据字典表(案件 DuckDB)
  2. -- 用途:保存电子数据展示层需要的编码名称,例如案件类型、证件类型、系统类型、
  3. -- 即时通信应用类型等;查询接口按 code_type_code + code_value 翻译为中文名称。
  4. -- 说明:字典随案件存放在案件 DuckDB,EdsDictStore 会按案件 ID 加载并缓存;
  5. -- 新增案件从基础案件库模板复制时需要包含本表,已有案件需单独执行本脚本。
  6. create table if not exists eds_dict
  7. (
  8. code_type varchar not null, -- 编码分类名称,例如“即时通信应用类型”
  9. code_type_code varchar not null, -- 编码分类代码,例如 WACODE_0163
  10. code_value varchar, -- 编码值,例如 000001
  11. code_name varchar not null, -- 编码名称,例如 微信
  12. remark varchar, -- 备注
  13. sort integer, -- 同一分类下的展示顺序
  14. state integer default 1, -- 状态:1 正常,2 停用
  15. create_time timestamp, -- 创建时间
  16. update_time timestamp, -- 更新时间
  17. unique (code_type_code, code_value)
  18. );
  19. create index if not exists idx_eds_dict_type
  20. on eds_dict (code_type_code, state, sort);
  21. comment on table eds_dict is '电子数据编码字典';
  22. comment on column eds_dict.code_type is '编码分类名称';
  23. comment on column eds_dict.code_type_code is '编码分类代码';
  24. comment on column eds_dict.code_value is '编码值';
  25. comment on column eds_dict.code_name is '编码名称';
  26. comment on column eds_dict.sort is '分类内排序';
  27. comment on column eds_dict.state is '状态:1正常,2停用';
  28. -- 旧库 MySQL 数据迁移示例(在目标案件 DuckDB 中执行,源表字段:bmlx_py、bmsz、bmmc、sort、state):
  29. -- insert into eds_dict (code_type, code_type_code, code_value, code_name, sort, state, create_time)
  30. -- select bmlx_py, bmlx_py, bmsz, bmmc, sort, state, now()
  31. -- from <旧库>.eds_dict
  32. -- on conflict (code_type_code, code_value) do nothing;