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

21 lines
1.3 KiB
SQL

-- ============================================================
-- P1.10: selection_result 选育结果 —— 晋级溯源字段(规格 §4 line 565)
-- ------------------------------------------------------------
-- 幂等。bre_selection_result 表已由 bre_tables.sql 建好。
-- ============================================================
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS clone_id integer REFERENCES bre_clone(id);
CREATE INDEX IF NOT EXISTS ix_bre_selection_result_clone_id ON bre_selection_result(clone_id);
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS rule_id integer REFERENCES bre_selection_rule(id);
CREATE INDEX IF NOT EXISTS ix_bre_selection_result_rule_id ON bre_selection_result(rule_id);
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS from_stage varchar(32);
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS to_stage varchar(32);
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS approved_by integer REFERENCES bre_personnel(id);
CREATE INDEX IF NOT EXISTS ix_bre_selection_result_approved_by ON bre_selection_result(approved_by);
ALTER TABLE bre_selection_result ADD COLUMN IF NOT EXISTS trial_study_id integer REFERENCES bre_trial_study(id);
CREATE INDEX IF NOT EXISTS ix_bre_selection_result_trial_study_id ON bre_selection_result(trial_study_id);