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

15 lines
916 B
SQL
Raw 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.
-- ============================================================
-- B8: 选择强度链接线 —— seedling/planting 挂 seed_lot_id(规格 §3.13
-- ------------------------------------------------------------
-- 幂等。bre_seed_lot 表已由 bre_tables.sql 建好。
-- 链:seed_lot.seed_count → used_count(seedling 按出苗数累加) →
-- COUNT(seedling WHERE seed_lot_id) → COUNT(tree WHERE planting.seed_lot_id)
-- → COUNT(selection_result 入选)
-- ============================================================
ALTER TABLE bre_seedling ADD COLUMN IF NOT EXISTS seed_lot_id integer REFERENCES bre_seed_lot(id);
CREATE INDEX IF NOT EXISTS ix_bre_seedling_seed_lot_id ON bre_seedling (seed_lot_id);
ALTER TABLE bre_planting ADD COLUMN IF NOT EXISTS seed_lot_id integer REFERENCES bre_seed_lot(id);
CREATE INDEX IF NOT EXISTS ix_bre_planting_seed_lot_id ON bre_planting (seed_lot_id);