-- ============================================================
-- P1.4: planting 定植 —— 砧木/参试条目/试验研究点/区组号（规格 §4 line 562）
-- ------------------------------------------------------------
-- 幂等。bre_planting 表已由 bre_tables.sql 建好。
-- ============================================================

ALTER TABLE bre_planting ADD COLUMN IF NOT EXISTS rootstock_id integer REFERENCES bre_rootstock(id);
CREATE INDEX IF NOT EXISTS ix_bre_planting_rootstock_id ON bre_planting (rootstock_id);

ALTER TABLE bre_planting ADD COLUMN IF NOT EXISTS entry_id integer REFERENCES bre_trial_study_entry(id);
CREATE INDEX IF NOT EXISTS ix_bre_planting_entry_id ON bre_planting (entry_id);

ALTER TABLE bre_planting ADD COLUMN IF NOT EXISTS trial_study_id integer REFERENCES bre_trial_study(id);
CREATE INDEX IF NOT EXISTS ix_bre_planting_trial_study_id ON bre_planting (trial_study_id);

ALTER TABLE bre_planting ADD COLUMN IF NOT EXISTS block_no integer;
