-- One-off migration: adds ent_scores.section_id, linking each score row to
-- an ent_sections row (subject/section) instead of ent_scores storing a
-- single unbroken total. Nullable so any pre-existing total-only rows
-- aren't broken by this change — the app enforces section_id on all new
-- inserts going forward, same nullable-FK-for-compatibility approach used
-- for charges.group_id/tariff_id (see make_charges_*_nullable.sql).
--
-- Run create_ent_sections_table.sql first — this FK depends on it.

ALTER TABLE ent_scores
    ADD COLUMN section_id INT NULL AFTER student_id,
    ADD FOREIGN KEY (section_id) REFERENCES ent_sections(id);
