-- One-off fix: create_ent_sections_table.sql seeded placeholder max_score
-- values and was missing a mandatory section entirely. Correct values per
-- the actual current ЕНТ format:
--   История Казахстана          — mandatory, max 20 (already correct)
--   Математическая грамотность  — mandatory, max 10 (was missing)
--   Грамотность чтения          — mandatory, max 10 (was seeded as 20)
--   profile subjects (Математика, Физика, ...) — max 50 (was seeded as 40)
--
-- IMPORTANT: this file contains Cyrillic text — force the client to
-- utf8mb4, otherwise the mysql CLI's default charset (often latin1) will
-- double-encode it into mojibake:
--
--   docker compose exec -T db mysql --default-character-set=utf8mb4 \
--       -u"$(grep '^DB_USER=' .env | cut -d '=' -f2-)" \
--       -p"$(grep '^DB_PASS=' .env | cut -d '=' -f2-)" \
--       "$(grep '^DB_NAME=' .env | cut -d '=' -f2-)" \
--       < scripts/fix_ent_sections_scoring.sql

-- Make room for the new mandatory section right after История Казахстана.
UPDATE ent_sections SET sort_order = sort_order + 1 WHERE sort_order >= 1;

INSERT INTO ent_sections (name, max_score, is_mandatory, sort_order) VALUES
    ('Математическая грамотность', 10.0, 1, 1);

UPDATE ent_sections SET max_score = 10.0 WHERE name = 'Грамотность чтения';
UPDATE ent_sections SET max_score = 50.0 WHERE is_mandatory = 0;
