-- One-off migration: adds the teacher_bonuses table, used to record a
-- discretionary bonus an admin grants a teacher on a given date. Shown on
-- the "Сводка по преподавателям" report (TeacherController::report(),
-- /admin/teachers_count.php) as a "Бонусы" column, scoped by that report's
-- existing date-range filter (bonus_date BETWEEN start_date AND end_date) —
-- same as how lesson-based earnings on that page are already scoped. Run
-- once against the app database:
--
--   mysql -h <host> -u <user> -p <database> < scripts/create_teacher_bonuses_table.sql
--
-- (or paste the statement below into phpMyAdmin / Adminer / your MySQL
-- client of choice). No existing tables are modified.

CREATE TABLE IF NOT EXISTS teacher_bonuses (
    id          INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    teacher_id  BIGINT UNSIGNED NOT NULL,
    amount      DECIMAL(10,2) NOT NULL,
    bonus_date  DATE NOT NULL,
    note        VARCHAR(500) NULL,
    created_by  BIGINT UNSIGNED NULL,
    created_at  DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_teacher_bonuses_teacher_date (teacher_id, bonus_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
