Files
dpb/backend/sql/bre_dus_seed.sql
34047007@qq.com b95053c52c init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
2026-08-06 00:17:49 +08:00

45 lines
3.3 KiB
SQL

-- ============================================================
-- 精修项落地:DUS/品种保护 —— UPOV TG/53 桃描述符种子(规格 §8.14)
-- ------------------------------------------------------------
-- bre_dus_descriptor / bre_dus_test / bre_dus_observation 三表由 ORM create_all 建表;
-- 此处幂等种入 ~15 条 UPOV TG/53 描述符模板。
-- trait_code → bre_trait.trait_code LEFT JOIN 解析 trait_id(复用性状字典的 ontology_uri 语义);
-- 无匹配 trait_code 的为自由描述符(trait_id 留空)。descriptor_no 冲突则跳过(DO NOTHING)。
-- ============================================================
INSERT INTO bre_dus_descriptor
(descriptor_no, trait_id, trait_code, descriptor_name, expression_type, method,
example_varieties, test_stage, required, remark, uuid, is_deleted, created_time, updated_time)
SELECT
v.descriptor_no,
t.id,
v.trait_code,
v.descriptor_name,
v.expression_type,
v.method,
v.example_varieties,
v.test_stage,
v.required,
v.remark,
gen_random_uuid(), false, now(), now()
FROM (VALUES
('TG/53/1', 'growth_vigor', '树势', 'QN', '目测', '早红珠', 'juvenile', '1', 'UPOV TG/53 桃特性表'),
('TG/53/2', 'flower_type', '花型', 'PQ', '目测', '砂子早生', 'evaluation', '1', '蔷薇型/铃型'),
('TG/53/3', NULL, '叶形', 'PQ', '目测', '上海水蜜', 'juvenile', '1', '披针形/卵形'),
('TG/53/4', NULL, '花期', 'QN', '目测', '早红珠', 'evaluation', '1', '始花至盛花'),
('TG/53/5', 'fruit_shape', '果形', 'PQ', '目测', '白凤', 'evaluation', '1', '扁平/扁圆/圆/椭圆/卵圆'),
('TG/53/6', 'skin_base_color', '果皮底色', 'PQ', '目测', '白凤', 'evaluation', '1', '淡绿/绿白/白/浅黄/深黄'),
('TG/53/7', 'coloration_depth', '着色程度', 'QN', '目测', '大久保', 'evaluation', '1', '浅/中/深'),
('TG/53/8', 'pubescence', '茸毛', 'QN', '目测', '油桃品种', 'evaluation', '1', '无/少/中/多'),
('TG/53/9', NULL, '果肉色', 'PQ', '目测', '白凤', 'evaluation', '1', '白/黄/红'),
('TG/53/10', NULL, '离核性', 'QL', '目测', '离核品种', 'evaluation', '1', '粘核/半离/离核'),
('TG/53/11', NULL, '成熟期', 'QN', '目测', '早红珠', 'evaluation', '1', '极早/早/中/晚/极晚'),
('TG/53/12', NULL, '风味', 'PQ', '品尝', '大久保', 'evaluation', '1', '酸/酸甜/甜/浓甜'),
('TG/53/13', 'avg_fruit_weight', '平均单果重', 'QN', '称重', '早红珠', 'evaluation', '1', '数值(g),连续'),
('TG/53/14', 'ssc', '可溶性固形物', 'QN', '折射仪', '大久保', 'evaluation', '1', '数值(%),连续'),
('TG/53/15', NULL, '树性', 'PQ', '目测', '久保', 'juvenile', '0', '直立/开张/垂枝')
) AS v(descriptor_no, trait_code, descriptor_name, expression_type, method,
example_varieties, test_stage, required, remark)
LEFT JOIN bre_trait t ON t.trait_code = v.trait_code AND t.is_deleted = false
ON CONFLICT (descriptor_no) DO NOTHING;