-- One-off migration: creates the ent_sections table — the dictionary of
-- ЕНТ (UNT) subjects/sections (2 mandatory + student-chosen profile
-- subjects) that ent_scores.section_id will reference. Managed afterward
-- via the Справочники admin page (DictionaryController).
--
-- IMPORTANT: the seeded max_score values below are placeholders — check
-- and adjust them via the Справочники page to match the current official
-- ЕНТ scoring for the exam year, since exact per-subject maximums change
-- over time and aren't hardcoded elsewhere in this app.
--
-- 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/create_ent_sections_table.sql

CREATE TABLE ent_sections (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    max_score DECIMAL(5,1) NOT NULL,
    is_mandatory TINYINT(1) NOT NULL DEFAULT 0,
    sort_order INT NOT NULL DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO ent_sections (name, max_score, is_mandatory, sort_order) VALUES
    ('История Казахстана', 20.0, 1, 0),
    ('Грамотность чтения', 20.0, 1, 1),
    ('Математика', 40.0, 0, 2),
    ('Физика', 40.0, 0, 3),
    ('Химия', 40.0, 0, 4),
    ('Биология', 40.0, 0, 5),
    ('География', 40.0, 0, 6),
    ('Всемирная история', 40.0, 0, 7),
    ('Основы права', 40.0, 0, 8),
    ('Информатика', 40.0, 0, 9),
    ('Английский язык', 40.0, 0, 10),
    ('Казахский язык', 40.0, 0, 11),
    ('Русский язык', 40.0, 0, 12);
