<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        App\Support\SqliteCompat::statement(<<<'SQL'
CREATE TABLE `teacher_submission_notification_history` (
`id` int UNSIGNED NOT NULL,
  `teacher_id` int UNSIGNED NOT NULL,
  `class_section_id` int UNSIGNED NOT NULL,
  `admin_id` int UNSIGNED NOT NULL,
  `notification_category` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'teacher_submissions',
  `message` text COLLATE utf8mb4_general_ci,
  `status` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'sent',
  `school_year` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `semester` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sent_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `teacher_submission_notification_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_teacher_class` (`teacher_id`,`class_section_id`);
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `teacher_submission_notification_history`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
SQL
        );

    }

    public function down(): void
    {
        Schema::dropIfExists('teacher_submission_notification_history');
    }
};